Beispiel #1
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);
        }