public string orderGenerator(string cusid) { string orderid = null; string sql = " select top 1 * from T_allsale where cusid ='" + cusid + "' order by number desc"; databaseexe databaseexe = new databaseexe(); int number; string judge = databaseexe.getTopselect(sql, "number"); if (judge == null) { number = 0; } else { number = int.Parse(judge); } number = number + 1; orderid = number.ToString(); for (int i = 0; i <(8- number.ToString().Length); i++) { orderid = "0" + orderid; } orderid = cusid + orderid; JObject jsonObject = new JObject(); jsonObject["number"] = number; jsonObject["orderid"] = orderid; var json = jsonObject.ToString(); return json; }
private void ProductIndataGridView1_CellEndEdit_1(object sender, DataGridViewCellEventArgs e) { string zhuananid = ProductIndataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); string changestring = ProductIndataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); try { databaseexe databaseexe = new databaseexe(); //string QuantityNow = ClientdataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); //int CurrentQuantity = int.Parse(QuantityNow) + int.Parse(changestring); string QuantityQuery = "select sum(proinquantity) as a from T_productin group by zhuananID having sum(proinquantity)is not null and zhuananID='" + zhuananid + "'"; string lastQuantity = databaseexe.getTopselect(QuantityQuery, "a"); int CurrentQuantity = int.Parse(lastQuantity) + int.Parse(changestring); string sql = "update T_productIn set proinquantity ='" + changestring + "',proquantity ='" + CurrentQuantity + "'where zhuananid ='" + zhuananid + "'and proinid='" + textBoxProductInId.Text.ToString() + "'"; databaseexe.sqlcmd(sql); // dgload2(purid); string MatStock = "Update T_fixpro set Stock=Stock+'" + changestring + "' where id=(select pid from T_alls where id='" + zhuananid + "')"; dbexe.sqlcmd(MatStock); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonSearch_Click(object sender, EventArgs e) { try { Connstr connstr = new Connstr(); databaseexe dbexe = new databaseexe(); string ProName = textBoxName.Text.Trim(); string sql = "select id as 编码,productName as 品名,productType as 箱式,PLength as 长,Pwide as 宽,Pheight as 高,unit as 单位, Price as 单价 from T_fixpro where fatherid is null and CusId ='" + Cid + "'and productname like'%" + ProName + "%'"; //string sql = "select CusID as 客户编码,CusShort as 客户简称, CusName as 客户全称, CusTelephone as 电话,CusFax as 传真,CusAdress as 地址,CusPerson as 联系人 from T_customer where CusId like'%" + CusId + "%'"; DataTable dt = dbexe.getdataset(sql, "T_T_fixpro").Tables[0]; ProductdataGridView2.DataSource = dt; if (dt.Rows.Count == 0) { MessageBox.Show("没有符合条件的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //buttonModify.Enabled = false; textBoxName.Clear(); } else { MessageBox.Show("查询到:" + dt.Rows.Count + " 条记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //buttonModify.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonSaveNew_Click(object sender, EventArgs e) { if (comboBoxMultiColumnsClientid.Text == "") { MessageBox.Show("请先选择客户!"); } else { string cusid = comboBoxMultiColumnsClientid.Text.Trim(); OrderGenerator orderGenerator = new OrderGenerator(); JObject jsonObject = new JObject(); jsonObject = JObject.Parse(orderGenerator.orderGenerator(cusid)); //Boxid= textBoxOrderid.Text = jsonObject.GetValue("orderid").ToString(); string orderid = jsonObject.GetValue("orderid").ToString(); dataValue.saleid = orderid; string number = jsonObject.GetValue("number").ToString(); dataValue.salenumber = number; dataValue.indate = textBoxInDate.Text.ToString(); dataValue.deliverytime = DeliveryTimePicker2.Value.ToShortDateString(); dataValue.orderdate = OrderdateTimePicker1.Value.ToShortDateString(); dataValue.orderPerson = textBoxOderperson.Text.Trim(); string sql = "insert into T_allsale (number,orderid,cusid,indate,orderDate,deliverytime)values('" + number + "','" + orderid + "','" + cusid + "','" + textBoxInDate.Text.Trim() + "','" + OrderdateTimePicker1.Value.ToShortDateString() + "','" + DeliveryTimePicker2.Value.ToShortDateString() + "')"; databaseexe databaseexe = new databaseexe(); //dbexe.sqlcmd(sql); //MessageBox.Show("数据添加成功!"); } }
private void buttonDelete_Click(object sender, EventArgs e) { try { DialogResult dialogresult = MessageBox.Show("您确定要删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogresult == DialogResult.No) { return; } else { databaseexe dbexe = new databaseexe(); string PairID = PairListdataGridView.SelectedRows[0].Cells["编码"].Value.ToString(); string sql = "delete from T_fixpro where ID='" + PairID + "'"; dbexe.sqlcmd(sql); MessageBox.Show("数据删除成功!"); PairListdataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; string sql1 = "select id as 编码, productname as 名称,producttype as 纸箱种类, materialname as 纸板材质,plength as 长,pwide as 宽,pheight as 高,unit as 单位,quantity as 数量 from T_fixpro where fatherId='" + fatherId + "'"; PairListdataGridView.DataSource = dbexe.getdataset(sql1, "T_fixpro").Tables[0]; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void dgload(string Manuorderid, string ManuId) { ManudataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; string sql = "select zhuananId as 专案编码, Productname as 品名, producttype as 箱式," + "materialname as 纸板名称 ,plength as 长,pwide as 宽,pheight as 高,unit as 单位,Bomsize as 用料," + "allMaterialQuantity as 张数 from T_manus where orderid= '" + Manuorderid + "'"; ManudataGridView1.DataSource = dbexe.getdataset(sql, "T_manus").Tables[0]; ManudataGridView1.EnableHeadersVisualStyles = false; ManudataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 11, FontStyle.Bold); ManudataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.LightSlateGray; ManudataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; databaseexe databaseexe = new databaseexe(); textBoxSaleID.Text = Manuorderid; textBoxManuId.Text = ManuId; string CusidQuery = "select distinct(Cusid) from T_allsale where orderid='" + Manuorderid + "'"; string da = databaseexe.getTopselect(CusidQuery, "Cusid"); textBoxCusid.Text = da; string CusShortQuery = "select CusShort from T_Customer where Cusid='" + da + "'"; textBoxCusshort.Text = databaseexe.getTopselect(CusShortQuery, "CusShort"); string OrderDateQuery = "select distinct(orderDate) from T_allSale where Orderid='" + Manuorderid + "'"; textBoxOrderdate.Text = databaseexe.getTopselect(OrderDateQuery, "OrderDate"); string DeliveryDateQuery = "select distinct(Deliverytime) from T_allSale where orderid='" + Manuorderid + "'"; textBoxDeliveryDate.Text = databaseexe.getTopselect(DeliveryDateQuery, "deliverytime"); }
private void comboBoxMultiColumnsClientid_TextChanged(object sender, EventArgs e) { string sql = "select cusShort from T_Customer where cusid='" + comboBoxMultiColumnsClientid.Text.Trim() + "'"; databaseexe databaseexe = new databaseexe(); string da = databaseexe.getTopselect(sql, "Cusshort"); textBoxClientName.Text = da; }
private void btnOK_Click(object sender, EventArgs e) { if (i > 2) { MessageBox.Show("您已经密码错误了2次,不能登录"); textBox1.Clear(); textBox2.Clear(); timer1.Enabled = true; btnOK.Enabled = false; timer2.Enabled = true; return; } string yhm = textBox1.Text.ToString().Trim(); string mm = textBox2.Text.ToString().Trim(); string yzm = textBox3.Text.ToString().Trim(); dataValue.UserName = yhm; dataValue.Password = mm; string sql2 = "select * from T_member where jobno='" + yhm + "' "; databaseexe databaseexe1 = new databaseexe(); dataValue.StaffName = databaseexe1.getTopName(sql2); if (yhm == "") { MessageBox.Show("用户名不能为空!"); } else { Connstr connstr = new Connstr(); SqlConnection conn = connstr.getcon(); string sql = "select * from T_user where username='******' and password='******' "; SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { MessageBox.Show("登陆成功"); databaseexe dbexe = new databaseexe(); string sql1 = "select jobname from T_Member where jobNo='" + yhm + "'"; DataTable de = dbexe.getdataset(sql1, "T_member").Tables[0]; for (int i = 0; i < de.Rows.Count; i++) { DataRow dc = de.Rows[i]; dataValue.StaffName = dc["jobname"].ToString(); } FrmMain mainform = new FrmMain(); mainform.Show(); this.Hide(); } else { MessageBox.Show("用户名或密码错误!"); textBox1.Clear(); textBox2.Clear(); i++; } } }
private void frmBomAdd3_Load(object sender, EventArgs e) { string BomidQuery = "select top 1 bomid from t_bom order by bomid desc "; databaseexe databaseexe = new databaseexe(); string Bomid = databaseexe.getTopselect(BomidQuery, "bomid"); Bomid = (int.Parse(Bomid) + 1).ToString(); textBoxBoid1.Text = Bomid; textBoxProId.Text = dataValue.Bomid; textBoxLength.Text = dataValue.Bomlength; textBoxWide.Text = dataValue.BomWide; textBoxHeight.Text = dataValue.Bomheight; string productid = textBoxProId.Text.Trim(); string sql = "select productName from T_bomall where id ='" + productid + "'"; DataTable de = dbexe.getdataset(sql, "T_bomall").Tables[0]; for (int i = 0; i < de.Rows.Count; i++) { DataRow dc = de.Rows[i]; textBoxProductName.Text = dc["productname"].ToString(); } string sql1 = "select quantity from T_bomall where id ='" + productid + "'"; DataTable da = dbexe.getdataset(sql1, "T_bomall").Tables[0]; for (int i = 0; i < da.Rows.Count; i++) { DataRow dz = da.Rows[i]; textBoxProQuantity.Text = dz["quantity"].ToString(); } string sql4 = "select MaterialId from T_material"; DataTable dk = dbexe.getdataset(sql4, " T_Material").Tables[0]; for (int i = 0; i < dk.Rows.Count; i++) { DataRow dc = dk.Rows[i]; BomNamecomboBox1.Items.Add(dc["materialID"]); } if (dk.Rows.Count > 0) { BomNamecomboBox1.SelectedIndex = -1; } string sql5 = "select materialName from T_material where materialid='" + BomNamecomboBox1.Text.ToString() + "'"; DataTable dm = dbexe.getdataset(sql5, "T_material").Tables[0]; for (int i = 0; i < dm.Rows.Count; i++) { DataRow dc = dm.Rows[i]; textBoxBomname1.Text = dc["materialname"].ToString(); } }
public string proInGenerator() { string sql = "select top 1 ProinID from t_ProductIn order by id desc"; databaseexe databaseexe = new databaseexe(); string lastid = databaseexe.getTopselect(sql, "Proinid"); int result = int.Parse(lastid) + 1; return(result.ToString()); }
public string MatinGenerator() { string sql = "select top 1 matinId from t_MaterialIn order by id desc"; databaseexe databaseexe = new databaseexe(); string lastid = databaseexe.getTopselect(sql, "matinid"); int result = int.Parse(lastid) + 1; return(result.ToString()); }
private void buttonChoose_Click(object sender, EventArgs e) { try { databaseexe databaseexe = new databaseexe(); string ZhuanAnid = PurchaseOrderdataGridView2.CurrentRow.Cells[0].Value.ToString(); string PurchaseQuantity = PurchaseOrderdataGridView2.CurrentRow.Cells[5].Value.ToString(); string BomidQuery = "select bomid from T_pur where zhuananid='" + ZhuanAnid + "'"; string bomid = databaseexe.getTopselect(BomidQuery, "bomid"); string priceQuery = "Select materialprice from T_BOMPRICE where bomid='" + bomid + "'and Supid='" + Supid + "'"; string price = databaseexe.getTopselect(priceQuery, "materialprice"); string sql1 = "insert into T_purchaseOrder (purchaseid,purchasequantity,zhuananid,price,supid) values('" + PurchaseId + "','" + PurchaseQuantity + "','" + ZhuanAnid + "','" + price + "','" + Supid + "')"; dbexe.sqlcmd(sql1); /*string sql = "select zhuananid as 专案编号,CusShort as 客户,productName as 品名,materialName as 纸板名称,bomsize as 规格, allMaterialQuantity-matstock as 欠料数量 from T_pur where purchaseid is null and manuid is not null "; * dbexe.sqlcmd(sql);*/ string sql2 = "select zhuananid as 专案编号,CusShort as 客户,productName as 品名,materialName as 纸板名称,bomsize as 规格, allMaterialQuantity-matstock as 欠料数量 from T_pur where purchaseid is null and manuid is not null "; // dbexe.getdataset(sql2, "T_pur").Tables[0]; DataTable Datatable; Datatable = dbexe.getdataset(sql2, "T_pur").Tables[0]; for (int i = 0; i < Datatable.Rows.Count; i++) { if (int.Parse(Datatable.Rows[i]["欠料数量"].ToString()) < 0) { Datatable.Rows[i]["欠料数量"] = "0"; } } PurchaseOrderdataGridView2.DataSource = Datatable; /*string[] arr; * arr = databaseexe.getMultiData(sql, "id"); * for (int i = 0; i < arr.Length; i++) * { * * * //string AllMaterialQuery = " Select unitquantity*orderquantity as a from T_manus where ZhuanAnID = '" + arr[i].ToString() + "'"; * //string AllMaterialQuantity = databaseexe.getTopselect(AllMaterialQuery, "a"); * //string PurchaseQuantity="update T_PurchaseOrder set purchasequantity='"+PurchaseOrderdataGridView2.CurrentRow.Cells[5].Value.ToString()+"'where zhuananid= '"+ZhuanAnid+"'"; * * }*/ frmPurchaseAdd4 f1 = (frmPurchaseAdd4)this.Owner; f1.dgload(PurchaseId); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public Boolean getMultiMatIn(string PurId) { string sql = "select id from T_matin where purid ='" + PurId + "'"; databaseexe databaseexe = new databaseexe(); string result = databaseexe.getTopselect(sql, "id"); if (result == null) { return(false); } else { return(true); } }
public frmFixAdd(DataGridViewRow dgvr1, string id, string tid, string quantity) { InitializeComponent(); dgvr = dgvr1; getValue(); clientID = id; typeId = tid; Quantity = quantity; string tidquery = "select typeid from T_FixPRO where id ='" + typeId + "'"; databaseexe databaseexe = new databaseexe(); tid = databaseexe.getTopselect(tidquery, "typeid"); string mIdQuery = "select materialID from T_FixPRO where id ='" + typeId + "'"; MaterialId = databaseexe.getTopselect(mIdQuery, "materialId"); comboBoxTypeID.Text = tid; string MnameQuery = "select materialID from T_MATERIAL where id ='" + MaterialId + "'"; comboBoxMaterialID.Text = databaseexe.getTopselect(MnameQuery, "materialID"); string PriceQuery = "select price from T_fixpro where id ='" + textBoxFixId.Text + "'"; textBoxPrice.Text = databaseexe.getTopselect(PriceQuery, "price"); string yinshuaQuery = "select yingshua from T_fixPRO where id='" + textBoxFixId.Text + "'"; yinshuaQuery = databaseexe.getTopselect(yinshuaQuery, "yingshua"); string zhanjiaoQuery = "select zhanjiao from T_fixPRO where id='" + textBoxFixId.Text + "'"; zhanjiaoQuery = databaseexe.getTopselect(zhanjiaoQuery, "zhanjiao"); string dadingQuery = "select dading from T_fixPRO where id ='" + textBoxFixId.Text + "'"; dadingQuery = databaseexe.getTopselect(dadingQuery, "dading"); if (yinshuaQuery.Equals("true")) { checkBox1.Checked = true; } if (zhanjiaoQuery.Equals("true")) { checkBox2.Checked = true; } if (dadingQuery.Equals("true")) { checkBox3.Checked = true; } }
private void buttonChoose_Click(object sender, EventArgs e) { try { databaseexe databaseexe = new databaseexe(); string zhuananid = FixProductGridView1.CurrentRow.Cells[1].Value.ToString(); string CusShort = FixProductGridView1.CurrentRow.Cells[0].Value.ToString(); //dataValue.CurrentQuantity = ChooseProductGridView1.CurrentRow.Cells[5].Value.ToString(); //string SupShort = comboBox1.Text.ToString(); //string SupidQuery = "select Supid from T_Supplier where SupShort='" + SupShort + "'"; //string Supid = databaseexe.getTopselect(SupidQuery, "Supid"); string sql1 = "insert into T_DeliveryOut (DeliveryId,zhuananid,deliveryPerson,deliveryindate,deliverydate) values('" + DeliveryId + "','" + zhuananid + "','" + DeliveryPerson + "','" + Deliveryindate + "','" + DeliveryDate + "')"; dbexe.sqlcmd(sql1); string sql = "select CusShort as 客户,zhuananid as 专案编号,Orderid as 订单号,productName as 品名,producttYPE as 箱式,plength as 长,pwide as 宽,pheight as 高,unit as 单位,materialName as 纸板名称,orderquantity as 订单数量, deliveryquantity as 已送数量,(orderquantity-deliveryquantity)as 未送数量,deliverytime as 交货日期 from T_delout where id is null and zhuananid is not null or id in(select max(id) from T_delout group by zhuananid having max(id)is not null )"; DataTable Datatable; Datatable = dbexe.getdataset(sql, "T_delout").Tables[0]; for (int i = 0; i < Datatable.Rows.Count; i++) { if (Datatable.Rows[i]["已送数量"].ToString() == "") { Datatable.Rows[i]["已送数量"] = "0"; Datatable.Rows[i]["未送数量"] = Datatable.Rows[i]["订单数量"]; } } FixProductGridView1.DataSource = Datatable; //string QuantityRefresh = "update T_Matin3 set MatQuantity='" + dataValue.CurrentQuantity + "'where matinid='" + MatInID + "'and purid='" + PurId + "'"; //dbexe.sqlcmd(QuantityRefresh); frmDeliveryAdd5 f1 = (frmDeliveryAdd5)this.Owner; f1.dgload(DeliveryId, zhuananid, CusShort); //f1.dgload2(PurId); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void dgload(string supid, string matinid, string purid) { textBoxProductInId.Text = matinid; //textBoxSup.Text = supid; string SupShortQuery = "select SupShort from t_Supplier where Supid='" + supid + "'"; databaseexe databaseexe = new databaseexe(); textBoxSup.Text = databaseexe.getTopselect(SupShortQuery, "Supshort"); MaterialIndataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; string sql = "select purid as 采购序号,Supshort as 供方,MaterialName as 纸板,bomsize as 规格,MatQuantity as 数量,price as 单价,MatQuantity*price as 金额 from T_Matin2 where Matinid='" + matinid + "'"; DataTable datatable = dbexe.getdataset(sql, "T_matin2").Tables[0]; for (int i = 0; i < datatable.Rows.Count; i++) { datatable.Rows[i]["数量"] = "0"; } MaterialIndataGridView1.DataSource = datatable; MaterialIndataGridView1.EnableHeadersVisualStyles = false; MaterialIndataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Bold); MaterialIndataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.LightSlateGray; MaterialIndataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; string quantityNow = dataValue.CurrentQuantity; ClientdataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; string sql1 = "select Zhuananid as 专案编号,CusShort as 客户,ProductName as 品名,purchaseQuantity as 采购数量,Matquantity as 入仓数量 from T_matin3 where matinid = '" + textBoxProductInId.Text.ToString() + "'"; ClientdataGridView1.DataSource = dbexe.getdataset(sql1, "T_matin3").Tables[0]; ClientdataGridView1.EnableHeadersVisualStyles = false; ClientdataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Bold); ClientdataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.LightSlateGray; ClientdataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; }
public string deliveryGenerator() { DateTime dt = DateTime.Now; //string year = dt.Year.ToString(); //string month = dt.Month.ToString(); /*if (month.Length < 2) { * month = "0" + month; * } * string day = dt.Day.ToString(); * if (day.Length < 2) * { * day = "0" + day; * }*/ string count = ""; //声明新生成的送货单号 string deliveryidQuery = "select top 1 deliveryid from t_deliveryout order by id desc"; //查询数据库中最后一个送货单号 databaseexe databaseexe = new databaseexe(); string lastid = databaseexe.getTopselect(deliveryidQuery, "deliveryid"); string lastidDate = lastid.Substring(0, 6); //截取最后一个送货单号的日期yyyyMM string lastidSEQ = lastid.Substring(6); //截取最后流水号 DateTime dateTime = DateTime.ParseExact(lastidDate, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture); int result = CompanyDate(dateTime.ToString(), DateTime.Now.ToShortDateString()); //比较今天和最后一个送货单号的时间 if (result == 1 || result == 0) { count = "001"; } else { int _count = int.Parse(lastidSEQ) + 1; for (int i = 0; i < 3 - _count.ToString().Length; i++) { count = count + "0"; } count = count + _count.ToString(); } string code = DateTime.Now.ToString("yyyyMM") + count;//最后组成送货单 return(code); }
private void DeliverydataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { string zhuananid = DeliverydataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); string changestring = DeliverydataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); string deliveryId = textBoxDeliveryID.Text.ToString(); try { databaseexe databaseexe = new databaseexe(); //string QuantityNow = ClientdataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); //int CurrentQuantity = int.Parse(QuantityNow) + int.Parse(changestring); string QuantityQuery = "select sum(deliveryoutquantity) as a from T_deliveryOut group by zhuananID having sum(deliveryoutquantity)is not null and zhuananID='" + zhuananid + "'"; string lastQuantity = databaseexe.getTopselect(QuantityQuery, "a"); int CurrentQuantity = int.Parse(lastQuantity) + int.Parse(changestring); string sql = "update T_deliveryOut set deliveryoutquantity ='" + changestring + "',deliveryquantity ='" + CurrentQuantity + "'where zhuananid ='" + zhuananid + "'and deliveryid='" + textBoxDeliveryID.Text.ToString() + "'"; databaseexe.sqlcmd(sql); this.BeginInvoke(new MethodInvoker(() => {//异步处理 string sql1 = "select CusShort as 客户,zhuananid as 专案编号,productName as 品名,productType as 箱式,materialName as 纸板名称,plength as 长,pwide as 宽,pheight as 高,unit as 单位,deliveryoutquantity as 出货数量,price as 单价,(deliveryOutquantity*price) as 金额 from T_DelOut where deliveryid='" + deliveryId + "'"; //DeliverydataGridView1.DataSource = //dbexe.getdataset(sql1, "T_delout").Tables[0]; //string sql = "select CusShort as 客户,zhuananid as 专案编号,Orderid as 订单号,productName as 品名,producttYPE as 箱式,plength as 长,pwide as 宽,pheight as 高,unit as 单位,materialName as 纸板名称,orderquantity as 订单数量, deliveryquantity as 已送数量,(orderquantity-deliveryquantity)as 未送数量,deliverytime as 交货日期 from T_delout where id is null and zhuananid is not null or id in(select max(id) from T_delout group by zhuananid having max(id)is not null )"; DataTable Datatable; Datatable = dbexe.getdataset(sql1, "T_DelOut").Tables[0]; DeliverydataGridView1.DataSource = Datatable; })); this.BeginInvoke(new MethodInvoker(() => { string MatStock = "Update T_fixpro set Stock=Stock-'" + changestring + "' where id=(select pid from T_alls where id='" + zhuananid + "')"; dbexe.sqlcmd(MatStock); })); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonChoose_Click(object sender, EventArgs e) { try { databaseexe databaseexe = new databaseexe(); string PurId = ChooseProductGridView1.CurrentRow.Cells[1].Value.ToString(); dataValue.CurrentQuantity = ChooseProductGridView1.CurrentRow.Cells[5].Value.ToString(); string SupShort = comboBox1.Text.ToString(); string SupidQuery = "select Supid from T_Supplier where SupShort='" + SupShort + "'"; string Supid = databaseexe.getTopselect(SupidQuery, "Supid"); string sql1 = "insert into T_MaterialIn (Matinid,PurId,Supid,MatinDate,MatDate,MatinPerson) values('" + MatInID + "','" + PurId + "','" + Supid + "','" + Matindate + "','" + Matdate + "','" + MatPerson + "')"; dbexe.sqlcmd(sql1); string sql = "select SupShort as 供方,purid as 采购序号,MaterialName as 纸板名称,bomsize as 规格,PurchaseQuantity as 采购数量,MatQuantity as 进料数量,(purchaseQuantity-matquantity)as 未进数量,PurchaseDate as 订货日期,deliverydate as 交货日期 from T_Matin2 where id is null and purid is not null and purchaseQuantity <> '0' and Supshort ='" + SupShort + "' or id in(select max(id) from T_Matin2 group by Purid having max(id)is not null ) and purchaseQuantity <> '0' and Supshort ='" + SupShort + "'"; DataTable Datatable; Datatable = dbexe.getdataset(sql, "T_MATin2").Tables[0]; for (int i = 0; i < Datatable.Rows.Count; i++) { if (Datatable.Rows[i]["进料数量"].ToString() == "") { Datatable.Rows[i]["进料数量"] = "0"; Datatable.Rows[i]["未进数量"] = Datatable.Rows[i]["采购数量"]; } } ChooseProductGridView1.DataSource = Datatable; string QuantityRefresh = "update T_Matin3 set MatQuantity='" + dataValue.CurrentQuantity + "'where matinid='" + MatInID + "'and purid='" + PurId + "'"; dbexe.sqlcmd(QuantityRefresh); frmMaterialInOrder4 f1 = (frmMaterialInOrder4)this.Owner; f1.dgload(Supid, MatInID, PurId); //f1.dgload2(PurId); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonCheck_Click(object sender, EventArgs e) { string OrderId = textBoxOrderid.Text.ToString(); string CheckTime = DateTime.Now.ToShortDateString(); string checkperson = dataValue.StaffName; string sql = "update T_OrderSale set status ='已审核',checktime ='" + CheckTime + "',checkperson='" + checkperson + "' where orderid='" + OrderId + "'"; dbexe.sqlcmd(sql); string statusQuery = "select distinct(status) from T_ordersale where orderid='" + OrderId + "'"; databaseexe databaseexe = new databaseexe(); string da = databaseexe.getTopselect(statusQuery, "status"); textBoxStatus.Text = da; string CheckDateQuery = "select distinct(checktime) from T_ordersale where orderid='" + OrderId + "'"; string dc = databaseexe.getTopselect(CheckDateQuery, "checktime"); textBoxCheckDate.Text = dc; string checkPersonQuery = "select distinct(checkperson) from T_ordersale where orderid='" + OrderId + "'"; string db = databaseexe.getTopselect(checkPersonQuery, "checkperson"); textBoxCheckPerson.Text = db; }
private void buttonSaveNew_Click(object sender, EventArgs e) { try { databaseexe dbexe = new databaseexe(); string CusId = textBoxCusId.Text.Trim(); string CusShort = textBoxCusShort.Text.Trim(); string CusName = textBoxCusName.Text.Trim(); string CusTel = textBoxCusTel.Text.Trim(); string CusFax = textBoxCusFax.Text.Trim(); string CusAdress = textBoxCusAdress.Text.Trim(); string CusPerson = textBoxCusPerson.Text.Trim(); string CusBank = textBoxBank.Text.Trim(); string CusAccount = textBoxAccount.Text.Trim(); string CusMemo = textBoxMemo.Text.Trim(); if (CusId == "" || CusShort == "" || CusName == "" || CusTel == "" || CusAdress == "") { MessageBox.Show("数据添加不完整"); } else { try { string sql = "insert into T_Customer (CusID,CusShort,CusName,CusTelephone,CusFax,CusAdress,CusPerson,CusBank,CusAccount,CusMemo) values ('" + CusId + "','" + CusShort + "','" + CusName + "','" + CusTel + "','" + CusFax + "','" + CusAdress + "','" + CusPerson + "','" + CusBank + "','" + CusAccount + "','" + CusMemo + "')"; dbexe.sqlcmd(sql); MessageBox.Show("数据添加成功!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void MaterialIndataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { string changestring = MaterialIndataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); string Purid = MaterialIndataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); try { string QuantityNow = ClientdataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); int CurrentQuantity = int.Parse(QuantityNow) + int.Parse(changestring); string sql = "update T_MaterialIN set matinquantity ='" + changestring + "',matquantity = '" + CurrentQuantity + "' where id =(select top 1 id from T_matin2 where purid ='" + Purid + "' order by id desc)"; databaseexe databaseexe = new databaseexe(); databaseexe.sqlcmd(sql); // dgload2(purid); ClientdataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; string sql1 = "select Zhuananid as 专案编号,CusShort as 客户,ProductName as 品名,purchaseQuantity as 采购数量,Matquantity as 入仓数量 from T_matin3 where matinid = '" + textBoxProductInId.Text.ToString() + "'"; ClientdataGridView1.DataSource = dbexe.getdataset(sql1, "T_matin3").Tables[0]; ClientdataGridView1.EnableHeadersVisualStyles = false; ClientdataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Bold); ClientdataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.LightSlateGray; ClientdataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; string UniqueId = ClientdataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); string MatStock = "Update T_Bom set Stock=Stock+'" + MaterialIndataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString() + "' where bomid=(select bomid from T_pur where ZhuanAnID='" + UniqueId + "')"; dbexe.sqlcmd(MatStock); // string MatStock="update T_Bom set stock=" } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonChoose_Click(object sender, EventArgs e) { try { ManuGenarator manu = new ManuGenarator(); dataValue.ManuSaleid = SaleOrderdataGridView1.CurrentRow.Cells[0].Value.ToString(); string ManuOrderid = dataValue.ManuSaleid; string ManuId = manu.manuGenerator(ManuOrderid); string sql = " Select id from t_ordersale where orderid ='" + ManuOrderid + "'order by id asc"; databaseexe databaseexe = new databaseexe(); string[] arr; arr = databaseexe.getMultiData(sql, "id"); for (int i = 0; i < arr.Length; i++) { string AllMaterialQuery = " Select unitquantity*orderquantity as a from T_manus where ZhuanAnID = '" + arr[i].ToString() + "'"; string AllMaterialQuantity = databaseexe.getTopselect(AllMaterialQuery, "a"); string sql1 = "insert into T_manuOrder (manuid,allmaterialquantity,saleid,zhuananid) values('" + ManuId + "','" + AllMaterialQuantity + "','" + ManuOrderid + "','" + arr[i].ToString() + "')"; dbexe.sqlcmd(sql1); } frmManuOrderAdd3 f1 = (frmManuOrderAdd3)this.Owner; f1.dgload(ManuOrderid, ManuId); } catch (Exception ex) { MessageBox.Show(ex.Message); } /*string orderQuantity = SaleOrderdataGridView1.CurrentRow.Cells[10].Value.ToString(); * string Uniqueid = SaleOrderdataGridView1.CurrentRow.Cells[1].Value.ToString(); * string unitQuantityQuery = "select unitquantity from T_manus where zhuananid ='" + Uniqueid + "'"; * databaseexe databaseexe = new databaseexe(); * string UnitQuantity = databaseexe.getTopselect(unitQuantityQuery, "unitquantity"); * * AutoCount autoCount = new AutoCount(); * string MaterialAll = autoCount.MaterialCount(orderQuantity,UnitQuantity); * * //frmManuOrderAdd3 frmsub = new frmManuOrderAdd3(SaleOrderdataGridView1.CurrentRow); * //frmsub.Show(); * * * /* string Orderid = dataValue.saleid; * frmOrderSaleNew2 frmsub = new frmOrderSaleNew2(Orderid); * frmOrderSaleNew2.FrmOrderSaleNew2.dgload(Orderid); * this.Close();*/ //string Orderid = dataValue.saleid; /* dataValue.ManuSaleid = SaleOrderdataGridView1.CurrentRow.Cells[0].Value.ToString(); * string ManuOrderid = dataValue.ManuSaleid; * Select id from t_ordersale * * string sql = "insert into T_manuOrder (manuid,saleid,allMaterialQuantity) values ('" + ManuId + "','"+ManuOrderid+ "','"+MaterialAll+"')"; * dbexe.sqlcmd(sql); * MessageBox.Show("数据添加成功!");*/ //frmManuOrderAdd3 frmManuOrderAdd3 = new frmManuOrderAdd3(ManuOrderid); // frmManuOrderAdd3.FrmManuOrderAdd3.dgload(ManuOrderid); this.Close(); MessageBox.Show("数据添加成功!"); }
private void buttonSearch_Click(object sender, EventArgs e) { if (radioButtonNo.Checked) { if (textBoxNo.Text == "") { MessageBox.Show("未输入编号!"); return; } try { Connstr connstr = new Connstr(); databaseexe dbexe = new databaseexe(); string ProductId = textBoxNo.Text.Trim(); string sql = "select id as 编码,ProductName as 品名, productType as 箱式,PLength as 长,Pwide as 宽,Pheight as 高,unit as 单位, Price as 单价 from T_FixPRO where ID like'%" + ProductId + "%'"; DataTable dt = dbexe.getdataset(sql, "T_FixPRO").Tables[0]; FixProductGridView1.DataSource = dt; if (dt.Rows.Count == 0) { MessageBox.Show("没有符合条件的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = false; } else { MessageBox.Show("查询到:" + dt.Rows.Count + " 条记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { if (textBoxName.Text == "") { MessageBox.Show("查询产品名称不得为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string ProductName = textBoxName.Text.Trim(); string sql = "select id as 编码,ProductName as 品名, productType as 箱式,PLength as 长,Pwide as 宽,Pheight as 高,unit as 单位, Price as 单价 from T_FixPRO where ProductName like'%" + ProductName + "%'"; try { Connstr connstr = new Connstr(); databaseexe dbexe = new databaseexe(); DataTable dt = dbexe.getdataset(sql, "T_FixPRO'").Tables[0]; FixProductGridView1.DataSource = dt; if (dt.Rows.Count == 0) { MessageBox.Show("没有符合条件的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = false; } else { MessageBox.Show("查询到:" + dt.Rows.Count + " 条记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void buttonSearch_Click(object sender, EventArgs e) { if (radioButtonNo.Checked) { if (textBoxNo.Text == "") { MessageBox.Show("未输入编号!"); return; } try { Connstr connstr = new Connstr(); databaseexe dbexe = new databaseexe(); string CusId = textBoxNo.Text.Trim(); string sql = "select CusID as 客户编码,CusShort as 客户简称, CusName as 客户全称, CusTelephone as 电话," + "CusFax as 传真,CusAdress as 地址,CusPerson as 联系人 from T_customer where CusId like'%" + CusId + "%'"; DataTable dt = dbexe.getdataset(sql, "T_Customer").Tables[0]; ClientdataGridView1.DataSource = dt; if (dt.Rows.Count == 0) { MessageBox.Show("没有符合条件的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = false; } else { MessageBox.Show("查询到:" + dt.Rows.Count + " 条记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { if (textBoxName.Text == "") { MessageBox.Show("查询客户名称不得为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string CusShort = textBoxName.Text.Trim(); string sql = "select CusID as 客户编码,CusShort as 客户简称, CusName as 客户全称, CusTelephone as 电话,CusFax as 传真,CusAdress as 地址,CusPerson as 联系人 from T_customer where CusShort like'%" + CusShort + "%'"; try { Connstr connstr = new Connstr(); databaseexe dbexe = new databaseexe(); DataTable dt = dbexe.getdataset(sql, "T_customer").Tables[0]; ClientdataGridView1.DataSource = dt; if (dt.Rows.Count == 0) { MessageBox.Show("没有符合条件的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = false; } else { MessageBox.Show("查询到:" + dt.Rows.Count + " 条记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void buttonSaveNew_Click(object sender, EventArgs e) { try { string FixID = textBoxFixId.Text.Trim(); string CusID = textBoxClientID.Text.Trim(); string ProductName = textBoxProductName.Text.Trim(); string typeId = comboBoxTypeID.Text.Trim(); string TypeName = textBoxTypeNAME.Text.Trim(); string unit = textBoxUnit.Text.Trim(); string materialID = comboBoxMaterialID.Text.Trim(); string materialName = textBoxMaterialName.Text.Trim(); string Plength = textBoxLength.Text.Trim(); string Pwide = textBoxWide.Text.Trim(); string Pheight = textBoxHeight.Text.Trim(); string quantity = textBoxQuantity.Text.Trim(); string memo = textBoxMemo.Text.Trim(); string price = textBoxPrice.Text.Trim(); Boolean yinshua = checkBox1.Checked; Boolean zhanjiao = checkBox2.Checked; Boolean dading = checkBox3.Checked; string MidQuery = "select ID from T_MATERIAL where materialid ='" + materialID + "'"; databaseexe databaseexe = new databaseexe(); string id = databaseexe.getTopselect(MidQuery, "ID"); string sql = "update T_FixPRO set typeId='" + typeId + "',ProductName ='" + ProductName + "',productType='" + TypeName + "',materialId='" + id + "',MaterialName='" + materialName + "',Plength='" + Plength + "',Pwide='" + Pwide + "',Pheight='" + Pheight + "',unit='" + unit + "',quantity='" + quantity + "',price='" + price + "',memo='" + memo + "'where Id='" + FixID + "'"; dbexe.sqlcmd(sql); if (yinshua.Equals(true)) { string sql2 = "update T_fixPRO set yingshua ='true' where id='" + FixID + "'"; dbexe.sqlcmd(sql2); } if (zhanjiao.Equals(true)) { string sql3 = "update T_fixPRO set zhanjiao ='true' where id='" + FixID + "'"; dbexe.sqlcmd(sql3); } if (dading.Equals(true)) { string sql4 = "update T_fixPRO set dading ='true' where id='" + FixID + "'"; dbexe.sqlcmd(sql4); } if (yinshua.Equals(false)) { string sql5 = "update T_fixPRO set yingshua ='false' where id='" + FixID + "'"; dbexe.sqlcmd(sql5); } if (zhanjiao.Equals(false)) { string sql6 = "update T_fixPRO set zhanjiao ='false' where id='" + FixID + "'"; dbexe.sqlcmd(sql6); } if (dading.Equals(false)) { string sql7 = "update T_fixPRO set dading ='false' where id='" + FixID + "'"; dbexe.sqlcmd(sql7); } MessageBox.Show("数据保存成功!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonSearch_Click(object sender, EventArgs e) { if (radioButtonNo.Checked) { if (textBoxNo.Text == "") { MessageBox.Show("未输入编号!"); return; } try { Connstr connstr = new Connstr(); databaseexe dbexe = new databaseexe(); string SupId = textBoxNo.Text.Trim(); string sql = "select SupId as 供方编码,SupShort as 供方简称, SupName as 供方全称, SupTelephone as 电话,SupFax as 传真,SupAdress as 地址,SupPerson as 负责人 from T_Supplier where SupId like'%" + SupId + "%'"; DataTable dt = dbexe.getdataset(sql, "T_Supplier").Tables[0]; SupplierdataGridView.DataSource = dt; if (dt.Rows.Count == 0) { MessageBox.Show("没有符合条件的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = false; } else { MessageBox.Show("查询到:" + dt.Rows.Count + " 条记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { if (textBoxName.Text == "") { MessageBox.Show("查询供方名称不得为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string SupShort = textBoxName.Text.Trim(); string sql = "select SupId as 供方编码,SupShort as 供方简称, SupName as 供方全称, SupTelephone as 电话,SupFax as 传真,SupAdress as 地址,SupPerson as 负责人 from T_Supplier where SupShort like'%" + SupShort + "%'"; try { Connstr connstr = new Connstr(); databaseexe dbexe = new databaseexe(); DataTable dt = dbexe.getdataset(sql, "T_Supplier").Tables[0]; SupplierdataGridView.DataSource = dt; if (dt.Rows.Count == 0) { MessageBox.Show("没有符合条件的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = false; } else { MessageBox.Show("查询到:" + dt.Rows.Count + " 条记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void buttonSaveNew_Click(object sender, EventArgs e) { //frmFixAdd frmsub = new frmFixAdd(); //frmsub.buttonPairSearch.Enabled = true; try { string CusID = textBoxClientID.Text.Trim(); string FatherId = textBoxFixMaiNId.Text.Trim(); string fittingName = textBoxProductName.Text.Trim(); string typeId = comboBoxTypeID.Text.Trim(); string TypeName = textBoxTypeNAME.Text.Trim(); string unit = textBoxUnit.Text.Trim(); string materialID = comboBoxMaterialID.Text.Trim(); string materialName = textBoxMaterialName.Text.Trim(); string Flength = textBoxLength.Text.Trim(); string Fwide = textBoxWide.Text.Trim(); string Fheight = textBoxHeight.Text.Trim(); string quantity = textBoxQuantity.Text.Trim(); string memo = textBoxMemo.Text.Trim(); string price = textBoxPrice.Text.Trim(); Boolean yinshua = checkBox1.Checked; Boolean zhanjiao = checkBox2.Checked; Boolean dading = checkBox3.Checked; //string sql = "insert into T_fixbox (cusID,productname,producttype,materialname,plength,pwide,pheight,unit,quantity,price,memo) values string MidQuery = "select ID from T_MATERIAL where materialid ='" + materialID + "'"; databaseexe databaseexe = new databaseexe(); string id = databaseexe.getTopselect(MidQuery, "ID"); string sql = "insert into T_fixpro (CusId,productNAME,typeid,producttype,materialId,MaterialName,plength,pwide,pheight,unit,quantity,fatherid,memo,price) values ('" + CusID + "','" + fittingName + "','" + typeId + "','" + TypeName + "','" + id + "','" + materialName + "','" + Flength + "','" + Fwide + "','" + Fheight + "','" + unit + "','" + quantity + "','" + FatherId + "','" + memo + "','" + price + "')"; /*string sql = "update T_Customer set CusShort='" + CusShort + "',CusName='" + CusName + "',CusTelephone='" + CusTel + "',CusFax='" + CusFax + "',CusAdress='" + CusAdress + "',CusPerson='" + CusPerson + "',CusBank='" + CusBank + "',CusAccount='" + CusAccount + "',CusMemo='" + CusMemo + "'where CusId='" + CusId + "'";*/ dbexe.sqlcmd(sql); string sql1 = "select top 1 id from T_fixpro order by id DESC "; databaseexe databaseexe2 = new databaseexe(); string newid = databaseexe2.getTopid(sql1); if (yinshua.Equals(true)) { string sql2 = "update T_fixpro set yingshua ='true' where id='" + newid + "'"; dbexe.sqlcmd(sql2); } if (zhanjiao.Equals(true)) { string sql3 = "update T_fixpro set zhanjiao ='true' where id='" + newid + "'"; dbexe.sqlcmd(sql3); } if (dading.Equals(true)) { string sql4 = "update T_fixpro set dading ='true' where id='" + newid + "'"; dbexe.sqlcmd(sql4); } MessageBox.Show("数据保存成功!"); string sql5 = "select top 1 id from T_fixpro order by id DESC "; databaseexe databaseexe3 = new databaseexe(); textBoxFixId.Text = databaseexe2.getTopid(sql5); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonSearch_Click(object sender, EventArgs e) { if (radioButtonNo.Checked) { if (textBoxNo.Text == "") { MessageBox.Show("未输入编号!"); return; } try { Connstr connstr = new Connstr(); databaseexe dbexe = new databaseexe(); string MaterialID = textBoxNo.Text.Trim(); string sql = "select MaterialId as 纸板编码,MaterialName as 纸板名称, MaterialType as 瓦楞类型 from T_material where MaterialId like'%" + MaterialID + "%'"; DataTable dt = dbexe.getdataset(sql, "T_Supplier").Tables[0]; MaterialdataGridView1.DataSource = dt; if (dt.Rows.Count == 0) { MessageBox.Show("没有符合条件的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = false; } else { MessageBox.Show("查询到:" + dt.Rows.Count + " 条记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { if (textBoxName.Text == "") { MessageBox.Show("查询名称不得为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string MaterialName = textBoxName.Text.Trim(); string sql = "select MaterialId as 纸板编码,MaterialName as 纸板名称, MaterialType as 瓦楞类型 from T_material where MaterialName like'%" + MaterialName + "%'"; try { Connstr connstr = new Connstr(); databaseexe dbexe = new databaseexe(); DataTable dt = dbexe.getdataset(sql, "T_Supplier").Tables[0]; MaterialdataGridView1.DataSource = dt; if (dt.Rows.Count == 0) { MessageBox.Show("没有符合条件的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = false; } else { MessageBox.Show("查询到:" + dt.Rows.Count + " 条记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonModify.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void button1_Click(object sender, EventArgs e) { string saleid = dataValue.saleid; try { if (textBoxNumber.Text == "") { MessageBox.Show("未填写数量!"); return; } else { /* string cusid = Cid; * OrderGenerator orderGenerator = new OrderGenerator(); * JObject jsonObject = new JObject(); * jsonObject = JObject.Parse(orderGenerator.orderGenerator(cusid)); * //Boxid= * * /*textBoxOrderid.Text = jsonObject.GetValue("orderid").ToString(); * string orderid = jsonObject.GetValue("orderid").ToString(); * string number = jsonObject.GetValue("number").ToString(); * string sql = "insert into T_allsale (number,orderid,cusid)values('" + number + "','" + orderid + "','" + cusid + "')"; * databaseexe databaseexe = new databaseexe();*/ string boxid = ProductdataGridView2.CurrentRow.Cells[0].Value.ToString(); string idQuery = "select id from T_fixpro where fatherid='" + boxid + "'or id ='" + boxid + "'order by id asc"; databaseexe databaseexe = new databaseexe(); string[] arr = databaseexe.getMultiData(idQuery, "id"); for (int i = 0; i < arr.Length; i++) { string id; id = arr[i]; string sql = "insert into T_ordersale (number,orderid ,proid,cusid,quantity,indate,orderdate,deliverytime,orderperson) values ('" + dataValue.salenumber + "','" + dataValue.saleid + "','" + id + "','" + Cid + "','" + textBoxNumber.Text.Trim() + "','" + dataValue.indate + "','" + dataValue.orderdate + "','" + dataValue.deliverytime + "','" + dataValue.orderPerson + "')"; dbexe.sqlcmd(sql); } string biliQuery = "select quantity from T_fixpro where id ='" + boxid + "' or fatherid = '" + boxid + "' order by id asc"; string[] bili = databaseexe.getMultiData(biliQuery, "quantity"); string shuliang = textBoxNumber.Text.ToString().Trim(); for (int j = 1; j < bili.Length; j++) { string tempid = arr[j]; string tempbili = bili[j]; int tempnumber = int.Parse(tempbili) * int.Parse(shuliang); string sql = "update t_ordersale set quantity='" + tempnumber + "' where proid = '" + tempid + "'"; databaseexe.sqlcmd(sql); } MessageBox.Show("数据添加成功!"); /*teacherdataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; * string sql1 = "select teacherId as 教师编号,teacherName as 教师姓名,tage as 年龄,Tdepartement as 所属学院 from teacher"; * teacherdataGridView1.DataSource = * dbexe.getdataset(sql1, "teacher").Tables[0];*/ string Orderid = dataValue.saleid; frmOrderSaleNew2 frmsub = new frmOrderSaleNew2(Orderid); frmOrderSaleNew2.FrmOrderSaleNew2.dgload(Orderid); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }