예제 #1
0
파일: POS.cs 프로젝트: kimykunjun/test
        private void InitTblGiro()
        {
            myGiroTable = new DataTable();

            ACMSDAL.TblGIRO tblgiro = new TblGIRO();
            myGiroTable = tblgiro.FillSchema("Select * From tblReceiptGIROCredit");

            DataColumn colEntryID = new DataColumn("nEntryID", typeof(int));
            myGiroTable.Columns.Add(colEntryID);
        }
예제 #2
0
파일: POS.cs 프로젝트: kimykunjun/test
        //private int UpgradePackage(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos)
        //{
        //        UpgradeNonGIRO(connProvider, pos);
        private void PostToMemberPackage(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos)
        {
            //MemberRecord myMemberRecord = new MemberRecord(pos.StrMembershipID.ToString(), pos.StrBranchCode.ToString());
            TblMemberPackage memberPackage = new TblMemberPackage();
            memberPackage.MainConnectionProvider = connProvider;

            DataTable memberPackagetable = memberPackage.FillSchema("Select * from tblMemberPackage");

            string strUpgradeFrom="";
            string strRemarks = "";
            foreach (DataRow dr in pos.WantToUpgradeMemberPackageTable.Rows)
            {
                strRemarks += dr["strPackageCode"].ToString() + " / " + dr["strReceiptNo"].ToString() + " / " + dr["UsageBalAmt"].ToString() + ",";
                if (dr["nCategoryID"].ToString() == "7" || dr["nCategoryID"].ToString() == "36" || dr["nCategoryID"].ToString() == "37")
                    strUpgradeFrom += dr["nPackageID"].ToString() + "(C),";
                else if (dr["nCategoryID"].ToString() == "8" || dr["nCategoryID"].ToString() == "9")
                    strUpgradeFrom += dr["nPackageID"].ToString() + "(B),";
                else
                    strUpgradeFrom += dr["nPackageID"].ToString() + ",";

                if (ACMS.Convert.ToInt32(dr["nCategoryID"]) == 5 && dr["strFreePkgCode"] != DBNull.Value)
                {
                    TblMemberPackage mp = new TblMemberPackage();
                    mp.MainConnectionProvider = connProvider;
                    DataTable freePkgTable = mp.LoadData("select * from tblMemberPackage where strReceiptNo=@strReceiptNo and strPackageCode =@strFreePackageCode ",
                        new string[] { "@strReceiptNo", "@strFreePackageCode" }, new object[] { dr["strReceiptNo"], dr["strFreePkgCode"].ToString() });

                    if (freePkgTable.Rows.Count > 0)
                    {
                        if (dr["nCategoryID"].ToString() == "7" || dr["nCategoryID"].ToString() == "36" || dr["nCategoryID"].ToString() == "37")
                            strUpgradeFrom += freePkgTable.Rows[0]["nPackageID"].ToString() + "(C),";
                        else if (dr["nCategoryID"].ToString() == "8" || dr["nCategoryID"].ToString() == "9")
                            strUpgradeFrom += freePkgTable.Rows[0]["nPackageID"].ToString() + "(B),";
                        else
                            strUpgradeFrom += freePkgTable.Rows[0]["nPackageID"].ToString() + ",";
                    }
                }
            }
            if (pos.WantToUpgradeMemberPackageTable.Rows.Count > 0)
            {
                strUpgradeFrom = strUpgradeFrom.Remove(strUpgradeFrom.Length - 1, 1);
                strRemarks = "Convert from: " + strRemarks.Remove(strRemarks.Length - 1, 1);
            }

            if (pos.NCategoryID == 1 ||
                pos.NCategoryID == 3 || pos.NCategoryID == 4 ||
                pos.NCategoryID == 5 || pos.NCategoryID == 6 ||
                pos.NCategoryID == 14 || pos.NCategoryID == 23)

            {
                foreach (DataRow r in pos.ReceiptItemsTable.Rows)
                {
                    int nQuantity = ACMS.Convert.ToInt32(r["nQuantity"]);

                    if (r["strCode"].ToString().ToUpper() != "REG")
                    {
                        for (int i = 0; i < nQuantity; i++)
                        {
                            DataRow rowToAdd = memberPackagetable.NewRow();

                            MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, r["strCode"].ToString(), "", false);
                            rowToAdd["strRemarks"] = strRemarks;
                            rowToAdd["strUpgradeFrom"] = strUpgradeFrom;
                            memberPackagetable.Rows.Add(rowToAdd);
                        }
                    }
                    else
                    {

                        TblMember sqlMember = new TblMember();
                        TblCardRequest sqlCardRequest = new TblCardRequest();
                        TblAudit sqlAudit = new TblAudit();
                        try
                        {
                            sqlMember.MainConnectionProvider = connProvider;
                            sqlCardRequest.MainConnectionProvider = connProvider;
                            sqlAudit.MainConnectionProvider = connProvider;
                            sqlMember.UpdateCardStatus(pos.StrMembershipID.ToString(), 0, pos.StrBranchCode.ToString());
                            sqlCardRequest.NEmployeeID = pos.NCashierID;
                            sqlCardRequest.NStatusID = 0;
                            sqlCardRequest.StrBranchCode = pos.StrBranchCode.ToString();
                            sqlCardRequest.StrMembershipID = pos.StrMembershipID.ToString();
                            sqlCardRequest.DtLastEditDate = DateTime.Now;
                            sqlCardRequest.Insert();

                            sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                            sqlAudit.NEmployeeID = pos.NCashierID;
                            sqlAudit.StrAuditEntry = "Reprint member card.";
                            sqlAudit.StrReference = pos.StrMembershipID.ToString();
                            sqlAudit.DtDate = DateTime.Now;
                            sqlAudit.Insert();

                        }
                        catch (Exception)
                        {
                            throw;
                        }
                        finally
                        {

                            sqlMember.Dispose();
                            sqlCardRequest.Dispose();
                            sqlAudit.Dispose();
                        }

                    }
                }

                if (memberPackagetable.Rows.Count > 0)
                    memberPackage.SaveData(memberPackagetable);
            }
            else if (pos.NCategoryID == 7 ||
                pos.NCategoryID == 36 || pos.NCategoryID == 37) //Credit Pkg
            {
                foreach (DataRow r in pos.ReceiptItemsTable.Rows)
                {
                    if (r["strCode"].ToString() == "JOINFEES" || r["strCode"].ToString() == "JOINFEE" || r["strCode"].ToString() == "FA")
                    {
                        int nQuantity = ACMS.Convert.ToInt32(r["nQuantity"]);

                        if (r["strCode"].ToString().ToUpper() != "REG")
                        {
                            for (int i = 0; i < nQuantity; i++)
                            {
                                DataRow rowToAdd = memberPackagetable.NewRow();

                                MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, r["strCode"].ToString(), "", false);
                                rowToAdd["strRemarks"] = strRemarks;
                                rowToAdd["strUpgradeFrom"] = strUpgradeFrom;
                                memberPackagetable.Rows.Add(rowToAdd);
                            }
                        }
                        else
                        {

                            TblMember sqlMember = new TblMember();
                            TblCardRequest sqlCardRequest = new TblCardRequest();
                            TblAudit sqlAudit = new TblAudit();
                            try
                            {
                                sqlMember.MainConnectionProvider = connProvider;
                                sqlCardRequest.MainConnectionProvider = connProvider;
                                sqlAudit.MainConnectionProvider = connProvider;
                                sqlMember.UpdateCardStatus(pos.StrMembershipID.ToString(), 0, pos.StrBranchCode.ToString());
                                sqlCardRequest.NEmployeeID = pos.NCashierID;
                                sqlCardRequest.NStatusID = 0;
                                sqlCardRequest.StrBranchCode = pos.StrBranchCode.ToString();
                                sqlCardRequest.StrMembershipID = pos.StrMembershipID.ToString();
                                sqlCardRequest.DtLastEditDate = DateTime.Now;
                                sqlCardRequest.Insert();

                                sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                                sqlAudit.NEmployeeID = pos.NCashierID;
                                sqlAudit.StrAuditEntry = "Reprint member card.";
                                sqlAudit.StrReference = pos.StrMembershipID.ToString();
                                sqlAudit.DtDate = DateTime.Now;
                                sqlAudit.Insert();

                            }
                            catch (Exception)
                            {
                                throw;
                            }
                            finally
                            {

                                sqlMember.Dispose();
                                sqlCardRequest.Dispose();
                                sqlAudit.Dispose();
                            }
                        }
                    }
                }

                if (memberPackagetable.Rows.Count > 0)
                    memberPackage.SaveData(memberPackagetable);
            }
            else if ((pos.NCategoryID == 2) || (pos.NCategoryID == 34) || (pos.NCategoryID == 35))//New GIRO = 35
            {
                TblGIRO giro = new TblGIRO();
                giro.MainConnectionProvider = connProvider;

                foreach (DataRow r in pos.ReceiptItemsTable.Rows)
                {
                    // need to save tblGiro 1st
                    int nQuantity = ACMS.Convert.ToInt32(r["nQuantity"]);
                    DataRow[] giroRows = pos.GiroTable.Select("nEntryID = " + r["nEntryID"].ToString(), "", DataViewRowState.CurrentRows);
                    if (giroRows.Length > 0)
                    {

                        giro.strCardHolderName = giroRows[0]["strCardHolderName"].ToString();
                        giro.strReceiptNo = pos.StrReceiptNo;
                        giro.nCreditCard = giroRows[0]["nCreditCard"].ToString();
                        giro.dtCreditCardExpired = DateTime.Now;
                        giro.strTypeofCard = giroRows[0]["strTypeofCard"].ToString();
                        giro.strReceiptNo = pos.StrReceiptNo;
                        giro.Insert();

                        for (int i = 0; i < nQuantity; i++)
                        {
                            DataRow rowToAdd = memberPackagetable.NewRow();
                            MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, r["strCode"].ToString(), "",
                                false, giro.NGIRORefID.IsNull ? -1 : giro.NGIRORefID.Value, pos.dtPackageStart, pos.NProrateDays);

                            memberPackagetable.Rows.Add(rowToAdd);
                        }
                    }
                    else
                    {
                        TblMemberPackage GIROPackage = new TblMemberPackage();
                        GIROPackage.MainConnectionProvider = connProvider;
                        GIROPackage.NPackageID = pos.NExtendGIROpkg;
                        DataTable memberGIROPKG = GIROPackage.SelectOne();

                        //start
                        //if (pos.NExtendGIROpkg == 0)
                        //{

                        //    foreach (DataRow rs in pos.ReceiptItemsTable.Rows)
                        //    {
                        //        int nQuantity1 = ACMS.Convert.ToInt32(r["nQuantity"]);

                        //        if (rs["strCode"].ToString().ToUpper() != "REG")
                        //        {
                        //            for (int i = 0; i < nQuantity1; i++)
                        //            {
                        //                DataRow rowToAdd = memberPackagetable.NewRow();

                        //                MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, rs["strCode"].ToString(), "", false);

                        //                memberPackagetable.Rows.Add(rowToAdd);

                        //            }
                        //        }

                        //    }
                        //GIROPackage.SaveData(memberGIROPKG);

                        //}
                        //else

                        //GIROPackage start
                        //  {
                        //DateTime ExtendExpiryDate = System.Convert.ToDateTime(GIROPackage.DtExpiryDate.ToString());
                        //if (ExtendExpiryDate.Day > 27)
                        //    memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 1).AddMonths(2).AddDays(-1);
                        //else if (ExtendExpiryDate.Day == 15)
                        //    memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 15).AddMonths(1);
                        //memberGIROPKG.Rows[0]["fGiroStatus"] = "S";

                        DateTime ExtendExpiryDate = System.Convert.ToDateTime(GIROPackage.DtExpiryDate.ToString());
                        if (ExtendExpiryDate.Day > 27)
                            if (nQuantity > 1)
                                memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 1).AddMonths(nQuantity + 1).AddDays(-1);
                            else
                                memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 1).AddMonths(2).AddDays(-1);
                        else if (ExtendExpiryDate.Day == 15)
                            if (nQuantity > 1)
                                memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 15).AddMonths(nQuantity + 1);
                            else
                                memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 15).AddMonths(1);

                        memberGIROPKG.Rows[0]["fGiroStatus"] = "S";

                        //set package status to active if expired date > today
                        if (Convert.ToDateTime(memberGIROPKG.Rows[0]["dtexpirydate"]) > DateTime.Now)
                            memberGIROPKG.Rows[0]["nStatusID"] = 0;

                        if (pos.NCategoryID == 34)
                        {
                            memberGIROPKG.Rows[0]["nAdjust"] = ACMS.Convert.ToDBInt32(memberGIROPKG.Rows[0]["nAdjust"]) + 1;

                            POSHelper myPOSHelper = new POSHelper(pos);
                            DataTable tblSpaPackage = myPOSHelper.SearchOnePackageCode(memberGIROPKG.Rows[0]["strPackageCode"].ToString());
                            if (tblSpaPackage != null)
                            {
                                if (tblSpaPackage.Rows.Count > 0)
                                {
                                    string strFreePackageCode = tblSpaPackage.Rows[0]["strFreePkgCode"].ToString();
                                    DataTable tblFreePackage = GIROPackage.SelectPackageCode(strFreePackageCode, pos.StrMembershipID);
                                    int nFreePackageID = Convert.ToInt32(tblFreePackage.Rows[0]["nPackageID"]);

                                    TblMemberPackage GIROFreePackage = new TblMemberPackage();
                                    GIROFreePackage.MainConnectionProvider = connProvider;
                                    GIROFreePackage.NPackageID = nFreePackageID;

                                    DataTable memberGIROFREEPKG = GIROFreePackage.SelectOne();

                                    memberGIROFREEPKG.Rows[0]["nAdjust"] = ACMS.Convert.ToDBInt32(memberGIROFREEPKG.Rows[0]["nAdjust"]) + 1;

                                    if (ExtendExpiryDate.Day > 27)
                                        memberGIROFREEPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 1).AddMonths(2).AddDays(-1);
                                    else if (ExtendExpiryDate.Day == 15)
                                        memberGIROFREEPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 15).AddMonths(1);
                                    memberGIROFREEPKG.Rows[0]["fGiroStatus"] = "S";
                                    GIROFreePackage.SaveData(memberGIROFREEPKG);
                                }
                            }
                        }
                        GIROPackage.SaveData(memberGIROPKG);
                        // }//GIROPackage start
                    }
                }

                if (memberPackagetable.Rows.Count > 0)
                    memberPackage.SaveData(memberPackagetable);
            }

            else if (pos.NCategoryID == 8 || pos.NCategoryID == 9)
            {
                TblPackageGroupEntries pckGroupEntries = new TblPackageGroupEntries();
                pckGroupEntries.MainConnectionProvider = connProvider;

                foreach (DataRow r in pos.ReceiptItemsTable.Rows)
                {
                    string strPackageGroupCode = r["strCode"].ToString();
                    int nQuantity = ACMS.Convert.ToInt32(r["nQuantity"]);

                    DataTable table = pckGroupEntries.GetPackageCodeList(strPackageGroupCode);

                    if (table != null && table.Rows.Count > 0)
                    {
                        int packageQty = 0;

                        foreach (DataRow r2 in table.Rows)
                        {
                            packageQty = ACMS.Convert.ToInt32(r2["nQuantity"]);

                            for (int i = 0; i < nQuantity; i++)
                            {
                                for (int j = 0; j < packageQty; j++)
                                {
                                    DataRow rowToAdd = memberPackagetable.NewRow();

                                    MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo,
                                        pos.StrMembershipID, r2["strPackageCode"].ToString(), "", false);
                                    rowToAdd["strUpgradeFrom"] = strUpgradeFrom;
                                    rowToAdd["strRemarks"] = strRemarks;
                                    memberPackagetable.Rows.Add(rowToAdd);
                                }
                            }
                        }
                    }
                }
                if (memberPackagetable.Rows.Count > 0)
                    memberPackage.SaveData(memberPackagetable);
            }
        }
