Example #1
0
        //获取单个对象
        public NCCQ.Model.T_role GetModel(int id)
        {
            try
            {
                string            strSql = string.Format("select * from T_Role where Id={0}", id);
                NCCQ.Model.T_role model  = null;
                using (dynamic read = DbHelper.Factory().ExecuteReader(strSql.ToString()))
                {
                    model = new Model.T_role();
                    if (read.Read())
                    {
                        model.id = int.Parse(read["Id"].ToString());
                        try { model.rolename = int.Parse(read["rolename"].ToString()); }
                        catch { }
                        try { model.editer = int.Parse(read["editer"].ToString()); }
                        catch { }

                        try { model.creatdate = DateTime.Parse(read["creatdate"].ToString()); }
                        catch { }
                    }
                    read.Dispose();
                }
                return(model);
            }
            catch (Exception) { throw; }
        }
Example #2
0
        private Model.T_role GetModel(HttpContext context)
        {
            Model.T_role model = new Model.T_role();
            try { model.id = int.Parse(context.Request.Form["Id"].ToString()); }
            catch { }
            model.rolename = context.Request.Form["rolename"].ToString();
            model.editer   = admin.Id.ToString();
            try { model.creatdate = System.DateTime.Now; }
            catch { }

            return(model);
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.T_role GetModelRole(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" id,rolename,editer,creatdate ");
            strSql.Append(" from T_Role ");
            strSql.Append(" where id=" + id + "");
            Model.T_role model = new Model.T_role();
            DataTable    ds    = DbHelper.Factory().ExecuteDataTable(strSql.ToString());

            if (ds.Rows.Count > 0)
            {
                return(DataRowToModel(ds.Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.T_role DataRowToModel(DataRow row)
 {
     Model.T_role model = new Model.T_role();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["rolename"] != null)
         {
             model.rolename = row["rolename"].ToString();
         }
         if (row["editer"] != null)
         {
             model.editer = row["editer"].ToString();
         }
         if (row["creatdate"] != null && row["creatdate"].ToString() != "")
         {
             model.creatdate = DateTime.Parse(row["creatdate"].ToString());
         }
     }
     return(model);
 }