예제 #1
0
        public bool Delete(string strMembershipID, User aUser, string strRemark)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            TblAudit  sqlAudit  = new TblAudit();

            bool isSuccess = false;

            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider  = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("DeleteMember");

                sqlMember.DeleteMember(strMembershipID, strRemark);
                sqlAudit.NAuditTypeID  = ACMSLogic.AuditTypeID.MemberRecord;
                sqlAudit.NEmployeeID   = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Delete member " + strMembershipID;
                sqlAudit.StrReference  = strMembershipID;
                sqlAudit.DtDate        = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("DeleteMember");
                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();
                sqlAudit.Dispose();
            }
            return(isSuccess);
        }