//查询单个对象 public T_SysFun GetById(int id) { string strSql = string.Format(" SELECT NodeId,DisplayName,NodeURL,DisplayOrder,ParentNodeId,Editor,CreateDate FROM T_SysFun where NodeId = {0} ", id); T_SysFun model = null; using (dynamic read = DbHelper.Factory().ExecuteReader(strSql)) { if (read.Read()) { model = new T_SysFun(); try { model.NodeId = int.Parse(read["NodeId"].ToString()); } catch { } model.DisplayName = read["DisplayName"].ToString(); model.NodeURL = read["NodeURL"].ToString(); try { model.DisplayOrder = int.Parse(read["DisplayOrder"].ToString()); } catch { } try { model.ParentNodeId = int.Parse(read["ParentNodeId"].ToString()); } catch { } model.Editor = read["Editor"].ToString(); model.CreateDate = DateTime.Parse(read["CreateDate"].ToString()); } read.Dispose(); } return(model); }
//更新 public bool Update(T_SysFun model) { object[] obj = { model.DisplayName, model.NodeURL, model.DisplayOrder, model.ParentNodeId, model.Editor, model.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"), model.NodeId }; string strSql = string.Format(" update T_SysFun set DisplayName = '{0}',NodeURL = '{1}',DisplayOrder = {2},ParentNodeId = {3},Editor = '{4}',CreateDate ='{5}' where NodeId={6} ", obj); if (DbHelper.Factory().ExecuteNonQuery(strSql) > 0) { return(true); } else { return(false); } }
//创建 public bool Create(T_SysFun model) { object[] obj = { model.DisplayName, model.NodeURL, model.DisplayOrder, model.ParentNodeId, model.Editor, model.CreateDate.ToString("yyyy-MM-dd HH:mm:ss") }; string strSql = string.Format(" insert into T_SysFun (DisplayName,NodeURL,DisplayOrder,ParentNodeId,Editor,CreateDate) values ('{0}','{1}',{2},{3},'{4}','{5}') ", obj); if (DbHelper.Factory().ExecuteNonQuery(strSql) > 0) { return(true); } else { return(false); } }
private T_SysFun GetModel(HttpContext context) { T_SysFun model = new T_SysFun(); try { model.NodeId = int.Parse(context.Request.Form["NodeId"].ToString()); } catch { } model.DisplayName = context.Request.Form["DisplayName"].ToString(); model.NodeURL = context.Request.Form["NodeURL"].ToString(); try { model.DisplayOrder = int.Parse(context.Request.Form["DisplayOrder"].ToString()); } catch { } try { model.ParentNodeId = int.Parse(context.Request.Form["ParentNodeId"].ToString()); } catch { } model.Editor = admin.AdminLogName; return(model); }