private void BindDropDowns()
        {
            List <Models.MBankAccount> BankAccount = new List <Models.MBankAccount>();
            List <Models.MCashAccount> CashAccount = new List <Models.MCashAccount>();

            Classes.CBankOfAccount ca = new Classes.CBankOfAccount();
            Classes.CCashAccount   cc = new Classes.CCashAccount();
            BankAccount = ca.GetAll();
            CashAccount = cc.GetAll();
            BankAccount = BankAccount.Where(o => o.WareHouseId == Session["WareHouse"].ToString()).ToList();
            CashAccount = CashAccount.Where(o => o.WareHouseId == Convert.ToInt32(Session["WareHouse"].ToString())).ToList();
            Dictionary <int, string> Bank = new Dictionary <int, string>();
            Dictionary <int, string> Cash = new Dictionary <int, string>();

            Cash.Add(-1, "Please Select");
            Bank.Add(-1, "Please Select");
            for (int i = 0; i < CashAccount.Count; i++)
            {
                Cash.Add(CashAccount[i].id, CashAccount[i].CashAccountName);
            }
            for (int i = 0; i < BankAccount.Count; i++)
            {
                Bank.Add(Convert.ToInt32(BankAccount[i].id), BankAccount[i].Accounttitle + "-" + BankAccount[i].accountNumber);
            }
            ddlCashAccount.DataTextField  = "Value";
            ddlCashAccount.DataValueField = "Key";
            ddlSaleAccount.DataTextField  = "Value";
            ddlSaleAccount.DataValueField = "Key";
            ddlCashAccount.DataSource     = Cash;
            ddlSaleAccount.DataSource     = Bank;
            ddlCashAccount.DataBind();
            ddlSaleAccount.DataBind();
        }
        private int TransferAmount()
        {
            string CashAccountId = string.Empty;
            string BankAccountId = string.Empty;
            string Amount        = string.Empty;
            string ActualBalance = string.Empty;

            CashAccountId = ddlCashAccount.SelectedValue.ToString();
            BankAccountId = ddlBankAccount.SelectedValue.ToString();
            Amount        = txtAmount.Text;
            ActualBalance = lblCashAccount.Text;
            if (CashAccountId != "-1")
            {
                if (BankAccountId != "-1")
                {
                    float differece      = Convert.ToSingle(Amount) - Convert.ToSingle(ActualBalance);
                    float oldBankBalance = Convert.ToSingle(lblBankAccount.Text);
                    if (differece >= 0)
                    {
                        Classes.CBankOfAccount cb  = new Classes.CBankOfAccount();
                        Classes.CCashAccount   cca = new Classes.CCashAccount();
                        if (cb.SetNewAccountTotal(Convert.ToInt32(BankAccountId), oldBankBalance + Convert.ToSingle(Amount)) > 0)
                        {
                            float oldCashAccount = Convert.ToSingle(lblCashAccount.Text);
                            float newCashTotal   = Convert.ToSingle(oldCashAccount - Convert.ToSingle(Amount));
                            if (cca.SetNewAccountTotal(Convert.ToInt32(CashAccountId), newCashTotal) > 0)
                            {
                                return(1);
                            }
                            else
                            {
                                return(-5);
                            }
                        }
                        else
                        {
                            return(-4);
                        }
                    }
                    else
                    {
                        return(-3);
                    }
                }
                else
                {
                    return(-2);
                }
            }
            else
            {
                return(-1);
            }
        }
Example #3
0
        private void BindData()
        {
            Classes.CCashAccount       ca          = new Classes.CCashAccount();
            List <Models.MCashAccount> CashAccount = new List <Models.MCashAccount>();

            CashAccount = ca.GetAll();
            CashAccount = CashAccount.Where(o =>
                                            o.WareHouseId == Convert.ToInt32(Session["WareHouse"].ToString()) &&
                                            o.ClientId == -1 && o.VendorId == -1).ToList();
            grdAccountTransaction.DataSource = CashAccount;
            grdAccountTransaction.DataBind();
        }
        protected void ddlCashAccount_SelectedIndexChanged(object sender, EventArgs e)
        {
            string id = ddlCashAccount.SelectedValue.ToString();

            if (id != "-1")
            {
                Classes.CCashAccount ca = new Classes.CCashAccount();
                string total            = ca.ReturnTotalOfCashAccount(Convert.ToInt32(id)).ToString();
                lblCashAccount.Text = total;
            }
            else
            {
                lblCashAccount.Text = string.Empty;
            }
        }
