private void initGridControl() { SimTerrainType.loadTerrainTileTypes(); gridControl1.DataRows.Clear(); //setup our control grid gridControl1.DataSource = mTypesList; gridControl1.SingleClickEdit = true; // AddComboEditor(gridControl1.Columns, getColumWithName("TerrainGroup"), SimEditor.SimTerrainType.mValidGroupings.ToArray()); int count = SimTerrainType.mTerrainTileTypes.mTypes.Count; string[] values = new string[count]; for (int i = 0; i < count; i++) { values[i] = SimTerrainType.mTerrainTileTypes.mTypes[i].Name; } AddComboEditor(gridControl1.Columns, getColumWithName("TileType"), values); //load our thumbnail images gridControl1.Columns["Preview"].Width = thumnailRes; for (int i = 0; i < mTypesList.Count; i++) { string pureName = SimTerrainType.getpureFileNameNoExt(mTypesList[i].TextureName); string texName = CoreGlobals.getWorkPaths().mTerrainTexturesPath + @"\" + mTypesList[i].Theme + @"\" + pureName + "_df.tga"; Xceed.Grid.DataRow row = gridControl1.DataRows[i]; row.Cells["Preview"].BackgroundImage = TextureManager.loadTextureToThumbnail(texName, thumnailRes); row.Height = thumnailRes; } }
void DataRowTemplate_EditEnded(object sender, EventArgs e) { bool hasValue = false; Xceed.Grid.DataRow row = sender as Xceed.Grid.DataRow; for (int j = 0; j < this.Columns.Count; ++j) { if (row.Cells[j].Value != null) { hasValue = true; } } if (hasValue) { int lastRow = FindFirstEmptyRow(); if (row.Index > lastRow - 1) { ServiceProvider.GetService <IMessageBox>().ShowWarning("此行上方还有空行,此行不会保存!"); } else if (row.Index == this.DataRows.Count - 1) { this.DataRows.AddNew().EndEdit(); } } }
void VarSearchGridControl_SelectedRowsChanged(object sender, EventArgs e) { if (mbPaused) { return; } if (VarSearchGridControl.SelectedRows.Count > 0) { Xceed.Grid.DataRow row = VarSearchGridControl.SelectedRows[0] as Xceed.Grid.DataRow; if (row != null) { TriggerVarJump jump = ((TriggerVarJump)row.SourceObject); if (jump.map != null) { mHostArea.SnapViewToItem(jump.map); } else { mHostArea.SnapViewToItem(jump.comp); TriggerValue val = mHostArea.CurrentTriggerNamespace.GetValues()[jump.var.ID]; mHostArea.UIUpdate(val, new BasicArgument(BasicArgument.eArgumentType.Select), eUpdateVisibilty.AnyVisiblity); } } } //throw new Exception("The method or operation is not implemented."); }
public static void 生成相同费用(ArchiveOperationForm masterForm) { if (masterForm.MasterGrid.GridControl.SelectedRows.Count == 0) { ServiceProvider.GetService <IMessageBox>().ShowWarning("请选择费用!"); return; } if (!MessageForm.ShowYesNo("是否要生成选中项相同的费用?", "确认")) { return; } int cnt = 0; using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <非业务费用>()) { foreach (Xceed.Grid.Row row in masterForm.MasterGrid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) { continue; } 非业务费用 entity = dataRow.Tag as 非业务费用; if (entity.非业务费用实体.费用实体类型编号 != 37 /*费用实体类型.其他非业务*/) { continue; } rep.Initialize(entity.费用实体, entity); 非业务费用 item = new 非业务费用(); item.收付标志 = entity.收付标志; item.费用实体 = entity.费用实体; item.费用项编号 = entity.费用项编号; item.费用类别编号 = entity.费用类别编号; item.金额 = entity.金额; item.相关人编号 = entity.相关人编号; object newEntity = masterForm.ControlManager.AddNew(); if (newEntity != null) { masterForm.ControlManager.DisplayManager.Items[masterForm.ControlManager.DisplayManager.Position] = item; masterForm.ControlManager.EndEdit(); (masterForm.MasterGrid.CurrentRow as Xceed.Grid.DataRow).Cells["费用项编号"].CellEditorManager = dataRow.Cells["费用项编号"].CellEditorManager; cnt++; } else { masterForm.ControlManager.CancelEdit(); break; } } } MessageForm.ShowInfo("已生成" + cnt + "条费用!"); }
internal static void LoadGridInfos(MyGrid grdSetup, IGrid masterGrid) { if (masterGrid == null) { return; } if (grdSetup.Columns.Count == 0) { grdSetup.Columns.Add(new Xceed.Grid.Column("名称", typeof(string))); grdSetup.Columns.Add(new Xceed.Grid.Column("是否显示", typeof(bool))); grdSetup.ReadOnly = false; grdSetup.Columns["是否显示"].ReadOnly = false; grdSetup.Columns["名称"].ReadOnly = true; } grdSetup.DataRows.Clear(); if (masterGrid != null) { Dictionary <string, GridColumnInfo> visibleColumns = new Dictionary <string, GridColumnInfo>(); IList <GridColumnInfo> gridColumnInfos = ADInfoBll.Instance.GetGridColumnInfos(masterGrid.GridName); bool hasInfo = gridColumnInfos.Count > 0; foreach (GridColumnInfo info in gridColumnInfos) { if (!Authority.AuthorizeByRule(info.ColumnVisible)) { continue; } visibleColumns[info.GridColumnName] = info; } SortedList <int, Xceed.Grid.Column> columns = new SortedList <int, Xceed.Grid.Column>(); foreach (Xceed.Grid.Column column in masterGrid.Columns) { if (hasInfo && !visibleColumns.ContainsKey(column.FieldName)) { continue; } columns.Add(column.VisibleIndex, column); } foreach (KeyValuePair <int, Xceed.Grid.Column> kvp in columns) { Xceed.Grid.DataRow row = grdSetup.DataRows.AddNew(); row.Cells["是否显示"].Value = kvp.Value.Visible; row.Cells["名称"].Value = kvp.Value.Title; row.EndEdit(); if (visibleColumns.ContainsKey(kvp.Value.FieldName)) { row.ReadOnly = Authority.AuthorizeByRule(visibleColumns[kvp.Value.FieldName].NotNull); } } } }
internal static void LoadSearchControlInfos(MyGrid grdSetup, IDisplayManager dmMaster) { if (dmMaster == null) { return; } if (grdSetup.Columns.Count == 0) { grdSetup.Columns.Add(new Xceed.Grid.Column("名称", typeof(string))); grdSetup.Columns.Add(new Xceed.Grid.Column("是否显示", typeof(bool))); grdSetup.ReadOnly = false; grdSetup.Columns["是否显示"].ReadOnly = false; grdSetup.Columns["名称"].ReadOnly = true; } grdSetup.DataRows.Clear(); ISearchManager sm = dmMaster.SearchManager; if (sm != null) { SortedList <int, ISearchControl> scc1 = new SortedList <int, ISearchControl>(); SortedList <int, ISearchControl> scc2 = new SortedList <int, ISearchControl>(); foreach (ISearchControl sc in sm.SearchControls) { GridColumnInfo info = sc.Tag as GridColumnInfo; if (info == null || (!string.IsNullOrEmpty(info.SearchControlType) && Authority.AuthorizeByRule(info.SearchControlVisible))) { if (sc.Available) { scc1.Add(sc.Index, sc); } else { scc2.Add(sc.Index, sc); } } } foreach (KeyValuePair <int, ISearchControl> kvp in scc1) { Xceed.Grid.DataRow row = grdSetup.DataRows.AddNew(); row.Cells["是否显示"].Value = kvp.Value.Available; row.Cells["名称"].Value = kvp.Value.Caption; row.EndEdit(); } foreach (KeyValuePair <int, ISearchControl> kvp in scc2) { Xceed.Grid.DataRow row = grdSetup.DataRows.AddNew(); row.Cells["是否显示"].Value = kvp.Value.Available; row.Cells["名称"].Value = kvp.Value.Caption; row.EndEdit(); } } }
static void DataRowTemplate_BeginningEdit(object sender, System.ComponentModel.CancelEventArgs e) { Xceed.Grid.DataRow row = sender as Xceed.Grid.DataRow; 非业务费用 item = row.Tag as 非业务费用; string filter = "现有费用实体类型 LIKE '%" + item.费用实体.费用实体类型编号 + ",%'"; row.Cells["费用项编号"].CellEditorManager = GridDataLoad.GetGridComboEditor("费用项_非业务", filter); }
public static void 生成油费对外费用(ArchiveOperationForm masterForm) { if (MessageForm.ShowYesNo("是否自动生成油费对外费用?", "提示")) { int count = 0; try { if (masterForm.DisplayManager.Items != null && masterForm.DisplayManager.Items.Count > 0) { foreach (Xceed.Grid.Row row in masterForm.MasterGrid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) { continue; } 业务费用 fy = dataRow.Tag as 业务费用; // 把 费用归属=驾驶员 费用项=204 的记录 逐条生成 费用归属=对外的 // 收付标志 反一下 相关人=null using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <业务费用>()) { rep.Initialize(fy.车辆产值, fy); } if (fy.费用归属 == 费用归属.驾驶员 && fy.费用项编号 == "204") { 业务费用 kps = masterForm.ControlManager.AddNew() as 业务费用; kps.费用归属 = 费用归属.对外; kps.收付标志 = fy.收付标志 == 收付标志.收 ? 收付标志.付 : 收付标志.收; kps.数量 = fy.数量; kps.费用项编号 = fy.费用项编号; kps.金额 = fy.金额; kps.费用实体 = fy.费用实体; kps.车辆产值 = fy.车辆产值; kps.车辆编号 = fy.车辆编号; kps.任务 = fy.任务; masterForm.DisplayManager.DisplayCurrent(); masterForm.ControlManager.EndEdit(true); count++; } } } } catch (Exception ex) { throw new InvalidUserOperationException(ex.Message); } finally { MessageForm.ShowInfo("已生成 " + count + " 条对外费用!"); } } }
public int GetSelectedRowIndex() { if (gridControl1.SelectedRows.Count > 0) { Xceed.Grid.DataRow dr = gridControl1.SelectedRows[0] as Xceed.Grid.DataRow; if (dr != null) { return(dr.Index); } } return(-1); }
internal static void SetGridRowCellPermissions(this IBoundGrid grid, Xceed.Grid.DataRow row) { GridRowInfo info = ADInfoBll.Instance.GetGridRowInfo(grid.GridName); object entity = row.Tag; if (grid.ReadOnly) { return; } // Only set when readOnly(如果ReadOnly=false,则不设置,继承Parent's ReadOnly) bool readOnly = Feng.Permission.AuthorizeByRule(info.ReadOnly, entity); if (readOnly) { row.ReadOnly = readOnly; } if (row.ReadOnly) { return; } foreach (GridCellInfo cellInfo in ADInfoBll.Instance.GetGridCellInfos(grid.GridName)) { Xceed.Grid.Cell cell = row.Cells[cellInfo.GridColumName]; if (cell == null) { continue; } if (cell.ParentGrid.ReadOnly) { continue; } if (cell.ParentColumn.ReadOnly) { continue; } if (cell.ParentRow.ReadOnly) { continue; } readOnly = Permission.AuthorizeByRule(cellInfo.ReadOnly, entity); if (readOnly) { cell.ReadOnly = readOnly; } } }
internal static void SetGridRowVisible(this IBoundGrid grid, Xceed.Grid.DataRow row) { GridRowInfo info = ADInfoBll.Instance.GetGridRowInfo(grid.GridName); object entity = row.Tag; bool visible = Permission.AuthorizeByRule(info.Visible, entity); row.Visible = visible; if (!row.Visible) { grid.DataRows.Remove(row); return; } }
private static void ExpandDataRow(Xceed.Grid.DataRow row) { if (row.DetailGrids.Count > 0) { foreach (Xceed.Grid.DetailGrid detailGrid in row.DetailGrids) { detailGrid.Expand(); foreach (Xceed.Grid.DataRow subRow in detailGrid.DataRows) { ExpandDataRow(subRow); } } } }
void gridControl1_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } Point p = new Point(e.X, e.Y); object o2 = gridControl1.GetVisualGridElementAtPoint(p); Xceed.Grid.DataCell cell = o2 as Xceed.Grid.DataCell; if (cell != null) { //cell.Value; int col = cell.ParentColumn.Index; Xceed.Grid.DataBoundColumn dataCol = cell.ParentColumn as Xceed.Grid.DataBoundColumn; Xceed.Grid.DataRow dataRow = cell.ParentRow as Xceed.Grid.DataRow; if (dataCol != null && dataRow != null) { object sourceObject = dataRow.SourceObject; int rowNum = dataRow.Index; string field = dataCol.FieldName; if (mCellClicked != null) { mCellClicked.Invoke(sourceObject, field, rowNum, col); } if (mObjectEditor != null) { Control c = mObjectEditor.GetSingleControl(sourceObject, field); PopupEditor pe = new PopupEditor(); Form f = pe.ShowPopup(this, c, FormBorderStyle.FixedSingle, true); Point p2 = this.PointToScreen(p); f.Deactivate += new EventHandler(f_Deactivate); f.Tag = cell; f.Top = p2.Y; f.Left = p2.X; f.Show(); //if (ContentMessageBox.ShowMessage(this, c, "") == DialogResult.OK) //{ // //this.LocStringID = p.LocStringID; //} } } } }
public static void 进口_要求承运天数(object sender, EventArgs e) { Xceed.Grid.Cell cell = sender as Xceed.Grid.Cell; Xceed.Grid.DataRow row = cell.ParentRow as Xceed.Grid.DataRow; if (row.Cells["放行时间"].Value == null || row.Cells["到港时间"].Value == null || row.Cells["免箱天数"].Value == null || cell.ReadOnly) { return; } TimeSpan ts = Convert.ToDateTime(row.Cells["放行时间"].Value).Subtract(Convert.ToDateTime(row.Cells["到港时间"].Value)); cell.CellEditorControl.Text = (Convert.ToInt32(row.Cells["免箱天数"].Value) - ts.Days).ToString(); }
private static IList <费用> GetSelectedFee4Pz(ArchiveOperationForm masterForm) { IList <费用> list = new List <费用>(); foreach (Xceed.Grid.Row row in masterForm.MasterGrid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) { continue; } 非业务费用 item = dataRow.Tag as 非业务费用; if (item.凭证费用明细 == null) { list.Add(item.Clone() as 非业务费用); } } return(list); }
private void GetSelectedEntities(Xceed.Grid.DataRow row) { if (!row.Visible) { return; } if (Convert.ToBoolean(row.Cells[Feng.Grid.Columns.CheckColumn.DefaultSelectColumnName].Value)) { m_selectedEntities.Add(row.Tag); } foreach (MyDetailGrid detailGrid in row.DetailGrids) { foreach (Xceed.Grid.DataRow subRow in detailGrid.DataRows) { GetSelectedEntities(subRow); } } }
void DataRowTemplate_EditEnded(object sender, EventArgs e) { Xceed.Grid.DataRow row = sender as Xceed.Grid.DataRow; if (row.Cells["费用项"].Value != null) { if (row.Cells["费用项"].Value.ToString() == "011") { ArchiveDetailForm detailForm = ArchiveFormFactory.GenerateArchiveDetailForm(ADInfoBll.Instance.GetWindowInfo("资金票据_凭证_会计付款_固定资产")); if (detailForm != null) { detailForm.ControlManager.AddNew(); detailForm.UpdateContent(); detailForm.DisplayManager.DataControls["购入金额"].SelectedDataValue = row.Cells["金额"].Value; Hd.Model.Kj.固定资产 entity = detailForm.DisplayManager.CurrentItem as Hd.Model.Kj.固定资产; if (this.DisplayManager.DataControls["日期"].SelectedDataValue != null) { entity.购入时间 = (DateTime)this.DisplayManager.DataControls["日期"].SelectedDataValue; } else { entity.购入时间 = System.DateTime.Today; } detailForm.ShowDialog(); } } else if (row.Cells["费用项"].Value.ToString() == "012") { ArchiveDataControlForm form = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("资金票据_凭证_会计付款_结算期限")) as ArchiveDataControlForm; if (form != null) { if (form.ShowDialog() == DialogResult.OK) { row.Cells["结算期限"].Value = form.DataControls["结算期限"].SelectedDataValue; row.Cells["业务分类"].Value = form.DataControls["业务分类"].SelectedDataValue; } } } } }
static void DataRowTemplate_BeginningEdit(object sender, System.ComponentModel.CancelEventArgs e) { //masterForm.ActiveGrid.DataRowTemplate.Cells["票.费用实体类型"].ValueChanged += new EventHandler(process_fy_yw_ValueChanged); Xceed.Grid.DataRow dataRow = sender as Xceed.Grid.DataRow; if (((IBoundGrid)dataRow.GridControl).DisplayManager.InBatchOperation) { return; } //if (cell.ParentRow.Cells["费用类别编号"].Value != null // && cell.ParentRow.Cells["收付标志"].Value != null) //{ // StringBuilder filter = new StringBuilder(); // if (((收付标志)cell.ParentRow.Cells["收付标志"].Value) == 收付标志.收) // { // filter.Append("收 = 'true' AND 收入类别 = '" + cell.ParentRow.Cells["费用类别编号"].Value.ToString() + "'"); // } // else // { // filter.Append("付 = 'true' AND 支出类别 = '" + cell.ParentRow.Cells["费用类别编号"].Value.ToString() + "'"); // } // cell.ParentRow.Cells["费用项编号"].CellEditorManager = Feng.Windows.ControlDataLoad.GetGridComboEditor("费用项_业务_" + m_type, filter.ToString()); //} 业务费用 item = dataRow.Tag as 业务费用; bool isPiao = !item.箱Id.HasValue; string filter = "现有费用实体类型 LIKE '%" + item.票.费用实体类型编号; if (isPiao) { filter += ",%' AND 票 = " + isPiao; } else { filter += ",%' AND 箱 = " + !isPiao; } dataRow.Cells["费用项编号"].CellEditorManager = Feng.Windows.Utils.GridDataLoad.GetGridComboEditor("费用项_业务", filter); }
private static IList <费用> GetSelectedFee4Pz(ArchiveOperationForm masterForm) { IList <费用> list = new List <费用>(); foreach (Xceed.Grid.Row row in masterForm.MasterGrid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) { continue; } 业务费用 item = dataRow.Tag as 业务费用; if (item.凭证费用明细 == null && item.对账单 == null) { // 界面之间跳转的,不共用数据,用复制数据,这样数据不会搞混 // 例如这里,生成凭证,费用的凭证费用明细字段设置了,但如果凭证地方取消,凭证费用明细字段却没清空 // 如果是用公用数据的话,会对这里产生影响。 list.Add(item.Clone() as 业务费用); } } return(list); }
private void LoadGridInfos() { grdGridColumns.DataRows.Clear(); IBoundGrid masterGrid = m_masterGrid as IBoundGrid; if (masterGrid != null) { Dictionary <string, GridColumnInfo> visibleColumns = new Dictionary <string, GridColumnInfo>(); bool hasInfo = GridSettingInfoCollection.Instance[masterGrid.GridName].GridColumnInfos.Count > 0; foreach (GridColumnInfo info in GridSettingInfoCollection.Instance[masterGrid.GridName].GridColumnInfos) { if (!Authority.AuthorizeByRule(info.ColumnVisible)) { continue; } visibleColumns[info.GridColumnName] = info; } foreach (Xceed.Grid.Column column in masterGrid.Columns) { if (hasInfo && !visibleColumns.ContainsKey(column.FieldName)) { continue; } Xceed.Grid.DataRow row = grdGridColumns.DataRows.AddNew(); row.Cells["是否显示"].Value = column.Visible; row.Cells["名称"].Value = column.Title; row.EndEdit(); if (visibleColumns.ContainsKey(column.FieldName)) { row.ReadOnly = Authority.AuthorizeByRule(visibleColumns[column.FieldName].NotNull); } } } }
internal static bool TryChangeCurrentRow(IDisplayManager dm, IGrid grid) { int newPos; Xceed.Grid.DataRow row = grid.CurrentRow as Xceed.Grid.DataRow; if (row == null) { newPos = -1; } else { newPos = row.Index; } int oldPos = dm.Position; if (oldPos == newPos) { return(false); } dm.Position = newPos; // Change failed because of something if (dm.Position == oldPos) { // if in add, there is no addrow if (oldPos < grid.DataRows.Count) { if (oldPos >= 0 && oldPos < grid.DataRows.Count) { grid.CurrentRow = grid.DataRows[oldPos]; } } return(false); } else { return(true); } }
void ComponentGridControl_SelectedRowsChanged(object sender, EventArgs e) { if (mbPaused) { return; } if (ComponentGridControl.SelectedRows.Count > 0) { Xceed.Grid.DataRow row = ComponentGridControl.SelectedRows[0] as Xceed.Grid.DataRow; if (row != null) { ComponentJump jump = ((ComponentJump)row.SourceObject); if (jump.map != null) { mHostArea.SnapViewToItem(jump.map); } else { mHostArea.SnapViewToItem(jump.comp); } } } }
internal static void MoveRow(MyGrid grid, bool up) { Xceed.Grid.DataRow row = grid.CurrentRow as Xceed.Grid.DataRow; if (row != null) { int n = row.Index; if (up) { if (n - 1 >= 0) { SwapRow(grid, grid.DataRows[n - 1], row); grid.CurrentRow = grid.DataRows[n - 1]; } } else { if (n + 1 < grid.DataRows.Count) { SwapRow(grid, grid.DataRows[n + 1], row); grid.CurrentRow = grid.DataRows[n + 1]; } } } }
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("车辆类别不规范!"); } } } }
public static void FyDoubleClick(object sender1, EventArgs e1) { Xceed.Grid.DataCell cell = sender1 as Xceed.Grid.DataCell; Xceed.Grid.DataRow row = cell.ParentRow as Xceed.Grid.DataRow; //if (row.ParentGrid.ReadOnly) // return; //IBoundGrid grid = (m_masterForm.ArchiveDetailForm as IArchiveDetailFormWithDetailGrids).DetailGrids[0]; ArchiveSeeForm masterForm = cell.GridControl.FindForm() as ArchiveSeeForm; if (masterForm == null) { // 通过DetailForm来的 masterForm = (cell.GridControl.FindForm() as ArchiveDetailForm).ParentForm as ArchiveSeeForm; } ArchiveOperationForm fydjForm = masterForm.Tag as ArchiveOperationForm; //if (cell.FieldName == "拟付金额" || cell.FieldName == "拟收金额" || cell.FieldName == "费用项") { if (fydjForm == null) { if (masterForm.Name == "内贸出港_票费用") { fydjForm = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("内贸出港_票费用项费用登记")) as ArchiveOperationForm; } else { fydjForm = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("业务财务_票费用项费用登记")) as ArchiveOperationForm; } masterForm.Tag = fydjForm; Dictionary <string, object> setDatanew = new Dictionary <string, object>(); fydjForm.Tag = setDatanew; (fydjForm.ControlManager.Dao as 业务费用Dao).TransactionBeginning += new EventHandler <OperateArgs <业务费用> >(delegate(object sender, OperateArgs <业务费用> e) { if (e.Entity.费用实体 == null) { 业务费用 fy = e.Entity as 业务费用; fy.费用实体 = e.Repository.Get <费用实体>(setDatanew["费用实体"]); fy.票 = fy.费用实体 as 普通票; fy.费用项编号 = (string)setDatanew["费用项"]; } }); fydjForm.DisplayManager.SearchManager.EnablePage = false; fydjForm.DisplayManager.SearchManager.DataLoaded += new EventHandler <DataLoadedEventArgs>(delegate(object sender, DataLoadedEventArgs e) { fydjForm.TopMost = true; fydjForm.Show(); }); fydjForm.FormClosing += new FormClosingEventHandler(delegate(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { if (!masterForm.IsDisposed) { if (masterForm is ArchiveOperationForm) { //(masterForm as ArchiveOperationForm).ControlManager.DisplayManager.Items[(masterForm as ArchiveOperationForm).ControlManager.DisplayManager.Position] = (fydjForm.DisplayManager.CurrentItem as 费用).费用实体; (masterForm as ArchiveOperationForm).ControlManager.DisplayManager.SearchManager.ReloadItem((masterForm as ArchiveOperationForm).ControlManager.DisplayManager.Position); (masterForm as ArchiveOperationForm).ControlManager.OnCurrentItemChanged(); } //IBoundGrid grid = (masterForm.ArchiveDetailForm as IArchiveDetailFormWithDetailGrids).DetailGrids[0]; //ISearchManager sm = grid.DisplayManager.SearchManager; //System.Data.DataTable dt = (System.Data.DataTable)sm.FindData(new List<ISearchExpression> { }, null); //foreach (System.Data.DataRow i in dt.Rows) //{ // if (i["费用项"].ToString() == setDatanew["费用项"].ToString()) // { // object save = row.Cells["Submitted"].Value; // grid.SetDataRowsIListData(i, row); // row.Cells["Submitted"].Value = save; // break; // } //} e.Cancel = true; fydjForm.Hide(); } } }); } Dictionary <string, object> setData = fydjForm.Tag as Dictionary <string, object>; setData.Clear(); //进口_额外费用_委托人 费用项双击事件 if (masterForm.Text.Equals("进口_额外费用_委托人")) { //明细窗体 if (cell.ParentColumn.Title.Equals("费用项")) { setData["费用实体"] = (Guid)row.Cells["费用实体"].Value; setData["费用项"] = (string)row.Cells["费用项"].Value; } //主窗体 else { using (var rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <费用项>()) { IList <费用项> list = (rep as Feng.NH.INHibernateRepository).List <费用项>(NHibernate.Criterion.DetachedCriteria.For <费用项>() .Add(NHibernate.Criterion.Expression.Eq("名称", cell.ParentColumn.Title))); if (list != null && list.Count > 0) { setData["费用实体"] = (row.Tag as 进口票).ID; setData["费用项"] = list[0].编号; } } } } // 票费用登记窗体 else if (row.Cells["费用实体"] != null) { setData["费用实体"] = (Guid)row.Cells["费用实体"].Value; setData["费用项"] = (string)row.Cells["费用项"].Value; if (/*cell.FieldName == "已收金额" || cell.FieldName == "应收金额" || */ cell.FieldName == "拟收金额") { setData["收付标志"] = 收付标志.收; } else if (/*cell.FieldName == "已付金额" || cell.FieldName == "应付金额" || */ cell.FieldName == "拟付金额") { setData["收付标志"] = 收付标志.付; } } // 滞箱费 else { setData["费用实体"] = (row.Tag as 费用信息).票Id; setData["费用项"] = "167"; } NameValueMappingCollection.Instance["信息_箱号_动态"].Params["@票"] = (Guid)setData["费用实体"]; NameValueMappingCollection.Instance.Reload(fydjForm.DisplayManager.Name, "信息_箱号_动态"); ISearchExpression se = SearchExpression.And(SearchExpression.Eq("费用实体.ID", (Guid)setData["费用实体"]), SearchExpression.Eq("费用项编号", (string)setData["费用项"])); if (setData.ContainsKey("收付标志")) { se = SearchExpression.And(se, SearchExpression.Eq("收付标志", setData["收付标志"])); } fydjForm.ControlManager.DisplayManager.SearchManager.LoadData(se, null); } //Dictionary<string, bool?> submitted = new Dictionary<string, bool?>(); //foreach (Xceed.Grid.DataRow i in grid.DataRows) //{ // submitted[i.Cells["费用项"].Value.ToString()] = (bool?)i.Cells["Submitted"].Value; //} //(row.GridControl as IBoundGrid).ReloadData(); //foreach (Xceed.Grid.DataRow i in grid.DataRows) //{ // i.Cells["Submitted"].Value = submitted[i.Cells["费用项"].Value.ToString()]; //} }
internal static ISearchExpression GetSearchExpressionFromGrid(IArchiveMasterForm sourceForm, GridRelatedAddressInfo info, bool onlyFirstOne) { if (sourceForm == null) { throw new ArgumentException("未能找到父窗体!", "sourceForm"); } if (info.RelatedType == GridRelatedType.ByRows) { if (sourceForm.MasterGrid == null) { throw new ArgumentException("未能找到主表格!", "sourceForm"); } List <object> selectedEntities = new List <object>(); if (sourceForm.MasterGrid.GridControl.SelectedRows.Count == 0) { Xceed.Grid.Row row = sourceForm.MasterGrid.CurrentRow; Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow != null && dataRow.Visible && (Feng.Grid.MyGrid.GetGridLevel(dataRow.ParentGrid) == info.GridLevel || string.IsNullOrEmpty(info.GridLevel))) { selectedEntities.Add(dataRow.Tag); } } else { foreach (Xceed.Grid.Row row in sourceForm.MasterGrid.GridControl.SelectedRows) { if (!row.Visible) { continue; } Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) { continue; } if (Feng.Grid.MyGrid.GetGridLevel(dataRow.ParentGrid) == info.GridLevel || string.IsNullOrEmpty(info.GridLevel)) { selectedEntities.Add(dataRow.Tag); } else { foreach (Xceed.Grid.DetailGrid dg in dataRow.DetailGrids) { GetDetailGridRows(info, dataRow.DetailGrids[0], selectedEntities); } } if (onlyFirstOne && selectedEntities.Count > 0) { break; } } } if (selectedEntities.Count == 0) { throw new InvalidOperationException("请选择表格行!"); } Dictionary <string, string> exps = new Dictionary <string, string>(); foreach (object entity in selectedEntities) { //if (entity.GetType() != Feng.Utils.ReflectionHelper.GetTypeFromName(info.EntityType)) // continue; string exp = EntityHelper.ReplaceEntity(info.SearchExpression, entity); exps[exp] = exp; } ISearchExpression se = null; foreach (string exp in exps.Keys) { ISearchExpression subSearch = SearchExpression.Parse(exp); if (se == null) { se = subSearch; } else { se = SearchExpression.Or(se, subSearch); } } return(se); //string[] fromColumns = info.FromColumnName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //for (int i = 0; i < fromColumns.Length; ++i) //{ // fromColumns[i] = fromColumns[i].Replace(":", "."); //} //int count = fromColumns.Length; //string[] toColumns = info.ToColumnName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //Debug.Assert(count == toColumns.Length, "FromColumnName必须和ToColumnName内容个数相同"); //ArrayList[] selected = new ArrayList[count]; //for (int i = 0; i < count; ++i) //{ // selected[i] = new ArrayList(); // string columnName = fromColumns[i]; // foreach (object entity in selectedEntities) // { // object o = EntityHelper.GetPropertyValue(entity, columnName); // //if (o != null && !string.IsNullOrEmpty(o.ToString())) // { // selected[i].Add(o); // } // } //} } else { throw new NotSupportedException("Not Supported now!"); } }
internal static void SetGridRowCellColors(this IBoundGrid grid, Xceed.Grid.DataRow row) { GridRowInfo rowInfo = ADInfoBll.Instance.GetGridRowInfo(grid.GridName); object entity = row.Tag; if (!string.IsNullOrEmpty(rowInfo.BackColor)) { string s = (string)EntityScript.CalculateExpression(rowInfo.BackColor, entity); if (!string.IsNullOrEmpty(s)) { row.BackColor = System.Drawing.Color.FromName(s); } else { row.ResetBackColor(); } } if (!string.IsNullOrEmpty(rowInfo.ForeColor)) { string s = (string)EntityScript.CalculateExpression(rowInfo.ForeColor, entity); if (!string.IsNullOrEmpty(s)) { row.ForeColor = System.Drawing.Color.FromName(s); } else { row.ResetForeColor(); } } foreach (GridCellInfo cellInfo in ADInfoBll.Instance.GetGridCellInfos(grid.GridName)) { Xceed.Grid.Cell cell = row.Cells[cellInfo.GridColumName]; if (cell == null) { continue; } if (!string.IsNullOrEmpty(cellInfo.BackColor)) { string s = (string)EntityScript.CalculateExpression(cellInfo.BackColor, entity); if (!string.IsNullOrEmpty(s)) { cell.BackColor = System.Drawing.Color.FromName(s); } else { cell.ResetBackColor(); } } if (!string.IsNullOrEmpty(rowInfo.ForeColor)) { string s = (string)EntityScript.CalculateExpression(cellInfo.ForeColor, entity); if (!string.IsNullOrEmpty(s)) { cell.ForeColor = System.Drawing.Color.FromName(s); } else { cell.ResetForeColor(); } } } }
private void SelectRow(Xceed.Grid.DataRow row, Xceed.Grid.DataRow rowMaster) { bool prevSelect = Convert.ToBoolean(row.Cells[m_selectCaption].Value); bool nowSelect = true; foreach (KeyValuePair <IDataControl, Operators> kvp in m_ht) { if (kvp.Key.SelectedDataValue == null) { continue; } object cellValue = null; if (row.Cells[kvp.Key.Name] != null) { cellValue = row.Cells[kvp.Key.Name].Value; } else if (rowMaster != null) { cellValue = rowMaster.Cells[kvp.Key.Name].Value; } if (cellValue == null) { nowSelect = false; continue; } switch (kvp.Value) { case Operators.Equal: nowSelect &= (cellValue.ToString() == kvp.Key.SelectedDataValue.ToString()); break; case Operators.NotEqual: nowSelect &= (cellValue.ToString() != kvp.Key.SelectedDataValue.ToString()); break; case Operators.GreaterThan: nowSelect &= (Convert.ToDateTime(cellValue) > Convert.ToDateTime(kvp.Key.SelectedDataValue)); break; case Operators.GreaterOrEqualThan: nowSelect &= (Convert.ToDateTime(cellValue) >= Convert.ToDateTime(kvp.Key.SelectedDataValue)); break; case Operators.LessThan: nowSelect &= (Convert.ToDateTime(cellValue) < Convert.ToDateTime(kvp.Key.SelectedDataValue).AddDays(1)); break; case Operators.LessOrEqualThan: nowSelect &= (Convert.ToDateTime(cellValue) <= Convert.ToDateTime(kvp.Key.SelectedDataValue).AddDays(1)); break; case Operators.Like: nowSelect &= (cellValue.ToString().Contains(kvp.Key.SelectedDataValue.ToString())); break; } } switch (rbgFilterMethod.SelectedValue.ToString()) { case "0": row.Cells[m_selectCaption].Value = nowSelect; break; case "1": row.Cells[m_selectCaption].Value = prevSelect && nowSelect; break; case "2": row.Cells[m_selectCaption].Value = prevSelect || nowSelect; break; case "3": row.Cells[m_selectCaption].Value = prevSelect && !nowSelect; break; } }
public static void 生成收款相应费用(ArchiveOperationForm masterForm) { if (masterForm.MasterGrid.GridControl.SelectedRows.Count == 0) { ServiceProvider.GetService <IMessageBox>().ShowWarning("请选择付款费用!"); return; } if (!MessageForm.ShowYesNo("是否要生成选中项相应的收款费用?", "确认")) { return; } int cnt = 0; using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <业务费用>()) { foreach (Xceed.Grid.Row row in masterForm.MasterGrid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) { continue; } 业务费用 entity = dataRow.Tag as 业务费用; if (entity.收付标志 == 收付标志.收) { continue; } rep.Initialize(entity.票, entity); 业务费用 item = new 业务费用(); item.收付标志 = 收付标志.收; item.费用实体 = entity.费用实体; item.费用项编号 = entity.费用项编号; //item.费用信息 = entity.费用信息; item.费用类别编号 = entity.费用类别编号; item.金额 = entity.金额; item.箱Id = entity.箱Id; item.相关人编号 = entity.票.委托人编号; item.票 = entity.票; item.箱 = entity.箱; object newEntity = masterForm.ControlManager.AddNew(); if (newEntity != null) { masterForm.ControlManager.DisplayManager.Items[masterForm.ControlManager.DisplayManager.Position] = item; masterForm.ControlManager.EndEdit(); //masterForm.ActiveGrid.CurrentDataRow.Cells["费用项编号"].CellEditorManager = dataRow.Cells["费用项编号"].CellEditorManager; cnt++; } else { masterForm.ControlManager.CancelEdit(); break; } } } MessageForm.ShowInfo("已生成" + cnt + "条收款费用!"); }
private void 电子作业单_Load(object sender, EventArgs e) { int[] taskIdx = null; string[] importantAreas = null; string[] importantTaskStatus = null; string[] importantWorkStatus = null; using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <车辆作业>()) { var clzy = rep.Get <车辆作业>(m_clzy.ID); m_cm.DisplayManager.SetDataBinding(new List <车辆作业> { clzy }, string.Empty); m_cm.EditCurrent(); ModelHelper.Get任务状态(clzy.专家任务, out taskIdx, out importantAreas, out importantTaskStatus, out importantWorkStatus); StringBuilder strZylx = new StringBuilder(); for (int i = 0; i < taskIdx.Length; ++i) { Xceed.Grid.DataRow row = m_作业流程.DataRows.AddNew(); row.Cells["次序"].Value = i; row.Cells["作业地点"].Value = importantAreas[i]; row.Cells["动作"].Value = importantWorkStatus[i]; var rw = clzy.专家任务.任务[taskIdx[i]]; row.Cells["箱号"].Value = rw.箱号; row.Cells["箱型"].Value = rw.箱型编号; if (importantWorkStatus[i].StartsWith("港区提箱")) { m_cm.DisplayManager.DataControls["疏港期限"].SelectedDataValue = rw.提箱时间要求.HasValue ? rw.提箱时间要求.Value : rw.提箱时间要求; } else if (importantWorkStatus[i].StartsWith("还箱") || importantWorkStatus[i].StartsWith("进港")) { m_cm.DisplayManager.DataControls["进港还箱期限"].SelectedDataValue = rw.还箱进港时间要求.HasValue ? rw.还箱进港时间要求.Value : rw.还箱进港时间要求; } else if (importantWorkStatus[i].StartsWith("卸货")) { row.Cells["详细地址"].Value = rw.卸货地详细地址; row.Cells["联系人"].Value = rw.卸货联系人; row.Cells["联系电话"].Value = rw.卸货联系手机 + "," + rw.卸货联系座机; } else if (importantWorkStatus[i].StartsWith("装货")) { row.Cells["详细地址"].Value = rw.装货地详细地址; row.Cells["联系人"].Value = rw.装货联系人; row.Cells["联系电话"].Value = rw.装货联系手机 + "," + rw.装货联系座机; } row.EndEdit(); if (i != 0) { strZylx.Append("、"); } strZylx.Append(row.Cells["作业地点"].GetDisplayText() + "(" + row.Cells["动作"].GetDisplayText() + ")"); } m_cm.DisplayManager.DataControls["作业路线"].SelectedDataValue = strZylx.ToString(); if (m_cm.DisplayManager.DataControls["开始时间"].SelectedDataValue == null) { m_cm.DisplayManager.DataControls["开始时间"].SelectedDataValue = System.DateTime.Now; } if (m_cm.DisplayManager.DataControls["车载Id号"].SelectedDataValue == null) { m_cm.DisplayManager.DataControls["车载Id号"].SelectedDataValue = clzy.车辆.车载Id号; } if (m_cm.DisplayManager.DataControls["驾驶员编号"].SelectedDataValue == null) { m_cm.DisplayManager.DataControls["驾驶员编号"].SelectedDataValue = clzy.车辆.主驾驶员编号; } } }