Example #1
0
        public ReceiptPayment()
        {
            configReader = new AppSettingsReader();
            connString = configReader.GetValue("Main.ConnectionString", typeof(string)).ToString();

            myRP = new TblReceiptPayment();
            dtblPreset = myRP.SelectAllWnReceiptIPPIDLogic();
        }
Example #2
0
        private void BindData()
        {
            dal.TblIPP IPP = new dal.TblIPP();
            DataTable  dt  = IPP.SelectAll();

            //cbReceipient
            ddlIPP.DataSource  = dt;
            ddlIPP.ValueMember = "nIPPID";

            if (IPPId != "")
            {
                ddlIPP.SelectedValue = IPPId;
            }

            dal.TblReceiptPayment ReceiptPayment = new dal.TblReceiptPayment();
            dt = ReceiptPayment.SelectAll();
            //cbReceipient
            ddlReceipt.DataSource    = dt;
            ddlReceipt.ValueMember   = "nPaymentID";
            ddlReceipt.DisplayMember = "strReceiptNo";
        }
Example #3
0
        public bool SavePOS(ACMSLogic.POS pos)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            //ACMSDAL.ConnectionProvider connProvider1 = new ConnectionProvider();

            try
            {
                DataTable branchReceiptNoTable = new DataTable();
                int latestReceiptNo = GetLatestReceiptNo(connProvider, pos, ref branchReceiptNoTable) + 1;
                string receiptNo = pos.StrBranchCode.ToString().Trim() + pos.NTerminalID.ToString().Trim() + latestReceiptNo.ToString().Trim();

                pos.StrReceiptNo = receiptNo;

                //Derek Instalment Plan Need to Add PaymentPlan Table Here
                //Get pos.NCategoryID here to determine if the item is Pay O/S
                //Here Can get the new Receipt No Value
                //3 Main table that always need to update

                TblReceipt receipt = new TblReceipt();
                TblReceiptEntries receiptEntries = new TblReceiptEntries();
                TblReceiptPayment receiptPayment = new TblReceiptPayment();
                TblPaymentPlan myPaymentPlan = new TblPaymentPlan();

                receipt.MainConnectionProvider = connProvider;
                receiptEntries.MainConnectionProvider = connProvider;
                receiptPayment.MainConnectionProvider = connProvider;
                myPaymentPlan.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("SaveReceipt");

                DataTable receiptTable = pos.ReceiptMasterTable.Copy();
                DataTable receiptEntriesTable = pos.ReceiptItemsTable.Copy();
                DataTable receiptPaymentTable = pos.ReceiptPaymentTable.Copy();
                DataTable freeMemberPackageTable = receipt.FillSchema("Select * From tblMemberPackage"); // use to store the free member package.
                DataTable freeMemberCreditPackageTable = receipt.FillSchema("Select * From tblMemberCreditPackage");

                if (pos.PaymentPlanTable != null && pos.NCategoryID != 0)
                {
                    DataTable paymentPlanTable = pos.PaymentPlanTable.Copy();

                    if (paymentPlanTable != null && paymentPlanTable.Rows.Count > 0)
                    {
                        foreach (DataRow r in paymentPlanTable.Rows)
                        {
                            r["strReceiptNo"] = pos.StrReceiptNo;

                            if (r["nInstalmentNo"].ToString() == "1")
                            {
                                r["strPaymentReceiptNo"] = pos.StrReceiptNo;

                                myPaymentPlan.IPPPrimaryEntry(r["strReceiptNo"].ToString(), Convert.ToInt32(r["nInstalmentNo"]),
                                                                r["strPaymentReceiptNo"].ToString(), Convert.ToDecimal(r["mPaymentPlanAmt"]),
                                                                Convert.ToDecimal(r["mPaidAmount"]), Convert.ToDecimal(r["mAdjustedPaymentPlanAmt"]),
                                                                Convert.ToDecimal(r["mOutstandingAmt"]), Convert.ToDateTime(r["dtPaymentDate"]),
                                                                Convert.ToDateTime(r["dtDueDate"]), Convert.ToDateTime(r["dtFinalDueDate"]),
                                                                Convert.ToInt32(r["nPaymentPlanID"]));

                            }
                            else
                            {
                                myPaymentPlan.IPPSubsequentEntry(r["strReceiptNo"].ToString(), Convert.ToInt32(r["nInstalmentNo"]),
                                                                    Convert.ToDecimal(r["mPaymentPlanAmt"]), Convert.ToDecimal(r["mPaidAmount"]),
                                                                    Convert.ToDecimal(r["mAdjustedPaymentPlanAmt"]), Convert.ToDecimal(r["mOutstandingAmt"]),
                                                                    Convert.ToDateTime(r["dtDueDate"]), Convert.ToDateTime(r["dtFinalDueDate"]),
                                                                    Convert.ToInt32(r["nPaymentPlanID"]));
                            }
                        }
                        paymentPlanTable.AcceptChanges();
                    }
                    pos.PaymentPlanTable.AcceptChanges();

                }
                else if (pos.PaymentPlanTable != null && pos.NCategoryID == 0)
                {
                    DataTable paymentPlanTable = pos.PaymentPlanTable.Copy();

                    if (paymentPlanTable != null && paymentPlanTable.Rows.Count > 0)
                    {
                        foreach (DataRow r in paymentPlanTable.Rows)
                        {
                            if (r["lastestUpdate"].ToString() == "1")
                            {
                                r["strPaymentReceiptNo"] = pos.StrReceiptNo;

                                myPaymentPlan.IPPPrimaryUpdate(Convert.ToInt32(r["nPaymentPlanID"]), r["strReceiptNo"].ToString(),
                                                                Convert.ToInt32(r["nInstalmentNo"]), r["strPaymentReceiptNo"].ToString(),
                                                                Convert.ToDecimal(r["mPaidAmount"]), Convert.ToDecimal(r["mAdjustedPaymentPlanAmt"]),
                                                                Convert.ToDecimal(r["mOutstandingAmt"]), Convert.ToDateTime(r["dtPaymentDate"]));

                            }
                            else
                            {
                                myPaymentPlan.IPPSubsequentUpdate(Convert.ToInt32(r["nPaymentPlanID"]), r["strReceiptNo"].ToString(),
                                                                    Convert.ToInt32(r["nInstalmentNo"]), Convert.ToDecimal(r["mPaidAmount"]),
                                                                    Convert.ToDecimal(r["mAdjustedPaymentPlanAmt"]), Convert.ToDecimal(r["mOutstandingAmt"]));
                            }
                        }

                        //paymentPlanTable.AcceptChanges();
                    }
                    pos.PaymentPlanTable.AcceptChanges();
                }

                receipt.SaveData(receiptTable);
                receiptEntries.SaveData(receiptEntriesTable);
                receiptPayment.SaveData(receiptPaymentTable);

                receiptEntries.StrReceiptNo = pos.StrReceiptNo;
                DataTable savedReceiptEntriesTable = receiptEntries.SelectAllWstrReceiptNoLogic();

                pos.ReceiptMasterTable.AcceptChanges();

                if (pos.StrFreebieCode.HasValue && pos.StrFreebieCode.ToString() != "")
                {
                    //Update Bill Freebie here
                    if (pos.ReceiptFreebieTable.Rows.Count > 0)
                    {
                        TblReceiptFreebie receiptFreebie = new TblReceiptFreebie();
                        receiptFreebie.MainConnectionProvider = connProvider;
                        DataTable receiptFreebieTable = pos.ReceiptFreebieTable.Copy();

                        // Save Bill Receipt Freebie
                        receiptFreebie.SaveData(receiptFreebieTable);

                        //TblProductInventory proInven = new TblProductInventory();
                        //proInven.MainConnectionProvider = connProvider;

                        //// deduct stock
                        //foreach (DataRow r in receiptFreebieTable.Rows)
                        //{
                        //    proInven.IncreaseQuantity(r["strItemCode"].ToString(), pos.StrBranchCode, -1);
                        //}
                    }
                    if (pos.ReceiptPackageTable.Rows.Count > 0)
                    {
                        // update package

                        foreach (DataRow r in pos.ReceiptPackageTable.Rows)
                        {
                            TblCreditPackage p = new TblCreditPackage();
                            p.StrCreditPackageCode = r["strPackageCode"].ToString();
                            p.SelectOne();

                            if (p.StrDescription.ToString() != "Null")
                            {
                                DataRow rowToAdd = freeMemberCreditPackageTable.NewRow();

                                ACMSLogic.MemberPackage.InitMemberCreditPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID,
                                    r["strPackageCode"].ToString(), r["strPromotionCode"].ToString(), true);

                                // Add to freeMemberPackageTable and will save
                                freeMemberCreditPackageTable.Rows.Add(rowToAdd);
                            }
                            else
                            {
                                DataRow rowToAdd = freeMemberPackageTable.NewRow();

                                ACMSLogic.MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID,
                                    r["strPackageCode"].ToString(), r["strPromotionCode"].ToString(), true);

                                // Add to freeMemberPackageTable and will save
                                freeMemberPackageTable.Rows.Add(rowToAdd);
                            }
                        }
                    }
                    //else
                    //{
                    //    throw new Exception("Bill Freebie have no free any product or package although the strFreebieCode is not null");
                    //}
                }

                if (pos.ReceiptItemsFreebiePackageTable.Rows.Count > 0)
                {
                    foreach (DataRow r in pos.ReceiptItemsFreebiePackageTable.Rows)
                    {
                        TblCreditPackage p = new TblCreditPackage();
                        p.StrCreditPackageCode = r["strPackageCode"].ToString();
                        p.SelectOne();

                        if (p.StrDescription.ToString() != "Null")
                        {
                            DataRow rowToAdd = freeMemberCreditPackageTable.NewRow();

                            ACMSLogic.MemberPackage.InitMemberCreditPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID,
                                r["strPackageCode"].ToString(), r["strPromotionCode"].ToString(), true);

                            // Add to freeMemberPackageTable and will save
                            freeMemberCreditPackageTable.Rows.Add(rowToAdd);
                        }
                        else
                        {
                            DataRow rowToAdd = freeMemberPackageTable.NewRow();
                            // Kean Yiap
                            if (pos.NCategoryID == 34)
                            {
                                MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, r["strPackageCode"].ToString(), "",
                                    true, -1, pos.dtPackageStart, pos.NProrateDays);
                            }
                            else
                            {
                                ACMSLogic.MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID,
                                    r["strPackageCode"].ToString(), r["strPromotionCode"].ToString(), true);
                            }
                            // Add to freeMemberPackageTable and will save
                            freeMemberPackageTable.Rows.Add(rowToAdd);
                        }
                    }
                }

                if (pos.ReceiptItemsFreebieProductTable.Rows.Count > 0)
                {
                    //					Update product
                    TblReceiptFreebie receiptFreebie = new TblReceiptFreebie();
                    receiptFreebie.MainConnectionProvider = connProvider;
                    DataTable receiptItemsFreebieProductTable = pos.ReceiptFreebieTable.Clone(); // i have to use this structure bcoz i wan to save to this table;

                    foreach (DataRow r in pos.ReceiptItemsFreebieProductTable.Rows)
                    {
                        DataRow rowToAdd = receiptItemsFreebieProductTable.NewRow();
                        rowToAdd["strReceiptNo"] = pos.StrReceiptNo;
                        rowToAdd["strItemCode"] = r["strProductCode"];
                        rowToAdd["strPromotionCode"] = r["strPromotionCode"];

                        DataRow[] tempRows = savedReceiptEntriesTable.Select("nTempEntryID = " + r["nEntryID"].ToString(),
                            "", DataViewRowState.CurrentRows);

                        if (tempRows.Length > 0)
                            rowToAdd["nEntryID"] = tempRows[0]["nEntryID"];

                        receiptItemsFreebieProductTable.Rows.Add(rowToAdd);
                    }

                    receiptFreebie.SaveData(receiptItemsFreebieProductTable);

                    //TblProductInventory proInven = new TblProductInventory();
                    //proInven.MainConnectionProvider = connProvider;

                    //foreach (DataRow r in receiptItemsFreebieProductTable.Rows)
                    //{
                    //    proInven.IncreaseQuantity(r["strItemCode"].ToString(), pos.StrBranchCode, -1);
                    //}
                }

                if (freeMemberPackageTable.Rows.Count > 0)
                {
                    // update the member package to database
                    TblMemberPackage memberPackage = new TblMemberPackage();
                    memberPackage.MainConnectionProvider = connProvider;
                    memberPackage.SaveData(freeMemberPackageTable);
                }

                if (freeMemberCreditPackageTable.Rows.Count > 0)
                {
                    // update the member package to database
                    TblMemberCreditPackage memberPackage = new TblMemberCreditPackage();
                    memberPackage.MainConnectionProvider = connProvider;
                    memberPackage.SaveData(freeMemberCreditPackageTable);
                }

            //part 2
                DeleteUselessIPP(connProvider, pos);
                UpdateRegistrationFee(connProvider, pos);
                UpdateOldPackSetDeactivate(connProvider, pos); //Update when upgrade
                PostToMemberCreditPackage(connProvider, pos);
                PostToMemberPackage(connProvider, pos);
                UpdateUsedCashVoucher(connProvider, pos);

                int ParentCategoryID = pos.NCategoryID;

                if (pos.NCategoryID == 10)
                {
                    ParentCategoryID = UpgradePackage(connProvider, pos);
                    if (ParentCategoryID == 10)
                    {
                        ParentCategoryID = UpgradeCreditPackage(connProvider, pos);
                    }
                }

                TopUpCreditPackage(connProvider, pos);
                TopUpSingleTreatmentTransaction(connProvider, pos);
                MakeDeposit(connProvider, pos);

                CashVoucherTransaction(connProvider, pos);
                LockerTransaction(connProvider, pos);
                ForgetCardTransaction(connProvider, pos);
                ReplaceMembershipCardTransaction(connProvider, pos);
                //MineralWaterTransaction(connProvider, pos);
                TblRewards rewardcode = new TblRewards();
                ACMSDAL.TblCategory category = new ACMSDAL.TblCategory();
                category.NCategoryID = pos.NCategoryID;
                category.SelectOne();
                int SalesCategory = ACMS.Convert.ToInt32(category.NSalesCategoryID);

                //Derek Instalment Plan - Here it assigned the Category to the Pay O/S Receipt Record
                if (pos.NCategoryID == 0)
                {
                    ParentCategoryID = PayOutstanding(connProvider, pos);
                    pos.StrRewardsCode = rewardcode.SelectRewards(ParentCategoryID, pos.StrBranchCode);
                }
                else
                    pos.StrRewardsCode = rewardcode.SelectRewards(pos.NCategoryID, pos.StrBranchCode);

                if (pos.StrRewardsCode.HasValue && pos.StrRewardsCode.ToString() != "" && pos.StrRewardsCode.ToString() != "Null")
                {
                    TblRewards rewards = new TblRewards();
                    rewards.StrRewardsCode = pos.StrRewardsCode.ToString();
                    rewards.SelectOne();

                    double dRewardPoint = 0;

                    double dRewardPercent = (rewards.DRewardsPercent.IsNull ? 0 : rewards.DRewardsPercent.Value);
                    double dRewardValue = (rewards.DRewardsValue.IsNull ? 0 : rewards.DRewardsValue.Value);

                    //jackie 23 others give 50% GIRO
                    //if (ParentCategoryID == 23 && pos.MNettAmount > 60)//pos.MNettAmount
                    //{
                    //    dRewardPercent = 50;

                    //}

                    if (dRewardPercent > 0 && dRewardValue == 0)
                    {
                        decimal mnettTotal = 0;

                        if (pos.MOutstandingAmount > 0)
                        {
                            mnettTotal = pos.MNettAmount - (pos.MOutstandingAmount - pos.MGSTAmount);
                        }
                        else
                        {
                            mnettTotal = pos.MNettAmount;
                        }

                        dRewardPoint = ((double)mnettTotal) * dRewardPercent / 100;
                    }
                    else
                    {
                        if (pos.NCategoryID == 0)
                        {
                            dRewardPoint = dRewardValue;
                        }
                    }
                    if (pos.NThisMonthBirthday == 1)
                    {
                        DialogResult result1 = MessageBox.Show("Member is having birthday this months. Do you want to give double point?", "Warning",
                        MessageBoxButtons.YesNo);

                        if (result1 == DialogResult.Yes)
                            dRewardPoint *= 2;
                    }

                    TblRewardsTransaction rewardTran = new TblRewardsTransaction();
                    rewardTran.MainConnectionProvider = connProvider;
                    if (pos.NCategoryID == 20)
                    {
                        rewardTran.StrMembershipID = pos.StrNewMembershipID;
                    }
                    else
                    {
                        rewardTran.StrMembershipID = pos.StrMembershipID;
                    }
                    rewardTran.DtDate = pos.DtDate;
                    rewardTran.NTypeID = 1;
                    rewardTran.NEmployeeID = pos.NCashierID;
                    rewardTran.DRewardsPoints = dRewardPoint;
                    rewardTran.StrReferenceNo = pos.StrReceiptNo;
                    if (dRewardPoint > 0) // rewards point > 0 then insert records //3004
                    {
                        rewardTran.Insert();
                    }
                }

                if (pos.StrRewardsCode.ToString() == "Null") pos.StrRewardsCode = "";

                DataTable QtyTable = receiptEntries.Get_StrCodeReceiptNo(pos.StrReceiptNo);
                //check is the receipt fully paid
                string Nett = pos.MNettAmount.ToString();
                string Outstanding = pos.MOutstandingAmount.ToString();

                //if (pos.MOutstandingAmount == 0 && (pos.NCategoryID == 11 || pos.NCategoryID == 12))
                //    PostToStock(connProvider, QtyTable, pos);

                receiptTable = pos.ReceiptMasterTable.Copy();
                int PosCategory = ACMS.Convert.ToInt32(receiptTable.Rows[0]["nCategoryID"]);
                if (PosCategory == 24)
                {
                    receiptTable.Rows[0]["fDeposit"] = true;
                    receipt.SaveData(receiptTable);
                }

                if (pos.StrBillReferenceNo != "")
                {
                    receiptTable.Rows[0]["strBillReferenceNo"] = pos.StrBillReferenceNo;
                    receipt.SaveData(receiptTable);
                }

                if (pos.NCategoryID == 0 || pos.NCategoryID == 10)
                {
                    receipt.StrReceiptNo = pos.StrReceiptNo;
                    receipt.SelectOne();
                    receipt.MOutstandingAmount = Convert.ToDecimal(pos.MOutstandingAmount);
                    receipt.NCategoryID = ParentCategoryID;
                    receipt.Update();
                    //TblReceipt receipt3 = new TblReceipt();
                    //receipt3.StrReceiptNo = pos.StrReceiptNo;
                    //receipt3.SelectOne();
                    //receipt3.MOutstandingAmount = Convert.ToDecimal(pos.MOutstandingAmount);
                    //receipt3.NCategoryID = ParentCategoryID;
                    //receipt3.Update();
                }

                if (pos.StrDeposit != "")
                {
                    receipt.StrReceiptNo = pos.StrDeposit;
                    DataTable tblDeposit = receipt.SelectOne();
                    if (tblDeposit.Rows.Count > 0)
                    {
                        receipt.FDeposit = false;
                        receipt.Update();

                    }
                    else
                    {
                        TblMemberPackage ConvertedPackage = new TblMemberPackage();
                        ConvertedPackage.NPackageID = ACMS.Convert.ToSqlInt32(pos.StrDeposit);
                        ConvertedPackage.NStatusID = 1;
                        ConvertedPackage.UpdateConvertedPackageStatus();
                    }
                }

                if (pos.ReceiptItemsTable.Select("", "", DataViewRowState.ModifiedCurrent).Length > 0)
                {
                    receiptEntriesTable = pos.ReceiptItemsTable.Copy();
                    receipt.SaveData(receiptEntriesTable);
                }
                //1503
                branchReceiptNoTable.Rows[0]["nReceiptNo"] = latestReceiptNo;

                SaveUpToDateReceiptNo(connProvider, branchReceiptNoTable);
                connProvider.CommitTransaction();

                if (pos.StrDeposit != "")
                {
                    TblReceipt receipt2 = new TblReceipt();
                    receipt2.StrReceiptNo = pos.StrDeposit;
                    receipt2.SelectOne();
                    receipt2.StrChildReceiptNo = receiptNo;
                    receipt2.Update();
                }
                return true;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();

                }
            }
        }
