private void btnAddPassLand_Click(object sender, EventArgs e) { try { if (gvDetail.FocusedRowHandle < 0) { return; } TaskConfigMustPass CurrConfigPass = baPass.Current as TaskConfigMustPass; if (CurrConfigPass != null) { IList <TaskConfigMustPass> AllPassLands = baPass.List as IList <TaskConfigMustPass>; if (AllPassLands != null && AllPassLands.Count(p => p.MustPassLandCode == CurrConfigPass.MustPassLandCode) > 1) { gvPass.FocusedColumn = colMustPassLandCode; gvPass.ShowEditor(); return; } if (string.IsNullOrEmpty(CurrConfigPass.MustPassLandCode)) { gvPass.FocusedColumn = colMustPassLandCode; gvPass.ShowEditor(); return; } } TaskConfigDetail CurrConfigDetail = bsDetail[gvDetail.FocusedRowHandle] as TaskConfigDetail; if (CurrConfigDetail != null) { TaskConfigMustPass newitem = new TaskConfigMustPass(); newitem.TaskConditonCode = CurrConfigDetail.TaskConditonCode; newitem.TaskConfigDetailID = CurrConfigDetail.DetailID; newitem.MustPassIOAction = new List <IOActionInfo>(); this.baPass.Add(newitem); this.baPass.ResetBindings(false); this.baPass.MoveLast(); gvPass.FocusedColumn = colMustPassLandCode; gvPass.ShowEditor(); } } catch (Exception ex) { MsgBox.ShowError(ex.Message); } }
private void gvDetail_BeforeLeaveRow(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e) { try { gvPass.BeforeLeaveRow -= gvPass_BeforeLeaveRow; labelControl1.Focus(); gvDetail.CloseEditor(); labelControl1.Focus(); e.Allow = Valid(); if (!e.Allow) { return; } if (gvDetail.FocusedRowHandle >= 0) { TaskConfigDetail CurrDetail = bsDetail[gvDetail.FocusedRowHandle] as TaskConfigDetail; if (CurrDetail != null) { if (gvPass.FocusedRowHandle >= 0) { TaskConfigMustPass CurrConfigPass = baPass[gvPass.FocusedRowHandle] as TaskConfigMustPass; if (CurrConfigPass != null) { if (string.IsNullOrEmpty(CurrConfigPass.MustPassLandCode)) { baPass.RemoveCurrent(); } } IList <IOActionInfo> Actions = bsIOActions.List as IList <IOActionInfo>; CurrConfigPass.MustPassIOAction = Actions; } IList <TaskConfigMustPass> ConfigMustPasss = baPass.List as List <TaskConfigMustPass>; if (ConfigMustPasss != null) { CurrDetail.TaskConfigMustPass = DataToObject.CreateDeepCopy <IList <TaskConfigMustPass> >(ConfigMustPasss); } } } } catch (Exception ex) { MsgBox.ShowError(ex.Message); } finally { gvPass.BeforeLeaveRow += gvPass_BeforeLeaveRow; } }
private void gvPass_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { try { if (gvPass.FocusedRowHandle < 0) { bsIOActions.Clear(); bsIOActions.ResetBindings(false); return; } TaskConfigMustPass CurrConfigPass = baPass[gvPass.FocusedRowHandle] as TaskConfigMustPass; if (CurrConfigPass != null) { this.bsIOActions.DataSource = CurrConfigPass.MustPassIOAction; this.bsIOActions.ResetBindings(false); } } catch (Exception ex) { MsgBox.ShowError(ex.Message); } }
private void gvPass_BeforeLeaveRow(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e) { try { if (gvPass.FocusedRowHandle < 0) { return; } TaskConfigMustPass CurrConfigPass = baPass[gvPass.FocusedRowHandle] as TaskConfigMustPass; if (CurrConfigPass != null) { IList <TaskConfigMustPass> AllPassLands = baPass.List as IList <TaskConfigMustPass>; if (AllPassLands != null && AllPassLands.Count(p => p.MustPassLandCode == CurrConfigPass.MustPassLandCode) > 1) { gvPass.FocusedColumn = colMustPassLandCode; gvPass.ShowEditor(); e.Allow = false; return; } if (string.IsNullOrEmpty(CurrConfigPass.MustPassLandCode)) { gvPass.FocusedColumn = colMustPassLandCode; gvPass.ShowEditor(); e.Allow = false; return; } IList <IOActionInfo> IOActions = bsIOActions.List as List <IOActionInfo>; if (IOActions != null) { CurrConfigPass.MustPassIOAction = DataToObject.CreateDeepCopy <IList <IOActionInfo> >(IOActions); } } } catch (Exception ex) { MsgBox.ShowError(ex.Message); } }
private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { gvPass.BeforeLeaveRow -= gvPass_BeforeLeaveRow; gvDetail.CloseEditor(); labelControl1.Focus(); if (!Valid()) { return; } if (gvPass.FocusedRowHandle >= 0) { TaskConfigMustPass CurrConfigPass = baPass[gvPass.FocusedRowHandle] as TaskConfigMustPass; if (CurrConfigPass != null) { if (string.IsNullOrEmpty(CurrConfigPass.MustPassLandCode)) { baPass.RemoveCurrent(); } IList <IOActionInfo> IOActions = bsIOActions.List as List <IOActionInfo>; if (IOActions != null) { CurrConfigPass.MustPassIOAction = DataToObject.CreateDeepCopy <IList <IOActionInfo> >(IOActions); } } } if (gvDetail.FocusedRowHandle >= 0) { TaskConfigDetail CurrDetail = bsDetail[gvDetail.FocusedRowHandle] as TaskConfigDetail; if (CurrDetail != null) { IList <TaskConfigMustPass> ConfigMustPasss = baPass.List as List <TaskConfigMustPass>; if (ConfigMustPasss != null) { CurrDetail.TaskConfigMustPass = DataToObject.CreateDeepCopy <IList <TaskConfigMustPass> >(ConfigMustPasss); } } } TaskConfigInfo CurrTaskConfig = bsConfig.Current as TaskConfigInfo; IList <TaskConfigDetail> AllTaskConfigDetail = bsDetail.List as IList <TaskConfigDetail>; if (CurrTaskConfig != null && AllTaskConfigDetail != null && AllTaskConfigDetail.Count > 0) { if (CurrTaskConfig.IsNew && AllTaskConfigs.Where(p => p.TaskConditonCode == CurrTaskConfig.TaskConditonCode).Count() > 0) { MsgBox.ShowWarn("任务条件配置编号已存在!"); return; } CurrTaskConfig.TaskConfigDetail = DataToObject.CreateDeepCopy <IList <TaskConfigDetail> >(AllTaskConfigDetail); OperateReturnInfo opr = AGVDAccess.AGVClientDAccess.SaveTaskConfig(CurrTaskConfig); MsgBox.Show(opr); if (opr.ReturnCode == OperateCodeEnum.Success) { this.DialogResult = DialogResult.OK; } } } catch (Exception ex) { MsgBox.ShowError(ex.Message); } finally { gvPass.BeforeLeaveRow += gvPass_BeforeLeaveRow; } }