Example #5
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();
                }
            }
        }
        private void BindCashAccountDdl()
        {
            Classes.CCashAccount       cv         = new Classes.CCashAccount();
            Dictionary <int, string>   VendorData = new Dictionary <int, string>();
            List <Models.MCashAccount> Get        = new List <Models.MCashAccount>();

            Get = cv.GetAll();
            Get = Get.Where(o => o.WareHouseId == Convert.ToInt32(Session["WareHouse"].ToString())).ToList();
            VendorData.Add(-1, "Please Select");
            for (int i = 0; i < Get.Count; i++)
            {
                VendorData.Add(Convert.ToInt32(Get[i].id), Get[i].CashAccountName);
            }
            ddlCashAccount.DataValueField = "Key";
            ddlCashAccount.DataTextField  = "Value";
            ddlCashAccount.DataSource     = VendorData;
            ddlCashAccount.DataBind();
        }
        private void BindDropDowns()
        {
            Classes.CCashAccount       cv         = new Classes.CCashAccount();
            Dictionary <int, string>   VendorData = new Dictionary <int, string>();
            List <Models.MCashAccount> Get        = new List <Models.MCashAccount>();

            Get = cv.GetAll();
            Get = Get.Where(o => o.ClientId == -1 &&
                            o.AccountType == Common.Constants.CashAccountTypes.Vendor.ToString()).ToList();
            VendorData.Add(-1, "Please Select");
            for (int i = 0; i < Get.Count; i++)
            {
                VendorData.Add(Convert.ToInt32(Get[i].id), Get[i].CashAccountName);
            }
            ddlAccountType.DataValueField = "Key";
            ddlAccountType.DataTextField  = "Value";
            ddlAccountType.DataSource     = VendorData;
            ddlAccountType.DataBind();
        }
        private void BindAccountNames()
        {
            Classes.CDefaultCashAccount cdf = new Classes.CDefaultCashAccount();
            Classes.CCashAccount        cba = new Classes.CCashAccount();
            List <Models.MCashAccount>  ListSalesAccounts    = new List <Models.MCashAccount>();
            List <Models.MCashAccount>  ListPurchaseAccounts = new List <Models.MCashAccount>();
            int SalesAccount = cdf.ReturnSaleDefaultAccount(Convert.ToInt32(Session["WareHouse"]));

            if (SalesAccount < 0)
            {
                lblSalesAccount.Text = "No Default Account Set";
            }
            else
            {
                ListSalesAccounts = cba.GetAllbyid(SalesAccount);
                if (ListSalesAccounts.Count == 0)
                {
                    lblSalesAccount.Text = "No Default Account Set";
                }
                else
                {
                    lblSalesAccount.Text = ListSalesAccounts[0].CashAccountName;
                }
            }
            int PurchaseAccount = cdf.ReturnPurchaseDefaultAccount(Convert.ToInt32(Session["WareHouse"]));

            if (PurchaseAccount < 0)
            {
                lblPurchaseAccount.Text = "No Default Account Set";
            }
            else
            {
                ListPurchaseAccounts = cba.GetAllbyid(PurchaseAccount);
                if (ListPurchaseAccounts.Count == 0)
                {
                    lblPurchaseAccount.Text = "No Default Account Set";
                }
                else
                {
                    lblPurchaseAccount.Text = ListPurchaseAccounts[0].CashAccountName;
                }
            }
        }
        private void BindDdl()
        {
            Dictionary <int, string> BankAccounts = new Dictionary <int, string>();

            Classes.CBankOfAccount     cca = new Classes.CBankOfAccount();
            List <Models.MBankAccount> ListOfBankAccounts = new List <Models.MBankAccount>();

            ListOfBankAccounts = cca.GetAll();
            ListOfBankAccounts = ListOfBankAccounts.Where(o => o.WareHouseId == Session["WareHouse"].ToString()).ToList();
            BankAccounts.Add(-1, "Please Select");
            for (int i = 0; i < ListOfBankAccounts.Count; i++)
            {
                BankAccounts.Add(Convert.ToInt32(ListOfBankAccounts[i].id),
                                 ListOfBankAccounts[i].AccountHolderId + "-" + ListOfBankAccounts[i].Accounttitle);
            }
            ddlBankAccount.DataSource     = BankAccounts;
            ddlBankAccount.DataTextField  = "Value";
            ddlBankAccount.DataValueField = "Key";
            ddlBankAccount.DataBind();
            Classes.CCashAccount       ca           = new Classes.CCashAccount();
            List <Models.MCashAccount> CashAccounts = new List <Models.MCashAccount>();

            CashAccounts = ca.GetAll();
            CashAccounts = CashAccounts.Where(o => o.WareHouseId == Convert.ToInt32(Session["WareHouse"].ToString()) &&
                                              o.VendorId == -1 && o.ClientId == -1).ToList();
            Dictionary <int, string> CashAccountsDc = new Dictionary <int, string>();

            CashAccountsDc.Add(-1, "Please Select");
            for (int i = 0; i < CashAccounts.Count; i++)
            {
                CashAccountsDc.Add(CashAccounts[i].id, CashAccounts[i].CashAccountName);
            }

            ddlCashAccount.DataSource     = CashAccountsDc;
            ddlCashAccount.DataTextField  = "Value";
            ddlCashAccount.DataValueField = "Key";
            ddlCashAccount.DataBind();
        }
