/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Product_Limit model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + TableName + " ("); strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsBuy") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsPriceShow") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsShow") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Product_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("UserLevel_id") + ")"); strSql.Append(" values ("); strSql.Append("@IsBuy,@IsPriceShow,@IsShow,@Product_id,@User_id,@UserLevel_id);select @@identity;"); SqlParameter[] parameters = { new SqlParameter("@IsBuy", model.IsBuy), new SqlParameter("@IsPriceShow", model.IsPriceShow), new SqlParameter("@IsShow", model.IsShow), new SqlParameter("@Product_id", model.Product_id), new SqlParameter("@User_id", model.User_id), new SqlParameter("@UserLevel_id", model.UserLevel_id) }; object obj = LB.DataAccess.DB.Instance.TextExecute(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_Product_Limit SafeBindForm(Lebi_Product_Limit model) { if (HttpContext.Current.Request["IsBuy"] != null) { model.IsBuy = LB.Tools.RequestTool.RequestInt("IsBuy", 0); } if (HttpContext.Current.Request["IsPriceShow"] != null) { model.IsPriceShow = LB.Tools.RequestTool.RequestInt("IsPriceShow", 0); } if (HttpContext.Current.Request["IsShow"] != null) { model.IsShow = LB.Tools.RequestTool.RequestInt("IsShow", 0); } if (HttpContext.Current.Request["Product_id"] != null) { model.Product_id = LB.Tools.RequestTool.RequestInt("Product_id", 0); } if (HttpContext.Current.Request["User_id"] != null) { model.User_id = LB.Tools.RequestTool.RequestInt("User_id", 0); } if (HttpContext.Current.Request["UserLevel_id"] != null) { model.UserLevel_id = LB.Tools.RequestTool.RequestInt("UserLevel_id", 0); } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Product_Limit model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + TableName + " set "); List <string> cols = new List <string>(); if (("," + model.UpdateCols + ",").IndexOf(",IsBuy,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsBuy") + "= @IsBuy"); } if (("," + model.UpdateCols + ",").IndexOf(",IsPriceShow,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsPriceShow") + "= @IsPriceShow"); } if (("," + model.UpdateCols + ",").IndexOf(",IsShow,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsShow") + "= @IsShow"); } if (("," + model.UpdateCols + ",").IndexOf(",Product_id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Product_id") + "= @Product_id"); } if (("," + model.UpdateCols + ",").IndexOf(",User_id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "= @User_id"); } if (("," + model.UpdateCols + ",").IndexOf(",UserLevel_id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("UserLevel_id") + "= @UserLevel_id"); } strSql.Append(string.Join(",", cols)); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", model.id), new SqlParameter("@IsBuy", model.IsBuy), new SqlParameter("@IsPriceShow", model.IsPriceShow), new SqlParameter("@IsShow", model.IsShow), new SqlParameter("@Product_id", model.Product_id), new SqlParameter("@User_id", model.User_id), new SqlParameter("@UserLevel_id", model.UserLevel_id) }; LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_Product_Limit ReaderBind(IDataReader dataReader) { Lebi_Product_Limit model = new Lebi_Product_Limit(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = Convert.ToInt32(ojb); } ojb = dataReader["IsBuy"]; if (ojb != null && ojb != DBNull.Value) { model.IsBuy = Convert.ToInt32(ojb); } ojb = dataReader["IsPriceShow"]; if (ojb != null && ojb != DBNull.Value) { model.IsPriceShow = Convert.ToInt32(ojb); } ojb = dataReader["IsShow"]; if (ojb != null && ojb != DBNull.Value) { model.IsShow = Convert.ToInt32(ojb); } ojb = dataReader["Product_id"]; if (ojb != null && ojb != DBNull.Value) { model.Product_id = Convert.ToInt32(ojb); } ojb = dataReader["User_id"]; if (ojb != null && ojb != DBNull.Value) { model.User_id = Convert.ToInt32(ojb); } ojb = dataReader["UserLevel_id"]; if (ojb != null && ojb != DBNull.Value) { model.UserLevel_id = Convert.ToInt32(ojb); } return(model); }
/// <summary> /// 得到一个对象实体 by where条件 /// </summary> public Lebi_Product_Limit GetModel(string strWhere, int seconds = 0) { if (strWhere.IndexOf("lbsql{") > 0) { SQLPara para = new SQLPara(strWhere, "", ""); return(GetModel(para, seconds)); } string strTableName = TableName; string strFieldShow = "*"; string cachekey = ""; string cachestr = ""; if (BaseUtils.BaseUtilsInstance.MemcacheInstance != null && seconds > 0) { cachestr = "select * " + TableName + " where " + strWhere + "|" + seconds; cachekey = LB.Tools.Utils.MD5(cachestr); var obj = LB.DataAccess.DB.Instance.GetMemchche(cachekey); if (obj != null) { return(obj as Lebi_Product_Limit); } } Lebi_Product_Limit model = null; using (IDataReader dataReader = LB.DataAccess.DB.Instance.TextExecuteReaderOne(strTableName, strFieldShow, strWhere, null)) { if (dataReader == null) { return(null); } while (dataReader.Read()) { model = ReaderBind(dataReader); if (cachekey != "") { LB.DataAccess.DB.Instance.SetMemchche(cachekey, model, "Lebi_Product_Limit", model.id, cachestr, seconds); } return(model); } } return(null); }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_Product_Limit model) { D_Lebi_Product_Limit.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Product_Limit model) { return(D_Lebi_Product_Limit.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Product_Limit SafeBindForm(Lebi_Product_Limit model) { return(D_Lebi_Product_Limit.Instance.SafeBindForm(model)); }