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