/// <summary> /// 新增颜色 /// lx 2017-06-22 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int AddColor(mg_PropertyModel model) { string maxid = @"declare @i int; SELECT @i=max([prop_id]) FROM [mg_Property]; if @i is null begin set @i=1 end else begin set @i=@i+1 end; "; StringBuilder strSql = new StringBuilder(); strSql.Append("insert into mg_Property("); strSql.Append("prop_id,Prop_type,prop_name)"); strSql.Append(" values ("); strSql.Append("@i,@Prop_type,@prop_name);"); 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); }
///陈名兴 ///增加下拉类型 /// public static List <mg_PropertyModel> QueryPropertyFlowlingForEditing(string type) { List <mg_PropertyModel> list = null; string sql = @"SELECT [prop_id] ,[Prop_Type] ,[prop_name] FROM [Mg_Property] 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_PropertyModel>(); foreach (DataRow row in dt.Rows) { mg_PropertyModel model = new mg_PropertyModel(); model.prop_id = NumericParse.StringToInt(DataHelper.GetCellDataToStr(row, "prop_id")); model.prop_name = DataHelper.GetCellDataToStr(row, "prop_name"); model.Prop_type = NumericParse.StringToInt(DataHelper.GetCellDataToStr(row, "Prop_type")); list.Add(model); } mg_PropertyModel firstmodel = new mg_PropertyModel(); firstmodel.prop_id = 0; firstmodel.prop_name = "-- 请选择类型 --"; list.Insert(0, firstmodel); } return(list); }
/// <summary> /// 保存颜色 /// </summary> void SaveColor() { try { string prop_id = Request.Params["prop_id"]; string prop_name = Request.Params["prop_name"]; string prop_type = Request.Params["prop_type"]; mg_PropertyModel model = new mg_PropertyModel(); 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_PropertyBLL.SaveColor(model); Response.Write(json); Response.End(); } catch (Exception ex) { } }
/// <summary> /// 更新颜色 /// lx 2017-06-22 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int UpdateColor(mg_PropertyModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update mg_Property 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_PropertyModel> queryJSONStringByPropertyType(mg_PropertyEnum propEnum) { List <mg_PropertyModel> list = null; string sql = @"SELECT [prop_id] ,[Prop_type] ,[prop_name] FROM [mg_Property] where Prop_type=" + (int)propEnum + @" order by prop_name"; DataTable dt = SqlHelper.GetDataDataTable(SqlHelper.SqlConnString, System.Data.CommandType.Text, sql, null); if (DataHelper.HasData(dt)) { list = new List <mg_PropertyModel>(); foreach (DataRow row in dt.Rows) { mg_PropertyModel model = new mg_PropertyModel(); model.prop_id = NumericParse.StringToInt(DataHelper.GetCellDataToStr(row, "prop_id")); model.prop_name = DataHelper.GetCellDataToStr(row, "prop_name"); list.Add(model); } } return(list); }
/// <summary> /// 新增颜色 /// lx 2017-06-22 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string AddColor(mg_PropertyModel model) { int count = mg_PropertyDAL.AddColor(model); return(count > 0 ? "true" : "false"); }
/// <summary> /// 保存颜色 /// lx 2017-06-22 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string SaveColor(mg_PropertyModel model) { return(model.prop_id == 0 ? AddColor(model) : UpdateColor(model)); }