private void mnuReviewAppAllocation_Click(object sender, EventArgs e) { var showRelease = false; var manual = new WorkbenchManualInfo(); var stockItem = new StockItem(viewLevers.GetFocusedRowCellValue(DetailedWorkbenchInfo.colAPPItemNo).ToString()); var workbench = viewLevers.GetFocusedRowCellValue(DetailedWorkbenchInfo.colWorkBench).ToString(); try { manual.ExceptionHandler.ExceptionEvent += ((ex, extraInfo, terminateApplication) => { ErrorDialog.Show(ex, extraInfo, terminateApplication); }); stockItem.ExceptionHandler.ExceptionEvent += ((ex, extraInfo, terminateApplication) => { ErrorDialog.Show(ex, extraInfo, terminateApplication); }); base.ClearStatusMessage(); this.Cursor = Cursors.WaitCursor; Application.DoEvents(); if (manual.IsItemLocked(stockItem)) base.UpdateStatusMessage("APP is being reviewed by " + manual.LockedBy, true); else if (this.IsDirty) switch (Question.YesNoCancel("Apply uncommitted changes to the model", "Review APP Allocation")) { case System.Windows.Forms.DialogResult.Yes: base.Instance._giveItBackChanged = _giveItBackChanged; showRelease = base.Instance.ApplyChanges(); _giveItBackChanged = false; base.Instance._giveItBackChanged = false; break; case System.Windows.Forms.DialogResult.No: base.Instance.DiscardChanges(); base.IsDirty = false; showRelease = true; break; case System.Windows.Forms.DialogResult.Cancel: break; } else { showRelease = true; } CriteriaSummary.SetFileGroup(base.Instance); if (showRelease) { if (base.Instance.GetNextFileGroup(workbench)) { var frm = new Forms.Workbench.WorkbenchAPPAllocationReleaseForm(); UpdateStatusMessage("Loading APP pre-pack Allocation workbench..."); var setupOk = frm.Setup(stockItem, workbench, base.Instance.GetMember(workbench)); ClearStatusMessage(); if (setupOk) { frm.ShowForm(); base.Instance.ReleaseLocks(); CriteriaSummary.SetFileGroup(base.Instance); //if (frm.RefreshParent) //{ RefreshGrid(true); //} } } } this.Cursor = Cursors.Default; } catch (Exception) { throw; } finally { base.Instance.ReleaseLocks(); } }
private void viewLevers_ShowingEditor(object sender, CancelEventArgs e) { SysInfo sysInfo = new SysInfo(); if (this.Visible) { var error = string.Empty; var workbench = (viewLevers.GetFocusedRowCellValue(DetailedWorkbenchInfo.colWorkBench) ?? string.Empty).ToString(); var storeType = (viewLevers.GetFocusedRowCellValue(DetailedWorkbenchInfo.colStoreType) ?? string.Empty).ToString(); var APPItemNo = (viewLevers.GetFocusedRowCellValue(DetailedWorkbenchInfo.colAPPItemNo) ?? string.Empty).ToString(); var stockItem = new StockItem((decimal)viewLevers.GetFocusedRowCellValue(DetailedWorkbenchInfo.colClass), (decimal)viewLevers.GetFocusedRowCellValue(DetailedWorkbenchInfo.colVendor), (decimal)viewLevers.GetFocusedRowCellValue(DetailedWorkbenchInfo.colStyle), (decimal)viewLevers.GetFocusedRowCellValue(DetailedWorkbenchInfo.colColour), (decimal)viewLevers.GetFocusedRowCellValue(DetailedWorkbenchInfo.colSize)); if (base.Instance.GetNextFileGroup(workbench)) { CriteriaSummary.SetFileGroup(base.Instance); e.Cancel = !base.Instance.LockItem(workbench, stockItem); } else { e.Cancel = true; } if (e.Cancel) { error = this.Instance.ErrorMessage; } else { // Include here any logic to determine whether a cell can be edited. switch (viewLevers.FocusedColumn.FieldName) { case DetailedWorkbenchInfo.colGiveItBack: var storType = viewLevers.GetFocusedRowCellValue(DetailedWorkbenchInfo.colStoreType); var currentLimit = (decimal)viewLevers.GetFocusedRowCellValue(GiveItBackCollection.GiveItBackMethod.ToString().ToUpper()); e.Cancel = !(currentLimit > 0 && workbench == Constants.kDaily); if (e.Cancel) { error = "Give it Back can only be applied for Daily entries where the " + GiveItBackCollection.GiveItBackMethod.ToString() + " value is greater than zero."; } if (storType.ToString() == Constants.kBricksAndMortar) { e.Cancel = true; error = "Give It Back cannot be applied to Brick && Mortar Stores."; } if (base.Instance.Parameter == DetailedWorkbenchInfo.Parameters.StyleLevel || base.Instance.Parameter == DetailedWorkbenchInfo.Parameters.StyleGradeLevel || base.Instance.Parameter == DetailedWorkbenchInfo.Parameters.StyleMarketLevel || base.Instance.Parameter == DetailedWorkbenchInfo.Parameters.StyleStoreLevel) { e.Cancel = true; error = "Cannot Give It Back at any Style level."; } break; case DetailedWorkbenchInfo.colNewAllocFlag: if (IsPackItem() && APPItemNo != string.Empty) { e.Cancel = true; error = "Allocations may not be applied to pack items with outstanding APP's."; } break; } } if (e.Cancel) base.UpdateStatusMessage(error, true); else base.ClearStatusMessage(); } }