Exemplo n.º 1
0
        protected virtual void OnBtnNewClick(
            object sender,
            System.EventArgs e)
        {
            IBusinessObject bo;

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                // KD - The second time you added a new record wasn//t clearing the combobox until there were
                //     two calls to set the SelectIndex
                cboSelect.SelectedIndex = -1;
                cboSelect.SelectedIndex = -1;
                bo = (IBusinessObject)Utility.InvokeSharedMethod(
                    this.mBusinessObjectType,
                    "New" + this.mBusinessObjectType.Name);

                mObject = bo;
                IEditUserControl ieuc = (IEditUserControl)this.mEditUserControl;
                ieuc.SetupControl(bo);
                Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(ex.ToString());
            }
            SetState();
            this.mEditUserControl.Focus();
        }
Exemplo n.º 2
0
        private void DisplayForEdits(System.EventArgs e, object pk)
        {
            IBusinessObject bo;

            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            bo = (IBusinessObject)Utility.InvokeSharedMethod(
                this.mBusinessObjectType,
                "Get" + this.mBusinessObjectType.Name,
                pk);
            mObject = bo;
            IEditUserControl ieuc = (IEditUserControl)this.mEditUserControl;

            ieuc.SetupControl((BusinessObjectSupport.IBusinessObject)bo);
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
        }
Exemplo n.º 3
0
        private void SetState()
        {
            IEditUserControl ieuc     = (IEditUserControl)this.mEditUserControl;
            EditMode         editMode = ieuc.EditMode;

            this.btnDelete.Enabled = ((editMode == EditMode.IsClean) |
                                      (editMode == EditMode.IsDirty));
            this.btnSave.Enabled = ((editMode & EditMode.IsDirty) > 0);
            this.btnNew.Enabled  = ((editMode == EditMode.IsClean) |
                                    (editMode == EditMode.IsEmpty));
            this.btnCancel.Enabled = ((editMode & EditMode.IsDirty) > 0) |
                                     ((editMode & EditMode.IsNew) > 0);
            this.tbbDelete.Enabled = this.btnDelete.Enabled;
            this.tbbSave.Enabled   = this.btnSave.Enabled;
            this.tbbNew.Enabled    = this.btnNew.Enabled;
            this.tbbCancel.Enabled = this.btnCancel.Enabled;
        }
Exemplo n.º 4
0
        protected virtual void OnBtnCancelClick(
            object sender,
            System.EventArgs e)
        {
            IEditUserControl ieuc  = (IEditUserControl)this.mEditUserControl;
            bool             isNew = ((ieuc.EditMode & EditMode.IsNew) > 0);

            ieuc.CancelEdit();
            this.mEditUserControl.VisitControls();
            if (isNew && (cboSelect.Items.Count == 0))
            {
                SetState();
            }
            else if (isNew)
            {
                cboSelect.SelectedIndex = 0;
            }
            else
            {
                SetState();
            }
        }
