コード例 #1
0
 public int Add(EmailBlockListQuery query)
 {
     query.Replace4MySQL();
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.AppendFormat(@"INSERT INTO email_block_list(email_address,block_reason,block_create_userid,block_update_userid,block_createdate,block_updatedate) VALUES('{0}','{1}','{2}','{3}',NOW(),NOW());", query.email_address, query.block_reason, query.block_create_userid, query.block_update_userid);
         return _access.execCommand(sql.ToString());
     }
     catch (MySqlException ex)
     {
         throw new Exception(ex.Number.ToString() + ":EmailBlockListDao-->Add" + ex.Message, ex);
     }
     catch (Exception ex)
     {
         throw new Exception("EmailBlockListDao-->Add-->" + ex.Message, ex);
     }
 }
コード例 #2
0
        public DataTable GetEmailBlockList(EmailBlockListQuery query)
        {
            query.Replace4MySQL();
            StringBuilder sql = new StringBuilder();
            StringBuilder count = new StringBuilder();
            int totalCount = 0;
           DataTable store = new DataTable();
            try
            {
                sql.AppendFormat(@"SELECT email_address,block_reason,block_createdate,(SELECT user_username FROM manage_user WHERE manage_user.user_id=email_block_list.block_create_userid ) as user_name from email_block_list where 1=1 ");
                count.AppendFormat(@"SELECT count(email_address) as totalCount from email_block_list where 1=1 ");
                if (query.email_address != string.Empty)
                {
                    sql.AppendFormat(" AND email_address LIKE N'%{0}%'", query.email_address);
                    count.AppendFormat(" AND email_address LIKE N'%{0}%'", query.email_address);
                }
                if (query.IsPage)
                {
                    DataTable _dt = _access.getDataTable(count.ToString());
                    if (_dt != null && _dt.Rows.Count > 0)
                    {
                        totalCount = Convert.ToInt32(_dt.Rows[0]["totalCount"]);
                    }
                    sql.AppendFormat("  limit {0},{1} ;", query.Start, query.Limit);
                }

                store = _access.getDataTable(sql.ToString());
                return store;
            }
            catch (MySqlException ex)
            {
                throw new Exception(ex.Number.ToString() + ":EmailBlockListDao-->GetEmailBlockList" + ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new Exception("EmailBlockListDao-->GetEmailBlockList-->" + ex.Message, ex);
            }
        }
コード例 #3
0
 public int Update(EmailBlockListQuery query)
 {
     query.Replace4MySQL();
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.AppendFormat(@"UPDATE email_block_list SET block_reason='{0}' ,block_update_userid={1},block_updatedate=NOW() WHERE email_address='{2}'", query.block_reason, query.block_update_userid, query.email_address);
         return _access.execCommand(sql.ToString());
     }
     catch (MySqlException ex)
     {
         throw new Exception(ex.Number.ToString() + ":EmailBlockListDao-->Update" + ex.Message, ex);
     }
     catch (Exception ex)
     {
         throw new Exception("EmailBlockListDao-->Update-->" + ex.Message, ex);
     }
 }