Example #10
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (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());
         if (ca.Save(ma) > 0)
         {
             ShowSuccessMessage();
             BindData();
         }
         else
         {
             ShowFailMessage();
         }
     }
 }
        private void BindDdl()
        {
            Classes.CCashAccount       ca           = new Classes.CCashAccount();
            List <Models.MCashAccount> CashAccounts = new List <Models.MCashAccount>();

            CashAccounts = ca.GetAll();
            CashAccounts = CashAccounts.Where(o => o.WareHouseId == Convert.ToInt32(Session["WareHouse"].ToString()) &&
                                              o.VendorId == -1 && o.ClientId == -1).ToList();
            Dictionary <int, string> Accounts = new Dictionary <int, string>();

            Accounts.Add(-1, "Please Select");
            for (int i = 0; i < CashAccounts.Count; i++)
            {
                Accounts.Add(CashAccounts[i].id, CashAccounts[i].CashAccountName);
            }
            ddlPurchaseAccount.DataValueField = "Key";
            ddlPurchaseAccount.DataTextField  = "Value";
            ddlSalesAccount.DataValueField    = "Key";
            ddlSalesAccount.DataTextField     = "Value";
            ddlSalesAccount.DataSource        = Accounts;
            ddlPurchaseAccount.DataSource     = Accounts;
            ddlSalesAccount.DataBind();
            ddlPurchaseAccount.DataBind();
        }
Example #12
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");
     }
 }
