/// <summary> /// 更新一条数据 /// </summary> public bool Update(ZhongLi.Model.Roles model) { int rowsAffected = 0; SqlParameter[] parameters = { new SqlParameter("@RoleId", SqlDbType.Int, 4), new SqlParameter("@RoleName", SqlDbType.NVarChar, 50), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@ParentID", SqlDbType.Int, 4), new SqlParameter("@Description", SqlDbType.NVarChar, 500), new SqlParameter("@ColValue", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.RoleId; parameters[1].Value = model.RoleName; parameters[2].Value = model.CreateTime; parameters[3].Value = model.ParentID; parameters[4].Value = model.Description; parameters[5].Value = model.ColValue; DbHelperSQL.RunProcedure("Roles_Update", parameters, out rowsAffected); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ZhongLi.Model.Roles DataRowToModel(DataRow row) { ZhongLi.Model.Roles model = new ZhongLi.Model.Roles(); if (row != null) { if (row["RoleId"] != null && row["RoleId"].ToString() != "") { model.RoleId = int.Parse(row["RoleId"].ToString()); } if (row["RoleName"] != null) { model.RoleName = row["RoleName"].ToString(); } if (row["CreateTime"] != null && row["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(row["CreateTime"].ToString()); } if (row["ParentID"] != null && row["ParentID"].ToString() != "") { model.ParentID = int.Parse(row["ParentID"].ToString()); } if (row["Description"] != null) { model.Description = row["Description"].ToString(); } if (row["ColValue"] != null) { model.ColValue = row["ColValue"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public ZhongLi.Model.Roles GetModel(int RoleId) { SqlParameter[] parameters = { new SqlParameter("@RoleId", SqlDbType.Int, 4) }; parameters[0].Value = RoleId; ZhongLi.Model.Roles model = new ZhongLi.Model.Roles(); DataSet ds = DbHelperSQL.RunProcedure("Roles_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ZhongLi.Model.Roles model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@RoleId", SqlDbType.Int, 4), new SqlParameter("@RoleName", SqlDbType.NVarChar, 50), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@ParentID", SqlDbType.Int, 4), new SqlParameter("@Description", SqlDbType.NVarChar, 500), new SqlParameter("@ColValue", SqlDbType.NVarChar, 50) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.RoleName; parameters[2].Value = model.CreateTime; parameters[3].Value = model.ParentID; parameters[4].Value = model.Description; parameters[5].Value = model.ColValue; DbHelperSQL.RunProcedure("Roles_ADD", parameters, out rowsAffected); return((int)parameters[0].Value); }