Example #4
0
        //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();
        }
Example #5
0
        private void BindData()
        {
            dal.TblIPP IPP = new dal.TblIPP();
            DataTable dt = IPP.SelectAll();
            //cbReceipient
            ddlIPP.DataSource = dt;
            ddlIPP.ValueMember = "nIPPID";

            if (IPPId != "")
                ddlIPP.SelectedValue = IPPId;

            dal.TblReceiptPayment ReceiptPayment = new dal.TblReceiptPayment();
            dt = ReceiptPayment.SelectAll();
            //cbReceipient
            ddlReceipt.DataSource = dt;
            ddlReceipt.ValueMember = "nPaymentID";
            ddlReceipt.DisplayMember = "strReceiptNo";
        }
Example #6
0
        public void page_write()
        {
            TblReceiptPayment BJreceipt = new TblReceiptPayment();
            DateTime ReceiptDate = DateTime.Now;
            DataTable tblBJReceipt = BJreceipt.selectBJsales(ReceiptDate);
            DataTable tblSetup = BJreceipt.BJFileSetup();
            string strMachineID = tblSetup.Rows[0]["strMachineID"].ToString();
            string strFile = tblSetup.Rows[0]["nFile"].ToString();
            string strDir = tblSetup.Rows[0]["strDir"].ToString();
            string strVal = string.Empty;
            double sumTotal= 0.00;
            TextWriter tw = new StreamWriter(strDir + strMachineID + "." + strFile);
            for (int i = 0; i < tblBJReceipt.Rows.Count; i++)
            {
                sumTotal = sumTotal + System.Convert.ToDouble(tblBJReceipt.Rows[i][0]);
            //				strVal = "0000000"+tblBJReceipt.Rows[i][0].ToString();
            //
            //				if(strVal.Length > 11)
            //					strVal = Right(strVal, 11);
            //
            //				tw.WriteLine(strMachineID + DateTime.Now.ToString("yyyyMMdd")+strVal);
            }
            strVal = "0000000" + sumTotal.ToString("#0.00");
            strVal = Right(strVal, 11);
            tw.WriteLine(strMachineID + DateTime.Now.ToString("yyyyMMdd")+strVal);
            tw.Close();
            int nFileNo = System.Convert.ToInt32(strFile);
            nFileNo = nFileNo + 1;
            strFile = nFileNo.ToString();
            BJreceipt.UpdateFileNo(strFile);
            //File.Delete(myFilePath);

            //			DataView attendedMemberTable = myClassAttendance.GetClassAttendanceView(NClassInstanceID);
            //
            //			attendedMemberTable.RowFilter = "nStatusID = 1";
            //			for (int i = 0; i < attendedMemberTable.Count; i++)
            //			{
            //				int j = i + 1;
            //
            //				if (j < attendedMemberTable.Count)
            //				{
            //					strLine = string.Format("--{0}      --{1}",
            //						attendedMemberTable[i]["strMembershipID"].ToString(),
            //						attendedMemberTable[j]["strMembershipID"].ToString());
            //					myReceiptPrinting.WriteLine(strLine);
            //					i = j;
            //					// write a line of text to the file
            //
            //				}
            //			}
        }
