/// <summary> /// 得到一个对象实体 /// </summary> public Jium.Model.plib GetModel(long id, string pcode) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,pcode,pname,pdesc,pleftcnt,plupdatetime,psumcnt,psalecnt,pls1,pls2,pls3,pls4,pls5,pld1,pld2,pld3,pld4,pld5 from plib "); strSql.Append(" where id=@id and pcode=@pcode "); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.bigint, 20), new MySqlParameter("@pcode", MySqlDbType.VarChar, 20) }; parameters[0].Value = id; parameters[1].Value = pcode; Jium.Model.plib model = new Jium.Model.plib(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Jium.Model.plib model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into plib("); strSql.Append("id,pcode,pname,pdesc,pleftcnt,plupdatetime,psumcnt,psalecnt,pls1,pls2,pls3,pls4,pls5,pld1,pld2,pld3,pld4,pld5)"); strSql.Append(" values ("); strSql.Append("@id,@pcode,@pname,@pdesc,@pleftcnt,@plupdatetime,@psumcnt,@psalecnt,@pls1,@pls2,@pls3,@pls4,@pls5,@pld1,@pld2,@pld3,@pld4,@pld5)"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.bigint, 20), new MySqlParameter("@pcode", MySqlDbType.VarChar, 20), new MySqlParameter("@pname", MySqlDbType.VarChar, 50), new MySqlParameter("@pdesc", MySqlDbType.VarChar, 200), new MySqlParameter("@pleftcnt", MySqlDbType.Int32, 11), new MySqlParameter("@plupdatetime", MySqlDbType.VarChar, 20), new MySqlParameter("@psumcnt", MySqlDbType.Int32, 11), new MySqlParameter("@psalecnt", MySqlDbType.Int32, 11), new MySqlParameter("@pls1", MySqlDbType.VarChar, 20), new MySqlParameter("@pls2", MySqlDbType.VarChar, 20), new MySqlParameter("@pls3", MySqlDbType.VarChar, 20), new MySqlParameter("@pls4", MySqlDbType.VarChar, 20), new MySqlParameter("@pls5", MySqlDbType.VarChar, 20), new MySqlParameter("@pld1", MySqlDbType.Int32, 11), new MySqlParameter("@pld2", MySqlDbType.Int32, 11), new MySqlParameter("@pld3", MySqlDbType.Int32, 11), new MySqlParameter("@pld4", MySqlDbType.Int32, 11), new MySqlParameter("@pld5", MySqlDbType.Int32, 11) }; parameters[0].Value = model.id; parameters[1].Value = model.pcode; parameters[2].Value = model.pname; parameters[3].Value = model.pdesc; parameters[4].Value = model.pleftcnt; parameters[5].Value = model.plupdatetime; parameters[6].Value = model.psumcnt; parameters[7].Value = model.psalecnt; parameters[8].Value = model.pls1; parameters[9].Value = model.pls2; parameters[10].Value = model.pls3; parameters[11].Value = model.pls4; parameters[12].Value = model.pls5; parameters[13].Value = model.pld1; parameters[14].Value = model.pld2; parameters[15].Value = model.pld3; parameters[16].Value = model.pld4; parameters[17].Value = model.pld5; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo(long id, string pcode) { Jium.BLL.plib bll = new Jium.BLL.plib(); Jium.Model.plib model = bll.GetModel(id, pcode); this.lblid.Text = model.id.ToString(); this.lblpcode.Text = model.pcode; this.txtpname.Text = model.pname; this.txtpdesc.Text = model.pdesc; this.txtpleftcnt.Text = model.pleftcnt.ToString(); this.txtplupdatetime.Text = model.plupdatetime; this.txtpsumcnt.Text = model.psumcnt.ToString(); this.txtpsalecnt.Text = model.psalecnt.ToString(); this.txtpls1.Text = model.pls1; //this.txtpls2.Text=model.pls2; //this.txtpls3.Text=model.pls3; //this.txtpls4.Text=model.pls4; //this.txtpls5.Text=model.pls5; this.txtpld1.Text = model.pld1.ToString(); //this.txtpld2.Text=model.pld2.ToString(); //this.txtpld3.Text=model.pld3.ToString(); //this.txtpld4.Text=model.pld4.ToString(); //this.txtpld5.Text=model.pld5.ToString(); }
/// <summary> /// 得到一个对象实体 /// </summary> public Jium.Model.plib DataRowToModel(DataRow row) { Jium.Model.plib model = new Jium.Model.plib(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = long.Parse(row["id"].ToString()); } if (row["pcode"] != null) { model.pcode = row["pcode"].ToString(); } if (row["pname"] != null) { model.pname = row["pname"].ToString(); } if (row["pdesc"] != null) { model.pdesc = row["pdesc"].ToString(); } if (row["pleftcnt"] != null && row["pleftcnt"].ToString() != "") { model.pleftcnt = int.Parse(row["pleftcnt"].ToString()); } if (row["plupdatetime"] != null) { model.plupdatetime = row["plupdatetime"].ToString(); } if (row["psumcnt"] != null && row["psumcnt"].ToString() != "") { model.psumcnt = int.Parse(row["psumcnt"].ToString()); } if (row["psalecnt"] != null && row["psalecnt"].ToString() != "") { model.psalecnt = int.Parse(row["psalecnt"].ToString()); } if (row["pls1"] != null) { model.pls1 = row["pls1"].ToString(); } if (row["pls2"] != null) { model.pls2 = row["pls2"].ToString(); } if (row["pls3"] != null) { model.pls3 = row["pls3"].ToString(); } if (row["pls4"] != null) { model.pls4 = row["pls4"].ToString(); } if (row["pls5"] != null) { model.pls5 = row["pls5"].ToString(); } if (row["pld1"] != null && row["pld1"].ToString() != "") { model.pld1 = int.Parse(row["pld1"].ToString()); } if (row["pld2"] != null && row["pld2"].ToString() != "") { model.pld2 = int.Parse(row["pld2"].ToString()); } if (row["pld3"] != null && row["pld3"].ToString() != "") { model.pld3 = int.Parse(row["pld3"].ToString()); } if (row["pld4"] != null && row["pld4"].ToString() != "") { model.pld4 = int.Parse(row["pld4"].ToString()); } if (row["pld5"] != null && row["pld5"].ToString() != "") { model.pld5 = int.Parse(row["pld5"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Jium.Model.plib model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update plib set "); strSql.Append("pname=@pname,"); strSql.Append("pdesc=@pdesc,"); strSql.Append("pleftcnt=@pleftcnt,"); strSql.Append("plupdatetime=@plupdatetime,"); strSql.Append("psumcnt=@psumcnt,"); strSql.Append("psalecnt=@psalecnt,"); strSql.Append("pls1=@pls1,"); strSql.Append("pls2=@pls2,"); strSql.Append("pls3=@pls3,"); strSql.Append("pls4=@pls4,"); strSql.Append("pls5=@pls5,"); strSql.Append("pld1=@pld1,"); strSql.Append("pld2=@pld2,"); strSql.Append("pld3=@pld3,"); strSql.Append("pld4=@pld4,"); strSql.Append("pld5=@pld5"); strSql.Append(" where id=@id and pcode=@pcode "); MySqlParameter[] parameters = { new MySqlParameter("@pname", MySqlDbType.VarChar, 50), new MySqlParameter("@pdesc", MySqlDbType.VarChar, 200), new MySqlParameter("@pleftcnt", MySqlDbType.Int32, 11), new MySqlParameter("@plupdatetime", MySqlDbType.VarChar, 20), new MySqlParameter("@psumcnt", MySqlDbType.Int32, 11), new MySqlParameter("@psalecnt", MySqlDbType.Int32, 11), new MySqlParameter("@pls1", MySqlDbType.VarChar, 20), new MySqlParameter("@pls2", MySqlDbType.VarChar, 20), new MySqlParameter("@pls3", MySqlDbType.VarChar, 20), new MySqlParameter("@pls4", MySqlDbType.VarChar, 20), new MySqlParameter("@pls5", MySqlDbType.VarChar, 20), new MySqlParameter("@pld1", MySqlDbType.Int32, 11), new MySqlParameter("@pld2", MySqlDbType.Int32, 11), new MySqlParameter("@pld3", MySqlDbType.Int32, 11), new MySqlParameter("@pld4", MySqlDbType.Int32, 11), new MySqlParameter("@pld5", MySqlDbType.Int32, 11), new MySqlParameter("@id", MySqlDbType.bigint, 20), new MySqlParameter("@pcode", MySqlDbType.VarChar, 20) }; parameters[0].Value = model.pname; parameters[1].Value = model.pdesc; parameters[2].Value = model.pleftcnt; parameters[3].Value = model.plupdatetime; parameters[4].Value = model.psumcnt; parameters[5].Value = model.psalecnt; parameters[6].Value = model.pls1; parameters[7].Value = model.pls2; parameters[8].Value = model.pls3; parameters[9].Value = model.pls4; parameters[10].Value = model.pls5; parameters[11].Value = model.pld1; parameters[12].Value = model.pld2; parameters[13].Value = model.pld3; parameters[14].Value = model.pld4; parameters[15].Value = model.pld5; parameters[16].Value = model.id; parameters[17].Value = model.pcode; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtpname.Text.Trim().Length == 0) { strErr += "pname不能为空!\\n"; } //if(this.txtpdesc.Text.Trim().Length==0) //{ // strErr+="pdesc不能为空!\\n"; //} if (!PageValidate.IsNumber(txtpleftcnt.Text)) { strErr += "pleftcnt格式错误!\\n"; } if (this.txtplupdatetime.Text.Trim().Length == 0) { strErr += "plupdatetime不能为空!\\n"; } if (!PageValidate.IsNumber(txtpsumcnt.Text)) { strErr += "psumcnt格式错误!\\n"; } if (!PageValidate.IsNumber(txtpsalecnt.Text)) { strErr += "psalecnt格式错误!\\n"; } if (this.txtpls1.Text.Trim().Length == 0) { strErr += "pls1不能为空!\\n"; } //if(this.txtpls2.Text.Trim().Length==0) //{ // strErr+="pls2不能为空!\\n"; //} //if(this.txtpls3.Text.Trim().Length==0) //{ // strErr+="pls3不能为空!\\n"; //} //if(this.txtpls4.Text.Trim().Length==0) //{ // strErr+="pls4不能为空!\\n"; //} //if(this.txtpls5.Text.Trim().Length==0) //{ // strErr+="pls5不能为空!\\n"; //} if (!PageValidate.IsNumber(txtpld1.Text)) { strErr += "pld1格式错误!\\n"; } //if(!PageValidate.IsNumber(txtpld2.Text)) //{ // strErr+="pld2格式错误!\\n"; //} //if(!PageValidate.IsNumber(txtpld3.Text)) //{ // strErr+="pld3格式错误!\\n"; //} //if(!PageValidate.IsNumber(txtpld4.Text)) //{ // strErr+="pld4格式错误!\\n"; //} //if(!PageValidate.IsNumber(txtpld5.Text)) //{ // strErr+="pld5格式错误!\\n"; //} if (strErr != "") { MessageBox.Show(this, strErr); return; } long id = long.Parse(this.lblid.Text); string pcode = this.lblpcode.Text; string pname = this.txtpname.Text; string pdesc = this.txtpdesc.Text; int pleftcnt = int.Parse(this.txtpleftcnt.Text); string plupdatetime = this.txtplupdatetime.Text; int psumcnt = int.Parse(this.txtpsumcnt.Text); int psalecnt = int.Parse(this.txtpsalecnt.Text); string pls1 = this.txtpls1.Text; //string pls2=this.txtpls2.Text; //string pls3=this.txtpls3.Text; //string pls4=this.txtpls4.Text; //string pls5=this.txtpls5.Text; int pld1 = int.Parse(this.txtpld1.Text); //int pld2=int.Parse(this.txtpld2.Text); //int pld3=int.Parse(this.txtpld3.Text); //int pld4=int.Parse(this.txtpld4.Text); //int pld5=int.Parse(this.txtpld5.Text); Jium.Model.plib model = new Jium.Model.plib(); model.id = id; model.pcode = pcode; model.pname = pname; model.pdesc = pdesc; model.pleftcnt = pleftcnt; model.plupdatetime = plupdatetime; model.psumcnt = psumcnt; model.psalecnt = psalecnt; model.pls1 = pls1; //model.pls2=pls2; //model.pls3=pls3; //model.pls4=pls4; //model.pls5=pls5; model.pld1 = pld1; //model.pld2=pld2; //model.pld3=pld3; //model.pld4=pld4; //model.pld5=pld5; Jium.BLL.plib bll = new Jium.BLL.plib(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { try { var bres = true; do { string strErr = ""; //if(this.txtptime.Text.Trim().Length==0) //{ // strErr+="ptime不能为空!\\n"; //} if (this.txtpcode.Text.Trim().Length == 0) { strErr += "pcode不能为空!\\n"; } if (!PageValidate.IsNumber(txtpcnt.Text)) { strErr += "pcnt格式错误!\\n"; } if (!PageValidate.IsNumber(txtpsaleprice.Text) && !PageValidate.IsDecimal(txtpsaleprice.Text)) { strErr += "psaleprice格式错误!\\n"; } if (!PageValidate.IsNumber(txtprealprice.Text) && !PageValidate.IsDecimal(txtprealprice.Text)) { strErr += "prealprice格式错误!\\n"; } if (!PageValidate.IsNumber(/*txtptype.Text*/ dropptype.SelectedValue)) { strErr += "ptype格式错误!\\n"; } if (!PageValidate.IsNumber(txtpzekou.Text) && !PageValidate.IsDecimal(txtpzekou.Text)) { strErr += "pzekou格式错误!\\n"; } //if(this.txtpremark.Text.Trim().Length==0) //{ // strErr+="premark不能为空!\\n"; //} if (!PageValidate.IsNumber(txtpguestid.Text)) { strErr += "pguestid格式错误!\\n"; } if (!PageValidate.IsNumber(txtpsalerid.Text)) { strErr += "psalerid格式错误!\\n"; } if (this.txtpios1.Text.Trim().Length == 0) { strErr += "pios1不能为空!\\n"; } if (this.txtpios2.Text.Trim().Length == 0) { strErr += "pios2不能为空!\\n"; } //if(this.txtpios3.Text.Trim().Length==0) //{ // strErr+="pios3不能为空!\\n"; //} /* * if(this.txtpios4.Text.Trim().Length==0) * { * strErr+="pios4不能为空!\\n"; * } * if(this.txtpios5.Text.Trim().Length==0) * { * strErr+="pios5不能为空!\\n"; * } * if(!PageValidate.IsNumber(txtpiod1.Text)) * { * strErr+="piod1格式错误!\\n"; * } * if(!PageValidate.IsNumber(txtpiod2.Text)) * { * strErr+="piod2格式错误!\\n"; * } * if(!PageValidate.IsNumber(txtpiod3.Text)) * { * strErr+="piod3格式错误!\\n"; * } * if(!PageValidate.IsNumber(txtpiod5.Text)) * { * strErr+="piod5格式错误!\\n"; * } * if(!PageValidate.IsNumber(txtpiod4.Text)) * { * strErr+="piod4格式错误!\\n"; * } * if(!PageValidate.IsDecimal(txtpiodc1.Text)) * { * strErr+="piodc1格式错误!\\n"; * } * if(!PageValidate.IsDecimal(txtpiodc2.Text)) * { * strErr+="piodc2格式错误!\\n"; * } * if(!PageValidate.IsDecimal(txtpiodc3.Text)) * { * strErr+="piodc3格式错误!\\n"; * } * if(!PageValidate.IsDecimal(txtpiodc4.Text)) * { * strErr+="piodc4格式错误!\\n"; * } * if(!PageValidate.IsDecimal(txtpiodc5.Text)) * { * strErr+="piodc5格式错误!\\n"; * } */ if (strErr != "") { MessageBox.Show(this, strErr); return; } string ptime = DateTime.Now.ToString("yyyyMMddHHmmss");// ,this.txtptime.Text; string pcode = this.txtpcode.Text; int pcnt = int.Parse(this.txtpcnt.Text); decimal psaleprice = decimal.Parse(this.txtpsaleprice.Text); decimal prealprice = decimal.Parse(this.txtprealprice.Text); int ptype = int.Parse(/*txtptype.Text*/ dropptype.SelectedValue); decimal pzekou = decimal.Parse(this.txtpzekou.Text); string premark = this.txtpremark.Text; int pguestid = int.Parse(this.txtpguestid.Text); int psalerid = int.Parse(this.txtpsalerid.Text); string pios1 = this.txtpios1.Text; string pios2 = this.txtpios2.Text; string pios3 = this.txtpios3.Text; //string pios4=this.txtpios4.Text; //string pios5=this.txtpios5.Text; //int piod1=int.Parse(this.txtpiod1.Text); //int piod2=int.Parse(this.txtpiod2.Text); //int piod3=int.Parse(this.txtpiod3.Text); //int piod5=int.Parse(this.txtpiod5.Text); //int piod4=int.Parse(this.txtpiod4.Text); //decimal piodc1=decimal.Parse(this.txtpiodc1.Text); //decimal piodc2=decimal.Parse(this.txtpiodc2.Text); //decimal piodc3=decimal.Parse(this.txtpiodc3.Text); //decimal piodc4=decimal.Parse(this.txtpiodc4.Text); //decimal piodc5=decimal.Parse(this.txtpiodc5.Text); Jium.Model.piorecord model = new Jium.Model.piorecord(); model.ptime = ptime; model.pcode = pcode; model.pcnt = pcnt; model.psaleprice = psaleprice; model.prealprice = prealprice; model.ptype = ptype; model.pzekou = pzekou; model.premark = premark; model.pguestid = pguestid; model.psalerid = psalerid; model.pios1 = pios1; model.pios2 = pios2; model.pios3 = pios3; //model.pios4=pios4; //model.pios5=pios5; //model.piod1=piod1; //model.piod2=piod2; //model.piod3=piod3; //model.piod5=piod5; //model.piod4=piod4; //model.piodc1=piodc1; //model.piodc2=piodc2; //model.piodc3=piodc3; //model.piodc4=piodc4; //model.piodc5=piodc5; Jium.BLL.product bllProduct = new Jium.BLL.product(); Jium.BLL.plib bllPlib = new Jium.BLL.plib(); var where = string.Format("pcode='{0}'", pcode); if (bllProduct.GetRecordCount(where) == 0) { if (this.txtpios3.Text.Trim().Length == 0) { Maticsoft.Common.MessageBox.ShowAndRedirect(this, "新品请输入货品名称!", "add.aspx"); return; } Jium.Model.product pmodel = new Jium.Model.product(); pmodel.pcode = model.pcode; pmodel.pname = model.pios3; pmodel.pdesc = model.premark; pmodel.psaleprice = model.psaleprice; pmodel.prealprice = model.prealprice; pmodel.ptype = "-"; pmodel.pisgroup = 0; bllProduct.Add(pmodel); } Jium.BLL.piorecord bll = new Jium.BLL.piorecord(); if (!bll.Add(model)) { break; } var pllst = bllPlib.GetModelList(where); if (pllst.Count == 0) { Jium.Model.plib plmodel = new Jium.Model.plib(); plmodel.pcode = model.pcode; plmodel.pname = model.pios3; plmodel.psalecnt = 0; plmodel.psumcnt = 0; plmodel.pleftcnt = 0; plmodel.pdesc = model.premark; plmodel.plupdatetime = DateTime.Now.ToString("yyyyMMddHHmmss"); plmodel.pls1 = ""; plmodel.pld1 = 0; switch (model.ptype) { case 0: //销售 plmodel.psalecnt += model.pcnt; plmodel.pleftcnt -= model.pcnt; break; case 1: //进货 plmodel.psumcnt += model.pcnt; plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(model.pios2)) { plmodel.pls1 += model.pios2 + ";"; } break; case 8: //退回厂商 plmodel.psumcnt -= model.pcnt; plmodel.pleftcnt -= model.pcnt; break; case 2: //订单 plmodel.pld1 += model.pcnt; break; case 3: //盘赢 plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(model.pios2)) { plmodel.pls1 += model.pios2 + ";"; } break; case 4: //盘亏 plmodel.pleftcnt -= model.pcnt; break; case 5: //退货 //plmodel.psalecnt -= model.pcnt; //plmodel.pleftcnt += model.pcnt; //break; case 6: //换货进 plmodel.psalecnt -= model.pcnt; plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(plmodel.pls1)) { plmodel.pls1 += model.pios2 + ";"; } break; case 7: //换货出 plmodel.psalecnt += model.pcnt; plmodel.pleftcnt -= model.pcnt; break; } bllPlib.Add(plmodel); } else { Jium.Model.plib plmodel = pllst[0]; plmodel.plupdatetime = DateTime.Now.ToString("yyyyMMddHHmmss"); switch (model.ptype) { case 0: //销售 plmodel.psalecnt += model.pcnt; plmodel.pleftcnt -= model.pcnt; break; case 1: //进货 plmodel.psumcnt += model.pcnt; plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(plmodel.pls1)) { plmodel.pls1 += model.pios2 + ";"; } break; case 8: //退回厂商 plmodel.psumcnt -= model.pcnt; plmodel.pleftcnt -= model.pcnt; break; case 2: //订单 plmodel.pld1 += model.pcnt; break; case 3: //盘赢 plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(plmodel.pls1)) { plmodel.pls1 += model.pios2 + ";"; } break; case 4: //盘亏 plmodel.pleftcnt -= model.pcnt; break; case 5: //退货 //plmodel.psalecnt -= model.pcnt; //plmodel.pleftcnt += model.pcnt; //break; case 6: //换货进 plmodel.psalecnt -= model.pcnt; plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(plmodel.pls1)) { plmodel.pls1 += model.pios2 + ";"; } break; case 7: //换货出 plmodel.psalecnt += model.pcnt; plmodel.pleftcnt -= model.pcnt; break; } bllPlib.Update(plmodel); } Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); return; } while (false); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存失败!", "add.aspx"); } catch (Exception ex) { Maticsoft.Common.MessageBox.ShowAndRedirect(this, "Error!" + ex.Message, "add.aspx"); } }
public static bool AddPiorecord(Jium.Model.piorecord model) { var bres = true; try { do { Jium.BLL.product bllProduct = new Jium.BLL.product(); Jium.BLL.plib bllPlib = new Jium.BLL.plib(); var where = string.Format("pcode='{0}'", model.pcode); if (bllProduct.GetRecordCount(where) == 0) { Jium.Model.product pmodel = new Jium.Model.product(); pmodel.pcode = model.pcode; pmodel.pname = model.pios3; pmodel.pdesc = model.premark; pmodel.psaleprice = model.psaleprice; pmodel.prealprice = model.prealprice; pmodel.ptype = model.pios5; //系列 pmodel.ps1 = model.pios4; //单位 pmodel.pisgroup = 0; bres = bllProduct.Add(pmodel); if (!bres) { break; } } Jium.BLL.piorecord bll = new Jium.BLL.piorecord(); bres = bll.Add(model); if (!bres) { break; } var pllst = bllPlib.GetModelList(where); if (pllst.Count == 0) { Jium.Model.plib plmodel = new Jium.Model.plib(); plmodel.pcode = model.pcode; plmodel.pname = model.pios3; plmodel.psalecnt = 0; plmodel.psumcnt = 0; plmodel.pleftcnt = 0; plmodel.pdesc = model.premark; plmodel.plupdatetime = DateTime.Now.ToString("yyyyMMddHHmmss"); plmodel.pls1 = ""; plmodel.pls2 = model.pios4; plmodel.pld1 = 0; switch ((PRODUCT_IO_TYPE)model.ptype) { case PRODUCT_IO_TYPE.SALE: //销售 plmodel.psalecnt += model.pcnt; plmodel.pleftcnt -= model.pcnt; break; case PRODUCT_IO_TYPE.ORDERIN: //进货 plmodel.psumcnt += model.pcnt; plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(model.pios2)) { plmodel.pls1 += model.pios2 + ";"; } break; case PRODUCT_IO_TYPE.RETURN: //退回厂商 plmodel.psumcnt -= model.pcnt; plmodel.pleftcnt -= model.pcnt; break; case PRODUCT_IO_TYPE.ORDERPLAN: //订单 plmodel.pld1 += model.pcnt; break; case PRODUCT_IO_TYPE.SUMADD: //盘赢 plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(model.pios2)) { plmodel.pls1 += model.pios2 + ";"; } break; case PRODUCT_IO_TYPE.SUMPLUS: //盘亏 plmodel.pleftcnt -= model.pcnt; break; case PRODUCT_IO_TYPE.REJECT: //退货 //plmodel.psalecnt -= model.pcnt; //plmodel.pleftcnt += model.pcnt; //break; case PRODUCT_IO_TYPE.RECHARGEIN: //换货进 plmodel.psalecnt -= model.pcnt; plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(plmodel.pls1)) { plmodel.pls1 += model.pios2 + ";"; } break; case PRODUCT_IO_TYPE.RECHARGEOUT: //换货出 plmodel.psalecnt += model.pcnt; plmodel.pleftcnt -= model.pcnt; break; } bres = bllPlib.Add(plmodel); } else { Jium.Model.plib plmodel = pllst[0]; plmodel.plupdatetime = DateTime.Now.ToString("yyyyMMddHHmmss"); switch ((PRODUCT_IO_TYPE)model.ptype) { case PRODUCT_IO_TYPE.SALE: //销售 plmodel.psalecnt += model.pcnt; plmodel.pleftcnt -= model.pcnt; break; case PRODUCT_IO_TYPE.ORDERIN: //进货 plmodel.psumcnt += model.pcnt; plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(model.pios2)) { plmodel.pls1 += model.pios2 + ";"; } break; case PRODUCT_IO_TYPE.RETURN: //退回厂商 plmodel.psumcnt -= model.pcnt; plmodel.pleftcnt -= model.pcnt; break; case PRODUCT_IO_TYPE.ORDERPLAN: //订单 plmodel.pld1 += model.pcnt; break; case PRODUCT_IO_TYPE.SUMADD: //盘赢 plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(model.pios2)) { plmodel.pls1 += model.pios2 + ";"; } break; case PRODUCT_IO_TYPE.SUMPLUS: //盘亏 plmodel.pleftcnt -= model.pcnt; break; case PRODUCT_IO_TYPE.REJECT: //退货 //plmodel.psalecnt -= model.pcnt; //plmodel.pleftcnt += model.pcnt; //break; case PRODUCT_IO_TYPE.RECHARGEIN: //换货进 plmodel.psalecnt -= model.pcnt; plmodel.pleftcnt += model.pcnt; if (!plmodel.pls1.Contains(plmodel.pls1)) { plmodel.pls1 += model.pios2 + ";"; } break; case PRODUCT_IO_TYPE.RECHARGEOUT: //换货出 plmodel.psalecnt += model.pcnt; plmodel.pleftcnt -= model.pcnt; break; } bres = bllPlib.Update(plmodel); } return(bres); } while (false); } catch (Exception ex) { bres = false; } return(false);; }