Example #13
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");
            }
        }
        private int ProcessPayments(string PaymentId, string OrderId, string totalCost, string CurrentAmountPaid,
                                    string AccountId, float AmountRemaining, string RemainingAmount, string DatePaid, string Type, string Cheque)
        {
            if (Page.IsValid)
            {
                Classes.CBankOfAccount      cba = new Classes.CBankOfAccount();
                Classes.CAccountTransaction cat = new Classes.CAccountTransaction();
                Classes.CCashAccount        cha = new Classes.CCashAccount();
                Classes.CCashTransaction    cht = new Classes.CCashTransaction();
                Classes.CPayment            cp  = new Classes.CPayment();
                Classes.CPaymentLine        cpl = new Classes.CPaymentLine();
                Classes.CSaleTransations    cs  = new Classes.CSaleTransations();
                Models.MAccountTransaction  mat = new Models.MAccountTransaction();
                Models.MPayments            mp  = new Models.MPayments();
                Models.PaymentLine          mpl = new Models.PaymentLine();
                Models.MCashTransactions    mht = new Models.MCashTransactions();
                Models.MCashAccount         mha = new Models.MCashAccount();

                #region Payments
                mp.Paid = (Convert.ToSingle(totalCost) - AmountRemaining).ToString();
                if (cp.UpdateAmountPaid(Convert.ToInt32(PaymentId), mp.Paid) < 0)
                {
                    return(-1);
                }
                #endregion

                #region PaymentLine
                mpl.PaymentId        = Convert.ToInt32(PaymentId);
                mpl.BankId           = Convert.ToInt32(AccountId);
                mpl.Date             = DatePaid;
                mpl.PaidAmount       = CurrentAmountPaid;
                mpl.RemainingAmount  = RemainingAmount;
                mpl.CumulativeAmount = (Convert.ToSingle(cpl.LastPaidAmount(mpl.PaymentId))
                                        + Convert.ToSingle(CurrentAmountPaid)).ToString();
                int OptionValue = Convert.ToInt32(ddlOption.SelectedValue);
                mpl.Cheque = Cheque;
                switch (OptionValue)
                {
                case -1:
                {
                    return(-1);
                }

                case 1:
                {
                    #region Account Transactions
                    mpl.ModeOfPayment = Common.Constants.ModeOfPayment.Cheque.ToString();
                    float AccountTotal = cba.ReturnTotalOfAccountById(Convert.ToInt32(AccountId));
                    mat.AccountId = AccountId;
                    if (Type.Contains("Vendor"))
                    {
                        mat.Description = "Payment Of Order Id[" + OrderId + "] Paid, Amount ["
                                          + CurrentAmountPaid + "]";
                        mat.Debit              = CurrentAmountPaid;
                        mat.Credit             = "0";
                        mat.Total              = (AccountTotal - Convert.ToSingle(CurrentAmountPaid)).ToString();
                        mat.CurrentTransaction = cs.GetIdByOrderId(Convert.ToInt32(OrderId)).ToString();
                        mat.Transactiontype    = "Debit";

                        mat.FiscalYearId = Session["FiscalYear"].ToString();
                        mat.eDate        = Convert.ToDateTime(DatePaid);
                    }
                    else if (Type.Contains("Client"))
                    {
                        mat.Description = "Payment Of Order Id[" + OrderId + "] Recieved, Amount ["
                                          + CurrentAmountPaid + "]";
                        mat.Debit              = "0";
                        mat.Credit             = CurrentAmountPaid;
                        mat.CurrentTransaction = cs.GetIdByOrderId(Convert.ToInt32(OrderId)).ToString();
                        mat.Total              = (AccountTotal + Convert.ToSingle(CurrentAmountPaid)).ToString();
                        mat.Transactiontype    = "Credit";
                        mat.FiscalYearId       = Session["FiscalYear"].ToString();
                        mat.eDate              = Convert.ToDateTime(DatePaid);
                    }
                    else
                    {
                        return(-3);
                    }

                    if (cat.Save(mat) < 0)
                    {
                        return(-4);
                    }
                    if (cba.SetNewAccountTotal(Convert.ToInt32(AccountId), Convert.ToSingle(mat.Total)) < 0)
                    {
                        return(-5);
                    }
                    #endregion
                    break;
                }

                case 2:
                {
                    #region Cash Transaction
                    mpl.ModeOfPayment = Common.Constants.ModeOfPayment.Cash.ToString();
                    mpl.Cheque        = "-";
                    float AccountTotal = cha.ReturnTotalOfCashAccount(Convert.ToInt32(AccountId));
                    mht.CashAccountId = Convert.ToInt32(AccountId);
                    if (Type.Contains("Vendor"))
                    {
                        mht.Credit      = "0";
                        mht.Debit       = CurrentAmountPaid;
                        mht.Description = "Payment Of Order Id[" + OrderId + "] Paid, Amount ["
                                          + CurrentAmountPaid + "]";
                        mht.eDate           = (DatePaid);
                        mht.FiscalYearId    = Convert.ToInt32(Session["FiscalYear"].ToString());
                        mht.OrderId         = Convert.ToInt32(OrderId);
                        mht.Total           = totalCost;
                        mht.TransactionId   = -1;
                        mht.TransactionType = "Debit";
                        mht.UserId          = Session["User"].ToString();
                        mht.WareHouseId     = Convert.ToInt32(Session["WareHouse"].ToString());
                    }
                    else if (Type.Contains("Client"))
                    {
                        mht.Credit      = CurrentAmountPaid;
                        mht.Debit       = "0";
                        mht.Description = "Payment Of Order Id[" + OrderId + "] Recieved, Amount ["
                                          + CurrentAmountPaid + "]";
                        mht.eDate           = (DatePaid);
                        mht.FiscalYearId    = Convert.ToInt32(Session["FiscalYear"].ToString());
                        mht.OrderId         = Convert.ToInt32(OrderId);
                        mht.Total           = totalCost;
                        mht.TransactionId   = -1;
                        mht.TransactionType = "Debit";
                        mht.UserId          = Session["User"].ToString();
                        mht.WareHouseId     = Convert.ToInt32(Session["WareHouse"].ToString());
                    }
                    else
                    {
                        return(-3);
                    }

                    if (cht.Save(mht) < 0)
                    {
                        return(-4);
                    }
                    if (cha.SetNewAccountTotal(Convert.ToInt32(AccountId), Convert.ToSingle(mat.Total)) < 0)
                    {
                        return(-5);
                    }
                    #endregion
                    break;
                }

                default:
                    return(-1);
                }
                if (cpl.Save(mpl) < 0)
                {
                    return(-2);
                }
                #endregion



                #region Accounts
                if (Convert.ToSingle(mp.Paid) > 0)
                {
                    if (Type == "Vendor")
                    {
                        Classes.CJournal cj = new Classes.CJournal();
                        Models.MJournal  mj = new Models.MJournal();
                        mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.MerchandiseInventory).ToString();
                        mj.amount = mp.Paid;
                        mj.des    = "Payment Recieved of Order id [" + OrderId + "]";
                        mj.e_date = (DatePaid);
                        mj.type   = Common.Constants.Accounts.Type.Debit.ToString();
                        cj.Save(mj);

                        mj        = new Models.MJournal();
                        mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.AccountsPayable).ToString();
                        mj.amount = mp.Paid;
                        mj.des    = "Payment Recieved of Order id [" + OrderId + "]";
                        mj.e_date = (DatePaid);
                        mj.type   = Common.Constants.Accounts.Type.Credit.ToString();
                        cj.Save(mj);
                    }
                    else if (Type == "Client")
                    {
                        Classes.CJournal cj = new Classes.CJournal();
                        Models.MJournal  mj = new Models.MJournal();
                        mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.CostOfGoodsSold).ToString();
                        mj.amount = mp.Paid;
                        mj.des    = "Payment Recieved of Order id [" + OrderId + "]";
                        mj.e_date = (DatePaid);
                        mj.type   = Common.Constants.Accounts.Type.Debit.ToString();
                        cj.Save(mj);

                        mj        = new Models.MJournal();
                        mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.MerchandiseInventory).ToString();
                        mj.amount = mp.Paid;
                        mj.des    = "Payment Recieved of Order id [" + OrderId + "]";
                        mj.e_date = (DatePaid);
                        mj.type   = Common.Constants.Accounts.Type.Credit.ToString();
                        cj.Save(mj);

                        cj        = new Classes.CJournal();
                        mj        = new Models.MJournal();
                        mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.AccountsRecievalbes).ToString();
                        mj.amount = mp.Paid;
                        mj.des    = "Payment Recieved of Order id [" + OrderId + "]";
                        mj.e_date = (DatePaid);
                        mj.type   = Common.Constants.Accounts.Type.Debit.ToString();
                        cj.Save(mj);

                        mj        = new Models.MJournal();
                        mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Sales).ToString();
                        mj.amount = mp.Paid;
                        mj.des    = "Payment Recieved of Order id [" + OrderId + "]";
                        mj.e_date = (DatePaid);
                        mj.type   = Common.Constants.Accounts.Type.Credit.ToString();
                        cj.Save(mj);
                    }
                }
                #endregion
            }
            lblSalesAmountRemaining.Text = AmountRemaining.ToString();
            lblSalesAmountPaid.Text      = (Convert.ToSingle(totalCost) - AmountRemaining).ToString();
            return(1);
        }
