Exemple #1
0
        private void ReplaceMembershipCardTransaction(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos)
        {
            if (pos.NCategoryID == 20)
            {
                TblMember sqlMember = new TblMember();
                sqlMember.MainConnectionProvider = connProvider;

                sqlMember.StrMembershipID = pos.StrMembershipID;
                sqlMember.SelectOne();
                sqlMember.NCardStatusID = 0;
                sqlMember.StrCardBranchCode = "WL";
                sqlMember.Update();

                TblMember sqlIntroduceMember = new TblMember();
                sqlIntroduceMember.MainConnectionProvider = connProvider;
                sqlIntroduceMember.StrIntroducerMembershipID = pos.StrMembershipID;
                DataTable introduceMemberTable = sqlIntroduceMember.SelectAllWstrIntroducerMembershipIDLogic();

                if (introduceMemberTable != null && introduceMemberTable.Rows.Count > 0)
                {
                    foreach (DataRow r in introduceMemberTable.Rows)
                        r["StrIntroducerMembershipID"] = DBNull.Value;

                    sqlIntroduceMember.SaveData(introduceMemberTable);
                }

                string membershipID = pos.StrMembershipID;
                string newStrMembershipID = "";
                bool isMember = !membershipID.StartsWith("NMC");

                if (!isMember)
                {
                    TblCardRequest sqlCardRequest = new TblCardRequest();
                    TblCompany sqlCompany = new TblCompany();
                    sqlCompany.MainConnectionProvider = connProvider;
                    sqlCardRequest.MainConnectionProvider = connProvider;

                    sqlCompany.IncOne();

                    sqlMember.StrMembershipID = pos.StrMembershipID;
                    DataTable memberTable = sqlMember.SelectOne();

                    newStrMembershipID = "NMC" + sqlCompany.NNonMembershipNo.Value.ToString();
                    string origStrMembershipID = sqlMember.StrMembershipID.Value;
                    pos.StrNewMembershipID = newStrMembershipID;

                    memberTable.Rows[0]["nMembershipNo"] = sqlCompany.NNonMembershipNo.Value;
                    memberTable.Rows[0]["strMembershipID"] = newStrMembershipID;
                    memberTable.Rows[0]["nCardStatusID"] = (int)CardStatusType.RequestPrint;

                    string cmdText = "Update tblMember SET strMembershipID = @NewStrMembershipID, " +
                        " nMembershipNo = @nMembershipNo Where strMembershipID = @OriginalStrMembershipID";

                    sqlMember.UpdateKey(memberTable,  cmdText, "@NewStrMembershipID",  newStrMembershipID,
                        "@OriginalStrMembershipID", origStrMembershipID, new string[] {"@nMembershipNo"},
                        new object[] {sqlCompany.NNonMembershipNo.Value});

                    #region ====== Added By Albert ======
                    //To update member packages after changing MembershipID.
                    TblMemberPackage mMemberPackage;
                    mMemberPackage = new TblMemberPackage();
                    mMemberPackage.StrMembershipIDOld = origStrMembershipID;
                    mMemberPackage.StrMembershipID = newStrMembershipID;
                    mMemberPackage.UpdateAllWstrMembershipIDLogic();

                    TblMemberCreditPackage mMemberCreditPackage;
                    mMemberCreditPackage = new TblMemberCreditPackage();
                    mMemberCreditPackage.StrMembershipIDOld = origStrMembershipID;
                    mMemberCreditPackage.StrMembershipID = newStrMembershipID;
                    mMemberCreditPackage.UpdateAllWstrMembershipIDLogic();
                    #endregion

                    //Request print for new non member
                    sqlCardRequest.NEmployeeID = pos.NCashierID;
                    sqlCardRequest.NStatusID = (int)CardStatusType.RequestPrint;
                    sqlCardRequest.StrBranchCode = pos.StrBranchCode;
                    sqlCardRequest.StrMembershipID = "NMC" +sqlCompany.NNonMembershipNo;
                    sqlCardRequest.DtLastEditDate = DateTime.Now;
                    sqlCardRequest.Insert();
                }
                else
                {
                    TblCardRequest sqlCardRequest = new TblCardRequest();
                    TblBranch sqlBranch = new TblBranch();

                    sqlBranch.MainConnectionProvider = connProvider;
                    sqlCardRequest.MainConnectionProvider = connProvider;

                    sqlBranch.StrBranchCode = pos.StrBranchCode;
                    sqlBranch.IncOne();

                    sqlMember.StrMembershipID = pos.StrMembershipID;
                    DataTable memberTable = sqlMember.SelectOne();

                    newStrMembershipID = pos.StrBranchCode.TrimEnd() + ACMS.Convert.ToInt32(sqlBranch.NMembershipNo);
                    string origStrMembershipID = sqlMember.StrMembershipID.Value;
                    pos.StrNewMembershipID = newStrMembershipID;

                    memberTable.Rows[0]["nMembershipNo"] = ACMS.Convert.ToInt32(sqlBranch.NMembershipNo);
                    memberTable.Rows[0]["strMembershipID"] = newStrMembershipID;
                    memberTable.Rows[0]["nCardStatusID"] = (int)CardStatusType.RequestPrint;

                    string cmdText = "Update tblMember SET strMembershipID = @NewStrMembershipID, " +
                        " nMembershipNo = @nMembershipNo Where strMembershipID = @OriginalStrMembershipID";

                    sqlMember.UpdateKey(memberTable,  cmdText, "@NewStrMembershipID",  newStrMembershipID,
                        "@OriginalStrMembershipID", origStrMembershipID, new string[] {"@nMembershipNo"},
                        new object[] {ACMS.Convert.ToInt32(sqlBranch.NMembershipNo)});

                    #region ====== Added By Albert ======
                    //To update member packages after changing MembershipID.
                    TblMemberPackage mMemberPackage;
                    mMemberPackage = new TblMemberPackage();
                    mMemberPackage.StrMembershipIDOld = origStrMembershipID;
                    mMemberPackage.StrMembershipID = newStrMembershipID;
                    mMemberPackage.UpdateAllWstrMembershipIDLogic();

                    TblMemberCreditPackage mMemberCreditPackage;
                    mMemberCreditPackage = new TblMemberCreditPackage();
                    mMemberCreditPackage.StrMembershipIDOld = origStrMembershipID;
                    mMemberCreditPackage.StrMembershipID = newStrMembershipID;
                    mMemberCreditPackage.UpdateAllWstrMembershipIDLogic();
                    #endregion

                    //Request print for new non member
                    sqlCardRequest.NEmployeeID = pos.NCashierID;
                    sqlCardRequest.NStatusID = (int)CardStatusType.RequestPrint;
                    sqlCardRequest.StrBranchCode = pos.StrBranchCode;
                    sqlCardRequest.StrMembershipID = newStrMembershipID;
                    sqlCardRequest.DtLastEditDate = DateTime.Now;
                    sqlCardRequest.Insert();
                }

                if (introduceMemberTable != null && introduceMemberTable.Rows.Count > 0)
                {
                    foreach (DataRow r in introduceMemberTable.Rows)
                        r["StrIntroducerMembershipID"] = newStrMembershipID;

                    sqlIntroduceMember.SaveData(introduceMemberTable);
                }

                TblAudit sqlAudit = new TblAudit();
                sqlAudit.MainConnectionProvider = connProvider;
                //Audit trail for request print
                sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                sqlAudit.NEmployeeID = pos.NCashierID;
                sqlAudit.StrAuditEntry = "Replace member card with new ID";
                sqlAudit.StrReference = newStrMembershipID;
                sqlAudit.DtDate = DateTime.Now;
                sqlAudit.Insert();
            }
        }
Exemple #2
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;
        }