예제 #1
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);
            }
        }
예제 #2
0
        public bool UpdateCardStatus(string strMembershipID, User aUser, CardStatusType myType, int nRequestID, 
			string strBranchCode)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            TblCardRequest sqlCardRequest = new TblCardRequest();
            TblAudit sqlAudit = new TblAudit();

            bool isSuccess = false;
            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                sqlCardRequest.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("ChangeCardStatus");

                if (CardStatusType.RequestPrint == myType)
                    sqlMember.UpdateCardStatus(strMembershipID, (int)myType, "HQ");
                else
                    sqlMember.UpdateCardStatus(strMembershipID, (int)myType, strBranchCode);
                sqlCardRequest.NEmployeeID = aUser.NEmployeeID();
                sqlCardRequest.NRequestID = nRequestID;
                sqlCardRequest.NStatusID = (int)myType;
                sqlCardRequest.StrBranchCode = strBranchCode;
                sqlCardRequest.StrMembershipID = strMembershipID;
                sqlCardRequest.DtLastEditDate = DateTime.Now;
                sqlCardRequest.Update();

                sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                sqlAudit.NEmployeeID = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Update member card to " +myType.ToString() +".";
                sqlAudit.StrReference = strMembershipID;
                sqlAudit.DtDate = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ChangeCardStatus");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                    connProvider.DBConnection.Dispose();
                }
                sqlMember.Dispose();
                sqlCardRequest.Dispose();
                sqlAudit.Dispose();
            }
            return isSuccess;
        }
예제 #3
0
        public string ConvertMember(DataRow rowMember, User aUser)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            TblBranch sqlBranch = new TblBranch();
            TblAudit sqlAudit = new TblAudit();
            TblCardRequest sqlCardRequest = new TblCardRequest();

            try
            {
                sqlBranch.MainConnectionProvider = connProvider;
                sqlMember.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider = connProvider;
                sqlCardRequest.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("ConvertMember");

                sqlBranch.StrBranchCode = aUser.StrBranchCode();
                sqlBranch.IncOne();
                string newMembershipID = aUser.StrBranchCode().TrimEnd() +sqlBranch.NMembershipNo;
                sqlMember.StrBranchCode = aUser.StrBranchCode();
                sqlMember.ConvertMember(rowMember["strMembershipID"].ToString(), newMembershipID);
                sqlMember.ConvertMemberPurchase(rowMember["strMembershipID"].ToString(), newMembershipID);
                sqlAudit.UpdateAllWstrReferenceLogic(newMembershipID, rowMember["strMembershipID"].ToString());
                sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberRecord;
                sqlAudit.NEmployeeID = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Convert member from " +rowMember["strMembershipID"].ToString() +" to " +newMembershipID;
                sqlAudit.StrReference = newMembershipID;
                sqlAudit.DtDate = DateTime.Now;
                sqlAudit.Insert();

                //Request print for convert non member to member
                //sqlCardRequest.NEmployeeID = aUser.NEmployeeID();
                //sqlCardRequest.NStatusID = (int)CardStatusType.RequestPrint;
                //sqlCardRequest.StrBranchCode = aUser.StrBranchCode();
                //sqlCardRequest.StrMembershipID = newMembershipID;
                //sqlCardRequest.DtLastEditDate = DateTime.Now;
                //sqlCardRequest.Insert();

                ////Audit trail for request print
                //sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                //sqlAudit.NEmployeeID = aUser.NEmployeeID();
                //sqlAudit.StrAuditEntry = "New member card request when create convert member.";
                //sqlAudit.StrReference = newMembershipID;
                //sqlAudit.DtDate = DateTime.Now;
                //sqlAudit.Insert();

                connProvider.CommitTransaction();
                return newMembershipID;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ConvertMember");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                    connProvider.DBConnection.Dispose();
                }
                sqlBranch.Dispose();
                sqlMember.Dispose();
                sqlAudit.Dispose();
                sqlCardRequest.Dispose();
            }
        }
예제 #4
0
        public bool Reprint(string strMembershipID, int nEmployee, int CardStatus, string strCardBranchCode)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            TblCardRequest sqlCardRequest = new TblCardRequest();
            TblAudit sqlAudit = new TblAudit();

            bool isSuccess = false;
            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                sqlCardRequest.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("ReprintCard");

                sqlMember.UpdateCardStatus(strMembershipID, CardStatus, strCardBranchCode);
                sqlCardRequest.NEmployeeID = nEmployee;
                sqlCardRequest.NStatusID = CardStatus;
                sqlCardRequest.StrBranchCode = strCardBranchCode;
                sqlCardRequest.StrMembershipID = strMembershipID;
                sqlCardRequest.DtLastEditDate = DateTime.Now;
                sqlCardRequest.Insert();

                sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                sqlAudit.NEmployeeID = nEmployee;
                sqlAudit.StrAuditEntry = "Reprint member card.";
                sqlAudit.StrReference = strMembershipID;
                sqlAudit.DtDate = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ReprintCard");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                    connProvider.DBConnection.Dispose();
                }
                sqlMember.Dispose();
                sqlCardRequest.Dispose();
                sqlAudit.Dispose();
            }
            return isSuccess;
        }