Example #15
0
        private int SavePaymentOfEmployee()
        {
            int    AccountId     = Convert.ToInt32(ddlAccount.SelectedValue);
            int    CashAccountId = Convert.ToInt32(ddlCashAccount.SelectedValue);
            string EmployeeId    = ddlEmployee.SelectedValue;
            string MonthPaid     = txtMonth.Text;
            string SalaryId      = Session["WareHouse"].ToString();
            string Paid          = txtPaidAmount.Text;
            string DatePaid      = txtDateOfPayment.Text;

            Classes.CPaidSalary cp = new Classes.CPaidSalary();
            Models.MPaidSalary  mp = new Models.MPaidSalary();
            mp.EmployeeId = EmployeeId;
            mp.MonthPaid  = MonthPaid;
            mp.Paid       = Paid;
            mp.SalaryId   = SalaryId;
            mp.DatePaid   = DatePaid;

            int option = Convert.ToInt32(ddlOption.SelectedValue);

            if (option < 1)
            {
                return(-4);
            }
            if (cp.Save(mp) > 0)
            {
                switch (option)
                {
                case 1:
                {
                    Classes.CBankOfAccount      cab = new Classes.CBankOfAccount();
                    Classes.CAccountTransaction cat = new Classes.CAccountTransaction();
                    Models.MAccountTransaction  mat = new Models.MAccountTransaction();
                    float AccountTotal = cab.ReturnTotalOfAccountById(AccountId);
                    AccountTotal = AccountTotal - Convert.ToSingle(Paid);
                    if (cab.SetNewAccountTotal(AccountId, AccountTotal) > 0)
                    {
                        // float PreviousAccountTotal = cab.ReturnTotalOfAccountById(AccountId);
                        mat.AccountId          = AccountId.ToString();
                        mat.Credit             = "0";
                        mat.CurrentTransaction = "-1";
                        mat.Debit       = Paid;
                        mat.Description = "Paid Salary for the month of [" + MonthPaid + "] to " +
                                          "Employee[" + ddlEmployee.SelectedItem.Text + "] Amount [" + Paid + "]";
                        mat.eDate        = Convert.ToDateTime(DatePaid);
                        mat.FiscalYearId = Convert.ToInt32(Session["FiscalYear"]).ToString();
                        //  PreviousAccountTotal = PreviousAccountTotal - Convert.ToSingle(Paid);
                        mat.Total = AccountTotal.ToString();
                        if (cat.Save(mat) > 0)
                        {
                            Classes.CJournal cj = new Classes.CJournal();
                            Models.MJournal  mj = new Models.MJournal();
                            mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.SalaryExpense).ToString();
                            mj.amount = mp.Paid;
                            mj.des    = "Payment of Employee  [" + ddlEmployee.SelectedItem.Text + "] ";
                            mj.e_date = (DatePaid);
                            mj.type   = Common.Constants.Accounts.Type.Debit.ToString();
                            cj.Save(mj);

                            mj        = new Models.MJournal();
                            mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Cash).ToString();
                            mj.amount = mp.Paid;
                            mj.des    = "Payment of Employee  [" + ddlEmployee.SelectedItem.Text + "] ";
                            mj.e_date = (DatePaid);
                            mj.type   = Common.Constants.Accounts.Type.Credit.ToString();
                            cj.Save(mj);

                            return(1);
                        }
                        else
                        {
                            return(-3);
                        }
                    }
                    else
                    {
                        return(-2);
                    }
                }

                case 2:
                {
                    Classes.CCashAccount     cab = new Classes.CCashAccount();
                    Classes.CCashTransaction cat = new Classes.CCashTransaction();
                    Models.MCashTransactions mat = new Models.MCashTransactions();
                    float AccountTotal           = cab.ReturnTotalOfCashAccount(CashAccountId);
                    AccountTotal = AccountTotal - Convert.ToSingle(Paid);
                    if (cab.SetNewAccountTotal(CashAccountId, AccountTotal) > 0)
                    {
                        // float PreviousAccountTotal = cab.ReturnTotalOfAccountById(AccountId);
                        mat.CashAccountId = CashAccountId;
                        mat.Credit        = "0";
                        mat.Debit         = Paid;
                        mat.Description   = "Paid Salary for the month of [" + MonthPaid + "] to " +
                                            "Employee[" + ddlEmployee.SelectedItem.Text + "] Amount [" + Paid + "]";
                        if (cat.Save(mat) > 0)
                        {
                            Classes.CJournal cj = new Classes.CJournal();
                            Models.MJournal  mj = new Models.MJournal();
                            mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.SalaryExpense).ToString();
                            mj.amount = mp.Paid;
                            mj.des    = "Payment of Employee  [" + ddlEmployee.SelectedItem.Text + "] ";
                            mj.e_date = (DatePaid);
                            mj.type   = Common.Constants.Accounts.Type.Debit.ToString();
                            cj.Save(mj);

                            mj        = new Models.MJournal();
                            mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Cash).ToString();
                            mj.amount = mp.Paid;
                            mj.des    = "Payment of Employee  [" + ddlEmployee.SelectedItem.Text + "] ";
                            mj.e_date = (DatePaid);
                            mj.type   = Common.Constants.Accounts.Type.Credit.ToString();
                            cj.Save(mj);

                            return(1);
                        }
                        else
                        {
                            return(-3);
                        }
                    }
                    else
                    {
                        return(-2);
                    }
                }

                default:
                    return(-5);
                }
            }
            else
            {
                return(-1);
            }
        }