Exemplo n.º 5
0
        protected override void OnLoad(System.EventArgs e)
        {
            int vMargin = ((IEditUserControl)this.mEditUserControl).VerticalMargin;
            int height;
            int width;

            base.OnLoad(e);
            if (this.CallingForm == null)
            {
                mFormMode = FormMode.Root;
            }
            else if (this.CallingForm is BaseEditForm)
            {
                mFormMode = FormMode.Child;
            }
            else
            {
                mFormMode = FormMode.Root;
            }
            if (mFormMode == FormMode.Child)
            {
                btnSave.Text = "OK";
            }
            else
            {
                btnSave.Text = "Save";
            }

            IEditUserControl ieuc = (IEditUserControl)this.mEditUserControl;

            this.cboSelect.Left  = ieuc.ControlLeft;
            this.cboSelect.Width = ieuc.ControlWidth;
            btnSave.Top          = ieuc.ControlTop;
            btnNew.Top           = btnSave.Bottom;
            btnDelete.Top        = btnNew.Bottom;
            btnCancel.Top        = btnDelete.Bottom;
            btnClose.Top         = btnCancel.Bottom;

            foreach (System.Windows.Forms.Control ctl in this.Controls)
            {
                if (ctl is IEditUserControl)
                {
                    (( IEditUserControl )ctl).SetupControl(mObject);
                }
            }

            ResetDatasource(null);
            this.tbbSearch.Pushed  = true;
            this.tbbGrid.Pushed    = false;
            this.pnlSelect.Visible = tbbSearch.Pushed;

            this.pnlSelect.Dock        = DockStyle.Top;
            this.pnlBottom.Dock        = DockStyle.Fill;
            this.pnlButtons.Dock       = DockStyle.Right;
            this.pnlEdit.Dock          = DockStyle.Fill;
            this.mEditUserControl.Dock = DockStyle.Fill;
            this.cboSelect.Width       = ((IEditUserControl)this.mEditUserControl).ControlWidth;
            this.cboSelect.Anchor      = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;

            if (ieuc.IdealHeight > 0)
            {
                height = ieuc.IdealHeight;
            }
            else
            {
                height = mEditUserControl.Height;
            }
            if (ieuc.IdealWidth > 0)
            {
                width = ieuc.IdealWidth + this.pnlButtons.Width;
            }
            else
            {
                width = this.ClientSize.Width;
            }
            if (height < mBtnLast.Bottom + vMargin)
            {
                height = mBtnLast.Bottom + vMargin;
            }
            else
            {
                height += 2 * vMargin;
            }
            this.ClientSize = new System.Drawing.Size(width, pnlBottom.Top + height);


            mbIsLoaded = true;
            if (this.cboSelect.Items.Count > 0)
            {
                this.cboSelect.SelectedIndex = -1;
                this.cboSelect.SelectedIndex = 0;
            }
        }
Exemplo n.º 6
0
        protected override void OnLoad(System.EventArgs e)
        {
            int vMargin = ((IEditUserControl)this.mEditUserControl).VerticalMargin;
            int height  = 0;
            int width   = 0;

            base.OnLoad(e);
            if (this.CallingForm == null)
            {
                mFormMode = FormMode.Root;
            }
            else if (this.CallingForm is BaseEditForm)
            {
                mFormMode = FormMode.Child;
            }
            else
            {
                mFormMode = FormMode.Root;
            }
            if (mFormMode == FormMode.Child)
            {
                btnSave.Text = "OK";
            }
            else
            {
                btnSave.Text = "Save";
            }

            foreach (System.Windows.Forms.Control ctl  in this.Controls)
            {
                if (ctl is IEditUserControl)
                {
                    ((IEditUserControl)ctl).SetupControl(mObject);
                }
            }

            //  this.pnlButtons.BringToFront()
            this.pnlButtons.Dock       = DockStyle.Right;
            this.pnlEdit.Dock          = DockStyle.Fill;
            this.mEditUserControl.Dock = DockStyle.None;
            this.mEditUserControl.Dock = DockStyle.Fill;

            //Height = CType(this.mEditUserControl , IEditUserControl).IdealHeight
            IEditUserControl ieuc = (IEditUserControl)this.mEditUserControl;

            if (ieuc.IdealHeight > 0)
            {
                height = ieuc.IdealHeight;
            }
            else
            {
                height = mEditUserControl.Height;
            }
            if (ieuc.IdealWidth > 0)
            {
                width = ieuc.IdealWidth + this.pnlButtons.Width;
            }
            else
            {
                width = this.ClientSize.Width;
            }
            if (height < mBtnLast.Bottom + vMargin)
            {
                height = mBtnLast.Bottom + vMargin;
            }
            else
            {
                height += 2 * vMargin;
            }
            this.ClientSize = new System.Drawing.Size(width, height);

            mbIsLoaded = true;
        }