예제 #5
0
        /// <summary>
        /// Include member or non member
        /// </summary>
        /// <param name="isMember"></param>
        /// <param name="branchCode"></param>
        /// <param name="name"></param>
        /// <param name="isSingaporean"></param>
        /// <param name="NRIC"></param>
        /// <param name="nSignUpID"></param>
        /// <param name="dob"></param>
        /// <param name="aUser"></param>
        ///
        /// 0705
        public string AddNewMember(bool isMember, string branchCode, string name, bool isSingaporean, string NRIC, int nSignUpID,
            DateTime dob, User aUser, bool isFemale, int nmediaSource)
        {
            string membershipID = string.Empty;
            TblMember sqlMember = new TblMember();
            sqlMember.FMember = isMember;
            sqlMember.StrMemberName = name;
            sqlMember.FFemale = isFemale;
            if (name.Length >= 19)
                sqlMember.StrCardName = name.Substring(0, 19);
            else
                sqlMember.StrCardName = name;
            sqlMember.StrNRICFIN = NRIC;
            sqlMember.DtDOB = dob;
            sqlMember.StrBranchCode = branchCode;
            sqlMember.FSingaporean = isSingaporean;
            sqlMember.NMediaSourceID = nmediaSource;
            TblCardRequest sqlCardRequest = new TblCardRequest();
            TblAudit sqlAudit = new TblAudit();

            if (!isMember)
            {
                ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
                TblCompany sqlCompany = new TblCompany();

                try
                {
                    sqlCompany.MainConnectionProvider = connProvider;
                    sqlMember.MainConnectionProvider = connProvider;
                    sqlCardRequest.MainConnectionProvider = connProvider;
                    sqlAudit.MainConnectionProvider = connProvider;
                    connProvider.OpenConnection();
                    connProvider.BeginTransaction("AddNewNonMember");

                    sqlCompany.IncOne();
                    sqlMember.NMembershipNo = sqlCompany.NNonMembershipNo;
                    sqlMember.NStatus = 1;
                    sqlMember.NSignupID = nSignUpID;
                    sqlMember.StrMembershipID = "NMC" +sqlCompany.NNonMembershipNo;
                    sqlMember.DtSignupDate = DateTime.Now;
                    //sqlMember.NCardStatusID = (int)CardStatusType.RequestPrint;
                    sqlMember.NLoyaltyStatusID = 1;
                    sqlMember.Insert();

                    membershipID = "NMC" +sqlCompany.NNonMembershipNo;

                    connProvider.CommitTransaction();
                }
                catch (Exception)
                {
                    connProvider.RollbackTransaction("AddNewNonMember");
                    throw;
                }
                finally
                {
                    if (connProvider.CurrentTransaction != null)
                        connProvider.CurrentTransaction.Dispose();
                    if (connProvider.DBConnection != null)
                    {
                        if (connProvider.DBConnection.State == ConnectionState.Open)
                            connProvider.DBConnection.Close();
                        connProvider.DBConnection.Dispose();
                    }
                    sqlCompany.MainConnactionIsCreatedLocal = true;
                    sqlMember.MainConnactionIsCreatedLocal = true;
                    sqlCardRequest.MainConnactionIsCreatedLocal = true;
                }
            }
            else
            {
                ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
                TblBranch sqlBranch = new TblBranch();

                try
                {
                    sqlBranch.MainConnectionProvider = connProvider;
                    sqlMember.MainConnectionProvider = connProvider;
                    sqlCardRequest.MainConnectionProvider = connProvider;
                    sqlAudit.MainConnectionProvider = connProvider;
                    connProvider.OpenConnection();
                    connProvider.BeginTransaction("AddNewNonMember");

                    sqlBranch.StrBranchCode = branchCode;
                    //sqlBranch.StrBranchCode = "PM";
                    sqlBranch.IncOne();
                    sqlMember.NMembershipNo = sqlBranch.NMembershipNo;
                    sqlMember.NStatus = 1;
                    sqlMember.NSignupID = nSignUpID;
                    sqlMember.StrMembershipID = branchCode.TrimEnd() +sqlBranch.NMembershipNo;
                   // sqlMember.StrMembershipID = "PM" + sqlBranch.NMembershipNo;
                    sqlMember.DtSignupDate = DateTime.Now;
                    sqlMember.NCardStatusID = (int)CardStatusType.RequestPrint;
                    sqlMember.StrCardBranchCode = "HQ";
                    sqlMember.NLoyaltyStatusID = 1;
                    sqlMember.Insert();

                    //Request print for member --now only for fitness member
            //					sqlCardRequest.NEmployeeID = aUser.NEmployeeID();
            //					sqlCardRequest.NStatusID = (int)CardStatusType.RequestPrint;
            //					sqlCardRequest.StrBranchCode = aUser.StrBranchCode();
            //					sqlCardRequest.StrMembershipID = branchCode.TrimEnd() +sqlBranch.NMembershipNo;
            //					sqlCardRequest.DtLastEditDate = DateTime.Now;
            //					sqlCardRequest.Insert();

                    //Audit trail for request print
            //					sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
            //					sqlAudit.NEmployeeID = aUser.NEmployeeID();
            //					sqlAudit.StrAuditEntry = "New member card request when create new member.";
            //					sqlAudit.StrReference = branchCode.TrimEnd() +sqlBranch.NMembershipNo;
            //					sqlAudit.DtDate = DateTime.Now;
            //					sqlAudit.Insert();

                    membershipID = branchCode.TrimEnd() +sqlBranch.NMembershipNo;

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

            return membershipID;
        }