示例#1
0
        private int ProcessPayments(string PaymentId, string OrderId, string totalCost, string CurrentAmountPaid,
                                    string AccountId, float AmountRemaining, string RemainingAmount, string DatePaid, string Type)
        {
            if (Page.IsValid)
            {
                Classes.CBankOfAccount      cba = new Classes.CBankOfAccount();
                Classes.CAccountTransaction cat = new Classes.CAccountTransaction();
                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();

                #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();
                if (cpl.Save(mpl) < 0)
                {
                    return(-2);
                }
                #endregion

                #region Account Transactions
                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

                #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
            }

            return(1);
        }
        private int Save()
        {
            Classes.CBankOfAccount cb = new Classes.CBankOfAccount();

            Classes.CAccountTransaction cat = new Classes.CAccountTransaction();
            Classes.CDefaultAccount     cd  = new Classes.CDefaultAccount();
            Models.MAccountTransaction  mat = new Models.MAccountTransaction();
            int      AccountId          = 0;
            string   Amount             = string.Empty;
            string   Description        = string.Empty;
            string   Debit              = string.Empty;
            string   Credit             = string.Empty;
            string   Total              = string.Empty;
            string   CurrentTransaction = string.Empty;
            string   FiscalYearId       = string.Empty;
            DateTime eDate;

            if (cbDefault.Checked)
            {
                AccountId = cd.ReturnPurchaseDefaultAccount(Convert.ToInt32(Session["WareHouse"]));
            }
            else
            {
                AccountId = Convert.ToInt32(ddlSaleAccount.SelectedValue);
            }
            Amount              = txtamount.Text;
            Description         = "Msc Expense: " + txtDescription.Text;
            Debit               = txtamount.Text;
            Credit              = "0";
            Total               = txtamount.Text;
            CurrentTransaction  = "-21";
            FiscalYearId        = Convert.ToInt32(Session["FiscalYear"]).ToString();
            eDate               = Convert.ToDateTime(txtdate.Text);
            mat.AccountId       = Convert.ToInt32(AccountId).ToString();
            mat.Credit          = Credit;
            mat.Debit           = Debit;
            mat.Description     = Description;
            mat.FiscalYearId    = FiscalYearId;
            mat.Total           = Total;
            mat.Transactiontype = "Expense";

            if (cb.SetNewAccountTotal(Convert.ToInt32(AccountId), Convert.ToSingle(Total)) > 0)
            {
                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.GeneralExpense).ToString();
                    mj.amount = Total;
                    mj.des    = "Msc Expense ";
                    mj.e_date = (eDate).ToShortDateString();
                    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 = Total;
                    mj.des    = "Msc Expense ";
                    mj.e_date = (eDate).ToShortDateString();
                    mj.type   = Common.Constants.Accounts.Type.Credit.ToString();
                    cj.Save(mj);

                    return(1);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                return(-1);
            }
        }
