// 从datagridview插入订单到数据库 private void materialRaisedButton8_Click(object sender, EventArgs e) { MysqlManager manager = new MysqlManager(); DialogResult dr = MessageBox.Show("确认添加订单到数据库 ? ", "提示", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { DataTable dt = GetDgvToTable(dataGridView2); if (dt.Rows.Count == 0) { MessageBox.Show("没有数据可添加"); } else { for (int i = 0; i < dt.Rows.Count; i++) { BillPO billPO = new BillPO(); billPO.Billid = dt.Rows[i]["Column1"].ToString(); billPO.GuestName = dt.Rows[i]["Column2"].ToString(); billPO.Xinghao = dt.Rows[i]["Column3"].ToString(); billPO.Zhonglei = dt.Rows[i]["Column4"].ToString(); billPO.Color = dt.Rows[i]["Column5"].ToString(); billPO.Num = Convert.ToInt32(dt.Rows[i]["Column6"]); billPO.SinglePrice = Convert.ToDouble(dt.Rows[i]["Column7"]); billPO.TotalPrice = Convert.ToDouble(dt.Rows[i]["Column8"]); billPO.OtherText = dt.Rows[i]["Column9"].ToString(); billPO.KaipiaoDate = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString(); billPO.Danwei = "码 / 米"; billPO.Kaipiaor = "硕麒拉链码庄"; billPO.Jinshour = "无"; billPO.PicPath = "无"; billPO.Address = "无"; manager.insertBill(billPO); } MessageBox.Show("订单添加成功,请返回首页查看 !"); } } }
// 删除页面 订单查询按钮 private void materialRaisedButton5_Click(object sender, EventArgs e) { MysqlManager manager = new MysqlManager(); if (textBox2.Text == "") { MessageBox.Show("请输入订单编号!"); } else { BillPO bill = manager.getBillPObyBillid(textBox2.Text); if (bill == null) { MessageBox.Show("订单编号输入有误,请重新输入!"); } else { DeleteBill deleteBill = new DeleteBill(textBox2.Text); deleteBill.StartPosition = FormStartPosition.CenterParent; deleteBill.ShowDialog(); } } }