예제 #3
0
파일: Payment.cs 프로젝트: kimykunjun/test
        private void ActionTakeWhenVoidReceiptForCategory_2(string strReceiptNo, ConnectionProvider connProvider)
        {
            TblMemberPackage memberPackage = new TblMemberPackage();
            TblGIRO giro = new TblGIRO();
            giro.MainConnectionProvider = connProvider;
            memberPackage.MainConnectionProvider = connProvider;

            memberPackage.StrReceiptNo = strReceiptNo;
            DataTable table = memberPackage.SelectAllWstrReceiptNo(strReceiptNo);

            TblClassAttendance sqlClassAttendance = new TblClassAttendance();
            TblServiceSession sqlServiceSession = new TblServiceSession();

            sqlClassAttendance.MainConnectionProvider = connProvider;
            sqlServiceSession.MainConnectionProvider = connProvider;

            if (table.Rows.Count > 0)
            {
                int nPackageID = 0;
                foreach (DataRow r in table.Rows)
                {
                    nPackageID = ACMS.Convert.ToInt32(r["nPackageID"]);
                    sqlClassAttendance.NPackageID = nPackageID;
                    DataTable classAttTable = sqlClassAttendance.SelectAllWnPackageIDLogic();
                    if (classAttTable.Rows.Count > 0)
                        throw new Exception("The item(s) has been used, you are not allow to void the receipt");
                    else
                    {
                        sqlServiceSession.NPackageID = nPackageID;
                        classAttTable = sqlServiceSession.SelectAllWnPackageIDLogic();
                        if (classAttTable.Rows.Count > 0)
                            throw new Exception("The item(s) has been used, you are not allow to void the receipt");
                    }

                    r["nEmployeeID"] = User.EmployeeID;
                    r["nStatusID"] = 2;
                    r["strRemarks"] = "Voided Receipt";
                    r["dtLastEdit"] = System.DateTime.Now;

                    if (r["nGIRORefID"] != DBNull.Value)
                    {
                        int nGiroRefID = ACMS.Convert.ToInt32(r["nGIRORefID"]);

                        giro.NGIRORefID = nGiroRefID;
                        giro.SelectOne();
                        giro.NEmployeeID = User.EmployeeID;
                        giro.NStatusID = 4;
                        giro.StrRemarks =  "Voided Receipt" + " - " + System.DateTime.Now.ToString("dd/MM/yyyy");
                        giro.Update();
                    }
                }

                memberPackage.SaveData(table);
            }
        }