/// <summary> /// 增加一条数据 /// </summary> public bool Add(ZhangWei.Model.EnterStock_Detail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into EnterStock_Detail("); strSql.Append("EnterStock_ID,Product_ID,Quantity,Price,HaveInvoice,InvoiceNum)"); strSql.Append(" values ("); strSql.Append("@EnterStock_ID,@Product_ID,@Quantity,@Price,@HaveInvoice,@InvoiceNum)"); SqlParameter[] parameters = { new SqlParameter("@EnterStock_ID", SqlDbType.Int, 4), new SqlParameter("@Product_ID", SqlDbType.Int, 4), new SqlParameter("@Quantity", SqlDbType.Decimal, 9), new SqlParameter("@Price", SqlDbType.Money, 8), new SqlParameter("@HaveInvoice", SqlDbType.Bit, 1), new SqlParameter("@InvoiceNum", SqlDbType.VarChar, 30) }; parameters[0].Value = model.EnterStock_ID; parameters[1].Value = model.Product_ID; parameters[2].Value = model.Quantity; parameters[3].Value = model.Price; parameters[4].Value = model.HaveInvoice; parameters[5].Value = model.InvoiceNum; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected void EnterAgain()//重新入库 { //Model.Sale ml_sale = bll_sale.GetModel(Convert.ToInt32(Request.Params["Sale_ID"])); Model.EnterStock ml_es = bl_es.GetModel(EnterStock_ID); ml_es.StoreHouse_ID = Convert.ToInt32(DropDownList1.SelectedValue); bl_es.Update(ml_es); //ml_sale.GatheringWay = this.DropDownList6.SelectedItem.Text; //ml_sale.Account = this.DropDownList4.SelectedItem.Text; //ml_sale.Address = this.TextBox1.Text; //ml_sale.Customer = Convert.ToInt32(DropDownList5.SelectedValue); //bll_sale.Update(ml_sale); string Ids = this.newId.Value.Replace(" ", "").Replace("\r\n", ""); string Qtys = this.newQty.Value.Replace(" ", "").Replace("\r\n", ""); string Prices = this.newPrice.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.EnterStock_Detail ml_esd = new ZhangWei.Model.EnterStock_Detail(); ml_esd.EnterStock_ID = EnterStock_ID; ml_esd.Product_ID = Convert.ToInt32(ArrIds[i]); ml_esd.Quantity = Convert.ToDecimal(ArrQty[i]); ml_esd.Price = Convert.ToDecimal(ArrPri[i]); BLL.Sale_Detail bl_sd = new ZhangWei.BLL.Sale_Detail(); //ml_sa.Sale_ID = Convert.ToInt32(Request.Params["Sale_ID"]); //ml_sa.Product_ID = Convert.ToInt32(ArrIds[i]); //ml_sa.SaleOrder_ID = 0; //ml_sa.Quantity = Convert.ToDecimal(ArrQty[i]); //ml_sa.Price = Convert.ToDecimal(ArrPri[i]); Model.StockPile ml_sp = new BLL.StockPile().GetModelByProId(Convert.ToInt32(ArrIds[i]), Convert.ToInt32(DropDownList1.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 = 1; ml_sp.FirstEnterDate = DateTime.Now; ml_sp.LastLeaveDate = DateTime.Now; ml_sp.Price = Convert.ToDecimal(ArrPri[i]); ml_sp.Quantity = 0; ml_sp.StoreHouse_ID = Convert.ToInt32(DropDownList1.SelectedValue); 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_esd.Add(ml_esd); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ZhangWei.Model.EnterStock_Detail GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 EnterStock_ID,Product_ID,Quantity,Price,HaveInvoice,InvoiceNum from EnterStock_Detail "); strSql.Append(" where "); SqlParameter[] parameters = { }; ZhangWei.Model.EnterStock_Detail model = new ZhangWei.Model.EnterStock_Detail(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["EnterStock_ID"] != null && ds.Tables[0].Rows[0]["EnterStock_ID"].ToString() != "") { model.EnterStock_ID = int.Parse(ds.Tables[0].Rows[0]["EnterStock_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()); } if (ds.Tables[0].Rows[0]["HaveInvoice"] != null && ds.Tables[0].Rows[0]["HaveInvoice"].ToString() != "") { if ((ds.Tables[0].Rows[0]["HaveInvoice"].ToString() == "1") || (ds.Tables[0].Rows[0]["HaveInvoice"].ToString().ToLower() == "true")) { model.HaveInvoice = true; } else { model.HaveInvoice = false; } } if (ds.Tables[0].Rows[0]["InvoiceNum"] != null && ds.Tables[0].Rows[0]["InvoiceNum"].ToString() != "") { model.InvoiceNum = ds.Tables[0].Rows[0]["InvoiceNum"].ToString(); } return(model); } else { return(null); } }
private void ShowInfo() { ZhangWei.BLL.EnterStock_Detail bll = new ZhangWei.BLL.EnterStock_Detail(); ZhangWei.Model.EnterStock_Detail model = bll.GetModel(); this.txtEnterStock_ID.Text = model.EnterStock_ID.ToString(); this.txtProduct_ID.Text = model.Product_ID.ToString(); this.txtQuantity.Text = model.Quantity.ToString(); this.txtPrice.Text = model.Price.ToString(); this.chkHaveInvoice.Checked = model.HaveInvoice; this.txtInvoiceNum.Text = model.InvoiceNum; }
private void ShowInfo() { ZhangWei.BLL.EnterStock_Detail bll = new ZhangWei.BLL.EnterStock_Detail(); ZhangWei.Model.EnterStock_Detail model = bll.GetModel(); this.lblEnterStock_ID.Text = model.EnterStock_ID.ToString(); this.lblProduct_ID.Text = model.Product_ID.ToString(); this.lblQuantity.Text = model.Quantity.ToString(); this.lblPrice.Text = model.Price.ToString(); this.lblHaveInvoice.Text = model.HaveInvoice?"是":"否"; this.lblInvoiceNum.Text = model.InvoiceNum; }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtEnterStock_ID.Text)) { strErr += "EnterStock_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 (this.txtInvoiceNum.Text.Trim().Length == 0) { strErr += "InvoiceNum不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int EnterStock_ID = int.Parse(this.txtEnterStock_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); bool HaveInvoice = this.chkHaveInvoice.Checked; string InvoiceNum = this.txtInvoiceNum.Text; ZhangWei.Model.EnterStock_Detail model = new ZhangWei.Model.EnterStock_Detail(); model.EnterStock_ID = EnterStock_ID; model.Product_ID = Product_ID; model.Quantity = Quantity; model.Price = Price; model.HaveInvoice = HaveInvoice; model.InvoiceNum = InvoiceNum; ZhangWei.BLL.EnterStock_Detail bll = new ZhangWei.BLL.EnterStock_Detail(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ZhangWei.Model.EnterStock_Detail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update EnterStock_Detail set "); strSql.Append("EnterStock_ID=@EnterStock_ID,"); strSql.Append("Product_ID=@Product_ID,"); strSql.Append("Quantity=@Quantity,"); strSql.Append("Price=@Price,"); strSql.Append("HaveInvoice=@HaveInvoice,"); strSql.Append("InvoiceNum=@InvoiceNum"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@EnterStock_ID", SqlDbType.Int, 4), new SqlParameter("@Product_ID", SqlDbType.Int, 4), new SqlParameter("@Quantity", SqlDbType.Decimal, 9), new SqlParameter("@Price", SqlDbType.Money, 8), new SqlParameter("@HaveInvoice", SqlDbType.Bit, 1), new SqlParameter("@InvoiceNum", SqlDbType.VarChar, 30) }; parameters[0].Value = model.EnterStock_ID; parameters[1].Value = model.Product_ID; parameters[2].Value = model.Quantity; parameters[3].Value = model.Price; parameters[4].Value = model.HaveInvoice; parameters[5].Value = model.InvoiceNum; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }