protected void btnSave_Click(object sender, EventArgs e) { tbProduct p = new tbProduct() { code = code.Text, cost_price = decimal.Parse(Cost_price.Text), description = FCKeditor1.Value.ToString(), expiry_date = DateTime.Parse(Expiry_date.Text.ToString()), lowerLimit = int.Parse(LowerLimit.Text), material = Material.Text, PingPaiId = int.Parse(ddlPingPai.SelectedValue.ToString()), product_name = Product_Name.Text, retail_price = this.Retail_Price.Text == "0" ? decimal.Parse((double.Parse(Retail_Price.Text) * 1.2).ToString()) : decimal.Parse(Retail_Price.Text), smallimg = s_fileName, spec = Spec.Text, type_id = int.Parse(ddlType.SelectedValue.ToString()), units = units.Text, upperLimit = int.Parse(UpperLimit.Text), weight = Weight.Text, wholesale_price = this.Wholesale_price.Text == "0" ?decimal.Parse((double.Parse(Wholesale_price.Text) * 1.1).ToString()): decimal.Parse(Wholesale_price.Text), Catalogid=int.Parse(ddlCatalog.SelectedValue.ToString()), Discount=decimal.Parse(txtdiscount.Text.Trim()) }; pbll.Add(p); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { typelistbang(); cataloglist(); PingPaiBind(); if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString() != "") { string id = Request.QueryString["id"].ToString(); p=pbll.GetModel(int.Parse(id)); this.Product_Name.Text = p.product_name; this.Retail_Price.Text= p.retail_price.ToString(); this.Cost_price.Text = p.cost_price.ToString(); this.units.Text = p.units; this.Wholesale_price.Text = p.wholesale_price.ToString(); this.Weight.Text = p.weight; this.Material.Text = p.material; this.UpperLimit.Text = p.upperLimit.ToString(); this.LowerLimit.Text = p.lowerLimit.ToString(); this.Spec.Text = p.spec.ToString(); this.code.Text = p.code.ToString(); this.Expiry_date.Text = p.expiry_date.ToString(); this.ddlCatalog.SelectedValue = p.Catalogid.ToString(); this.ddlType.SelectedValue = p.type_id.ToString(); this.ddlPingPai.SelectedValue = p.PingPaiId.ToString(); this.FCKeditor1.Value = p.description; this.txtdiscount.Text = p.Discount.ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString() != "") { proid =int.Parse( Request.QueryString["id"].ToString()); p= pbll.GetModel(proid); this.lbProname.Text = p.product_name; Proimglist(); } } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(tbProduct model) { SqlParameter[] parameters = { new SqlParameter("@product_id", SqlDbType.Int,4), new SqlParameter("@product_name", SqlDbType.NVarChar,200), new SqlParameter("@type_id", SqlDbType.Int,4), new SqlParameter("@cost_price", SqlDbType.Money,8), new SqlParameter("@wholesale_price", SqlDbType.Money,8), new SqlParameter("@retail_price", SqlDbType.Money,8), new SqlParameter("@units", SqlDbType.NVarChar,50), new SqlParameter("@weight", SqlDbType.NVarChar,50), new SqlParameter("@material", SqlDbType.NVarChar,50), new SqlParameter("@spec", SqlDbType.NVarChar,100), new SqlParameter("@upperLimit", SqlDbType.Int,4), new SqlParameter("@lowerLimit", SqlDbType.Int,4), new SqlParameter("@expiry_date", SqlDbType.DateTime), new SqlParameter("@code", SqlDbType.NVarChar,50), new SqlParameter("@description", SqlDbType.Text), new SqlParameter("@smallimg", SqlDbType.NVarChar,100), new SqlParameter("@PingPaiId",SqlDbType.Int,4), new SqlParameter("@catalogid",SqlDbType.Int,4), new SqlParameter("@discount",SqlDbType.Int,4) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.product_name; parameters[2].Value = model.type_id; parameters[3].Value = model.cost_price; parameters[4].Value = model.wholesale_price; parameters[5].Value = model.retail_price; parameters[6].Value = model.units; parameters[7].Value = model.weight; parameters[8].Value = model.material; parameters[9].Value = model.spec; parameters[10].Value = model.upperLimit; parameters[11].Value = model.lowerLimit; parameters[12].Value = model.expiry_date; parameters[13].Value = model.code; parameters[14].Value = model.description; parameters[15].Value = model.smallimg; parameters[16].Value = model.PingPaiId; parameters[17].Value = model.Catalogid; parameters[18].Value = model.Discount; dbhelper.ExcuteCommandReturnInt("tbProduct_ADD", CommandType.StoredProcedure, parameters); return (int)parameters[0].Value; }
/// <summary> /// 得到一个对象实体 /// </summary> public tbProduct GetModel(int product_id) { SqlParameter[] parameters = { new SqlParameter("@product_id", SqlDbType.Int,4) }; parameters[0].Value = product_id; tbProduct model = new tbProduct(); DataSet ds = dbhelper.ExcuteSelectReturnDataSet("tbProduct_GetModel", CommandType.StoredProcedure, parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["product_id"].ToString() != "") { model.product_id = int.Parse(ds.Tables[0].Rows[0]["product_id"].ToString()); } model.product_name = ds.Tables[0].Rows[0]["product_name"].ToString(); if (ds.Tables[0].Rows[0]["type_id"].ToString() != "") { model.type_id = int.Parse(ds.Tables[0].Rows[0]["type_id"].ToString()); } if (ds.Tables[0].Rows[0]["cost_price"].ToString() != "") { model.cost_price = decimal.Parse(ds.Tables[0].Rows[0]["cost_price"].ToString()); } if (ds.Tables[0].Rows[0]["wholesale_price"].ToString() != "") { model.wholesale_price = decimal.Parse(ds.Tables[0].Rows[0]["wholesale_price"].ToString()); } if (ds.Tables[0].Rows[0]["retail_price"].ToString() != "") { model.retail_price = decimal.Parse(ds.Tables[0].Rows[0]["retail_price"].ToString()); } model.units = ds.Tables[0].Rows[0]["units"].ToString(); model.weight = ds.Tables[0].Rows[0]["weight"].ToString(); model.material = ds.Tables[0].Rows[0]["material"].ToString(); model.spec = ds.Tables[0].Rows[0]["spec"].ToString(); if (ds.Tables[0].Rows[0]["upperLimit"].ToString() != "") { model.upperLimit = int.Parse(ds.Tables[0].Rows[0]["upperLimit"].ToString()); } if (ds.Tables[0].Rows[0]["lowerLimit"].ToString() != "") { model.lowerLimit = int.Parse(ds.Tables[0].Rows[0]["lowerLimit"].ToString()); } if (ds.Tables[0].Rows[0]["expiry_date"].ToString() != "") { model.expiry_date = DateTime.Parse(ds.Tables[0].Rows[0]["expiry_date"].ToString()); } model.code = ds.Tables[0].Rows[0]["code"].ToString(); model.description = ds.Tables[0].Rows[0]["description"].ToString(); model.smallimg = ds.Tables[0].Rows[0]["smallimg"].ToString(); model.PingPaiId = int.Parse(ds.Tables[0].Rows[0]["PingPaiId"].ToString()); model.Catalogid = int.Parse(ds.Tables[0].Rows[0]["catalogid"].ToString()); model.Discount = decimal.Parse(ds.Tables[0].Rows[0]["discount"].ToString()); model.Adddate = DateTime.Parse(ds.Tables[0].Rows[0]["addDate"].ToString()); return model; } else { return null; } }
protected void Page_Load(object sender, EventArgs e) { BLL.ProBLL pbll = new ProBLL(); p = pbll.GetModel(1); }