public void SaveSalePurchase(DBSite site, SalePurchaseEntity salePurchase, bool isOpeningBalance) { Util_BLL util = new Util_BLL(); /** * * // payment made If GM.isFees = 2 Then * Dim tmp As String * tmp = mode * mode = party * party = tmp * End If * **/ int party = Int32.Parse(util.GetLOVId(salePurchase.party)); int mode = Int32.Parse(util.GetLOVId(salePurchase.mode)); if (salePurchase.transactionType == TransactionType.PaymentMade) { int tmp; tmp = Int32.Parse(util.GetLOVId(salePurchase.mode)); mode = Int32.Parse(util.GetLOVId(salePurchase.party)); party = tmp; } if (salePurchase.transactionType == TransactionType.Sales) { mode = Modes.SaleAccount; } int ledgerNumber = util.GetAutoNumber(site, "LedgerNumber"); // opening balance string opening_qry = ""; if (isOpeningBalance) { string credit_debit = "Debit"; if (salePurchase.drcr == DrCr.Debit) { credit_debit = "Debit"; } else if (salePurchase.drcr == DrCr.Credit) { credit_debit = "Credit"; } opening_qry = " INSERT INTO tblLedger (" + " LedgerNumber, Ldate, AccountMasterId, modeId, Particulars, " + credit_debit + ", sourceId, UserId, SubUserId, FYear )" + " VALUES ( " + ledgerNumber + ", '" + salePurchase.BillDate + "' " + ", " + party + ", " + mode + ", '" + salePurchase.particulars + "' " + ", " + salePurchase.SalePurchaseAmount + ", " + salePurchase.transactionType + ", " + util.GetUserInsertQry(Util_BLL.User) + " ) "; site.Execute(opening_qry); } // sales - party string party_qry = " INSERT INTO tblLedger (" + " LedgerNumber, drcr, Ldate, AccountMasterId, modeId, BillNumber, Particulars, credit, Discount, sourceId, UserId, SubuserId, FYear )" + " VALUES ( " + ledgerNumber + ", 'C' " + ", '" + salePurchase.BillDate + "' " + ", " + party + ", " + mode + ", '" + util.GetLOVName(salePurchase.BillNumber) + "' " + ", '" + salePurchase.particulars + "' " + ", " + salePurchase.SalePurchaseAmount + ", '" + salePurchase.discount + "'" + ", " + salePurchase.transactionType + ", " + util.GetUserInsertQry(Util_BLL.User) + " ) "; // sales - party string mode_qry = " INSERT INTO tblLedger (" + " LedgerNumber, drcr, Ldate, AccountMasterId, modeId, BillNumber, Particulars, debit, Discount, sourceId, UserId, SubuserId, FYear )" + " VALUES ( " + ledgerNumber + ", 'D' " + ", '" + salePurchase.BillDate + "' " + ", " + mode + ", " + party + ", '" + util.GetLOVName(salePurchase.BillNumber) + "' " + ", '" + salePurchase.particulars + "' " + ", " + salePurchase.SalePurchaseAmount + ", '" + salePurchase.discount + "'" + ", " + salePurchase.transactionType + ", " + util.GetUserInsertQry(Util_BLL.User) + " ) "; site.Execute(party_qry); site.Execute(mode_qry); if (salePurchase.transactionType != TransactionType.PaymentMade && salePurchase.transactionType != TransactionType.PaymentRcd) { string tax_qry = ""; for (int i = 0; i < salePurchase.SalePurchaseTaxes.Count; i++) { tax_qry = " INSERT INTO tblTax(LedgerNumber, TaxMasterId, TaxAmount, UserID, SubuserId, FYear) " + " VALUES ( " + ledgerNumber + ", " + salePurchase.SalePurchaseTaxes[i].TaxId + ", " + salePurchase.SalePurchaseTaxes[i].TaxAmount + ", " + util.GetUserInsertQry(Util_BLL.User) + " ) "; site.Execute(tax_qry); } SaveProductLedger(site, salePurchase, ledgerNumber); } }
public void SaveProductLedger(DBSite site, SalePurchaseEntity salePurchase, int ledgerNumber) { string qry = ""; for (int i = 0; i < salePurchase.SalePurchaseDetails.Count; i++) { int productLedgerNumber = util.GetAutoNumber(site, "ProductLedgerNumber"); int theLocation = -1; if (salePurchase.transactionType == TransactionType.Sales) { theLocation = GetLocationId(site, "OUT"); } else { theLocation = GetLocationId(site, "IN"); } qry = " INSERT INTO tblProductLedger(LedgerNumber, ProductLedgerNumber, drcr, BillDate, BillNumber, AccountId, ProductID, BoughtQty, Discount, rate, SourceId, LocationID, UserID, subuserId, FYear) " + " VALUES ( " + ledgerNumber + ", " + productLedgerNumber + ", 'C'" + ", '" + salePurchase.BillDate + "'" + ", '" + salePurchase.BillNumber + "'" + ", '" + util.GetLOVId(salePurchase.party) + "'" + ", " + salePurchase.SalePurchaseDetails[i].productAutoId + ", " + salePurchase.SalePurchaseDetails[i].qty + ", '" + salePurchase.SalePurchaseDetails[i].discount + " '" + ", " + salePurchase.SalePurchaseDetails[i].rate + ", " + salePurchase.SaleType + ", " + theLocation //+ ", " + salePurchase.SalePurchaseDetails[i].locationId + ", " + util.GetUserInsertQry(Util_BLL.User) + " ) "; site.Execute(qry); qry = " INSERT INTO tblProductLedger(LedgerNumber, ProductLedgerNumber, drcr, BillDate, BillNumber, AccountId, ProductID, SoldQty, Discount, rate, SourceId, LocationID, UserID, subuserId, FYear) " + " VALUES ( " + ledgerNumber + ", " + productLedgerNumber + ", 'D'" + ", '" + salePurchase.BillDate + "'" + ", '" + salePurchase.BillNumber + "'" + ", '" + Modes.SaleAccount + "'" + ", " + salePurchase.SalePurchaseDetails[i].productAutoId + ", " + salePurchase.SalePurchaseDetails[i].qty + ", '" + salePurchase.SalePurchaseDetails[i].discount + " '" + ", " + salePurchase.SalePurchaseDetails[i].rate + ", " + salePurchase.SaleType + ", " + theLocation //+ ", " + salePurchase.SalePurchaseDetails[i].locationId + ", " + util.GetUserInsertQry(Util_BLL.User) + " ) "; site.Execute(qry); string tax_qry = ""; for (int j = 0; j < salePurchase.SalePurchaseDetails[i].SalePurchaseDetailsTaxes.Count; j++) { tax_qry = " INSERT INTO tblTax(LedgerNumber, ProductLedgerNumber, TaxMasterId, TaxAmount, UserID, subUserId, FYear) " + " VALUES ( " + ledgerNumber + ", " + productLedgerNumber + ", " + salePurchase.SalePurchaseDetails[i].SalePurchaseDetailsTaxes[j].TaxId + ", " + salePurchase.SalePurchaseDetails[i].SalePurchaseDetailsTaxes[j].TaxAmount + ", " + util.GetUserInsertQry(Util_BLL.User) + " ) "; site.Execute(tax_qry); } } }
public void SaveStore(DBSite site, StockMovement store, int update = 0) { string qry = ""; int productLedgerNumber = 0; if (update == 1) { productLedgerNumber = store.ProductLedgerNumber; } else { productLedgerNumber = util.GetAutoNumber(site, "ProductLedgerNumber"); } foreach (ProductDetail pd in store.ProductDetails) { qry = " INSERT INTO tblProductLedger(ProductLedgerNumber, drcr"; if (pd.bought_qty > 0) { qry = qry + " , BoughtQty "; } else { qry = qry + " , SoldQty "; } qry = qry + ", AccountId, BillDate, ProductID, SourceId, LocationID, Particulars, ToNarration, ProductId2, BoughtQty2, SoldQty2, locationId2, UserID, subuserId, FYear) " + " VALUES ( " + productLedgerNumber; if (pd.bought_qty > 0) { qry = qry + ", 'C'" + ", " + pd.bought_qty; } else { qry = qry + ", 'D'" + ", " + pd.sold_qty; } qry = qry + ", '" + pd.AccountId + "'" + ", '" + store.MovementDate + "'" + ", " + pd.ProductId + ", " + store.TransactionTypeId + ", " + pd.LocationId + ", '" + store.Narration + "' " + ", '" + pd.ToNarration + "' " + ", " + pd.ProductId2 + ", " + pd.bought_qty2 + ", " + pd.sold_qty2 + ", " + pd.LocationId2 + ", " + util.GetUserInsertQry(Util_BLL.User) + " ) "; site.Execute(qry); } }