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())); }
//check if all required columns are filled up private void IMasterDetailForm_ValidateSave() { foreach (JkDetailDataSet DataSet in IAppHandler.FindControlByType("JkDetailDataSet", this)) { foreach (JkDetailColumn column in DataSet.Columns) { if (column.Required) { foreach (DataRow row in DataSet.DataTable.Rows) { if (row.RowState != DataRowState.Deleted) { if (((row[column.Name] == null || row[column.Name] == DBNull.Value) && String.IsNullOrWhiteSpace(column.ControlName)) || (!String.IsNullOrWhiteSpace(column.ControlName) && int.Parse(row[column.Name].ToString()) == 0)) { IMessageHandler.Inform(ISystemMessages.FillRequiredFieldOnGridMessage(column.Caption)); ValidationFails = true; return; } } } } } } }
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"); } }