Пример #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (!btnEdit.Enabled)
            {
                return;
            }
            if (!grdRecords.Redraw)
            {
                return;
            }
            if (grdRecords.DataSource == null)
            {
                return;
            }
            if (grdRecords.RowSel < grdRecords.Rows.Fixed)
            {
                return;
            }

            Form _dialog = null; object _reference = null;

            foreach (Form _form in MdiParent.MdiChildren)
            {
                if (Materia.MethodExists(_form, "StayInBackground"))
                {
                    try { Materia.InvokeMethod(_form, "StayInBackground"); }
                    catch { }
                }
            }

            switch (_selectedsubmodule)
            {
            case SubModule.BankAccounts:
                _reference = grdRecords[grdRecords.RowSel, "BankAccountCode"].ToString();

                foreach (Form _form in MdiParent.MdiChildren)
                {
                    if (_form is BankInformationDialog)
                    {
                        _dialog = _form; break;
                    }
                }

                if (_dialog == null)
                {
                    _dialog = new BankInformationDialog(_reference.ToString());
                }
                else
                {
                    ((BankInformationDialog)_dialog).LoadBankAccountInformation(_reference.ToString());
                }

                break;

            case SubModule.Customers:
                _reference = grdRecords[grdRecords.RowSel, "CustomerCode"].ToString();

                foreach (Form _form in MdiParent.MdiChildren)
                {
                    if (_form is CustomersInformationDialog)
                    {
                        _dialog = _form; break;
                    }
                }

                if (_dialog == null)
                {
                    _dialog = new CustomersInformationDialog(_reference.ToString());
                }
                else
                {
                    ((CustomersInformationDialog)_dialog).LoadCustomerInformation(_reference.ToString());
                }

                break;

            case SubModule.PartsInventory:
                _reference = grdRecords[grdRecords.RowSel, "PartCode"].ToString();

                foreach (Form _form in MdiParent.MdiChildren)
                {
                    if (_form is PartInformationDialog)
                    {
                        _dialog = _form; break;
                    }
                }

                if (_dialog == null)
                {
                    _dialog = new PartInformationDialog(_reference.ToString());
                }
                ((PartInformationDialog)_dialog).InvokingForm = this;
                break;

            default: break;
            }

            if (_dialog != null)
            {
                _dialog.FormClosed -= new FormClosedEventHandler(_dialog_FormClosed);
                _dialog.FormClosed += new FormClosedEventHandler(_dialog_FormClosed);
                _dialog.MdiParent   = MdiParent; _dialog.WindowState = FormWindowState.Maximized;
                _dialog.MinimizeBox = false; _dialog.MaximizeBox = false;
                _dialog.ControlBox  = false; _dialog.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                _dialog.Dock        = DockStyle.Fill; _dialog.TopMost = true;
                _dialog.Show(); _dialog.Activate();
                _dialog.Size        = this.Size;
                _dialog.WindowState = FormWindowState.Normal;
                _dialog.WindowState = FormWindowState.Maximized;

                if (!Materia.IsNullOrNothing(_reference))
                {
                    if (_dialog is PartInformationDialog)
                    {
                        ((PartInformationDialog)_dialog).LoadPartInformation(_reference.ToString());
                    }
                    else
                    {
                    }
                }
            }
        }
Пример #2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            if (!btnNew.Enabled)
            {
                return;
            }

            Form _dialog = null;

            foreach (Form _form in MdiParent.MdiChildren)
            {
                if (Materia.MethodExists(_form, "StayInBackground"))
                {
                    try { Materia.InvokeMethod(_form, "StayInBackground"); }
                    catch { }
                }
            }

            switch (_selectedsubmodule)
            {
            case SubModule.BankAccounts:
                foreach (Form _form in MdiParent.MdiChildren)
                {
                    if (_form is BankInformationDialog)
                    {
                        _dialog = _form; break;
                    }
                }

                if (_dialog == null)
                {
                    _dialog = new BankInformationDialog();
                }
                else
                {
                    ((BankInformationDialog)_dialog).ClearInformation();
                }

                break;

            case SubModule.Customers:
                foreach (Form _form in MdiParent.MdiChildren)
                {
                    if (_form is CustomersInformationDialog)
                    {
                        _dialog = _form; break;
                    }
                }

                if (_dialog == null)
                {
                    _dialog = new CustomersInformationDialog();
                }
                else
                {
                    ((CustomersInformationDialog)_dialog).ClearInformation();
                }

                break;

            case SubModule.PartsInventory:
                foreach (Form _form in MdiParent.MdiChildren)
                {
                    if (_form is PartInformationDialog)
                    {
                        if (((PartInformationDialog)_form).Superseded == null)
                        {
                            _dialog = _form; break;
                        }
                    }
                }

                if (_dialog == null)
                {
                    _dialog = new PartInformationDialog();
                }
                else
                {
                    ((PartInformationDialog)_dialog).ClearInformation();
                }

                ((PartInformationDialog)_dialog).InvokingForm = this;
                break;

            default: break;
            }

            if (_dialog != null)
            {
                _dialog.FormClosed -= new FormClosedEventHandler(_dialog_FormClosed);
                _dialog.FormClosed += new FormClosedEventHandler(_dialog_FormClosed);
                _dialog.MdiParent   = MdiParent; _dialog.WindowState = FormWindowState.Maximized;
                _dialog.MinimizeBox = false; _dialog.MaximizeBox = false;
                _dialog.ControlBox  = false; _dialog.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                _dialog.Dock        = DockStyle.Fill; _dialog.TopMost = true;
                _dialog.Show(); _dialog.Activate();
                _dialog.Size        = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                _dialog.WindowState = FormWindowState.Normal;
                _dialog.WindowState = FormWindowState.Maximized;
            }
        }