/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_Product_Price ReaderBind(IDataReader dataReader) { Lebi_Product_Price model = new Lebi_Product_Price(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = (int)ojb; } ojb = dataReader["User_id"]; if (ojb != null && ojb != DBNull.Value) { model.User_id = (int)ojb; } ojb = dataReader["Price"]; if (ojb != null && ojb != DBNull.Value) { model.Price = (decimal)ojb; } ojb = dataReader["Product_id"]; if (ojb != null && ojb != DBNull.Value) { model.Product_id = (int)ojb; } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Product_Price model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_Product_Price]("); strSql.Append("User_id,Price,Product_id)"); strSql.Append(" values ("); strSql.Append("@User_id,@Price,@Product_id)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@User_id", model.User_id), new SqlParameter("@Price", model.Price), new SqlParameter("@Product_id", model.Product_id) }; object obj = SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
public Lebi_Product_Price GetPriceInfo(int userid) { Lebi_Product_Price model = B_Lebi_Product_Price.GetModel("Product_id=" + product.id + " and User_id=" + userid + ""); if (model == null) { return(new Lebi_Product_Price()); } return(model); }
/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_Product_Price SafeBindForm(Lebi_Product_Price model) { if (HttpContext.Current.Request["User_id"] != null) { model.User_id = Shop.Tools.RequestTool.RequestInt("User_id", 0); } if (HttpContext.Current.Request["Price"] != null) { model.Price = Shop.Tools.RequestTool.RequestDecimal("Price", 0); } if (HttpContext.Current.Request["Product_id"] != null) { model.Product_id = Shop.Tools.RequestTool.RequestInt("Product_id", 0); } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Product_Price model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_Product_Price] set "); strSql.Append("[User_id]=@User_id,"); strSql.Append("[Price]=@Price,"); strSql.Append("[Product_id]=@Product_id"); strSql.Append(" where id=" + model.id); OleDbParameter[] parameters = { new OleDbParameter("@User_id", model.User_id), new OleDbParameter("@Price", model.Price), new OleDbParameter("@Product_id", model.Product_id) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Product_Price model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_Product_Price]("); strSql.Append("[User_id],[Price],[Product_id])"); strSql.Append(" values ("); strSql.Append("@User_id,@Price,@Product_id)"); OleDbParameter[] parameters = { new OleDbParameter("@User_id", model.User_id), new OleDbParameter("@Price", model.Price), new OleDbParameter("@Product_id", model.Product_id) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); return(1); }
protected void Page_Load(object sender, EventArgs e) { if (!EX_Admin.Power("product_user_price", "商品会员价格")) { WindowNoPower(); } userlevelid = RequestTool.RequestInt("userlevelid"); userid = RequestTool.RequestInt("userid"); productid = RequestTool.RequestInt("productid"); key = RequestTool.RequestString("key"); userlevel = B_Lebi_UserLevel.GetModel(userlevelid); product = B_Lebi_Product.GetModel(productid); if (product == null) { product = new Lebi_Product(); } if (userlevel == null) { userlevel = new Lebi_UserLevel(); } string where = "IsAnonymous<>1"; if (key != "") { where += " and (UserName like '%" + key + "%' or RealName like '%" + key + "%' or NickName like '%" + key + "%')"; } if (userlevelid > 0) { where += " and UserLevel_id =" + userlevelid + ""; } PageSize = RequestTool.getpageSize(10); int recordCount = B_Lebi_User.Counts(where); PageString = Pager.GetPaginationStringForJS("reloadproducts({0},'" + key + "'," + userlevel.id + ");", page, PageSize, recordCount); users = B_Lebi_User.GetList(where, "", PageSize, page); userlevellimit = B_Lebi_Product_Price.GetModel("Product_id=" + product.id + ""); if (userlevellimit == null) { userlevellimit = new Lebi_Product_Price(); } }
/// <summary> /// 得到一个对象实体 by id /// </summary> public Lebi_Product_Price GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Product_Price] "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Lebi_Product_Price model = new Lebi_Product_Price(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["User_id"].ToString() != "") { model.User_id = int.Parse(ds.Tables[0].Rows[0]["User_id"].ToString()); } if (ds.Tables[0].Rows[0]["Price"].ToString() != "") { model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if (ds.Tables[0].Rows[0]["Product_id"].ToString() != "") { model.Product_id = int.Parse(ds.Tables[0].Rows[0]["Product_id"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 by where条件 /// </summary> public Lebi_Product_Price GetModel(string strWhere) { if (strWhere.IndexOf("lbsql{") > 0) { SQLPara para = new SQLPara(strWhere, "", ""); return(GetModel(para)); } StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Product_Price] "); strSql.Append(" where " + strWhere + ""); Lebi_Product_Price model = new Lebi_Product_Price(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["User_id"].ToString() != "") { model.User_id = int.Parse(ds.Tables[0].Rows[0]["User_id"].ToString()); } if (ds.Tables[0].Rows[0]["Price"].ToString() != "") { model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if (ds.Tables[0].Rows[0]["Product_id"].ToString() != "") { model.Product_id = int.Parse(ds.Tables[0].Rows[0]["Product_id"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Product_Price model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_Product_Price] set "); strSql.Append("User_id= @User_id,"); strSql.Append("Price= @Price,"); strSql.Append("Product_id= @Product_id"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@User_id", SqlDbType.Int, 4), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@Product_id", SqlDbType.Int, 4) }; parameters[0].Value = model.id; parameters[1].Value = model.User_id; parameters[2].Value = model.Price; parameters[3].Value = model.Product_id; SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_Product_Price model) { D_Lebi_Product_Price.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Product_Price model) { return(D_Lebi_Product_Price.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Product_Price SafeBindForm(Lebi_Product_Price model) { return(D_Lebi_Product_Price.Instance.SafeBindForm(model)); }