/// <summary> /// 更新一条数据 /// </summary> public bool Update(ESMonitor.Model.UserGroup model) { int rowsAffected = 0; SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 30), new SqlParameter("@Orders", SqlDbType.Int, 4), new SqlParameter("@Description", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.Id; parameters[1].Value = model.Name; parameters[2].Value = model.Orders; parameters[3].Value = model.Description; DbHelperSQL.RunProcedure("T_UserGroup_Update", parameters, out rowsAffected); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ESMonitor.Model.UserGroup model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 30), new SqlParameter("@Orders", SqlDbType.Int, 4), new SqlParameter("@Description", SqlDbType.NVarChar, 50) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.Name; parameters[2].Value = model.Orders; parameters[3].Value = model.Description; DbHelperSQL.RunProcedure("T_UserGroup_ADD", parameters, out rowsAffected); return((int)parameters[0].Value); }
/// <summary> /// 得到一个对象实体 /// </summary> public ESMonitor.Model.UserGroup GetModel(int Id) { SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; ESMonitor.Model.UserGroup model = new ESMonitor.Model.UserGroup(); DataSet ds = DbHelperSQL.RunProcedure("T_UserGroup_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ESMonitor.Model.UserGroup DataRowToModel(DataRow row) { ESMonitor.Model.UserGroup model = new ESMonitor.Model.UserGroup(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["Orders"] != null && row["Orders"].ToString() != "") { model.Orders = int.Parse(row["Orders"].ToString()); } if (row["Description"] != null) { model.Description = row["Description"].ToString(); } } return(model); }