public void Run() { try { IAppHandler.StartBusy("Preparing controls"); if (!this.Visible) { this.Show(); } IAppHandler.SuspendDrawing(this); EditingReady = false; //setup data first before controls, since there are //controls which are dependent on data OnSetupData(); OnSetupControl(); } finally { IAppHandler.ResumeDrawing(this); EditingReady = true; IAppHandler.EndBusy("Preparing controls"); } }
public static DialogResult ShowSelection(String FormName, String FilterName = null, List <String> Filters = null) { IPopupForm selection = null; selection = Activator.CreateInstance(Type.GetType("Jk_Accounting_Software.External.Popup." + FormName)) as IPopupForm; if (selection == null) { IMessageHandler.Inform(ISystemMessages.NoFormFound(FormName)); return(DialogResult.Cancel); } try { IAppHandler.StartBusy("Opening filter selection"); selection.StartPosition = FormStartPosition.CenterScreen; selection.Text = IAppHandler.ApplicationText; selection.LoadData(); selection.LoadFilter(FilterName, Filters); } finally { IAppHandler.EndBusy("Opening filter selection"); } return(selection.ShowDialog(IAppHandler.FindActiveForm())); }
private void ReQuery(object sender, EventArgs e) { try { IAppHandler.StartBusy("Fetching record"); switch (Convert.ToInt16((sender as ToolStripButton).Tag)) { case 1: KeyId = 0; break; case 2: KeyId -= 1; break; case 3: KeyId += 1; break; case 4: KeyId = KeyList.Count - 1; break; } Parameters[0].Value = Convert.ToString(KeyList[KeyId]); Run(); } finally { IAppHandler.EndBusy("Fetching record"); } }
private void reportViewer_ReportRefresh(object sender, CancelEventArgs e) { try { IAppHandler.StartBusy("Reloading report"); } finally { IAppHandler.EndBusy("Reloading report"); } }
private void GenerateReport() { try { IAppHandler.StartBusy("Generating report"); RefreshReport(); } finally { IAppHandler.EndBusy("Generating report"); } }
private void btnDone_Click(object sender, EventArgs e) { dataGridView.EndEdit(); if (dstMaster.DataTable.Select("Selected = 1").Length == 0) { IMessageHandler.Inform(ISystemMessages.SelectAtLeastOne); return; } try { IAppHandler.StartBusy("Filtering report"); DialogResult = DialogResult.OK; PerformOperation(); this.Close(); } finally { IAppHandler.EndBusy("Filtering report"); } }
protected virtual void OnOpenForm(IParentForm Form, object sender) { String senderName = null; if (sender.GetType().Name == "ToolStripButton" && (sender as ToolStripButton).Name == "btnNew") { senderName = "btnNew"; Form = IAppHandler.FindForm(this.NewFormName); } else { Form = IAppHandler.FindForm(this.OpenFormName); } try { IAppHandler.StartBusy("Opening master form"); if (Form == null) { if (senderName == "btnNew") { IMessageHandler.Inform(ISystemMessages.NoFormFound(this.NewFormName)); } else { IMessageHandler.Inform(ISystemMessages.NoFormFound(this.OpenFormName)); } return; } if (senderName == "btnNew") { Form.FormState = FormStates.fsNew; } else { Form.FormState = FormStates.fsView; } for (int i = 0; i <= this.Parameters.Count - 1; i++) { for (int j = 0; j <= Form.Parameters.Count - 1; j++) { if (this.Parameters[i].Name == Form.Parameters[j].Name) { Form.Parameters[j].Value = this.Parameters[i].Value; } if (Form.Parameters[j].Name == "Id") { if (Form.FormState == FormStates.fsNew) { Form.Parameters[j].Value = String.Empty; } else { Form.Parameters[j].Value = GetSelectedValueOnGrid(dataGridView, 0, "dataGridViewColumnId"); } } } } if (OpenForm != null) { OpenForm(); } (Form as IMasterForm).KeyList.Clear(); for (int i = 0; i <= dataGridView.Rows.Count - 1; i++) { (Form as IMasterForm).KeyList.Add(dataGridView.Rows[i].Cells[0].Value.ToString()); if (Form.Parameters[0].Value == dataGridView.Rows[i].Cells[0].Value.ToString()) { (Form as IMasterForm).KeyId = i; } } IAppHandler.AddUsedForm(this); this.Hide(); Form.Run(); } finally { IAppHandler.EndBusy("Opening master form"); } }
private void AssignEventOnButtons() { btnNew.Click += (obj, e) => { if (!btnNew.Visible || !btnNew.Enabled) { return; } try { IAppHandler.StartBusy("Executing New"); FormState = FormStates.fsNew; Run(); VMasterDataTable.Clear(); foreach (JkDetailDataSet DataSet in IAppHandler.FindControlByType("JkDetailDataSet", this)) { DataSet.DataTable.Clear(); } } finally { IAppHandler.EndBusy("Executing New"); } }; btnEdit.Click += (obj, e) => { if (!btnEdit.Visible || !btnEdit.Enabled) { return; } try { IAppHandler.StartBusy("Executing Edit"); FormState = FormStates.fsEdit; Run(); } finally { IAppHandler.EndBusy("Executing Edit"); } }; btnSave.Click += (obj, e) => { Control focusedControl = IAppHandler.FindFocusedControl(this); if (!btnSave.Visible || !btnSave.Enabled) { return; } //remove focus on databound controls, so that it will perform its validation or computation this.splitContainer.Panel2.Focus(); //perform Validation first OnValidateSave(); if (ValidationFails) { if (focusedControl != null) { focusedControl.Select(); } return; } if (IMessageHandler.Confirm(ISystemMessages.SavingQuestion) == DialogResult.Yes) { try { IAppHandler.StartBusy("Executing Save"); OnBeforeSave(); //this should be called after before save, so that before save can be used on //performing operations before assigning it to MasterColumns SetColumnsValue(); try { try { //all of the events which interacts with the database //should be just put in one connection, so if in case //error occurs all the processes will be rolled back VTransactionHandler.Connect(); VTransactionHandler.BeginTran(); if (FormState == FormStates.fsEdit) { UnPost(); } if (FormState == FormStates.fsNew) { VTransactionHandler.SaveMaster(CommandText, ref VMasterDataTable, Parameters); SaveDetail(); } else if (FormState == FormStates.fsEdit) { VTransactionHandler.EditMaster(CommandText, Parameters); EditDetail(); } Post(); VTransactionHandler.CommitTran(); } catch (Exception ex) { VTransactionHandler.Rollback(); if (FormState == FormStates.fsNew) { IMessageHandler.ShowError(ISystemMessages.SaveDataError + ex.Message); } else { IMessageHandler.ShowError(ISystemMessages.EditDataError + ex.Message); } return; } } finally { VTransactionHandler.Disconnect(); } if (FormState == FormStates.fsNew) { KeyList.Add(Parameters[0].Value); KeyId = KeyList.Count() - 1; } OnAfterSave(); FormState = FormStates.fsView; Run(); } finally { IAppHandler.EndBusy("Executing Save"); } } }; btnCancel.Click += (obj, e) => { if (!btnCancel.Visible || !btnCancel.Enabled) { return; } if (IMessageHandler.Confirm(ISystemMessages.ClosingOrCancellingQuestion) == DialogResult.Yes) { this.splitContainer.Panel2.Focus(); try { IAppHandler.StartBusy("Executing Cancel"); if (FormState == FormStates.fsNew) { if (ParametersHasValues()) { FormState = FormStates.fsView; Run(); } else { CloseForm(); } } else { FormState = FormStates.fsView; Run(); } } finally { IAppHandler.EndBusy("Executing Cancel"); } } }; btnFirstRecord.Click += (obj, e) => { if (!btnFirstRecord.Visible || !btnFirstRecord.Enabled) { return; } ReQuery(obj, e); }; btnPreviousRecord.Click += (obj, e) => { if (!btnPreviousRecord.Visible || !btnPreviousRecord.Enabled) { return; } ReQuery(obj, e); }; btnNextRecord.Click += (obj, e) => { if (!btnNextRecord.Visible || !btnNextRecord.Enabled) { return; } ReQuery(obj, e); }; btnLastRecord.Click += (obj, e) => { if (!btnLastRecord.Visible || !btnLastRecord.Enabled) { return; } ReQuery(obj, e); }; }