示例#3
0
        private int SaveOrders()
        {
            try
            {
                Classes.CDefaultCashAccount cda = new Classes.CDefaultCashAccount();
                Classes.CDefaultAccount     cba = new Classes.CDefaultAccount();

                int    OrderId            = 0;
                string OrderNo            = txtOrderNo.Text;
                string OrderName          = txtOrderName.Text;
                string OrderDescription   = txtOrderDescription.Text;
                string OrderDate          = txtOrderDate.Text;
                string OrderDeliveryDate  = txtDeliveryOfOrderDate.Text;
                string TotalCost          = ReturnTotalOrderCost().ToString();
                string OrderType          = ddlOrderType.SelectedValue;
                string VendorId           = ddlVendor.SelectedValue;
                string ClientId           = ddlCustomer.SelectedValue;
                string WareHouseId        = Session["WareHouse"].ToString();
                string ModeOfPayment      = ddlModeOfPayment.SelectedItem.Text;
                string Installments       = txtInstallments.Text;
                string InstallmentDueDate = txtIntallmentDueDate.Text;
                if (OrderType == "1")
                {
                    OrderType = "Order To Client";
                }
                else if (OrderType == "2")
                {
                    OrderType = "Order To Vendor";
                }
                else
                {
                    return(-2);
                }
                if (ModeOfPayment == "Please Select")
                {
                    return(-8);
                }
                Models.MOrders mr = new Models.MOrders();
                mr.OrdersNo           = OrderNo;
                mr.OrderName          = OrderName;
                mr.OrderDescription   = OrderDescription;
                mr.Orderdate          = OrderDate;
                mr.deliverydate       = OrderDeliveryDate;
                mr.TotalCost          = TotalCost;
                mr.OrderType          = OrderType;
                mr.eDate              = DateTime.Now.ToShortDateString();
                mr.FiscalYearld       = Session["FiscalYear"].ToString();
                mr.WareHouseId        = WareHouseId;
                mr.ModeOfPayment      = ModeOfPayment;
                mr.Installments       = Installments;
                mr.InstallmentDueDate = InstallmentDueDate;

                if (OrderType.EndsWith("Vendor"))
                {
                    mr.venorld  = VendorId;
                    mr.ClientId = "-1";
                    if (Convert.ToInt32(VendorId) < 0)
                    {
                        return(-5);
                    }
                }
                else
                {
                    if (cbGrantor.Checked)
                    {
                        string GrantorName = txtGrantorInfo.Text;
                        mr.GrantorName = GrantorName;
                    }

                    mr.ClientId = ClientId;
                    mr.venorld  = "-1";
                    if (Convert.ToInt32(ClientId) < 0)
                    {
                        return(-6);
                    }
                }
                Classes.COrders co = new Classes.COrders();
                if (Convert.ToInt32(WareHouseId) < 0)
                {
                    return(-7);
                }

                //Saving Order
                if (co.Save(mr) < 0)
                {
                    return(-1);
                }

                OrderId = co.GetLastOrderID();
                if (OrderId < 0)
                {
                    return(-3);
                }
                //Saving Order Products

                #region objects
                Models.MOrdersLine       mor = new Models.MOrdersLine();
                Models.MSaleTransactions ms  = new Models.MSaleTransactions();
                Classes.CSaleTransations ct  = new Classes.CSaleTransations();
                Classes.COrderOnline     cor = new Classes.COrderOnline();
                Models.MInventory        mi  = new Models.MInventory();
                Classes.CInventory       ci  = new Classes.CInventory();
                float OrderTotalCost         = 0;

                #endregion
                for (int i = 0; i < grdProducts.Rows.Count; i++)
                {
                    #region objects initializing
                    mor = new Models.MOrdersLine();
                    ms  = new Models.MSaleTransactions();
                    ct  = new Classes.CSaleTransations();
                    cor = new Classes.COrderOnline();
                    mi  = new Models.MInventory();
                    ci  = new Classes.CInventory();
                    DropDownList ddlProduct = (DropDownList)grdProducts.Rows[i].FindControl("ddlProducts");
                    TextBox      txtCp      = (TextBox)grdProducts.Rows[i].FindControl("txtCp");
                    TextBox      txtSp      = (TextBox)grdProducts.Rows[i].FindControl("txtSp");
                    TextBox      txtUnits   = (TextBox)grdProducts.Rows[i].FindControl("txtUnits");
                    TextBox      txtTotal   = (TextBox)grdProducts.Rows[i].FindControl("txtTotal");
                    string       ProductId  = ddlProduct.SelectedValue;
                    string       CostPrice  = txtCp.Text;
                    string       SalePrice  = txtSp.Text;
                    string       TotalUnits = txtUnits.Text;
                    string       totalCost  = (Convert.ToInt32(TotalUnits) * Convert.ToInt32(SalePrice)).ToString();
                    OrderTotalCost += Convert.ToSingle(totalCost);
                    #endregion

                    //OrderLine
                    #region OrderLine
                    mor.OrderId   = OrderId.ToString();
                    mor.ProductId = ProductId;
                    if (OrderType.EndsWith("Vendor"))
                    {
                        mor.SalePrice = CostPrice;
                    }
                    else
                    {
                        mor.SalePrice = SalePrice;
                    }
                    mor.unit             = TotalUnits;
                    mor.totalProductCost = totalCost;
                    mor.eDate            = DateTime.Now.ToShortDateString();
                    if (cor.Save(mor) < 0)
                    {
                        return(-3);
                    }
                    #endregion

                    //Sale transaction
                    #region Sale Transaction

                    ms.ProductID   = ProductId;
                    ms.clientID    = ClientId;
                    ms.CostPrice   = CostPrice;
                    ms.SalePrice   = SalePrice;
                    ms.units       = TotalUnits;
                    ms.clientID    = ClientId;
                    ms.VendorID    = VendorId;
                    ms.date        = Convert.ToDateTime(txtOrderDate.Text);
                    ms.WareHouseId = WareHouseId;
                    ms.OrderId     = OrderId.ToString();
                    if (OrderType.EndsWith("Vendor"))
                    {
                        ms.transactionType = Common.Constants.SaleTransactions.Addition.ToString();
                    }
                    else
                    {
                        ms.transactionType = Common.Constants.SaleTransactions.Deduction.ToString();
                    }


                    //sale transaction
                    if (ct.Save(ms) < 0)
                    {
                        return(-1);
                    }
                    #endregion


                    //Inventory
                    #region Inventory
                    mi.ProductId    = ProductId;
                    mi.WareHouseld  = WareHouseId;
                    mi.Quantity     = TotalUnits;
                    mi.FiscalYearld = Session["FiscalYear"].ToString();
                    mi.Date         = Convert.ToDateTime(OrderDate);
                    mi.Cost         = CostPrice;
                    if (OrderType.EndsWith("Vendor"))
                    {
                        //  mi.Cost = CostPrice;
                        if (ci.Save(mi, Common.Constants.SaleTransactions.Addition) < 0)
                        {
                            return(-4);
                        }
                    }
                    else
                    {
                        //   mi.Cost = SalePrice;
                        if (ci.Save(mi, Common.Constants.SaleTransactions.Deduction) < 0)
                        {
                            return(-4);
                        }
                    }
                    #endregion

                    //Accounts
                    #region Accounts
                    if (OrderType.Contains("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 = totalCost;
                        mj.des    = "Order Of Inventory for Vendor of Product Id [" + ProductId + "] units [" + TotalUnits + "] ";
                        mj.e_date = (OrderDate);
                        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 = totalCost;
                        mj.des    = "Order Of Inventory for Vendor of Product Id [" + ProductId + "] units [" + TotalUnits + "] ";
                        mj.e_date = (OrderDate);
                        mj.type   = Common.Constants.Accounts.Type.Credit.ToString();
                        cj.Save(mj);
                    }
                    else if (OrderType.Contains("Client"))
                    {
                        Classes.CJournal cj = new Classes.CJournal();
                        Models.MJournal  mj = new Models.MJournal();
                        mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.AccountsRecievalbes).ToString();
                        mj.amount = totalCost;
                        mj.des    = "Order Of Inventory for Client of Product Id [" + ProductId + "] units [" + TotalUnits + "] ";
                        mj.e_date = (OrderDate);
                        mj.type   = Common.Constants.Accounts.Type.Debit.ToString();
                        cj.Save(mj);

                        cj        = new Classes.CJournal();
                        mj        = new Models.MJournal();
                        mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Sales).ToString();
                        mj.amount = totalCost;
                        mj.des    = "Order Of Inventory for Client of Product Id [" + ProductId + "] units [" + TotalUnits + "] ";
                        mj.e_date = (OrderDate);
                        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.CostOfGoodsSold).ToString();
                        mj.amount = totalCost;
                        mj.des    = "Order Of Inventory for Client of Product Id [" + ProductId + "] units [" + TotalUnits + "] ";
                        mj.e_date = (OrderDate);
                        mj.type   = Common.Constants.Accounts.Type.Debit.ToString();
                        cj.Save(mj);

                        cj        = new Classes.CJournal();
                        mj        = new Models.MJournal();
                        mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.MerchandiseInventory).ToString();
                        mj.amount = totalCost;
                        mj.des    = "Order Of Inventory for Client of Product Id [" + ProductId + "] units [" + TotalUnits + "] ";
                        mj.e_date = (OrderDate);
                        mj.type   = Common.Constants.Accounts.Type.Credit.ToString();
                        cj.Save(mj);
                    }
                    #endregion
                }

                //Payments
                #region Payments
                Classes.CPayment cap           = new Classes.CPayment();
                Models.MPayments map           = new Models.MPayments();
                string           TransactionId = ct.GetLastTransactionId().ToString();
                if (ddlOrderType.SelectedItem.Text.Contains("Vendor"))
                {
                    map.ClientId = -1;
                    map.VendorId = Convert.ToInt32(VendorId);
                }
                else if (ddlOrderType.SelectedItem.Text.Contains("Client"))
                {
                    map.ClientId = Convert.ToInt32(ClientId);
                    map.VendorId = -1;
                }
                map.TransactionId = Convert.ToInt32(TransactionId);
                map.Paid          = "0";
                map.TotalCost     = OrderTotalCost.ToString();
                map.OrderId       = OrderId;
                map.PaymentType   = Common.Constants.PaymentTypes.Partial.ToString();
                map.Paymentstate  = Common.Constants.PaymentState.NotPaid.ToString();
                if (cap.Save(map) < 0)
                {
                    return(-4);
                }
                #endregion

                return(1);
            }
            catch
            {
                return(-1);
            }
        }
        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);
        }
示例#5
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);
            }
        }