Example #1
0
        public void SetAction(BtnEvent pAction, string pPkValue)
        {
            fAction = pAction;

            switch (fAction)
            {
            case BtnEvent.Open:
                btn_save.Text = "&CLOSE";
                obj           = CUpvc_Quotation_exten.PKId(pPkValue, new DAL());
                list          = CUpvc_Quotationitems_exten.FKId(pPkValue, new DAL());
                this.EnableControls(false);
                break;

            case BtnEvent.New:
                btn_save.Text = "&SAVE";
                obj           = CUpvc_Quotation.GetNew();
                list          = new List <Upvc_Quotationitems>();
                this.EnableControls(true);
                break;

            case BtnEvent.Edit:
                btn_save.Text = "&UPDATE";
                obj           = CUpvc_Quotation_exten.PKId(pPkValue, new DAL());
                list          = CUpvc_Quotationitems_exten.FKId(pPkValue, new DAL());
                this.EnableControls(true);
                break;

            case BtnEvent.Delete:
                btn_save.Text = "CONFIRM\r\n&DELETE";
                obj           = CUpvc_Quotation_exten.PKId(pPkValue, new DAL());
                list          = CUpvc_Quotationitems_exten.FKId(pPkValue, new DAL());
                this.EnableControls(false);
                break;

            case BtnEvent.Print:
                btn_save.Text = "&PRINT";
                obj           = CUpvc_Quotation_exten.PKId(pPkValue, new DAL());
                list          = CUpvc_Quotationitems_exten.FKId(pPkValue, new DAL());
                this.EnableControls(false);
                print_panel.Show();
                break;
            }

            LoadData(obj);
            Loaditems(list);
        }
Example #2
0
        private void Save_Event()
        {
            if (Validation() != false)
            {
                switch (fAction)
                {
                case BtnEvent.Open:
                    this.Hide();
                    Form_NeedToRefresh();
                    break;

                case BtnEvent.New:
                    try
                    {
                        var vData = CollectData();

                        dalsession = new DAL();
                        dalsession.BeginTransaction();
                        CUpvc_Quotation.Insert(vData, dalsession);
                        vId = DAL.GetIdentity(dalsession);
                        var itemsList = Collectitems(vId);
                        CUpvc_Quotationitems.Insert(itemsList, dalsession);
                        dalsession.Commit();

                        MessageBox.Show(this.FindForm(), "Record Saved Successfully.", "Save...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Hide();
                        Form_NeedToRefresh();
                    }
                    catch (Exception ex)
                    {
                        if (dalsession != null)
                        {
                            dalsession.Rollback();
                        }
                        MessageBox.Show(this.FindForm(), "Something Goes Wrong \r\n" + ex.Message, "Could Not Save...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SetFocus();
                        return;
                    }
                    break;

                case BtnEvent.Edit:
                    try
                    {
                        var vData = CollectData();

                        dalsession = new DAL();
                        dalsession.BeginTransaction();
                        CUpvc_Quotationitems.Delete(vId, dalsession);
                        CUpvc_Quotation.Update(vData, dalsession);
                        var itemsList = Collectitems(vId);
                        CUpvc_Quotationitems.Insert(itemsList, dalsession);
                        dalsession.Commit();

                        MessageBox.Show(this.FindForm(), "Record Updated Successfully.", "Update...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Hide();
                        Form_NeedToRefresh();
                    }
                    catch (Exception ex)
                    {
                        if (dalsession != null)
                        {
                            dalsession.Rollback();
                        }
                        MessageBox.Show(this.FindForm(), "Something Goes Wrong \r\n" + ex.Message, "Could Not Update...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SetFocus();
                        return;
                    }
                    break;

                case BtnEvent.Delete:
                    try
                    {
                        dalsession = new DAL();
                        dalsession.BeginTransaction();
                        CUpvc_Quotationitems.Delete(vId, dalsession);
                        CUpvc_Quotation.Delete(vId, dalsession);
                        dalsession.Commit();

                        MessageBox.Show(this.FindForm(), "Record Deleted Successfully.", "Delete...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Hide();
                        Form_NeedToRefresh();
                    }
                    catch (Exception ex)
                    {
                        if (dalsession != null)
                        {
                            dalsession.Rollback();
                        }
                        MessageBox.Show(this.FindForm(), "Something Goes Wrong \r\n" + ex.Message, "Could Not Update...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SetFocus();
                        return;
                    }
                    break;

                case BtnEvent.Print:
                    Print_copies();
                    this.Hide();
                    Form_NeedToRefresh();
                    break;
                }
            }
        }