Example #7
0
 private void Init()
 {
     myRP = new TblReceiptPayment();
     myDataTable = myRP.SelectAll();
 }
Example #8
0
        //Derek Instalment Plan - Void Pay OS - Update Payment Plan
        public void VoidReceipt(string strReceiptNo, bool VoidPre)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                // Check Access Right here
                TblReceipt receipt = new TblReceipt();
                TblReceiptFreebie sqlReceiptFreebie = new TblReceiptFreebie();
                TblRewardsTransaction mRewardTransaction = new TblRewardsTransaction();
                TblReceiptPayment sqlReceiptPayment = new TblReceiptPayment();
                TblPaymentPlan myPaymentPlan = new TblPaymentPlan();

                myPaymentPlan.MainConnectionProvider = connProvider;
                mRewardTransaction.MainConnectionProvider = connProvider;
                receipt.MainConnectionProvider = connProvider;
                sqlReceiptFreebie.MainConnectionProvider = connProvider;
                sqlReceiptPayment.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("VoidReceipt");

                receipt.StrReceiptNo = strReceiptNo;
                receipt.SelectOne();

                int nCategoryID = receipt.NCategoryID.Value;
                string strBranchCode = receipt.StrBranchCode.Value;

                if (receipt.DtDate.Value != System.DateTime.Today && VoidPre == false)
                    throw new Exception("Not allow to void previous data receipt. ");

                if (strBranchCode != User.BranchCode)
                    throw new Exception("Not allow to void other's branches' receipt. ");

                receipt.FVoid = System.Data.SqlTypes.SqlBoolean.True;
                receipt.Update();

                string strSQL;
                if (receipt.NCategoryID == 7 || receipt.NCategoryID == 36 || receipt.NCategoryID == 37)
                    strSQL = "select top 1 * from tblMemberCreditPackage where strReceiptNo ='" + receipt.StrReceiptNo.ToString() + "' AND fFree=0";
                else
                    strSQL = "select top 1 * from tblMemberPackage where strReceiptNo ='" + receipt.StrReceiptNo.ToString() + "' AND fFree=0";
                DataSet _ds1 = new DataSet();
                SqlHelper.FillDataset(connection, CommandType.StoredProcedure, "UP_GETDATA", _ds1, new string[] { "table" }, new SqlParameter("@strSQL", strSQL));

                //Roll back when package conversion
                if (_ds1.Tables["table"].Rows.Count > 0)
                {
                    string strPkgRemark = _ds1.Tables["table"].Rows[0]["strUpgradeFrom"].ToString();
                    string[] rollbackPackages = strPkgRemark.ToString().Split(',');

                    foreach (string rollbackPackage in rollbackPackages)
                    {
                        if (rollbackPackage.Trim() != "" && rollbackPackage.Trim() != "Null")
                        {
                            if (rollbackPackage.Contains("(C)"))
                            {
                                int nPackageID = Convert.ToInt32(rollbackPackage.Trim().Replace("(C)", ""));
                                TblMemberCreditPackage mp2 = new TblMemberCreditPackage();
                                mp2.NCreditPackageID = nPackageID;
                                mp2.SelectOne();
                                mp2.StrUpgradeTo = "";
                                mp2.StrRemarks = "";
                                mp2.NStatusID = 0;
                                mp2.Update();
                            }
                            else if (rollbackPackage.Contains("(B)"))
                            {
                                string strSQL2 = "select * from tblMemberPackage where strUpgradeTo='" + receipt.StrReceiptNo.ToString() + "' ";
                                DataSet _ds2 = new DataSet();
                                SqlHelper.FillDataset(connection, CommandType.StoredProcedure, "UP_GETDATA", _ds2, new string[] { "table" }, new SqlParameter("@strSQL", strSQL2));
                                foreach (DataRow drComboPkg in _ds2.Tables["table"].Rows)
                                {
                                    TblMemberPackage mp = new TblMemberPackage();
                                    DataTable convertedPkgTable = mp.LoadData("select * from tblMemberPackage where nPackageID=" + drComboPkg["nPackageID"].ToString());
                                    if (convertedPkgTable.Rows.Count > 0)
                                    {
                                        convertedPkgTable.Rows[0]["nStatusID"] = 0;
                                        convertedPkgTable.Rows[0]["strUpgradeTo"] = "";
                                        convertedPkgTable.Rows[0]["strRemarks"] = "";
                                        mp.SaveData(convertedPkgTable);
                                    }
                                }
                            }
                            else
                            {
                                int nPackageID = Convert.ToInt32(rollbackPackage.Trim());
                                TblMemberPackage mp2 = new TblMemberPackage();
                                mp2.NPackageID = nPackageID;
                                mp2.SelectOne();
                                mp2.StrUpgradeTo = "";
                                mp2.StrRemarks = "";
                                mp2.NStatusID = 0;
                                mp2.Update();

                                //rollback free package if have any
                                TblMemberPackage mp3 = new TblMemberPackage();
                                string strFreePackageCode = "";
                                string strSQL3 = "select strFreePkgCode from tblPackage where strPackageCode='" + Convert.ToString(mp2.StrPackageCode) + "' ";
                                DataSet _ds = new DataSet();
                                SqlHelper.FillDataset(connection, CommandType.StoredProcedure, "UP_GETDATA", _ds, new string[] { "table" }, new SqlParameter("@strSQL", strSQL3));
                                if (_ds.Tables["table"].Rows.Count > 0)
                                {
                                    strFreePackageCode = _ds.Tables["table"].Rows[0]["strFreePkgCode"].ToString();
                                }
                                DataTable freePkgTable = mp3.LoadData("select * from tblMemberPackage where strReceiptNo=@strReceiptNo and strPackageCode =@strFreePackageCode ",
                                    new string[] { "@strReceiptNo", "@strFreePackageCode" }, new object[] { mp2.StrReceiptNo.ToString(), strFreePackageCode });

                                if (freePkgTable.Rows.Count > 0)
                                {
                                    freePkgTable.Rows[0]["nStatusID"] = 0;
                                    freePkgTable.Rows[0]["strUpgradeTo"] = "";
                                    freePkgTable.Rows[0]["strRemarks"] = "";
                                    mp3.SaveData(freePkgTable);
                                }
                            }
                        }
                    }
                }

                receipt.MUpgradeAmount = System.Data.SqlTypes.SqlMoney.Null;
                receipt.StrRemarks = "";
                receipt.Update();

                #region ====== Added By Albert ======
                /*
                 * To remove reward transaction.
                 */
                mRewardTransaction.StrReferenceNo = strReceiptNo;
                mRewardTransaction.SelectAllWReferenceNo();
                mRewardTransaction.NTypeID = 3;
                mRewardTransaction.Update();
                #endregion

                //rollback used cash voucher
                TblReceiptPayment tblReceiptPayment = new ACMSDAL.TblReceiptPayment();
                tblReceiptPayment.StrReceiptNo = strReceiptNo;
                DataTable tblPayment = tblReceiptPayment.SelectAllWstrReceiptNoLogic();

                foreach (DataRow dr in tblPayment.Rows)
                {
                    if (dr["strPaymentCode"].ToString() == "CASHVOUCHER")
                    {
                        TblCashVoucher sqlCV = new TblCashVoucher();
                        sqlCV.MainConnectionProvider = connProvider;
                        sqlCV.StrSN = dr["strReferenceNo"].ToString();
                        DataTable table = sqlCV.SelectOne();
                        sqlCV.NStatusID = 1;
                        sqlCV.StrRedeemedByID = System.Data.SqlTypes.SqlString.Null;
                        sqlCV.DtRedeemedDate = System.Data.SqlTypes.SqlDateTime.Null;
                        sqlCV.StrRedeemedBranch = System.Data.SqlTypes.SqlString.Null;
                        sqlCV.Update();
                        sqlCV.SaveData(table);
                    }
                }

                if (!receipt.StrChildReceiptNo.IsNull)
                {
                    int IsVoid = 0;

                    IsVoid = receipt.CheckIfChildReceiptVoid(receipt.StrChildReceiptNo.Value);

                    if (IsVoid == 0)
                    {
                        throw new Exception("The receipt given has child receipt, please void child receipt first before void this receipt");
                    }
                }

                string strDepositReceiptNo = "";

                if (!receipt.StrParentReceiptNo.IsNull)
                {
                    TblReceiptEntries pReceipt = new TblReceiptEntries();
                    pReceipt.StrReceiptNo = receipt.StrParentReceiptNo.Value;
                    pReceipt.SelectAllWstrReceiptNoLogic();
                    if (pReceipt.StrCode.Value != "Deposit")
                    {
                        nCategoryID = 0; //Check if pay outstanding receipt, reset category to 0
                    }
                    else if (pReceipt.StrCode.Value == "Deposit")
                    {
                        strDepositReceiptNo = receipt.StrParentReceiptNo.Value;
                    }
                    pReceipt.Dispose();
                }

                if (strDepositReceiptNo != "")
                {
                    try
                    {
                        receipt.ReviveDepositForVoidMasterReceipt(strReceiptNo, strDepositReceiptNo);
                    }
                    catch { }
                }

                if (nCategoryID == 1 || nCategoryID == 3 || nCategoryID == 4 || nCategoryID == 5 ||
                    nCategoryID == 6 || nCategoryID == 8 || nCategoryID == 9 || nCategoryID == 14 || nCategoryID == 23)
                {
                    ActionTakeWhenVoidReceiptForCategory_1_3_4_5_6_8_9_14_23(strReceiptNo, connProvider);
                }
                else if (nCategoryID == 2)
                {
                    //Fitness GIRO
                    ActionTakeWhenVoidReceiptForCategory_2(strReceiptNo, connProvider);
                }
                else if (nCategoryID == 7)
                {
                    // Spa Credit Account
                    ActionTakeWhenVoidReceiptForCategory_7(strReceiptNo, connProvider);
                }
                else if (nCategoryID == 36 || nCategoryID == 37)
                {
                    // Holistic Credit Account
                    ActionTakeWhenVoidReceiptForCategory_7(strReceiptNo, connProvider);
                }
                else if (nCategoryID == 38)
                {
                    // Cash Voucher
                    ActionTakeWhenVoidReceiptForCategory_38(strReceiptNo, connProvider);
                }
                else
                {
                    DeleteFreeMemberPackage(strReceiptNo, connProvider);

                    if (nCategoryID == 11 || nCategoryID == 12)
                    {
                        //ActionTakeWhenVoidReceiptForCategory_11_12(strReceiptNo, connProvider);
                    }
                    else if (nCategoryID == 21)
                    {
                        // mineral water
                    }
                    else if (nCategoryID == 15)
                    {
                        //Locker Rental
                    }
                    else if (nCategoryID == 0)
                    {
                        // Pay Outstanding
                        ActionTakeWhenVoidReceiptForCategory_0(receipt, connProvider);

                        //Get New Payment Plan
                        //If Table Row Count > 0 Then Update Payment Plan

                        //Derek Instalment Plan - Update tblPaymentPlan (if any)
                        //Reset Payment Plan's Receipt by payment receipt No - Bool 1 Updated 0 Not Found
                        //Get Bool If 1
                        //Find the Master Receipt No if 1

                        string strMasterReceiptNo = "";

                        strMasterReceiptNo = myPaymentPlan.GetInhouseIPPMasterOSReceiptSimple(strReceiptNo);

                        if (strMasterReceiptNo != "")
                        {
                            if (myPaymentPlan.GetInhouseResetIPP_VoidPayOS(strReceiptNo) == 1)
                            {
                                DataTable paymentPlanTable = myPaymentPlan.GetInhouseAdjustedIPP_VoidPayOS(strMasterReceiptNo);

                                if (paymentPlanTable != null && paymentPlanTable.Rows.Count > 0)
                                {
                                    foreach (DataRow r in paymentPlanTable.Rows)
                                    {
                                        if (r["lastestUpdate"].ToString() == "1")
                                        {
                                            myPaymentPlan.IPPSubsequentUpdate(Convert.ToInt32(r["nPaymentPlanID"]), r["strReceiptNo"].ToString(),
                                                                                Convert.ToInt32(r["nInstalmentNo"]), Convert.ToDecimal(r["mPaidAmount"]),
                                                                                Convert.ToDecimal(r["mAdjustedPaymentPlanAmt"]), Convert.ToDecimal(r["mOutstandingAmt"]));
                                        }
                                    }
                                    //paymentPlanTable.AcceptChanges();
                                }
                            }
                        }
                    }
                    else if (nCategoryID == 18)
                    {
                        ActionTakeWhenVoidReceiptForCategory_18(strReceiptNo, connProvider);
                    }
                    else if (nCategoryID == 19)
                    {
                        ActionTakeWhenVoidReceiptForCategory_19(strReceiptNo, connProvider);
                    }
                    #region Un-support voiding
                    /*
                    else if (nCategoryID == 17)
                    {
                        //throw new Exception("Forget card's receipt is not allow to void.");
                        //do notthing. Just void the receipt
                    }
                    else if (nCategoryID == 10)
                    {
                        //throw new Exception("Upgrade Package's receipt is not allow to void.");
                        // do notthing. Just void the receipt.
                    }
                    else if (nCategoryID == 20)
                    {
                        //Replace Membership Card
                        //throw new Exception("Replace member card's receipt is not allow to void.");
                        //do notthing, just void the receipt
                    }
                    */
                    #endregion

                }

                connProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                connProvider.RollbackTransaction("VoidReceipt");
                throw ex;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();

                }
            }
        }
Example #9
0
 public DataTable GetReceiptPayment(string strReceiptNo)
 {
     TblReceiptPayment receiptPayment = new TblReceiptPayment();
     receiptPayment.StrReceiptNo = strReceiptNo;
     DataTable table = receiptPayment.SelectAllWstrReceiptNoLogic();
     return table;
 }
Example #10
0
 public DataTable GetReceiptPayment(string strMembershipID, int nSalesCategoryID)
 {
     TblReceiptPayment receiptPayment = new TblReceiptPayment();
     DataTable table = receiptPayment.GetReceiptPayment(strMembershipID, nSalesCategoryID);
     return table;
 }