コード例 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid && Page.IsPostBack)
            {
                Classes.CCashAccount ca = new Classes.CCashAccount();
                Models.MCashAccount  ma = new Models.MCashAccount();
                ma.AccountType     = "Personal";
                ma.BeginDate       = txtBeginDate.Text;
                ma.CashAccountName = txtCashAccountName.Text;
                ma.ClientId        = -1;
                ma.VendorId        = -1;
                ma.OpeningBalance  = txtOpeningBalance.Text;
                ma.WareHouseId     = Convert.ToInt32(Session["WareHouse"].ToString());
                ma.AccountType     = ma.AccountType = Common.Constants.CashAccountTypes.Personal.ToString();
                if (ca.Save(ma) > 0)
                {
                    Classes.CCashTransaction cct = new Classes.CCashTransaction();
                    Models.MCashTransactions mct = new Models.MCashTransactions();
                    mct.CashAccountId   = ca.GetLastAccountId();
                    mct.Credit          = txtOpeningBalance.Text;
                    mct.Debit           = "0";
                    mct.Description     = "Opened Account";
                    mct.eDate           = txtBeginDate.Text;
                    mct.FiscalYearId    = Convert.ToInt32(Session["FiscalYear"].ToString());
                    mct.OrderId         = -1;
                    mct.Total           = txtOpeningBalance.Text;
                    mct.TransactionId   = -1;
                    mct.TransactionType = "Credit";
                    mct.WareHouseId     = Convert.ToInt32(Session["WareHouse"].ToString());

                    mct.UserId = Session["UserId"].ToString();
                    if (cct.Save(mct) > 0)
                    {
                        ShowSuccessMessage();
                    }
                    else
                    {
                        ShowFailMessage();
                    }
                }
                else
                {
                    ShowFailMessage();
                }
            }
        }
コード例 #2
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (Session["WareHouse"] != null)
     {
         string WareHouseId = Session["WareHouse"].ToString();
         if (Convert.ToInt32(ddlClientType.SelectedValue) > 0)
         {
             string ClientTypeId   = ddlClientType.SelectedValue.ToString();
             string ClientName     = txtClientName.Text;
             string ClientPhone    = txtPhone.Text;
             string ClientEmail    = txtEmail.Text;
             string ClientAddress1 = txtAddress1.Text;
             string ClientAddress2 = txtAddress2.Text;
             string City           = txtCity.Text;
             string eDate          = DateTime.Now.ToString();
             bool   IsVendor       = false;
             if (cbIsVendor.Checked)
             {
                 IsVendor = true;
             }
             Models.MClients mc = new Models.MClients();
             mc.ClientTypeld = ClientTypeId;
             mc.Name         = ClientName;
             mc.phone        = ClientPhone;
             mc.Address1     = ClientAddress1;
             mc.Address2     = ClientAddress2;
             mc.EmailAddress = ClientEmail;
             mc.City         = City;
             mc.isVendor     = IsVendor;
             mc.edate        = eDate;
             mc.WareHouseId  = (WareHouseId);
             mc.GrantorName  = txtGrantorName.Text;
             mc.NIC          = txtNIC.Text;
             mc.GrantorNIC   = txtGrantorNIC.Text;
             Classes.CClients cc = new Classes.CClients();
             if (cc.Save(mc) > 0)
             {
                 Classes.CCashAccount ca = new Classes.CCashAccount();
                 Models.MCashAccount  ma = new Models.MCashAccount();
                 ma.CashAccountName = ClientName;
                 ma.BeginDate       = eDate;
                 ma.ClientId        = cc.GetLastClientId();
                 ma.OpeningBalance  = "0";
                 ma.AccountType     = Common.Constants.CashAccountTypes.Client.ToString();
                 ma.VendorId        = -1;
                 ma.WareHouseId     = Convert.ToInt32(Session["WareHouse"].ToString());
                 if (ca.Save(ma) > 0)
                 {
                     Classes.CCashTransaction cct = new Classes.CCashTransaction();
                     Models.MCashTransactions mct = new Models.MCashTransactions();
                     mct.CashAccountId   = ca.GetLastAccountId();
                     mct.Credit          = "0";
                     mct.Debit           = "0";
                     mct.Description     = "Opened Client Account[" + txtClientName.Text + "]";
                     mct.eDate           = DateTime.Now.ToShortDateString();
                     mct.FiscalYearId    = Convert.ToInt32(Session["FiscalYear"].ToString());
                     mct.OrderId         = -1;
                     mct.Total           = "0";
                     mct.TransactionId   = -1;
                     mct.TransactionType = "Credit";
                     mct.WareHouseId     = Convert.ToInt32(Session["WareHouse"].ToString());
                     mct.UserId          = Session["UserId"].ToString();
                     if (cct.Save(mct) > 0)
                     {
                         ShowSuccessMessage();
                         ClearTextBoxes(Page);
                     }
                     else
                     {
                         ShowFailMessage();
                     }
                 }
                 else
                 {
                     ShowErrorModal("Client Saved but Account was not opened");
                 }
             }
             else
             {
                 ShowFailMessage();
             }
         }
     }
     else
     {
         ShowErrorModal("Cannot Save, No Warehouse associated with current user");
     }
 }
