41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Collections.ObjectModel;
							 | 
						|||
| 
								 | 
							
								using System.Globalization;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Text;
							 | 
						|||
| 
								 | 
							
								using System.Threading.Tasks;
							 | 
						|||
| 
								 | 
							
								using System.Windows.Data;
							 | 
						|||
| 
								 | 
							
								using DM_Weight.Models;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace DM_Weight.Converter
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public class GroupSumConverter : IValueConverter
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        #region 分组组内求和
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            var total = 0;
							 | 
						|||
| 
								 | 
							
								            // DataGrid分组后对应的组及组内元素CollectionViewGroup.Items 类型是ReadOnlyObservableCollection<object>
							 | 
						|||
| 
								 | 
							
								            if (value is ReadOnlyObservableCollection<object> items)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                foreach (var item in items)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    var de = item as OrderDetail;
							 | 
						|||
| 
								 | 
							
								                    total += de.Quantity;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            return "用药总数:" + total;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            throw new NotImplementedException();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |