//DEREK Instalment Plan Need to Update Receipt Here public void PrintReceipt(string receiptNo) { DataColumn colItemDiscountAmt = new DataColumn("DiscountAmt", typeof(decimal)); DataColumn colBillDiscountAmt = new DataColumn("DiscountAmt", typeof(decimal)); DataColumn colMemberName = new DataColumn("strMemberName", typeof(string)); DataColumn colRewardPoint = new DataColumn("RewardPoint", typeof(decimal)); DataColumn colGSTPaid = new DataColumn("GSTPaid", typeof(decimal)); //DataColumn colOSAmt = new DataColumn("mOutstandingAmount", typeof(decimal)); TblReceipt receipt = new TblReceipt(); receipt.StrReceiptNo = receiptNo; DataTable tableReceipt = receipt.SelectOne(); tableReceipt.TableName = "TblReceipt"; tableReceipt.Columns.Add(colBillDiscountAmt); tableReceipt.Columns.Add(colMemberName); tableReceipt.Columns.Add(colRewardPoint); tableReceipt.Columns.Add(colGSTPaid); // tableReceipt.Columns.Add(colOSAmt); TblMember sqlMember = new TblMember(); sqlMember.StrMembershipID = receipt.StrMembershipID; sqlMember.SelectOne(); tableReceipt.Rows[0]["strMemberName"] = sqlMember.StrMemberName.IsNull ? "" : sqlMember.StrMemberName.Value.ToUpper(); TblBranch sqlBranch = new TblBranch(); sqlBranch.StrBranchCode = receipt.StrBranchCode == SqlString.Null ? "" : receipt.StrBranchCode.Value; DataTable branchTable = sqlBranch.SelectOne(); TblRewardsTransaction sqlRewTrans = new TblRewardsTransaction(); decimal rewardpoint = sqlRewTrans.GetMemberLoyaltyPoint(receipt.StrMembershipID.Value); tableReceipt.Rows[0]["RewardPoint"] = System.Math.Round(rewardpoint); TblReceiptEntries receiptEntries = new TblReceiptEntries(); receiptEntries.StrReceiptNo = receiptNo; DataTable tableReceiptEntries = receiptEntries.SelectAllWstrReceiptNoLogic(); tableReceiptEntries.TableName = "TblReceiptEntries"; tableReceiptEntries.Columns.Add(colItemDiscountAmt); TblReceiptFreebie freebie = new TblReceiptFreebie(); freebie.StrReceiptNo = receiptNo; DataTable tableReceiptFreebie = freebie.SelectReceiptFreebie(); tableReceiptFreebie.TableName = "TblReceiptFreebie"; TblMemberPackage FreePackage = new TblMemberPackage(); FreePackage.StrReceiptNo = receiptNo; DataTable tableFreePackage = FreePackage.GetFreePackage(receiptNo); tableFreePackage.TableName = "TblFreePackage"; TblMemberPackage ConvertedPackage = new TblMemberPackage(); ConvertedPackage.StrReceiptNo = receiptNo; DataTable tableConvertedPackage = ConvertedPackage.GetConvertedPackage(receiptNo); tableConvertedPackage.TableName = "TblConvertedPackage"; TblPaymentPlan myPaymentPlan = new TblPaymentPlan(); DataTable tablePaymentPlan = myPaymentPlan.GetInhouseIPPOSByReceiptNo(receiptNo); tablePaymentPlan.TableName = "TblPaymentPlan"; DataTable tableDeposit = myPaymentPlan.GetInhouseIPPReceiptDeposit(receiptNo); tableDeposit.TableName = "TblReceiptDeposit"; // TblProduct Product = new TblProduct(); // // Product.StrProductCode = tableReceiptFreebie.Rows[0]["strItemCode"].ToString(); // DataTable tableProduct = Product.SelectAll(); // tableProduct.TableName = "TblProductName"; decimal nettAmountB4Discount = 0; decimal discoutnAmt =0; decimal depositAmt = 0; if (tableDeposit.Rows.Count > 0) { depositAmt = Convert.ToDecimal(tableDeposit.Rows[0]["TotalDeposit"]); } foreach (DataRow r in tableReceiptEntries.Rows) { int qty = ACMS.Convert.ToInt32(r["nQuantity"]); decimal unitPrice = ACMS.Convert.ToDecimal(r["mUnitPrice"]); decimal currSubtotal = ACMS.Convert.ToDecimal(r["mSubTotal"]); discoutnAmt = (unitPrice * qty) - currSubtotal; r["DiscountAmt"] = decimal.Round(discoutnAmt, 2); nettAmountB4Discount += currSubtotal; } //Sub Total DataColumn colSubTotal = new DataColumn("mSubTotal", typeof(decimal)); tableReceipt.Columns.Add(colSubTotal); tableReceipt.Rows[0]["mSubTotal"] = nettAmountB4Discount; decimal nettAmountAfterDiscount = ACMS.Convert.ToDecimal(tableReceipt.Rows[0]["mNettAmount"]); if (tableReceipt.Rows[0]["strDiscountCode"].ToString().Length > 0 && tableReceipt.Rows[0]["strDiscountCode"] != DBNull.Value) { tableReceipt.Rows[0]["DiscountAmt"] = nettAmountB4Discount - (nettAmountAfterDiscount + depositAmt); } TblReceiptPayment receiptPayment = new TblReceiptPayment(); receiptPayment.StrReceiptNo = receiptNo; DataTable tableReceiptPayment = receiptPayment.SelectAllWstrReceiptNoLogic(); tableReceiptPayment.TableName = "TblReceiptPayment"; TblCompany comp = new TblCompany(); DataTable compTable = comp.SelectAll(); int myTaxID = ACMS.Convert.ToInt32(compTable.Rows[0]["NTaxID"]); TblTax tax = new TblTax(); tax.NTaxID = myTaxID; tax.SelectOne(); decimal myGSTRate = tax.DTaxRate.IsNull ? 0 : (decimal)tax.DTaxRate.Value; decimal GSTAmtPaid=0; decimal GSTRate1=myGSTRate;//0.05M; decimal GSTRate2=myGSTRate+1;// 1.05M; foreach (DataRow p in tableReceiptPayment.Rows) { GSTAmtPaid=GSTAmtPaid+ACMS.Convert.ToDecimal(p[3])* GSTRate1 /GSTRate2; } if (receipt.NCategoryID.ToString() != "38") { tableReceipt.Rows[0]["GSTPaid"] = decimal.Round(GSTAmtPaid, 2); } else { tableReceipt.Rows[0]["GSTPaid"] = decimal.Round(0, 2); } DataSet newDS = new DataSet("Receipt"); newDS.Tables.Add(tableReceipt); newDS.Tables.Add(tableReceiptEntries); newDS.Tables.Add(tableReceiptPayment); newDS.Tables.Add(branchTable); // newDS.Tables.Add(tableProduct); newDS.Tables.Add(tableReceiptFreebie); newDS.Tables.Add(tableFreePackage); newDS.Tables.Add(tableConvertedPackage); newDS.Tables.Add(tablePaymentPlan); newDS.Tables.Add(tableDeposit); DataRelation relation1 = new DataRelation("Receipt_ReceiptEntries_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblReceiptEntries"].Columns["strReceiptNo"], false); DataRelation relation2 = new DataRelation("Receipt_ReceiptPayment_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblReceiptPayment"].Columns["strReceiptNo"], false); DataRelation relation3 = new DataRelation("Receipt_ReceiptFreebie_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblReceiptFreebie"].Columns["strReceiptNo"], false); DataRelation relation4 = new DataRelation("Receipt_FreePackage_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblFreePackage"].Columns["strReceiptNo"], false); DataRelation relation5 = new DataRelation("Receipt_ConvertedPackage_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblConvertedPackage"].Columns["strReceiptNo"], false); DataRelation relation6 = new DataRelation("Receipt_PaymentPlan_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblPaymentPlan"].Columns["strReceiptNo"], false); DataRelation relation7 = new DataRelation("Receipt_Deposit_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblReceiptDeposit"].Columns["strReceiptNo"], false); newDS.Relations.Add(relation1); newDS.Relations.Add(relation2); newDS.Relations.Add(relation3); newDS.Relations.Add(relation4); newDS.Relations.Add(relation5); newDS.Relations.Add(relation6); newDS.Relations.Add(relation7); //display GST % DataColumn colGstTax = new DataColumn("GstTax", typeof(int)); tableReceipt.Columns.Add(colGstTax); tableReceipt.Rows[0]["GstTax"] = myGSTRate * 100; ACMSLogic.Report.Receipt receiptReport = new ACMSLogic.Report.Receipt(); receiptReport.DataSource = newDS; // if (ACMS.Convert.ToDecimal(tableReceipt.Rows[0]["DiscountAmt"])==0) // { // receiptReport.HideFields(false); // } // else // { // receiptReport.HideFields(true); // } // receiptReport.ShowDesignerDialog(); receiptReport.Print(); }
//Derek Instalment Plan Need to Add tblPaymentPlan private void Init() { TblCompany comp = new TblCompany(); DataTable compTable = comp.SelectAll(); myTaxID = ACMS.Convert.ToInt32(compTable.Rows[0]["NTaxID"]); TblTax tax = new TblTax(); tax.NTaxID = myTaxID; tax.SelectOne(); myGSTRate = tax.DTaxRate.IsNull ? 0 : (decimal)tax.DTaxRate.Value; myReceiptMasterTable = comp.FillSchema("Select * From tblReceipt"); myReceiptItemsTable = comp.FillSchema("Select * From tblReceiptEntries"); myReceiptFreebieTable = comp.FillSchema("Select * From tblReceiptFreebie"); myReceiptPaymentTable = comp.FillSchema("Select * From tblReceiptPayment"); InitTblReceipt(); InitTblReceiptEntries(); InitTblReceiptPackage(); InitTblReceiptItemsFreebie(); InitTblReceiptItemsPackage(); InitTblGiro(); InitWantToUpgradeMemberPackageTableNew(); //InitWantToUpgradeMemberPackageTable(); //Derek Instalment Plan No Need Fire ColumnChanged Event for tblPaymentPlan myReceiptMasterTable.ColumnChanged +=new DataColumnChangeEventHandler(myReceiptMasterTable_ColumnChanged); myReceiptItemsTable.ColumnChanged +=new DataColumnChangeEventHandler(myReceiptItemsTable_ColumnChanged); myReceiptPaymentTable.ColumnChanged +=new DataColumnChangeEventHandler(myReceiptPaymentTable_ColumnChanged); InitPaymentTypeTable(); }