コード例 #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Session["WareHouse"] != null)
            {
                string WareHouseId = Session["WareHouse"].ToString();

                if (Page.IsValid)
                {
                    string         VendorName    = txtVendorName.Text;
                    string         VendorAddress = txtVendorAddress.Text;
                    string         VendorPhone   = txtVendorPhoneNo.Text;
                    Models.MVendor mv            = new Models.MVendor();
                    mv.name        = VendorName;
                    mv.Addreess    = VendorAddress;
                    mv.phone       = VendorPhone;
                    mv.WareHouseId = WareHouseId;
                    Classes.CVendor ccv = new Classes.CVendor();
                    if (ccv.Save(mv) > 0)
                    {
                        //ShowFailMessage();
                        Classes.CCashAccount ca = new Classes.CCashAccount();
                        Models.MCashAccount  ma = new Models.MCashAccount();
                        ma.CashAccountName = VendorName;
                        ma.BeginDate       = DateTime.Now.ToShortDateString();
                        ma.ClientId        = -1;
                        ma.OpeningBalance  = "0";
                        ma.AccountType     = ma.AccountType = Common.Constants.CashAccountTypes.Vendor.ToString();
                        ma.VendorId        = ccv.GetLastVendorId();;
                        ma.WareHouseId     = Convert.ToInt32(Session["WareHouse"].ToString());
                        if (ca.Save(ma) > 0)
                        {
                            Classes.CCashTransaction cct = new Classes.CCashTransaction();
                            Models.MCashTransactions mct = new Models.MCashTransactions();
                            mct.CashAccountId   = ca.GetLastAccountId();
                            mct.Credit          = "0";
                            mct.Debit           = "0";
                            mct.Description     = "Opened Client Account[" + txtVendorName.Text + "]";
                            mct.eDate           = DateTime.Now.ToShortDateString();
                            mct.FiscalYearId    = Convert.ToInt32(Session["FiscalYear"].ToString());
                            mct.OrderId         = -1;
                            mct.Total           = "0";
                            mct.TransactionId   = -1;
                            mct.TransactionType = "Credit";
                            mct.WareHouseId     = Convert.ToInt32(Session["WareHouse"].ToString());
                            mct.UserId          = Session["UserId"].ToString();
                            if (cct.Save(mct) > 0)
                            {
                                ShowSuccessMessage();
                                ClearTextBoxes(Page);
                            }
                            else
                            {
                                ShowFailMessage();
                            }
                        }
                        else
                        {
                            ShowErrorModal("Vendor Saved but Account was not opened");
                        }
                    }
                    else
                    {
                        ShowFailMessage();
                    }
                }
            }
            else
            {
                ShowErrorModal("Cannot Save, No Warehouse associated with current user");
            }
        }