/// <summary> /// 收款确定按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { int id = Convert.ToInt32(Label1.Text); Model.OrderTab er = ot.GetModel(id); if (DropDownList8.Text == "0") { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('没选择收款状况!');</script>"); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv2();</script>"); } else { er.Zhuangtai2 = Convert.ToInt32(DropDownList8.Text); er.Deposit = er.Deposit + Convert.ToDecimal(TextBox1.Text); Model.Currentaccount cu = new Model.Currentaccount(); cu.billnumber = er.OrderNumber; cu.type = 2; cu.receipt = DateTime.Now; cu.money = Convert.ToDecimal(TextBox1.Text); int b = cur.Add(cu); bool a = ot.Update(er); if (a == true && b > 0) { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('收款成功');</script>"); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('收款失败');</script>"); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv2();</script>"); } } }
public string orderadd(string json) { try { json = @"{""OrderNumber"":""201812050001"",""MemberName"":""李四先生"",""MemberPhone"":""12356565656"",""MemberPhone1"":"""",""MemberAdd"":""铁西区南十路23号2-3-2"",""HomemadeID"":""2"",""StaffmemberID"":""2"",""UserTabID"":""3"",""PhotoID1"":""3"",""PhotoID2"":"""",""PhotoID3"":"""",""PhotoID4"":""5"",""validity"":""2018-12-06"",""Deposit"":""400.50"",""AllMoney"":""4500.50"",""alllength"":""33.22"",""Imperial"":""22.22"",""QhWidth"":""11.11"",""Beizhuwg"":""外购商品备注!!"",""Beizhuzz"":""自制商品备注!!"",""Zengsong"":""赠品备注"",""Zhuangtai2"":""1"",""table"": [{""CommodityID"": ""桌子卡门"",""by1"": ""1""}, {""CommodityID"": ""椅子卡门"",""by1"": ""2""}]}"; JObject joo = (JObject)JsonConvert.DeserializeObject(json); string OrderNumber = joo["OrderNumber"].ToString(); string MemberName = joo["MemberName"].ToString(); string MemberPhone = joo["MemberPhone"].ToString(); string MemberPhone1 = joo["MemberPhone1"].ToString(); string MemberAdd = joo["MemberAdd"].ToString(); string HomemadeID = joo["HomemadeID"].ToString(); string StaffmemberID = joo["StaffmemberID"].ToString(); string UserTabID = joo["UserTabID"].ToString(); string PhotoID1 = joo["PhotoID1"].ToString(); string PhotoID2 = joo["PhotoID2"].ToString(); string PhotoID3 = joo["PhotoID3"].ToString(); string PhotoID4 = joo["PhotoID4"].ToString(); string validity = joo["validity"].ToString(); string Deposit = joo["Deposit"].ToString(); string AllMoney = joo["AllMoney"].ToString(); string alllength = joo["alllength"].ToString(); string Imperial = joo["Imperial"].ToString(); string QhWidth = joo["QhWidth"].ToString(); string Beizhuwg = joo["Beizhuwg"].ToString(); string Beizhuzz = joo["Beizhuzz"].ToString(); string Zengsong = joo["Zengsong"].ToString(); string Zhuangtai2 = joo["Zhuangtai2"].ToString(); string table = joo["table"].ToString(); DataSet ds = ot.GetList(" validity='" + validity + "'"); if (ds.Tables[0].Rows.Count >= 15) { return(@"{""data"":{""ds"":""2""}}"); } else { JArray je = (JArray)JsonConvert.DeserializeObject(table); DataTable spb = new DataTable(); spb.Columns.Add("CommodityID"); spb.Columns.Add("by1"); foreach (JObject iom in je) { spb.Rows.Add(iom["CommodityID"].ToString(), iom["by1"].ToString()); } string qrEncoding = "BYTE"; string level = "M"; int version = 8; int scale = 3; QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); string encoding = qrEncoding; switch (encoding) { case "Byte": qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; break; case "AlphaNumeric": qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC; break; case "Numeric": qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.NUMERIC; break; default: qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; break; } qrCodeEncoder.QRCodeScale = scale; qrCodeEncoder.QRCodeVersion = version; switch (level) { case "L": qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L; break; case "M": qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; break; case "Q": qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q; break; default: qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H; break; } string serial = @"http://192.168.1.150:8585/xianshi.asmx/jiekou?id=" + OrderNumber; System.Drawing.Image image = qrCodeEncoder.Encode(serial); string filename = OrderNumber + ".jpg"; string filepath = Server.MapPath(@"~\qrcode111") + "\\" + filename; //如果文件夹不存在,则创建 //if (!Directory.Exists(filepath)) // Directory.CreateDirectory(filepath); System.IO.FileStream fs = new System.IO.FileStream(filepath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write); image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg); fs.Close(); image.Dispose(); Model.OrderTab ort = new Model.OrderTab(); ort.MemberName = MemberName; ort.MemberPhone = MemberPhone; ort.MemberPhone1 = MemberPhone1; ort.MemberAdd = MemberAdd; ort.Orderdate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); ort.OrderNumber = OrderNumber; ort.UserTabID = Convert.ToInt32(UserTabID); if (PhotoID1 != "") { ort.PhotoID1 = Convert.ToInt32(PhotoID1); } else { ort.PhotoID1 = 0; } if (PhotoID2 != "") { ort.PhotoID2 = Convert.ToInt32(PhotoID2); } else { ort.PhotoID2 = 0; } if (PhotoID3 != "") { ort.PhotoID3 = Convert.ToInt32(PhotoID3); } else { ort.PhotoID3 = 0; } if (PhotoID4 != "") { ort.PhotoID4 = Convert.ToInt32(PhotoID4); } else { ort.PhotoID4 = 0; } ort.qrcode = "../qrcode111/" + filename; ort.validity = Convert.ToDateTime(validity); ort.progress = 0; ort.AllMoney = Convert.ToDecimal(AllMoney); if (Deposit == "") { ort.Deposit = 0; } else { ort.Deposit = Convert.ToDecimal(Deposit); } ort.alllength = Convert.ToDecimal(alllength); ort.Imperial = Convert.ToDecimal(Imperial); ort.QhWidth = Convert.ToDecimal(QhWidth); ort.Beizhuwg = Beizhuwg; ort.Beizhuzz = Beizhuzz; ort.Zengsong = Zengsong; ort.Zhuangtai1 = 0;//草稿 ort.Zhuangtai2 = Convert.ToInt32(Zhuangtai2); ort.StaffmemberID = Convert.ToInt32(StaffmemberID); ort.HomemadeID = Convert.ToInt32(HomemadeID); if (spb.Rows.Count > 0) { for (int i = 0; i < spb.Rows.Count; i++) { Model.ContractTab con = new Model.ContractTab(); con.OrderNumber = OrderNumber; con.CommodityID = spb.Rows[i]["CommodityID"].ToString(); con.By1 = Convert.ToDecimal(spb.Rows[i]["By1"]); ct.Add(con); } } Model.Currentaccount cu = new Model.Currentaccount(); cu.billnumber = OrderNumber; cu.type = 1; cu.receipt = DateTime.Now; if (Deposit == "") { cu.money = 0; } else { cu.money = Convert.ToDecimal(Deposit); } int b = cur.Add(cu); int a = ot.Add(ort); if (a > 0 && b > 0) { return(@"{""data"":{""ds"":""1""}}"); } else { return(@"{""data"":{""ds"":""0""}}"); } } } catch (Exception ee) { return(@"{""data"":{""ds"":""-1"",""sm"":""数据处理有误:" + ee.Message + "\"}}"); } }
/// <summary> /// 生成单据方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { if (zzspid == 0) { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('请选择自制商品');</script>"); } else { if (TextBox7.Text.Trim() == "") { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('请添客户名称');</script>"); } else { if (TextBox8.Text.Trim() == "" && TextBox9.Text.Trim() == "") { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('至少添加一个电话号');</script>"); } else { if (TextBox10.Text.Trim() == "") { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('请添客户地址');</script>"); } else { if (TextBox1.Text.Trim() == "") { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('请添总长');</script>"); } else { if (TextBox2.Text.Trim() == "") { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('请添妃长');</script>"); } else { if (TextBox3.Text.Trim() == "") { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('请添前后宽');</script>"); } else { if (TextBox11.Text.Trim() == "") { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('请选送货日期');</script>"); } else { if (TextBox12.Text.Trim() == "") { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('请添单据总金额');</script>"); } else { DataSet ds = ot.GetList(" validity='" + TextBox11.Text + "'"); if (ds.Tables[0].Rows.Count >= 15) { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('以达到送货上线');</script>"); } else { if (DropDownList8.Text == "0") { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('请选择付款状况');</script>"); } else { string qrEncoding = "BYTE"; string level = "M"; int version = 8; int scale = 3; QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); string encoding = qrEncoding; switch (encoding) { case "Byte": qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; break; case "AlphaNumeric": qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC; break; case "Numeric": qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.NUMERIC; break; default: qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; break; } qrCodeEncoder.QRCodeScale = scale; qrCodeEncoder.QRCodeVersion = version; switch (level) { case "L": qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L; break; case "M": qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; break; case "Q": qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q; break; default: qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H; break; } string serial = @"http://192.168.1.150:8585/xianshi.asmx/jiekou?id=" + Label1.Text; System.Drawing.Image image = qrCodeEncoder.Encode(serial); string filename = Label1.Text + ".jpg"; string filepath = Server.MapPath(@"~\qrcode111") + "\\" + filename; //如果文件夹不存在,则创建 //if (!Directory.Exists(filepath)) // Directory.CreateDirectory(filepath); System.IO.FileStream fs = new System.IO.FileStream(filepath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write); image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg); fs.Close(); image.Dispose(); Model.OrderTab ort = new Model.OrderTab(); ort.MemberName = TextBox7.Text; ort.MemberPhone = TextBox8.Text; ort.MemberPhone1 = TextBox9.Text; ort.MemberAdd = TextBox10.Text; ort.Orderdate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); ort.OrderNumber = Label1.Text; ort.UserTabID = czy; ort.PhotoID1 = tp1; ort.PhotoID2 = tp2; ort.PhotoID3 = tp3; ort.PhotoID4 = tp4; ort.qrcode = "../qrcode111/" + filename; ort.validity = Convert.ToDateTime(TextBox11.Text); ort.progress = 0; ort.AllMoney = Convert.ToDecimal(TextBox12.Text); if (TextBox13.Text.Trim() == "") { ort.Deposit = 0; } else { ort.Deposit = Convert.ToDecimal(TextBox13.Text); } ort.alllength = Convert.ToDecimal(TextBox1.Text); ort.Imperial = Convert.ToDecimal(TextBox2.Text); ort.QhWidth = Convert.ToDecimal(TextBox3.Text); ort.Beizhuwg = TextBox5.Text; ort.Beizhuzz = TextBox4.Text; ort.Zengsong = TextBox6.Text; ort.Zhuangtai1 = 0;//草稿 ort.Zhuangtai2 = Convert.ToInt32(DropDownList8.Text); ort.StaffmemberID = Convert.ToInt32(DropDownList9.Text); ort.HomemadeID = zzspid; if (TextBox14.Text.Trim() != "") { Model.ContractTab con = new Model.ContractTab(); con.OrderNumber = Label1.Text; con.CommodityID = TextBox14.Text; con.By1 = 1; ct.Add(con); } if (TextBox15.Text.Trim() != "") { Model.ContractTab con = new Model.ContractTab(); con.OrderNumber = Label1.Text; con.CommodityID = TextBox15.Text; con.By1 = 2; ct.Add(con); } if (TextBox16.Text.Trim() != "") { Model.ContractTab con = new Model.ContractTab(); con.OrderNumber = Label1.Text; con.CommodityID = TextBox16.Text; con.By1 = 3; ct.Add(con); } if (TextBox17.Text.Trim() != "") { Model.ContractTab con = new Model.ContractTab(); con.OrderNumber = Label1.Text; con.CommodityID = TextBox17.Text; con.By1 = 4; ct.Add(con); } if (TextBox18.Text.Trim() != "") { Model.ContractTab con = new Model.ContractTab(); con.OrderNumber = Label1.Text; con.CommodityID = TextBox18.Text; con.By1 = 5; ct.Add(con); } if (TextBox19.Text.Trim() != "") { Model.ContractTab con = new Model.ContractTab(); con.OrderNumber = Label1.Text; con.CommodityID = TextBox19.Text; con.By1 = 6; ct.Add(con); } if (TextBox20.Text.Trim() != "") { Model.ContractTab con = new Model.ContractTab(); con.OrderNumber = Label1.Text; con.CommodityID = TextBox20.Text; con.By1 = 7; ct.Add(con); } Model.Currentaccount cu = new Model.Currentaccount(); cu.billnumber = Label1.Text; cu.type = 1; cu.receipt = DateTime.Now; if (TextBox13.Text.Trim() == "") { cu.money = 0; } else { cu.money = Convert.ToDecimal(TextBox13.Text); } int b = cur.Add(cu); int a = ot.Add(ort); if (a > 0 && b > 0) { Response.Write(string.Format("<script>alert('添加成功!');location='danjuluru.aspx'</script>")); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('添加失败!');</script>"); } } } } } } } } } } } } }