Exemplo n.º 1
0
        public void InsertParty()
        {
            string result = string.Empty;
            Party  party  = null;

            try
            {
                this.Cursor = Cursors.WaitCursor;

                party = new Party();

                party.PARTY_ID   = string.Empty;
                party.PARTY_NAME = this.txtPARTY_NAME.Text;
                party.PARTY_TYPE = (string)this.icbPARTY_TYPE.EditValue;
                party.ADD1       = this.txtADD1.Text;
                party.ADD2       = this.txtADD2.Text;
                party.ADD3       = this.txtADD3.Text;
                party.ADD4       = this.txtADD4.Text;
                party.TEL        = this.txtTEL.Text;
                party.FAX        = this.txtFAX.Text;
                party.EMAIL      = this.txtEMAIL.Text;
                party.PIC        = this.txtPIC.Text;
                party.REMARK     = this.txtREMARK.Text;
                party.REC_STAT   = (bool)this.icbREC_STAT.EditValue;


                using (PartyBLL partyBll = new PartyBLL())
                {
                    result = partyBll.InsertParty(ref party, ((frmMainMenu)this.ParentForm).UserID);
                }

                if (result.Equals("OK"))
                {
                    NotifierResult.Show("Insert Complete", "Result", 50, 1000, 50, NotifyType.Safe);
                }
                else
                {
                    NotifierResult.Show(result, "Error", 100, 1000, 0, NotifyType.Warning);
                }
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                NotifierResult.Show(ex.Message, "Error", 100, 1000, 0, NotifyType.Warning);
            }
            finally
            {
                this.Cursor    = Cursors.Default;
                this.FormState = eFormState.ReadOnly;

                this.GetPartyList(string.Empty);

                if (result.Equals("OK"))
                {
                    this.txtPARTY_ID.Text = party.PARTY_ID;
                    GridView viewList = (GridView)this.grdParty.Views[0];
                    viewList.ClearSorting();
                    int position = UiUtility.GetRowHandleByColumnValue(viewList, "PARTY_ID", party.PARTY_ID);
                    if (position != 0)
                    {
                        if (position != GridControl.InvalidRowHandle)
                        {
                            this.dntParty.Position = position;
                        }
                    }
                    else
                    {
                        viewList.FocusedRowHandle = 0;
                    }
                }
            }
        }