//获取单个对象 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; } }
/// <summary> /// 添加权限 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Create(NCCQ.Model.T_role model) { try { object[] obj = { model.rolename, model.editer, model.creatdate.ToString("yyyy-MM-dd HH:mm:ss") }; string strSql = string.Format("insert into T_Role (rolename,editer,creatdate) values ('{0}','{1}','{2}')", obj); if (DbHelper.Factory().ExecuteNonQuery(strSql) > 0) { return(true); } else { return(false); } } catch { return(false); } }