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