private void gridControl1_MouseUp(object sender, MouseEventArgs e) { Dictionary<string, decimal> dtary = new Dictionary<string, decimal>(); foreach (int i in gridView1.GetSelectedRows()) { vwERP_PM_DailyWorkNice da = gridView1.GetRow(i) as vwERP_PM_DailyWorkNice; //GridView gv = gridView1; //if (dr != null) foreach (GridColumn j in gridView1.GetSelectedCells(i)) { decimal num = 0.00m; string columnNum = ""; foreach (PropertyInfo pi in da.GetType().GetProperties()) { if (pi == null) continue; if (pi.CanWrite == false) continue; if (pi.Name == j.FieldName) { try { columnNum = pi.GetValue(da, null).ToString(); } catch { } } } if (decimal.TryParse(columnNum, out num)) { if (dtary.ContainsKey(j.Name)) dtary[j.Name] += num; else dtary[j.Name] = num; } //var a = j.Column.Name; } }
时间: 2024-11-09 02:22:57