/// <summary> /// 创建Group /// </summary> internal static void CreateArchiveEvents(this IArchiveGrid grid) { foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(grid.GridName)) { switch (info.GridColumnType) { case GridColumnType.NoColumn: break; default: if (info.DoubleClick != null) { GridColumnInfo info2 = info; Xceed.Grid.InsertionRow insertRow = grid.GetInsertionRow(); if (insertRow != null) { insertRow.Cells[info.GridColumnName].DoubleClick += new EventHandler(delegate(object sender, EventArgs e) { EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(info2.DoubleClick), sender, e); }); } } break; //default: // throw new InvalidOperationException("Invalide gridcolumnType of " + info.GridColumnType + " in " + info.Name); } } }
static void InsertionRow2_EditBegun(object sender, EventArgs e) { Xceed.Grid.InsertionRow row = sender as Xceed.Grid.InsertionRow; row.Cells["金额"].Value = ((row.GridControl.FindForm() as ArchiveDetailForm).DisplayManager.CurrentItem as 凭证).金额.数额; row.Cells["收付标志"].Value = 收付标志.收; (row.GridControl as IArchiveGrid).DisplayManager.OnSelectedDataValueChanged(new SelectedDataValueChangedEventArgs("收付标志", row.Cells["收付标志"])); }
static void InsertionRow2_EditBegun(object sender, EventArgs e) { Xceed.Grid.InsertionRow row = sender as Xceed.Grid.InsertionRow; row.Cells["金额"].Value = (row.GridControl.FindForm() as ArchiveDetailForm).DisplayManager.DataControls["金额.数额"].SelectedDataValue; if ((凭证类别)(row.GridControl.FindForm() as ArchiveDetailForm).DisplayManager.DataControls["凭证类别"].SelectedDataValue == 凭证类别.付款凭证) { row.Cells["收付标志"].Value = 收付标志.付; } else { row.Cells["收付标志"].Value = 收付标志.收; } (row.GridControl as IArchiveGrid).DisplayManager.OnSelectedDataValueChanged(new SelectedDataValueChangedEventArgs("收付标志", row.Cells["收付标志"])); }
public static void 油费金额计算(object sender, EventArgs e) { decimal count = 0; if (sender is Xceed.Grid.DataCell) { Xceed.Grid.DataCell cell = sender as Xceed.Grid.DataCell; Xceed.Grid.DataRow row = cell.ParentRow as Xceed.Grid.DataRow; if (cell.ReadOnly || !((string)row.Cells["费用项编号"].Value == "204" || (string)row.Cells["费用项编号"].Value == "205") || row.Cells["车辆编号"].Value == null) { return; } if (row.Cells["升数"] != null && row.Cells["升数"].Value != null) { count = (decimal)row.Cells["升数"].Value; } else if (row.Cells["数量"] != null && row.Cells["数量"].Value != null) { count = (decimal)row.Cells["数量"].Value; } else { return; } //ArchiveSeeForm form = cell.GridControl.FindForm() as ArchiveSeeForm; 车辆 cl = null; //if ((form.DisplayManager.CurrentItem) is 业务费用) //{ // cl = (form.DisplayManager.CurrentItem as 业务费用).车辆; //} //else if ((form.DisplayManager.CurrentItem) is 非业务车辆费用) //{ // cl = (form.DisplayManager.CurrentItem as 非业务车辆费用).车辆; //} //else //{ // throw new InvalidOperationException("实体不属于业务费用或非业务车辆费用!"); //} using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <车辆>()) { cl = rep.Get <车辆>(new Guid(row.Cells["车辆编号"].Value.ToString())); } if (cl != null) { switch (cl.车辆类别) { case 车辆类别.自有车: case 车辆类别.代管车: if (row.Cells["费用归属"] != null && row.Cells["费用归属"].Value.ToString() == "对外") { if (cbyj.HasValue) { cell.CellEditorControl.Text = (cbyj * count).ToString(); } else { throw new ArgumentException("数据库中必须配置成本油价!"); } } else { if (jsyyj.HasValue) { cell.CellEditorControl.Text = (jsyyj * count).ToString(); } else { throw new ArgumentException("数据库中必须配置驾驶员油价!"); } } break; case 车辆类别.挂靠车: if (row.Cells["费用归属"] != null && row.Cells["费用归属"].Value.ToString() == "对外") { cell.CellEditorControl.Text = decimal.Multiply(Convert.ToDecimal(cbyj), count).ToString(); } else if (row.Cells["费用归属"] != null && row.Cells["费用归属"].Value.ToString() == "车主") { if ((string)row.Cells["费用项编号"].Value == "204") //油费 { if (czyj.HasValue) { cell.CellEditorControl.Text = (czyj * count).ToString(); } else { throw new ArgumentException("数据库中必须配置车主油价!"); } } else //定耗油 { if (czyj.HasValue && jsyyj.HasValue) { cell.CellEditorControl.Text = ((czyj - jsyyj) * count).ToString(); } else { throw new ArgumentException("数据库中必须配置车主油价、驾驶员油价!!"); } } } else { throw new ArgumentException("费用归属不规范!"); } break; case 车辆类别.外协车: break; default: throw new ArgumentException("车辆类别不规范!"); } } } else if (sender is Xceed.Grid.InsertionCell) { Xceed.Grid.InsertionCell cell = sender as Xceed.Grid.InsertionCell; Xceed.Grid.InsertionRow row = cell.ParentRow as Xceed.Grid.InsertionRow; if (cell.ReadOnly || !((string)row.Cells["费用项编号"].Value == "204" || (string)row.Cells["费用项编号"].Value == "205") || row.Cells["车辆编号"].Value == null) { return; } if (row.Cells["升数"] != null && row.Cells["升数"].Value != null) { count = (decimal)row.Cells["升数"].Value; } else if (row.Cells["数量"] != null && row.Cells["数量"].Value != null) { count = (decimal)row.Cells["数量"].Value; } else { return; } //ArchiveSeeForm form = cell.GridControl.FindForm() as ArchiveSeeForm; 车辆 cl = null; //if ((form.DisplayManager.CurrentItem) is 业务费用) //{ // cl = (form.DisplayManager.CurrentItem as 业务费用).车辆; //} //else if ((form.DisplayManager.CurrentItem) is 非业务车辆费用) //{ // cl = (form.DisplayManager.CurrentItem as 非业务车辆费用).车辆; //} //else //{ // throw new InvalidOperationException("实体不属于业务费用或非业务车辆费用!"); //} using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <车辆>()) { cl = rep.Get <车辆>(new Guid(row.Cells["车辆编号"].Value.ToString())); } if (cl != null) { switch (cl.车辆类别) { case 车辆类别.自有车: case 车辆类别.代管车: if (row.Cells["费用归属"] != null && row.Cells["费用归属"].Value.ToString() == "对外") { cell.CellEditorControl.Text = decimal.Multiply(Convert.ToDecimal(cbyj), count).ToString(); } else { cell.CellEditorControl.Text = decimal.Multiply(Convert.ToDecimal(jsyyj), count).ToString(); } break; case 车辆类别.挂靠车: if (row.Cells["费用归属"] != null && row.Cells["费用归属"].Value.ToString() == "对外") { cell.CellEditorControl.Text = decimal.Multiply(Convert.ToDecimal(cbyj), count).ToString(); } else if (row.Cells["费用归属"] != null && row.Cells["费用归属"].Value.ToString() == "车主") { if ((string)row.Cells["费用项编号"].Value == "204") //油费 { cell.CellEditorControl.Text = decimal.Multiply(Convert.ToDecimal(czyj), count).ToString(); } else //定耗油 { cell.CellEditorControl.Text = decimal.Multiply(Convert.ToDecimal(czyj) - Convert.ToDecimal(jsyyj), count).ToString(); } } else { throw new ArgumentException("费用归属不规范!"); } break; case 车辆类别.外协车: break; default: throw new ArgumentException("车辆类别不规范!"); } } } }