private void ShowInfo(int Product_ID) { ZhangWei.BLL.Product bll = new ZhangWei.BLL.Product(); ZhangWei.Model.Product model = bll.GetModel(Product_ID); this.lblProduct_ID.Text = model.Product_ID.ToString(); //this.txtProductList_ID.Text = model.ProductList_ID.ToString(); DropDownList1.SelectedValue = model.ProductList_ID.ToString(); this.txtName.Text = model.Name; //this.txtProductSpec_ID.Text = model.ProductSpec_ID.ToString(); DropDownList2.SelectedValue = model.ProductSpec_ID.ToString(); //this.txtProductUnit_ID.Text = model.ProductUnit_ID.ToString(); DropDownList3.SelectedValue = model.ProductUnit_ID.ToString(); this.txtPrice.Text = model.Price.ToString(); this.Offering_Price.Text = model.Offering_Price.ToString(); //this.txtEmployee_ID.Text = model.Employee_ID.ToString(); DropDownList4.SelectedValue = model.Employee_ID.ToString(); DataSet ds = new BLL.ProductList().GetList(1, "ProductList_ID = " + model.ProductList_ID, "ProductList_ID"); DropDownList5.SelectedValue = ds.Tables[0].Rows[0]["ProductClass_ID"].ToString(); //this.txtCreateDate.Text = model.CreateDate.ToString(); this.Label1.Text = model.CreateDate.ToString(); this.txtRemark.Text = model.Remark; this.s_spell.Text = model.s_spell; this.spell.Text = model.spell; this.TextBox1.Text = model.shortname; ZhangWei.Model.Product_Supplier ml_ps = new BLL.Product_Supplier().GetModel(Product_ID); this.DropDownList6.SelectedValue = ml_ps.Supplier_ID.ToString(); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ZhangWei.Model.Product model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Product set "); strSql.Append("ProductList_ID=@ProductList_ID,"); strSql.Append("Name=@Name,"); strSql.Append("shortname=@shortname,"); strSql.Append("spell=@spell,"); strSql.Append("s_spell=@s_spell,"); strSql.Append("ProductSpec_ID=@ProductSpec_ID,"); strSql.Append("ProductUnit_ID=@ProductUnit_ID,"); strSql.Append("Price=@Price,"); strSql.Append("Offering_Price=@Offering_Price,"); strSql.Append("Employee_ID=@Employee_ID,"); strSql.Append("CreateDate=@CreateDate,"); strSql.Append("Remark=@Remark"); strSql.Append(" where Product_ID=@Product_ID"); SqlParameter[] parameters = { new SqlParameter("@ProductList_ID", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 50), new SqlParameter("@shortname", SqlDbType.VarChar, 50), new SqlParameter("@spell", SqlDbType.VarChar, 50), new SqlParameter("@s_spell", SqlDbType.VarChar, 50), new SqlParameter("@ProductSpec_ID", SqlDbType.Int, 4), new SqlParameter("@ProductUnit_ID", SqlDbType.Int, 4), new SqlParameter("@Price", SqlDbType.Money, 8), new SqlParameter("@Offering_Price", SqlDbType.Money, 8), new SqlParameter("@Employee_ID", SqlDbType.Int, 4), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@Remark", SqlDbType.VarChar, 250), new SqlParameter("@Product_ID", SqlDbType.Int, 4) }; parameters[0].Value = model.ProductList_ID; parameters[1].Value = model.Name; parameters[2].Value = model.shortname; parameters[3].Value = model.spell; parameters[4].Value = model.s_spell; parameters[5].Value = model.ProductSpec_ID; parameters[6].Value = model.ProductUnit_ID; parameters[7].Value = model.Price; parameters[8].Value = model.Offering_Price; parameters[9].Value = model.Employee_ID; parameters[10].Value = model.CreateDate; parameters[11].Value = model.Remark; parameters[12].Value = model.Product_ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ZhangWei.Model.Product model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Product("); strSql.Append("ProductList_ID,Name,shortname,spell,s_spell,ProductSpec_ID,ProductUnit_ID,Price,Offering_Price,Employee_ID,CreateDate,Remark)"); strSql.Append(" values ("); strSql.Append("@ProductList_ID,@Name,@shortname,@spell,@s_spell,@ProductSpec_ID,@ProductUnit_ID,@Price,@Offering_Price,@Employee_ID,@CreateDate,@Remark)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ProductList_ID", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 50), new SqlParameter("@shortname", SqlDbType.VarChar, 50), new SqlParameter("@spell", SqlDbType.VarChar, 50), new SqlParameter("@s_spell", SqlDbType.VarChar, 50), new SqlParameter("@ProductSpec_ID", SqlDbType.Int, 4), new SqlParameter("@ProductUnit_ID", SqlDbType.Int, 4), new SqlParameter("@Price", SqlDbType.Money, 8), new SqlParameter("@Offering_Price", SqlDbType.Money, 8), new SqlParameter("@Employee_ID", SqlDbType.Int, 4), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@Remark", SqlDbType.VarChar, 250) }; parameters[0].Value = model.ProductList_ID; parameters[1].Value = model.Name; parameters[2].Value = model.shortname; parameters[3].Value = model.spell; parameters[4].Value = model.s_spell; parameters[5].Value = model.ProductSpec_ID; parameters[6].Value = model.ProductUnit_ID; parameters[7].Value = model.Price; parameters[8].Value = model.Offering_Price; parameters[9].Value = model.Employee_ID; parameters[10].Value = model.CreateDate; parameters[11].Value = model.Remark; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int Product_ID) { ZhangWei.BLL.Product bll = new ZhangWei.BLL.Product(); ZhangWei.Model.Product model = bll.GetModel(Product_ID); this.lblProduct_ID.Text = model.Product_ID.ToString(); //this.lblCode.Text=model.Code.ToString(); this.lblProductList_ID.Text = new BLL.ProductList().GetModel(model.ProductList_ID).Name; this.lblName.Text = model.Name; this.lblshortname.Text = model.shortname; this.lblspell.Text = model.spell; this.lbls_spell.Text = model.s_spell; this.lblProductSpec_ID.Text = new BLL.ProductSpec().GetModel(model.ProductSpec_ID).Name; this.lblProductUnit_ID.Text = new BLL.ProductUnit().GetModel(model.ProductUnit_ID).Name; this.lblPrice.Text = model.Price.ToString(); this.lblOffering_Price.Text = model.Offering_Price.ToString(); this.lblEmployee_ID.Text = new BLL.Employee().GetModel(model.Employee_ID).Name; this.lblCreateDate.Text = model.CreateDate.ToString(); this.lblRemark.Text = model.Remark; }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; //if (!PageValidate.IsNumber(txtProductList_ID.Text)) //{ // strErr += "ProductList_ID格式错误!\\n"; //} if (Request.Form["DropDownList1"] == null) { strErr += "请选择产品分类!\\n"; } if (this.txtName.Text.Trim().Length == 0) { strErr += "名称不能为空!\\n"; } if (this.TextBox1.Text.Trim().Length == 0) { strErr += "简称不能为空!\\n"; } if (this.Offering_Price.Text.Trim().Length == 0) { strErr += "零售价不能空!\\n"; } if (this.txtPrice.Text.Trim().Length == 0) { strErr += "进价不能空!\\n"; } //if (!PageValidate.IsNumber(txtProductSpec_ID.Text)) //{ // strErr += "ProductSpec_ID格式错误!\\n"; //} //if (!PageValidate.IsNumber(txtProductUnit_ID.Text)) //{ // strErr += "ProductUnit_ID格式错误!\\n"; //} //if (!PageValidate.IsDecimal(txtPrice.Text)) //{ // strErr += "Price格式错误!\\n"; //} //if (!PageValidate.IsNumber(txtEmployee_ID.Text)) //{ // strErr += "Employee_ID格式错误!\\n"; //} //if (!PageValidate.IsDateTime(txtCreateDate.Text)) //{ // strErr += "CreateDate格式错误!\\n"; //} //if (this.txtRemark.Text.Trim().Length == 0) //{ // strErr += "Remark不能为空!\\n"; //} if (strErr != "") { MessageBox.Show(this, strErr); return; } int ProductList_ID = int.Parse(Request.Form["DropDownList1"]); string Name = this.txtName.Text; string spell = LTP.Common.Hz2Py.GetQuanPing(Name); string s_spell = LTP.Common.Hz2Py.GetPYString(Name); int ProductSpec_ID = int.Parse(this.DropDownList2.SelectedItem.Value); int ProductUnit_ID = int.Parse(this.DropDownList3.SelectedValue); decimal Price = decimal.Parse(this.txtPrice.Text); decimal Offering_Price = decimal.Parse(this.Offering_Price.Text); int Employee_ID = UserModel.Employee_ID; string shortname = this.TextBox1.Text; string Remark = this.txtRemark.Text; ZhangWei.Model.Product model = new ZhangWei.Model.Product(); model.ProductList_ID = ProductList_ID; model.Name = Name; model.spell = spell; model.s_spell = s_spell; model.ProductSpec_ID = ProductSpec_ID; model.ProductUnit_ID = ProductUnit_ID; model.Price = Price; model.Offering_Price = Offering_Price; model.Employee_ID = Employee_ID; model.CreateDate = DateTime.Now; model.Remark = Remark; model.shortname = shortname; string strWhere = "Name like '%" + Name + "%' AND ProductSpec_ID = " + ProductSpec_ID + " AND ProductUnit_ID = " + ProductUnit_ID; if (new BLL.Product().GetList(strWhere).Tables[0].Rows.Count > 0) { Maticsoft.Common.MessageBox.Show(this, "您添加的商品似乎与ID号为“" + new BLL.Product().GetList(strWhere).Tables[0].Rows[0]["Product_ID"].ToString() + "”的商品比较相像,请确认是否重复添加。"); } else { ZhangWei.BLL.Product bll = new ZhangWei.BLL.Product(); Int32 PId = bll.Add(model); Model.Product_Supplier PS = new Model.Product_Supplier(); PS.Product_ID = PId; PS.Supplier_ID = Convert.ToInt32(DropDownList5.SelectedValue); BLL.Product_Supplier bl_ps = new ZhangWei.BLL.Product_Supplier(); bl_ps.Add(PS); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "添加成功!", "add.aspx"); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; //if (!PageValidate.IsNumber(txtProductList_ID.Text)) //{ // strErr += "ProductList_ID格式错误!\\n"; //} if (DropDownList1.SelectedValue == "") { strErr += "请选择产品类别!\\n"; } if (this.txtName.Text.Trim().Length == 0) { strErr += "名称不能为空!\\n"; } //if (!PageValidate.IsNumber(txtProductSpec_ID.Text)) //{ // strErr += "ProductSpec_ID格式错误!\\n"; //} //if (!PageValidate.IsNumber(txtProductUnit_ID.Text)) //{ // strErr += "ProductUnit_ID格式错误!\\n"; //} if (!PageValidate.IsDecimal(txtPrice.Text)) { strErr += "进价格式错误!应该为货币格式\\n"; } //if (!PageValidate.IsNumber(txtEmployee_ID.Text)) //{ // strErr += "Employee_ID格式错误!\\n"; //} //if (!PageValidate.IsDateTime(txtCreateDate.Text)) //{ // strErr += "CreateDate格式错误!\\n"; //} //if (this.txtRemark.Text.Trim().Length == 0) //{ // strErr += "Remark不能为空!\\n"; //} if (strErr != "") { MessageBox.Show(this, strErr); return; } int Product_ID = int.Parse(this.lblProduct_ID.Text); //int ProductList_ID = int.Parse(this.txtProductList_ID.Text); int ProductList_ID = int.Parse(this.DropDownList1.SelectedValue); string Name = this.txtName.Text; //int ProductSpec_ID = int.Parse(this.txtProductSpec_ID.Text); int ProductSpec_ID = int.Parse(this.DropDownList2.SelectedValue); //int ProductUnit_ID = int.Parse(this.txtProductUnit_ID.Text); int ProductUnit_ID = int.Parse(this.DropDownList3.SelectedValue); decimal Price = decimal.Parse(this.txtPrice.Text); decimal Offering_Price = decimal.Parse(this.Offering_Price.Text); int Employee_ID = int.Parse(this.DropDownList4.SelectedValue); DateTime CreateDate = DateTime.Parse(this.Label1.Text); string Remark = this.txtRemark.Text; string shortname = this.TextBox1.Text; ZhangWei.Model.Product model = new ZhangWei.Model.Product(); model.Product_ID = Product_ID; model.ProductList_ID = ProductList_ID; model.Name = Name; model.ProductSpec_ID = ProductSpec_ID; model.ProductUnit_ID = ProductUnit_ID; model.Price = Price; model.Offering_Price = Offering_Price; model.Employee_ID = Employee_ID; model.CreateDate = CreateDate; model.Remark = Remark; model.spell = spell.Text; model.s_spell = s_spell.Text; model.shortname = shortname; ZhangWei.BLL.Product bll = new ZhangWei.BLL.Product(); bll.Update(model); ZhangWei.Model.Product_Supplier ml_ps = new BLL.Product_Supplier().GetModel(Product_ID); ZhangWei.BLL.Product_Supplier bl_ps = new ZhangWei.BLL.Product_Supplier(); ml_ps.Supplier_ID = Convert.ToInt32(this.DropDownList6.SelectedValue); bl_ps.Update(ml_ps); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public ZhangWei.Model.Product GetModel(int Product_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Product_ID,ProductList_ID,Name,shortname,spell,s_spell,ProductSpec_ID,ProductUnit_ID,Price,Offering_Price,Employee_ID,CreateDate,Remark from Product "); strSql.Append(" where Product_ID=@Product_ID"); SqlParameter[] parameters = { new SqlParameter("@Product_ID", SqlDbType.Int, 4) }; parameters[0].Value = Product_ID; ZhangWei.Model.Product model = new ZhangWei.Model.Product(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { 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]["ProductList_ID"] != null && ds.Tables[0].Rows[0]["ProductList_ID"].ToString() != "") { model.ProductList_ID = int.Parse(ds.Tables[0].Rows[0]["ProductList_ID"].ToString()); } if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "") { model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); } if (ds.Tables[0].Rows[0]["shortname"] != null && ds.Tables[0].Rows[0]["shortname"].ToString() != "") { model.shortname = ds.Tables[0].Rows[0]["shortname"].ToString(); } if (ds.Tables[0].Rows[0]["spell"] != null && ds.Tables[0].Rows[0]["spell"].ToString() != "") { model.spell = ds.Tables[0].Rows[0]["spell"].ToString(); } if (ds.Tables[0].Rows[0]["s_spell"] != null && ds.Tables[0].Rows[0]["s_spell"].ToString() != "") { model.s_spell = ds.Tables[0].Rows[0]["s_spell"].ToString(); } if (ds.Tables[0].Rows[0]["ProductSpec_ID"] != null && ds.Tables[0].Rows[0]["ProductSpec_ID"].ToString() != "") { model.ProductSpec_ID = int.Parse(ds.Tables[0].Rows[0]["ProductSpec_ID"].ToString()); } if (ds.Tables[0].Rows[0]["ProductUnit_ID"] != null && ds.Tables[0].Rows[0]["ProductUnit_ID"].ToString() != "") { model.ProductUnit_ID = int.Parse(ds.Tables[0].Rows[0]["ProductUnit_ID"].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]["Offering_Price"] != null && ds.Tables[0].Rows[0]["Offering_Price"].ToString() != "") { model.Offering_Price = decimal.Parse(ds.Tables[0].Rows[0]["Offering_Price"].ToString()); } if (ds.Tables[0].Rows[0]["Employee_ID"] != null && ds.Tables[0].Rows[0]["Employee_ID"].ToString() != "") { model.Employee_ID = int.Parse(ds.Tables[0].Rows[0]["Employee_ID"].ToString()); } if (ds.Tables[0].Rows[0]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString()); } if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "") { model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); } return(model); } else { return(null); } }