/// <summary> /// 更新一条数据 /// </summary> public bool Update(ZhangWei.Model.BackStock_Detail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BackStock_Detail set "); strSql.Append("BackStock_ID=@BackStock_ID,"); strSql.Append("Product_ID=@Product_ID,"); strSql.Append("Quantity=@Quantity,"); strSql.Append("Price=@Price"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@BackStock_ID", SqlDbType.Int, 4), new SqlParameter("@Product_ID", SqlDbType.Int, 4), new SqlParameter("@Quantity", SqlDbType.Decimal, 9), new SqlParameter("@Price", SqlDbType.Money, 8) }; parameters[0].Value = model.BackStock_ID; parameters[1].Value = model.Product_ID; parameters[2].Value = model.Quantity; parameters[3].Value = model.Price; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(ZhangWei.Model.BackStock_Detail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BackStock_Detail("); strSql.Append("BackStock_ID,Product_ID,Quantity,Price)"); strSql.Append(" values ("); strSql.Append("@BackStock_ID,@Product_ID,@Quantity,@Price)"); SqlParameter[] parameters = { new SqlParameter("@BackStock_ID", SqlDbType.Int, 4), new SqlParameter("@Product_ID", SqlDbType.Int, 4), new SqlParameter("@Quantity", SqlDbType.Decimal, 9), new SqlParameter("@Price", SqlDbType.Money, 8) }; parameters[0].Value = model.BackStock_ID; parameters[1].Value = model.Product_ID; parameters[2].Value = model.Quantity; parameters[3].Value = model.Price; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo() { ZhangWei.BLL.BackStock_Detail bll = new ZhangWei.BLL.BackStock_Detail(); ZhangWei.Model.BackStock_Detail model = bll.GetModel(); this.lblBackStock_ID.Text = model.BackStock_ID.ToString(); this.lblProduct_ID.Text = model.Product_ID.ToString(); this.lblQuantity.Text = model.Quantity.ToString(); this.lblPrice.Text = model.Price.ToString(); }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtBackStock_ID.Text)) { strErr += "BackStock_ID格式错误!\\n"; } if (!PageValidate.IsNumber(txtProduct_ID.Text)) { strErr += "Product_ID格式错误!\\n"; } if (!PageValidate.IsNumber(txtQuantity.Text)) { strErr += "Quantity格式错误!\\n"; } if (!PageValidate.IsDecimal(txtPrice.Text)) { strErr += "Price格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int BackStock_ID = int.Parse(this.txtBackStock_ID.Text); int Product_ID = int.Parse(this.txtProduct_ID.Text); int Quantity = int.Parse(this.txtQuantity.Text); decimal Price = decimal.Parse(this.txtPrice.Text); ZhangWei.Model.BackStock_Detail model = new ZhangWei.Model.BackStock_Detail(); model.BackStock_ID = BackStock_ID; model.Product_ID = Product_ID; model.Quantity = Quantity; model.Price = Price; ZhangWei.BLL.BackStock_Detail bll = new ZhangWei.BLL.BackStock_Detail(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public ZhangWei.Model.BackStock_Detail GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 BackStock_ID,Product_ID,Quantity,Price from BackStock_Detail "); strSql.Append(" where "); SqlParameter[] parameters = { }; ZhangWei.Model.BackStock_Detail model = new ZhangWei.Model.BackStock_Detail(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["BackStock_ID"] != null && ds.Tables[0].Rows[0]["BackStock_ID"].ToString() != "") { model.BackStock_ID = int.Parse(ds.Tables[0].Rows[0]["BackStock_ID"].ToString()); } if (ds.Tables[0].Rows[0]["Product_ID"] != null && ds.Tables[0].Rows[0]["Product_ID"].ToString() != "") { model.Product_ID = int.Parse(ds.Tables[0].Rows[0]["Product_ID"].ToString()); } if (ds.Tables[0].Rows[0]["Quantity"] != null && ds.Tables[0].Rows[0]["Quantity"].ToString() != "") { model.Quantity = decimal.Parse(ds.Tables[0].Rows[0]["Quantity"].ToString()); } if (ds.Tables[0].Rows[0]["Price"] != null && ds.Tables[0].Rows[0]["Price"].ToString() != "") { model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } return(model); } else { return(null); } }
protected void Button2_Click(object sender, EventArgs e) { if (HiddenField1.Value == "") { Maticsoft.Common.MessageBox.Show(this, "请添加商品"); return; } else { Model.BackStock ml_bs = new ZhangWei.Model.BackStock(); ml_bs.BackDate = Convert.ToDateTime(BackDate.Text); ml_bs.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); ml_bs.Employee_ID = Convert.ToInt32(DropDownList2.SelectedValue); ml_bs.StoreHouse_ID = Convert.ToInt32(DropDownList3.SelectedValue); ml_bs.Remark = this.TextBox1.Text; Int32 BackStock_id = new BLL.BackStock().Add(ml_bs); string Ids = HiddenField1.Value.Replace(" ", "").Replace("\r\n", ""); string Qtys = HiddenField2.Value.Replace(" ", "").Replace("\r\n", ""); string Prices = HiddenField3.Value.Replace(" ", "").Replace("\r\n", ""); string[] ArrIds = Ids.Split(new char[] { '|' }); string[] ArrQty = Qtys.Split(new char[] { '|' }); string[] ArrPri = Prices.Split(new char[] { '|' }); for (int i = 0; i < ArrIds.Length - 1; i++) { //Model.Sale_Detail ml_sa = new ZhangWei.Model.Sale_Detail(); Model.BackStock_Detail ml_bsd = new ZhangWei.Model.BackStock_Detail(); ml_bsd.BackStock_ID = BackStock_id; ml_bsd.Product_ID = Convert.ToInt32(ArrIds[i]); ml_bsd.Price = Convert.ToDecimal(ArrPri[i]); ml_bsd.Quantity = Convert.ToDecimal(ArrQty[i]); BLL.BackStock_Detail bl_bsd = new ZhangWei.BLL.BackStock_Detail(); Model.StockPile ml_sp = new BLL.StockPile().GetModelByProId(Convert.ToInt32(ArrIds[i]), Convert.ToInt32(DropDownList3.SelectedValue)); BLL.StockPile bl_sp = new ZhangWei.BLL.StockPile(); if (ml_sp == null) { Model.Product ml_pr = new BLL.Product().GetModel(Convert.ToInt32(ArrIds[i])); ml_sp = new ZhangWei.Model.StockPile(); ml_sp.Product_ID = Convert.ToInt32(ArrIds[i]); ml_sp.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); ml_sp.FirstEnterDate = DateTime.Now; ml_sp.LastLeaveDate = DateTime.Now; ml_sp.Price = Convert.ToDecimal(ArrPri[i]); ml_sp.StoreHouse_ID = Convert.ToInt32(DropDownList3.SelectedValue); ml_sp.Quantity = 0; ml_sp.Quantity -= Convert.ToDecimal(ArrQty[i]); bl_sp.Add(ml_sp); } else { ml_sp.Quantity -= Convert.ToDecimal(ArrQty[i]); ml_sp.LastLeaveDate = DateTime.Now; bl_sp.Update(ml_sp); } bl_bsd.Add(ml_bsd); } Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "/warehouse/BackStock/List.aspx"); } }