/// <summary> /// 新增类型 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int AddMaterialProperty(mg_MaterialPropertyModel model) { string maxid = @"declare @i int; SELECT @i=max([prop_id]) FROM [Mg_MaterialProperty]; if @i is null begin set @i=1 end else begin set @i=@i+1 end; "; StringBuilder strSql = new StringBuilder(); strSql.Append("SET IDENTITY_INSERT Mg_MaterialProperty ON; "); strSql.Append("insert into Mg_MaterialProperty("); strSql.Append("prop_id,Prop_type,prop_name)"); strSql.Append(" values ("); strSql.Append("@i,@Prop_type,@prop_name);"); strSql.Append("SET IDENTITY_INSERT Mg_MaterialProperty OFF; "); SqlParameter[] parameters = { new SqlParameter("@Prop_type", SqlDbType.Int), new SqlParameter("@prop_name", SqlDbType.NVarChar) }; parameters[0].Value = model.Prop_type; parameters[1].Value = model.prop_name; int rows = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, System.Data.CommandType.Text, maxid + strSql, parameters); return(rows); }
/// <summary> /// 保存颜色 /// </summary> void SaveMaterialProperty() { try { string prop_id = Request.Params["prop_id"]; string prop_name = Request.Params["prop_name"]; string prop_type = Request.Params["prop_type"]; mg_MaterialPropertyModel model = new mg_MaterialPropertyModel(); model.prop_name = prop_name; model.Prop_type = NumericParse.StringToInt(prop_type); if (!string.IsNullOrWhiteSpace(prop_id)) { model.prop_id = Convert.ToInt32(prop_id); } else { model.prop_id = 0; } string json = mg_MaterialPropertyBLL.SaveMaterialProperty(model); Response.Write(json); Response.End(); } catch (Exception ex) { } }
/// <summary> /// 更新类型 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int UpdateMaterialProperty(mg_MaterialPropertyModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Mg_MaterialProperty set "); strSql.Append("prop_name=@prop_name"); strSql.Append(" where prop_id=@prop_id "); SqlParameter[] parameters = { new SqlParameter("@prop_id", SqlDbType.Int), new SqlParameter("@prop_name", SqlDbType.NVarChar) }; parameters[0].Value = model.prop_id; parameters[1].Value = model.prop_name; int rows = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, System.Data.CommandType.Text, strSql.ToString(), parameters); return(rows); }
public static List <mg_MaterialPropertyModel> queryJSONStringByPropertyType(string type) { List <mg_MaterialPropertyModel> list = null; string sql = @"SELECT [prop_id] ,[Prop_type] ,[prop_name] FROM [Mg_MaterialProperty] where Prop_type=" + type + " order by prop_id"; DataTable dt = SqlHelper.GetDataDataTable(SqlHelper.SqlConnString, System.Data.CommandType.Text, sql, null); if (DataHelper.HasData(dt)) { list = new List <mg_MaterialPropertyModel>(); foreach (DataRow row in dt.Rows) { mg_MaterialPropertyModel model = new mg_MaterialPropertyModel(); model.prop_id = NumericParse.StringToInt(DataHelper.GetCellDataToStr(row, "prop_id")); model.Prop_type = NumericParse.StringToInt(DataHelper.GetCellDataToStr(row, "Prop_type")); model.prop_name = DataHelper.GetCellDataToStr(row, "prop_name"); list.Add(model); } } return(list); }
/// <summary> /// 更新类型 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string UpdateMaterialProperty(mg_MaterialPropertyModel model) { int count = mg_MaterialPropertyDAL.UpdateMaterialProperty(model); return(count > 0 ? "true" : "false"); }
/// <summary> /// 保存 /// lx 2017-06-22 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string SaveMaterialProperty(mg_MaterialPropertyModel model) { return(model.prop_id == 0 ? AddMaterialProperty(model) : UpdateMaterialProperty(model)); }