private void btnApply_Click(object sender, EventArgs e) { var ok = false; var buttonState = new ControlStateCollection(); if (Question.YesNo("Are you sure you want to apply changes to these levers?", this.Text)) { viewLevers.CloseEditor(); viewLevers.UpdateCurrentRow(); buttonState.SaveState(btnEdit, btnModelRun, btnApply, btnBack, btnExit); buttonState.Disable(); _allowExit = false; this.Cursor = Cursors.WaitCursor; Application.DoEvents(); base.Instance._giveItBackChanged = _giveItBackChanged; ok = base.Instance.ApplyChanges(); _giveItBackChanged = false; base.Instance._giveItBackChanged = false; this.Cursor = Cursors.Default; buttonState.RestoreState(); _allowExit = true; if (ok) { base.IsDirty = false; this.Close(); base.ShowParentForm(); } } }
/// <summary> /// Saves changes back to AS400 /// Calls program to perform a model run /// Refreshes data and grids /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnModelRun_Click(object sender, EventArgs e) { if (Question.YesNo("Commence the Model Run?", "MODEL RUN")) { viewClass.CloseEditor(); viewClass.UpdateCurrentRow(); viewClassGrade.CloseEditor(); viewClassGrade.UpdateCurrentRow(); viewClassMarket.CloseEditor(); viewClassMarket.UpdateCurrentRow(); viewClassStore.CloseEditor(); viewClassStore.UpdateCurrentRow(); viewDept.CloseEditor(); viewDept.UpdateCurrentRow(); viewDeptGrade.CloseEditor(); viewDeptGrade.UpdateCurrentRow(); viewDeptMarket.CloseEditor(); viewDeptMarket.UpdateCurrentRow(); viewDeptStore.CloseEditor(); viewDeptStore.UpdateCurrentRow(); var buttonState = new ControlStateCollection(); buttonState.SaveState(btnEdit, btnCancel, btnApply, btnModelRun, btnExit); buttonState.Disable(); _allowExit = false; try { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); if (_summaryWorkbenchInfo.IsModelRunAvailable()) { var timeStart = System.DateTime.Now; this.Cursor = Cursors.WaitCursor; base.UpdateStatusMessage("Running Model..."); if (_summaryWorkbenchInfo.SaveChanges() && _summaryWorkbenchInfo.RunModel()) { gridDept.Visible = false; gridDept.SuspendLayout(); _summaryWorkbenchInfo.AliasDrop(); _summaryWorkbenchInfo.InitialDataLoad(); _summaryWorkbenchInfo.InitialiseScreen(); ClearAllGrids(); BuildAllGrids(); BuildAllViews(); tabControl.Visible = true; gridDept.Visible = true; SetupMenu(); gridDept.ResumeLayout(); RefreshGrid(GetCurrentGrid(), GetCurrentView(), _summaryWorkbenchInfo.SelectedSummaryLevel); UpdateStatusMessage(string.Format("Model run time {0:0.0}secs", System.DateTime.Now.Subtract(timeStart).TotalSeconds)); } else UpdateStatusMessage("Failed to complete model run"); } else MessageBox.Show("Unable to process your request at this time. The system is still preparing files. Please try again in a few minutes", "Model Run", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); buttonState.RestoreState(); } catch (Exception exc) {} finally { this.Cursor = Cursors.Default; _allowExit = true; } } }
private void btnModelRun_Click(object sender, EventArgs e) { var ok = false; var buttonState = new ControlStateCollection(); if (Question.YesNo("Commence the Model Run?", this.Text)) { viewLevers.CloseEditor(); viewLevers.UpdateCurrentRow(); buttonState.SaveState(btnEdit, btnModelRun, btnApply, btnBack, btnExit); buttonState.Disable(); _allowExit = false; this.Cursor = Cursors.WaitCursor; Application.DoEvents(); base.Instance._giveItBackChanged = _giveItBackChanged; ok = base.Instance.RunModel(); _giveItBackChanged = false; base.Instance._giveItBackChanged = false; this.Cursor = Cursors.Default; buttonState.RestoreState(); _allowExit = true; if (ok) { gridLevers.RefreshDataSource(); if (base.Instance.GetGiveItBackItems.Count() > 0) { var frm = new GiveItBackConfirmationDialog(); frm.ShowForm(base.Instance.GetGiveItBackItems); } } } }
/// <summary> /// Saves changes back to AS400 /// Calls program to apply changes to the lever files /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnApply_Click(object sender, EventArgs e) { if (Question.YesNo("Are you sure you want to apply changes to these levers?", "APPLY CHANGES")) { viewClass.CloseEditor(); viewClass.UpdateCurrentRow(); viewClassGrade.CloseEditor(); viewClassGrade.UpdateCurrentRow(); viewClassMarket.CloseEditor(); viewClassMarket.UpdateCurrentRow(); viewClassStore.CloseEditor(); viewClassStore.UpdateCurrentRow(); viewDept.CloseEditor(); viewDept.UpdateCurrentRow(); viewDeptGrade.CloseEditor(); viewDeptGrade.UpdateCurrentRow(); viewDeptMarket.CloseEditor(); viewDeptMarket.UpdateCurrentRow(); viewDeptStore.CloseEditor(); viewDeptStore.UpdateCurrentRow(); var buttonState = new ControlStateCollection(); buttonState.SaveState(btnEdit, btnCancel, btnApply, btnModelRun, btnExit); buttonState.Disable(); _allowExit = false; try { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); if (_summaryWorkbenchInfo.IsModelRunAvailable()) { var timeStart = System.DateTime.Now; this.Cursor = Cursors.WaitCursor; base.UpdateStatusMessage("Applying changes..."); if (_summaryWorkbenchInfo.SaveChanges() && _summaryWorkbenchInfo.ApplyChanges()) { tabControl.Visible = false; ResetDepartmentSelector(); EditMode = false; ResetForm(); UpdateStatusMessage("Lever changes have been applied"); } else UpdateStatusMessage("Failed to apply lever changes"); } else { MessageBox.Show("Unable to process your request at this time. The system is still preparing files. Please try again in a few minutes", "Apply", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } buttonState.RestoreState(); } catch (Exception exc) {} finally { this.Cursor = Cursors.Default; _allowExit = true; } } }