private void ShowInfo(long id) { Jium.BLL.consumerservice bll = new Jium.BLL.consumerservice(); Jium.Model.consumerservice model = bll.GetModel(id); this.lblid.Text = model.id.ToString(); this.txtccode.Text = model.ccode; this.txtcphone.Text = model.cphone; this.txtcstype.Text = model.cstype; this.txtcsnum.Text = model.csnum.ToString(); this.txtcsleft.Text = model.csleft.ToString(); this.txtcsiostatus.Text = model.csiostatus.ToString(); this.txtcstime0.Text = model.cstime0; this.txtcstime1.Text = model.cstime1; this.txtcstime2.Text = model.cstime2; this.txtcstime3.Text = model.cstime3; this.txtcstime4.Text = model.cstime4; this.txtcstime5.Text = model.cstime5; this.txtcstime6.Text = model.cstime6; this.txtcstime7.Text = model.cstime7; this.txtcstime8.Text = model.cstime8; this.txtcstime9.Text = model.cstime9; this.txtcstime10.Text = model.cstime10; //this.txtcss1.Text=model.css1; //this.txtcss2.Text=model.css2; //this.txtcss3.Text=model.css3; //this.txtcss4.Text=model.css4; //this.txtcss5.Text=model.css5; //this.txtcsd1.Text=model.csd1; //this.txtcsd2.Text=model.csd2; //this.txtcsd3.Text=model.csd3; //this.txtcsd4.Text=model.csd4; //this.txtcsd5.Text=model.csd5; }
/// <summary> /// 得到一个对象实体 /// </summary> public Jium.Model.consumerservice GetModel(long id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,ccode,cphone,cstype,csnum,csleft,csiostatus,cstime0,cstime1,cstime2,cstime3,cstime4,cstime5,cstime6,cstime7,cstime8,cstime9,cstime10,css1,css2,css3,css4,css5,csd1,csd2,csd3,csd4,csd5 from consumerservice "); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int64) }; parameters[0].Value = id; Jium.Model.consumerservice model = new Jium.Model.consumerservice(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtccode.Text.Trim().Length == 0) { strErr += "ccode不能为空!\\n"; } if (this.txtcphone.Text.Trim().Length == 0) { strErr += "cphone不能为空!\\n"; } if (this.txtcstype.Text.Trim().Length == 0) { strErr += "cstype不能为空!\\n"; } if (!PageValidate.IsNumber(txtcsnum.Text)) { strErr += "csnum格式错误!\\n"; } if (!PageValidate.IsNumber(txtcsleft.Text)) { strErr += "csleft格式错误!\\n"; } if (!PageValidate.IsNumber(txtcsiostatus.Text)) { strErr += "csiostatus格式错误!\\n"; } if (this.txtcstime0.Text.Trim().Length == 0) { strErr += "cstime0不能为空!\\n"; } if (this.txtcstime1.Text.Trim().Length == 0) { strErr += "cstime1不能为空!\\n"; } if (this.txtcstime2.Text.Trim().Length == 0) { strErr += "cstime2不能为空!\\n"; } if (this.txtcstime3.Text.Trim().Length == 0) { strErr += "cstime3不能为空!\\n"; } if (this.txtcstime4.Text.Trim().Length == 0) { strErr += "cstime4不能为空!\\n"; } if (this.txtcstime5.Text.Trim().Length == 0) { strErr += "cstime5不能为空!\\n"; } if (this.txtcstime6.Text.Trim().Length == 0) { strErr += "cstime6不能为空!\\n"; } if (this.txtcstime7.Text.Trim().Length == 0) { strErr += "cstime7不能为空!\\n"; } if (this.txtcstime8.Text.Trim().Length == 0) { strErr += "cstime8不能为空!\\n"; } if (this.txtcstime9.Text.Trim().Length == 0) { strErr += "cstime9不能为空!\\n"; } if (this.txtcstime10.Text.Trim().Length == 0) { strErr += "cstime10不能为空!\\n"; } if (this.txtcss1.Text.Trim().Length == 0) { strErr += "css1不能为空!\\n"; } if (this.txtcss2.Text.Trim().Length == 0) { strErr += "css2不能为空!\\n"; } if (this.txtcss3.Text.Trim().Length == 0) { strErr += "css3不能为空!\\n"; } if (this.txtcss4.Text.Trim().Length == 0) { strErr += "css4不能为空!\\n"; } if (this.txtcss5.Text.Trim().Length == 0) { strErr += "css5不能为空!\\n"; } if (this.txtcsd1.Text.Trim().Length == 0) { strErr += "csd1不能为空!\\n"; } if (this.txtcsd2.Text.Trim().Length == 0) { strErr += "csd2不能为空!\\n"; } if (this.txtcsd3.Text.Trim().Length == 0) { strErr += "csd3不能为空!\\n"; } if (this.txtcsd4.Text.Trim().Length == 0) { strErr += "csd4不能为空!\\n"; } if (this.txtcsd5.Text.Trim().Length == 0) { strErr += "csd5不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string ccode = this.txtccode.Text; string cphone = this.txtcphone.Text; string cstype = this.txtcstype.Text; int csnum = int.Parse(this.txtcsnum.Text); int csleft = int.Parse(this.txtcsleft.Text); int csiostatus = int.Parse(this.txtcsiostatus.Text); string cstime0 = this.txtcstime0.Text; string cstime1 = this.txtcstime1.Text; string cstime2 = this.txtcstime2.Text; string cstime3 = this.txtcstime3.Text; string cstime4 = this.txtcstime4.Text; string cstime5 = this.txtcstime5.Text; string cstime6 = this.txtcstime6.Text; string cstime7 = this.txtcstime7.Text; string cstime8 = this.txtcstime8.Text; string cstime9 = this.txtcstime9.Text; string cstime10 = this.txtcstime10.Text; string css1 = this.txtcss1.Text; string css2 = this.txtcss2.Text; string css3 = this.txtcss3.Text; string css4 = this.txtcss4.Text; string css5 = this.txtcss5.Text; string csd1 = this.txtcsd1.Text; string csd2 = this.txtcsd2.Text; string csd3 = this.txtcsd3.Text; string csd4 = this.txtcsd4.Text; string csd5 = this.txtcsd5.Text; Jium.Model.consumerservice model = new Jium.Model.consumerservice(); model.ccode = ccode; model.cphone = cphone; model.cstype = cstype; model.csnum = csnum; model.csleft = csleft; model.csiostatus = csiostatus; model.cstime0 = cstime0; model.cstime1 = cstime1; model.cstime2 = cstime2; model.cstime3 = cstime3; model.cstime4 = cstime4; model.cstime5 = cstime5; model.cstime6 = cstime6; model.cstime7 = cstime7; model.cstime8 = cstime8; model.cstime9 = cstime9; model.cstime10 = cstime10; model.css1 = css1; model.css2 = css2; model.css3 = css3; model.css4 = css4; model.css5 = css5; model.csd1 = csd1; model.csd2 = csd2; model.csd3 = csd3; model.csd4 = csd4; model.csd5 = csd5; Jium.BLL.consumerservice bll = new Jium.BLL.consumerservice(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Jium.Model.consumerservice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into consumerservice("); strSql.Append("ccode,cphone,cstype,csnum,csleft,csiostatus,cstime0,cstime1,cstime2,cstime3,cstime4,cstime5,cstime6,cstime7,cstime8,cstime9,cstime10,css1,css2,css3,css4,css5,csd1,csd2,csd3,csd4,csd5)"); strSql.Append(" values ("); strSql.Append("@ccode,@cphone,@cstype,@csnum,@csleft,@csiostatus,@cstime0,@cstime1,@cstime2,@cstime3,@cstime4,@cstime5,@cstime6,@cstime7,@cstime8,@cstime9,@cstime10,@css1,@css2,@css3,@css4,@css5,@csd1,@csd2,@csd3,@csd4,@csd5)"); MySqlParameter[] parameters = { new MySqlParameter("@ccode", MySqlDbType.VarChar, 20), new MySqlParameter("@cphone", MySqlDbType.VarChar, 20), new MySqlParameter("@cstype", MySqlDbType.VarChar, 40), new MySqlParameter("@csnum", MySqlDbType.Int32, 11), new MySqlParameter("@csleft", MySqlDbType.Int32, 11), new MySqlParameter("@csiostatus", MySqlDbType.Int32, 11), new MySqlParameter("@cstime0", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime1", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime2", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime3", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime4", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime5", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime6", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime7", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime8", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime9", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime10", MySqlDbType.VarChar, 20), new MySqlParameter("@css1", MySqlDbType.VarChar, 20), new MySqlParameter("@css2", MySqlDbType.VarChar, 20), new MySqlParameter("@css3", MySqlDbType.VarChar, 20), new MySqlParameter("@css4", MySqlDbType.VarChar, 20), new MySqlParameter("@css5", MySqlDbType.VarChar, 20), new MySqlParameter("@csd1", MySqlDbType.VarChar, 20), new MySqlParameter("@csd2", MySqlDbType.VarChar, 20), new MySqlParameter("@csd3", MySqlDbType.VarChar, 20), new MySqlParameter("@csd4", MySqlDbType.VarChar, 20), new MySqlParameter("@csd5", MySqlDbType.VarChar, 20) }; parameters[0].Value = model.ccode; parameters[1].Value = model.cphone; parameters[2].Value = model.cstype; parameters[3].Value = model.csnum; parameters[4].Value = model.csleft; parameters[5].Value = model.csiostatus; parameters[6].Value = model.cstime0; parameters[7].Value = model.cstime1; parameters[8].Value = model.cstime2; parameters[9].Value = model.cstime3; parameters[10].Value = model.cstime4; parameters[11].Value = model.cstime5; parameters[12].Value = model.cstime6; parameters[13].Value = model.cstime7; parameters[14].Value = model.cstime8; parameters[15].Value = model.cstime9; parameters[16].Value = model.cstime10; parameters[17].Value = model.css1; parameters[18].Value = model.css2; parameters[19].Value = model.css3; parameters[20].Value = model.css4; parameters[21].Value = model.css5; parameters[22].Value = model.csd1; parameters[23].Value = model.csd2; parameters[24].Value = model.csd3; parameters[25].Value = model.csd4; parameters[26].Value = model.csd5; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Jium.Model.consumerservice DataRowToModel(DataRow row) { Jium.Model.consumerservice model = new Jium.Model.consumerservice(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = long.Parse(row["id"].ToString()); } if (row["ccode"] != null) { model.ccode = row["ccode"].ToString(); } if (row["cphone"] != null) { model.cphone = row["cphone"].ToString(); } if (row["cstype"] != null) { model.cstype = row["cstype"].ToString(); } if (row["csnum"] != null && row["csnum"].ToString() != "") { model.csnum = int.Parse(row["csnum"].ToString()); } if (row["csleft"] != null && row["csleft"].ToString() != "") { model.csleft = int.Parse(row["csleft"].ToString()); } if (row["csiostatus"] != null && row["csiostatus"].ToString() != "") { model.csiostatus = int.Parse(row["csiostatus"].ToString()); } if (row["cstime0"] != null) { model.cstime0 = row["cstime0"].ToString(); } if (row["cstime1"] != null) { model.cstime1 = row["cstime1"].ToString(); } if (row["cstime2"] != null) { model.cstime2 = row["cstime2"].ToString(); } if (row["cstime3"] != null) { model.cstime3 = row["cstime3"].ToString(); } if (row["cstime4"] != null) { model.cstime4 = row["cstime4"].ToString(); } if (row["cstime5"] != null) { model.cstime5 = row["cstime5"].ToString(); } if (row["cstime6"] != null) { model.cstime6 = row["cstime6"].ToString(); } if (row["cstime7"] != null) { model.cstime7 = row["cstime7"].ToString(); } if (row["cstime8"] != null) { model.cstime8 = row["cstime8"].ToString(); } if (row["cstime9"] != null) { model.cstime9 = row["cstime9"].ToString(); } if (row["cstime10"] != null) { model.cstime10 = row["cstime10"].ToString(); } if (row["css1"] != null) { model.css1 = row["css1"].ToString(); } if (row["css2"] != null) { model.css2 = row["css2"].ToString(); } if (row["css3"] != null) { model.css3 = row["css3"].ToString(); } if (row["css4"] != null) { model.css4 = row["css4"].ToString(); } if (row["css5"] != null) { model.css5 = row["css5"].ToString(); } if (row["csd1"] != null) { model.csd1 = row["csd1"].ToString(); } if (row["csd2"] != null) { model.csd2 = row["csd2"].ToString(); } if (row["csd3"] != null) { model.csd3 = row["csd3"].ToString(); } if (row["csd4"] != null) { model.csd4 = row["csd4"].ToString(); } if (row["csd5"] != null) { model.csd5 = row["csd5"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Jium.Model.consumerservice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update consumerservice set "); strSql.Append("ccode=@ccode,"); strSql.Append("cphone=@cphone,"); strSql.Append("cstype=@cstype,"); strSql.Append("csnum=@csnum,"); strSql.Append("csleft=@csleft,"); strSql.Append("csiostatus=@csiostatus,"); strSql.Append("cstime0=@cstime0,"); strSql.Append("cstime1=@cstime1,"); strSql.Append("cstime2=@cstime2,"); strSql.Append("cstime3=@cstime3,"); strSql.Append("cstime4=@cstime4,"); strSql.Append("cstime5=@cstime5,"); strSql.Append("cstime6=@cstime6,"); strSql.Append("cstime7=@cstime7,"); strSql.Append("cstime8=@cstime8,"); strSql.Append("cstime9=@cstime9,"); strSql.Append("cstime10=@cstime10,"); strSql.Append("css1=@css1,"); strSql.Append("css2=@css2,"); strSql.Append("css3=@css3,"); strSql.Append("css4=@css4,"); strSql.Append("css5=@css5,"); strSql.Append("csd1=@csd1,"); strSql.Append("csd2=@csd2,"); strSql.Append("csd3=@csd3,"); strSql.Append("csd4=@csd4,"); strSql.Append("csd5=@csd5"); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@ccode", MySqlDbType.VarChar, 20), new MySqlParameter("@cphone", MySqlDbType.VarChar, 20), new MySqlParameter("@cstype", MySqlDbType.VarChar, 40), new MySqlParameter("@csnum", MySqlDbType.Int32, 11), new MySqlParameter("@csleft", MySqlDbType.Int32, 11), new MySqlParameter("@csiostatus", MySqlDbType.Int32, 11), new MySqlParameter("@cstime0", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime1", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime2", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime3", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime4", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime5", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime6", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime7", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime8", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime9", MySqlDbType.VarChar, 20), new MySqlParameter("@cstime10", MySqlDbType.VarChar, 20), new MySqlParameter("@css1", MySqlDbType.VarChar, 20), new MySqlParameter("@css2", MySqlDbType.VarChar, 20), new MySqlParameter("@css3", MySqlDbType.VarChar, 20), new MySqlParameter("@css4", MySqlDbType.VarChar, 20), new MySqlParameter("@css5", MySqlDbType.VarChar, 20), new MySqlParameter("@csd1", MySqlDbType.VarChar, 20), new MySqlParameter("@csd2", MySqlDbType.VarChar, 20), new MySqlParameter("@csd3", MySqlDbType.VarChar, 20), new MySqlParameter("@csd4", MySqlDbType.VarChar, 20), new MySqlParameter("@csd5", MySqlDbType.VarChar, 20), new MySqlParameter("@id", MySqlDbType.Int64, 20) }; parameters[0].Value = model.ccode; parameters[1].Value = model.cphone; parameters[2].Value = model.cstype; parameters[3].Value = model.csnum; parameters[4].Value = model.csleft; parameters[5].Value = model.csiostatus; parameters[6].Value = model.cstime0; parameters[7].Value = model.cstime1; parameters[8].Value = model.cstime2; parameters[9].Value = model.cstime3; parameters[10].Value = model.cstime4; parameters[11].Value = model.cstime5; parameters[12].Value = model.cstime6; parameters[13].Value = model.cstime7; parameters[14].Value = model.cstime8; parameters[15].Value = model.cstime9; parameters[16].Value = model.cstime10; parameters[17].Value = model.css1; parameters[18].Value = model.css2; parameters[19].Value = model.css3; parameters[20].Value = model.css4; parameters[21].Value = model.css5; parameters[22].Value = model.csd1; parameters[23].Value = model.csd2; parameters[24].Value = model.csd3; parameters[25].Value = model.csd4; parameters[26].Value = model.csd5; parameters[27].Value = model.id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected void btnConfirmSale_Click(object sender, EventArgs e) { try { //#warning 代码生成警告:请检查确认真实主键的名称和类型是否正确 string orderid = DateTime.Now.ToString("yyyyMMddHHmmss"); var lstModel = new List <Jium.Model.piorecord>(); for (int i = 0; i < gridViewBuy.Rows.Count; i++) { var model = new Jium.Model.piorecord(); model.pcode = gridViewBuy.Rows[i].Cells[0].Text; model.pios3 = gridViewBuy.Rows[i].Cells[1].Text; model.psaleprice = decimal.Parse(gridViewBuy.Rows[i].Cells[3].Text); model.pcnt = int.Parse(gridViewBuy.Rows[i].Cells[5].Text); model.pzekou = decimal.Parse(gridViewBuy.Rows[i].Cells[6].Text); model.psalerid = 0; model.ptype = (int)PRODUCT_IO_TYPE.SALE;; model.ptime = orderid; model.pguestid = int.Parse(txtCcode.Text); var txtNum = gridViewBuy.Rows[i].Cells[4].Text.Trim(); model.piod1 = string.IsNullOrWhiteSpace(txtNum.Replace(" ", "")) ? 0 : int.Parse(gridViewBuy.Rows[i].Cells[4].Text); //服务 model.pios4 = gridViewBuy.Rows[i].Cells[2].Text.Replace(" ", ""); //单位 model.piod5 = 5; //model.pios5 = cells[i, 0].StringValue.Trim();//系列 model.pios1 = "销售"; lstModel.Add(model); } ERR_CODE iRes = ERR_CODE.SUCCESS; ///事务回滚机制??? var bllCustomeService = new Jium.BLL.consumerservice(); foreach (var model in lstModel) { if (!Ctrl.piorecord.AddPiorecord(model)) { iRes = ERR_CODE.FAIL; break; } if (model.piod1 > 0)//add service for guset { var consumerservice = new Jium.Model.consumerservice(); consumerservice.ccode = model.pguestid.ToString(); consumerservice.csnum = model.piod1 ?? 0; consumerservice.cstype = model.pios3; consumerservice.csleft = model.piod1 ?? 0; consumerservice.csiostatus = 0; consumerservice.cstime0 = orderid; consumerservice.csd5 = "5"; bllCustomeService.Add(consumerservice); } } //update guest info var consumerBll = new Jium.BLL.consumer(); var lstConsumer = consumerBll.GetModelList(string.Format("ccode='{0}' and csd5=5", txtCcode.Text.Trim())); if (lstConsumer.Count == 0) { ///error ///return; } lstConsumer[0].css1 = orderid; lstConsumer[0].csum += decimal.Parse(txtSumReal.Text); lstConsumer[0].clevel = Jium.BLL.consumer.getLevelByConsume(lstConsumer[0].csum).ToString();//get from csum consumerBll.Update(lstConsumer[0]); Maticsoft.Common.MessageBox.ShowAndRedirects(this, "操作完成!", "/default.aspx"); } catch (Exception ex) { Maticsoft.Common.MessageBox.Show(this, "系统错误:" + ex.Message); return; } }