public int Update(Models.PaymentLine model) { Common.Logger l = new Common.Logger(); string ClassName = "CPaymentLine"; try { var query = from o in obj.PaymentLines where o.id == model.id select o; foreach (var item in query) { item.PaymentId = model.PaymentId; item.PaidAmount = model.PaidAmount; } l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] PaymentId[" + model.PaymentId + "] PaidAmount[" + model.PaidAmount + "] "); obj.SubmitChanges(); l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Updated Successfully"); return(1); } catch (Exception ex) { l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString()); return(-1); } }
public int Save(Models.PaymentLine model) { Common.Logger l = new Common.Logger(); string ClassName = "CPaymentLine"; try { DB.PaymentLine bs = new DB.PaymentLine(); bs.id = Convert.ToInt32(model.id); bs.PaymentId = model.PaymentId; bs.PaidAmount = model.PaidAmount; bs.BankId = model.BankId; bs.PaidAmount = model.PaidAmount; bs.RemainingAmount = model.RemainingAmount; bs.CumulativeAmount = model.CumulativeAmount; bs.Date = Convert.ToDateTime(model.Date); bs.ModeOfPayment = model.ModeOfPayment; bs.Cheque = model.Cheque; l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] PaymentId[" + model.PaymentId + "] PaidAmount[" + model.PaidAmount + "] "); obj.PaymentLines.InsertOnSubmit(bs); obj.SubmitChanges(); l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully"); return(1); } catch (Exception ex) { l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString()); return(-1); } }
public ActionResult Direct(int id, int group, string action) { ServiceClient sc = Sas.GetAuthenticatedServiceClient(this, action); var nodes = BuildPaymentGraph( sc, group, id); var WindowInfo = sc.GetTransactionWindow(id, group); Models.PaymentData pd = new Models.PaymentData() { Title = WindowInfo.Name + " Direct Payment" }; pd.Lines = new List<Models.PaymentLine>(); var users = sc.GetAllUsersInGroup(group); foreach (var node in nodes) { foreach (var edge in node.EdgeWeight) { if (edge.Value > 0) { Models.PaymentLine pl = new Models.PaymentLine(); pl.FromUsername = users.Where(p => p.Id == node.UserId).SingleOrDefault().Username; pl.ToUsername = users.Where(p => p.Id == edge.Key).SingleOrDefault().Username; pl.Amount = edge.Value; pd.Lines.Add(pl); } } } return View(pd); }
public List <Models.PaymentLine> GetAllbyid(int id) { List <Models.PaymentLine> model = new List <Models.PaymentLine>(); var query = from o in obj.PaymentLines where Convert.ToString(o.id) == id.ToString() select o; foreach (var item in query) { Models.PaymentLine m = new Models.PaymentLine(); m.id = item.id; m.PaymentId = Convert.ToInt32(item.PaymentId); m.PaidAmount = item.PaidAmount; model.Add(m); } return(model); }
public List <Models.PaymentLine> GetAll() { List <Models.PaymentLine> model = new List <Models.PaymentLine>(); var query = from o in obj.PaymentLines select o; foreach (var item in query) { Models.PaymentLine m = new Models.PaymentLine(); m.id = item.id; m.PaymentId = Convert.ToInt32(item.PaymentId); m.PaidAmount = item.PaidAmount; m.ModeOfPayment = item.ModeOfPayment; m.RemainingAmount = item.RemainingAmount; m.BankId = Convert.ToInt32(item.BankId); m.Cheque = item.Cheque; m.CumulativeAmount = item.CumulativeAmount; m.Date = Convert.ToDateTime(item.Date).ToShortDateString(); model.Add(m); } return(model); }
protected void btnSave_Click(object sender, EventArgs e) { //Saving Journal try { #region Objects Classes.CBankOfAccount cab = new Classes.CBankOfAccount(); Classes.CAccountTransaction cat = new Classes.CAccountTransaction(); Classes.CSaleTransations ct = new Classes.CSaleTransations(); Classes.CDefaultAccount df = new Classes.CDefaultAccount(); Classes.CInventory ci = new Classes.CInventory(); Classes.CPayment cpay = new Classes.CPayment(); Classes.CPaymentLine cpl = new Classes.CPaymentLine(); Classes.CPaymentContainer cpc = new Classes.CPaymentContainer(); Models.MInventory mi = new Models.MInventory(); Models.MAccountTransaction mat = new Models.MAccountTransaction(); Models.MSaleTransactions ms = new Models.MSaleTransactions(); Models.MPayments mpay = new Models.MPayments(); Models.PaymentContainer mpc = new Models.PaymentContainer(); Models.PaymentLine mpl = new Models.PaymentLine(); #endregion string WareHouseId = ddlWareHouse.SelectedValue; string ClientId = ddlClient.SelectedValue; float Discount = Convert.ToSingle(txtDiscount.Text); Discount = Discount / grdSales.Rows.Count; bool[] Result = new bool[grdSales.Rows.Count]; if (Convert.ToInt32(WareHouseId) > 0) { if (Convert.ToInt32(ClientId) > 0) { #region Start Saving for (int i = 0; i < grdSales.Rows.Count; i++) { DropDownList ddlProduct = (DropDownList)grdSales.Rows[i].FindControl("ddlProducts"); Label txtCp = (Label)grdSales.Rows[i].FindControl("txtCp"); TextBox txtSp = (TextBox)grdSales.Rows[i].FindControl("txtSp"); TextBox txtUnits = (TextBox)grdSales.Rows[i].FindControl("txtUnits"); TextBox txtTotal = (TextBox)grdSales.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(); totalCost = Convert.ToSingle(Convert.ToSingle(totalCost) - Discount).ToString(); ms.ProductID = ProductId; ms.CostPrice = CostPrice; ms.SalePrice = SalePrice.ToString(); ms.units = TotalUnits; ms.clientID = ClientId; ms.VendorID = "-1"; ms.date = Convert.ToDateTime(txtDate.Text); ms.transactionType = Common.Constants.SaleTransactions.Deduction.ToString(); ms.date = Convert.ToDateTime(txtDate.Text); ms.OrderId = "-1"; ms.WareHouseId = WareHouseId; ms.Discount = Discount.ToString(); //sale transaction if (ct.Save(ms) > 0) { mi.WareHouseld = WareHouseId; mi.Cost = CostPrice; mi.Quantity = TotalUnits; mi.ProductId = ProductId; mi.FiscalYearld = Session["FiscalYear"].ToString();; mi.Date = Convert.ToDateTime(txtDate.Text); //inventory int retVal = ci.Save(mi, Common.Constants.SaleTransactions.Deduction); if (retVal > 0) { #region Accounts Transactions //Payments int TransactionId = 0; TransactionId = ct.GetLastTransactionId(); if (TransactionId != 0) { string AccountId = string.Empty; AccountId = df.ReturnSaleDefaultAccount(Convert.ToInt32(Session["WareHouse"])).ToString(); mat.AccountId = AccountId; mat.Debit = "0"; mat.Credit = totalCost; mat.Description = "Purchased Product[" + ddlProduct.SelectedItem.Text + "] Units [" + TotalUnits + " At Cost/Unit[" + CostPrice + "]] "; float AccountTotal = cab.ReturnTotalOfAccountById(Convert.ToInt32(AccountId)); AccountTotal = AccountTotal + Convert.ToSingle(totalCost); mat.Total = AccountTotal.ToString(); mat.CurrentTransaction = TransactionId.ToString(); mat.Transactiontype = "Credit"; mat.FiscalYearId = Session["FiscalYear"].ToString(); mat.eDate = Convert.ToDateTime(txtDate.Text); //Account Transation if (cat.Save(mat) > 0) { //Updating Account total if (cab.SetNewAccountTotal(Convert.ToInt32(AccountId), AccountTotal) > 0) { //Updating Payments mpay.ClientId = Convert.ToInt32(ClientId); mpay.VendorId = 0; mpay.OrderId = 0; mpay.TransactionId = TransactionId; mpay.Paid = totalCost; mpay.TotalCost = totalCost; mpay.PaymentType = Common.Constants.PaymentTypes.Full.ToString(); mpay.Paymentstate = Common.Constants.PaymentState.Paid.ToString(); if (cpay.Save(mpay) > 0) { int PaymentId = cpay.ReturnLastPaymentId(); mpc.BankId = Convert.ToInt32(AccountId); mpc.PaymentId = PaymentId; mpc.AmountRemaning = "0"; if (cpc.Save(mpc) > 0) { mpl.PaymentId = PaymentId; mpl.PaidAmount = totalCost; mpl.RemainingAmount = "0"; mpl.Date = txtDate.Text; mpl.BankId = Convert.ToInt32(AccountId); mpl.CumulativeAmount = totalCost; if (cpl.Save(mpl) > 0) { ShowErrorModal("Successfully Saved Journal"); } } } } } } #endregion } else if (retVal == 0) { ShowErrorModal("Not enough units in Warehouse:" + ddlWareHouse.SelectedItem.Text + "Of Product: " + ddlProduct.SelectedItem.Text); break; } else { ShowErrorModal("There was Error Saving the Journal"); break; } } else { ShowErrorModal("There was Error Saving the Journal"); break; } } #endregion } else { ShowErrorModal("Please select a Client"); } } else { ShowErrorModal("Please select WareHouse"); } bool FinalResuls = false; for (int i = 0; i < Result.Length; i++) { if (Result[i]) { FinalResuls = true; } else { FinalResuls = true; ShowErrorModal("Some Transactions might have been incompleted"); break; } } if (FinalResuls) { ShowErrorModal("Journal Successfully Saved"); DeleteAllRowsFromGrid(); ClearTextBoxes(Page); HidePreviewModal(); // Response.Redirect("~/Pages/Main.aspx"); } } catch { } }
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 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); }
protected void btnSave_Click(object sender, EventArgs e) { //Saving Journal try { #region Objects Classes.CBankOfAccount cab = new Classes.CBankOfAccount(); Classes.CAccountTransaction cat = new Classes.CAccountTransaction(); Classes.CSaleTransations ct = new Classes.CSaleTransations(); Classes.CDefaultAccount df = new Classes.CDefaultAccount(); Classes.CInventory ci = new Classes.CInventory(); Classes.CPayment cpay = new Classes.CPayment(); Classes.CPaymentLine cpl = new Classes.CPaymentLine(); Classes.CPaymentContainer cpc = new Classes.CPaymentContainer(); Models.MInventory mi = new Models.MInventory(); Models.MAccountTransaction mat = new Models.MAccountTransaction(); Models.MSaleTransactions ms = new Models.MSaleTransactions(); Models.MPayments mpay = new Models.MPayments(); Models.PaymentContainer mpc = new Models.PaymentContainer(); Models.PaymentLine mpl = new Models.PaymentLine(); #endregion string WareHouseId = ddlWareHouse.SelectedValue; // float Discount = Convert.ToSingle(txtDiscount.Text); // Discount = Discount / grdSales.Rows.Count; if (Convert.ToInt32(WareHouseId) > 0) { #region Start Saving for (int i = 0; i < grdSales.Rows.Count; i++) { DropDownList ddlProduct = (DropDownList)grdSales.Rows[i].FindControl("ddlProducts"); TextBox txtCp = (TextBox)grdSales.Rows[i].FindControl("txtCp"); Label txtVendor = (Label)grdSales.Rows[i].FindControl("txtVendor"); TextBox txtUnits = (TextBox)grdSales.Rows[i].FindControl("txtUnits"); TextBox txtTotal = (TextBox)grdSales.Rows[i].FindControl("txtTotal"); string ProductId = ddlProduct.SelectedValue; string CostPrice = txtCp.Text; string[] VendorDetails = txtVendor.Text.Split('-'); string VendorId = VendorDetails[0]; string TotalUnits = txtUnits.Text; string totalCost = (Convert.ToInt32(TotalUnits) * Convert.ToInt32(CostPrice)).ToString(); totalCost = Convert.ToSingle(Convert.ToSingle(totalCost)).ToString(); ms.ProductID = ProductId; ms.CostPrice = CostPrice; ms.units = TotalUnits; ms.date = Convert.ToDateTime(txtDate.Text); ms.transactionType = Common.Constants.SaleTransactions.Addition.ToString(); ms.date = Convert.ToDateTime(txtDate.Text); ms.VendorID = VendorId; ms.OrderId = "-1"; ms.WareHouseId = WareHouseId; ms.clientID = "-1"; ms.Discount = "0"; //sale transaction if (ct.Save(ms) > 0) { mi.WareHouseld = WareHouseId; mi.Cost = CostPrice; mi.Quantity = TotalUnits; mi.ProductId = ProductId; mi.FiscalYearld = "1"; mi.Date = Convert.ToDateTime(txtDate.Text); //inventory int retVal = ci.Save(mi, Common.Constants.SaleTransactions.Addition); if (retVal > 0) { //dance } else if (retVal == 0) { ShowErrorModal("Not enough units"); } else { ShowErrorModal("There was Error Saving the Journal"); break; } } else { ShowErrorModal("There was Error Saving the Journal"); break; } } ShowErrorModal("Successfully Saved Journal"); DeleteAllRowsFromGrid(); ClearTextBoxes(Page); HidePreviewModal(); #endregion } else { ShowErrorModal("Please Select Warehouse"); } } catch { } }