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(); } }
/// <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); }