예제 #1
0
        public void ConvertToModel(IDataReader reader, Class_Notice model)
        {
            if (reader["Id"] != DBNull.Value)
                model.Id = Convert.ToInt32(reader["Id"]);

            if (reader["ClassId"] != DBNull.Value)
                model.ClassId = Convert.ToInt32(reader["ClassId"]);

            if (reader["Title"] != DBNull.Value)
                model.Title = reader["Title"].ToString();

            if (reader["Content"] != DBNull.Value)
                model.Content = reader["Content"].ToString();

            if (reader["Creater"] != DBNull.Value)
                model.Creater = Convert.ToInt32(reader["Creater"]);

            if (reader["Display"] != DBNull.Value)
                model.Display = Convert.ToBoolean(reader["Display"]);

            if (reader["Delflag"] != DBNull.Value)
                model.Display = Convert.ToBoolean(reader["Delflag"]);

            if (reader["CreateDate"] != DBNull.Value)
                model.CreateDate = Convert.ToDateTime(reader["CreateDate"]);

            if (reader["RealName"] != DBNull.Value)
                model.OrganTitle = reader["RealName"].ToString();
        }
예제 #2
0
 public ActionResult Add(Class_Notice model)
 {
     model.CreateDate = DateTime.Now;
     if (bll.Add(model) > 0)
     {
         return Content("<script>alert('添加成功');location.href = '/Prepare/ClassMessage/Index?ClassId=" + QueryString.UrlEncrypt(model.ClassId) + "'</script>");
     }
     else
     {
         return Content("<script>alert('添加失败');location.href = '/Prepare/ClassMessage/Index?ClassId=" + QueryString.UrlEncrypt(model.ClassId) + "'</script>");
     }
 }
예제 #3
0
 public ActionResult Edit(Class_Notice model)
 {
     model.Delflag = false;
     model.Creater = Code.SiteCache.Instance.LoginInfo.UserId;
     if (bll.Update(model))
     {
         return Content("<script>alert('修改成功');location.href = '/Prepare/ClassMessage/Index?ClassId=" + QueryString.UrlEncrypt(model.ClassId) + "'</script>");
     }
     else
     {
         return Content("<script>alert('修改失败');location.href = '/Prepare/ClassMessage/Index?ClassId=" + QueryString.UrlEncrypt(model.ClassId) + "'</script>");
     }
 }
예제 #4
0
 public List<Class_Notice> GetList(int pageSize, int pageIndex, string where, string orderBy, out int recordCount)
 {
     if (string.IsNullOrEmpty(orderBy))
         throw new ArgumentNullException();
     StringBuilder sb = new StringBuilder();
     sb.Append("select count(1) from [dbo].[Class_Notice] a where a.Delflag = 0 ");
     if (!string.IsNullOrEmpty(where))
         sb.Append(where);
     recordCount = Convert.ToInt32(MSEntLibSqlHelper.ExecuteScalarBySql(sb.ToString()));
     int start = (pageIndex - 1) * pageSize + 1;
     int end = pageIndex * pageSize;
     StringBuilder sql = new StringBuilder();
     sql.Append("select * from (select a.*,b.RealName,ROW_NUMBER() over (order by " + orderBy + ") as RowNum from [dbo].[Class_Notice] a left join dbo.Member_BaseInfo b on a.Creater = b.AccountId where a.Delflag = 0 ");
     if (!string.IsNullOrEmpty(where))
         sql.Append(where);
     sql.Append(") as T where RowNum between " + start + " and " + end);
     List<Class_Notice> list = new List<Class_Notice>();
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString()))
     {
         while (reader.Read())
         {
             Class_Notice model = new Class_Notice();
             ConvertToModel(reader, model);
             list.Add(model);
         }
     }
     return list;
 }