Example #1
0
        private T_NewsType GetModel(HttpContext context)
        {
            T_NewsType model = new T_NewsType();

            try { model.Id = int.Parse(context.Request.Form["Id"].ToString().Trim()); }
            catch { }
            model.NewsTypeName = context.Request.Form["NewsTypeName"].ToString().Trim();
            try { model.UpId = int.Parse(context.Request.Form["UpId"].ToString().Trim()); }
            catch { }
            try { model.TypeLevel = int.Parse(context.Request.Form["TypeLevel"].ToString().Trim()); }
            catch { }
            model.Editor = admin.AdminLogName;
            return(model);
        }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 public bool Update(T_NewsType model)
 {
     try
     {
         object[] obj    = { model.NewsTypeName, model.UpId, model.TypeLevel, model.Editor, model.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"), model.Id };
         string   strSql = string.Format(" update [T_NewsType] set [NewsTypeName] ='{0}' ,[UpId] ={1} ,[TypeLevel] = {2},[Editor] ='{3}' ,[CreateDate] ='{4}'  where Id={5} ", obj);
         if (DbHelper.Factory().ExecuteNonQuery(strSql) > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch { return(false); }
 }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 public bool Create(T_NewsType model)
 {
     try
     {
         object[] obj    = { model.NewsTypeName, model.UpId, model.TypeLevel, model.Editor, model.CreateDate.ToString("yyyy-MM-dd HH:mm:ss") };
         string   strSql = string.Format(" insert into [T_NewsType]([NewsTypeName],[UpId],[TypeLevel],[Editor],[CreateDate])values('{0}',{1},{2},'{3}','{4}')", obj);
         if (DbHelper.Factory().ExecuteNonQuery(strSql) > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch { return(false); }
 }
Example #4
0
        //
        public T_NewsType GetById(int id)
        {
            string     strSql = string.Format(" select [Id],[NewsTypeName],[UpId],[TypeLevel],[Editor],[CreateDate] from [T_NewsType] where Id = {0}", id);
            T_NewsType model  = null;

            using (dynamic read = DbHelper.Factory().ExecuteReader(strSql.ToString()))
            {
                model = new T_NewsType();
                if (read.Read())
                {
                    try { model.Id = int.Parse(read["Id"].ToString()); }
                    catch { }
                    model.NewsTypeName = read["NewsTypeName"].ToString();
                    try { model.UpId = int.Parse(read["UpId"].ToString()); }
                    catch { }
                    try { model.TypeLevel = int.Parse(read["TypeLevel"].ToString()); }
                    catch { }
                    model.Editor     = read["Editor"].ToString();
                    model.CreateDate = DateTime.Parse(read["CreateDate"].ToString());
                }
                read.Dispose();
            }
            return(model);
        }