public CheckFrom(string orderID, Users user) { MORBusinessLogic mORBusinessLogic = new MORBusinessLogic(); OrderBusinessLogic orderBusinessLogic = new OrderBusinessLogic(); InitializeComponent(); this.orderID = orderID; this.user = user; Order order = orderBusinessLogic.GetOrderByID(orderID); txbOrderId.Text = order.OrderNumber; txbDepartment.Text = order.Department; txbCreator.Text = order.Creator; txbStatus.Text = order.Status; txbProvider.Text = order.Provider; dtpOrderTime.Text = order.InputDate.ToString(); label7.Text = order.TotalMoney.ToString(); this.dt = mORBusinessLogic.GetMOR(orderID); dgvOrderCheck.DataSource = this.dt; if (user.Remark == "班组") { btnSubmit.Visible = false; } setColumn(); }
/// <summary> /// 单击操作列触发的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvOrder_CellContentClick(object sender, DataGridViewCellEventArgs e) { OrderBusinessLogic orderBusinessLogic = new OrderBusinessLogic(); //单击编辑执行的操作 if (e.ColumnIndex == 0 && e.RowIndex != -1) { string orderID = this.dgvOrder.Rows[e.RowIndex].Cells[3].Value.ToString(); OrderEditForm orderEditForm = new OrderEditForm(orderID, user); orderEditForm.ShowDialog(); this.dgvOrder.DataSource = orderBusinessLogic.GetOrderByStatus("未提交"); } //单击删除执行的操作 if (e.ColumnIndex == 1 && e.RowIndex != -1) { DialogResult result = MessageBox.Show("确定删除此订单?", "提示", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { string orderID = this.dgvOrder.Rows[e.RowIndex].Cells[3].Value.ToString(); orderBusinessLogic.DeleteOrderById(orderID);//删除已经做级联 MessageBox.Show("删除成功!"); this.dgvOrder.DataSource = orderBusinessLogic.GetOrderByStatus("未提交"); } else { MessageBox.Show("删除取消!"); } } //单击提交执行的操作 if (e.ColumnIndex == 2 && e.RowIndex != -1) { //OrderBusinessLogic orderBusinessLogic = new OrderBusinessLogic(); DialogResult result = MessageBox.Show("确定提交此订单?", "提示", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { string orderID = this.dgvOrder.Rows[e.RowIndex].Cells[3].Value.ToString(); Order order = orderBusinessLogic.GetOrderByID(orderID); order.Status = "未审核"; order.InputDate = System.DateTime.Now; orderBusinessLogic.UpdataOrder(order); MessageBox.Show("提交成功!"); this.dgvOrder.DataSource = orderBusinessLogic.GetOrderByStatus("未提交"); } else { MessageBox.Show("提交取消!"); } } }
private void btnSubmit_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("确定验收后此订单不可更改!\n是否确定?", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { OrderBusinessLogic orderBusinessLogic = new OrderBusinessLogic(); CheckedOrderBusinessLogic checkedOrderBusinessLogic = new CheckedOrderBusinessLogic(); MCORBusinessLogic mCORBusinessLogic = new MCORBusinessLogic(); CheckedOrder checkedOrder = new CheckedOrder();//验收单 Order order = orderBusinessLogic.GetOrderByID(orderID); checkedOrder.CheckedOrderID = order.OrderID; checkedOrder.OrderNumber = order.OrderNumber; checkedOrder.Provider = order.Provider; checkedOrder.Status = "已验收"; checkedOrder.VeriDate = order.VeriDate; checkedOrder.Verifier = order.Verifier; checkedOrder.Remark = textBox1.Text.Trim(); checkedOrder.Department = order.Department; checkedOrder.Creator = order.Creator; checkedOrder.TotalMoney = Convert.ToDouble(label7.Text); checkedOrder.InputDate = order.InputDate; order.Status = "已验收"; bool flag1, flag2; try { flag1 = checkedOrderBusinessLogic.AddOrder(checkedOrder); flag2 = orderBusinessLogic.UpdataOrder(order); } catch (Exception) { throw; } if (flag1 && flag2) { int count = dgvOrderCheck.Rows.Count; for (int i = 0; i < count; i++) { if (dgvOrderCheck.Rows[i].Cells[3].Value != null && dgvOrderCheck.Rows[i].Cells[8].Value != null) { MenuCheckedOrder_R MCOR = new MenuCheckedOrder_R(); MCOR.MenuCheckedOrderID = Guid.NewGuid().ToString(); MCOR.CheckedOrderID = order.OrderID; MCOR.MenuName = dgvOrderCheck.Rows[i].Cells[3].Value.ToString(); MCOR.Unit = dgvOrderCheck.Rows[i].Cells[4].Value.ToString(); MCOR.Quote = Convert.ToDouble(dgvOrderCheck.Rows[i].Cells[5].Value); MCOR.Rate = Convert.ToDouble(dgvOrderCheck.Rows[i].Cells[6].Value); MCOR.Price = Convert.ToDouble(dgvOrderCheck.Rows[i].Cells[7].Value); MCOR.Count = Convert.ToDouble(dgvOrderCheck.Rows[i].Cells[8].Value); MCOR.Money = Convert.ToDouble(dgvOrderCheck.Rows[i].Cells[9].Value); MCOR.InputDate = order.InputDate; //MOR.Remark = null; mCORBusinessLogic.AddMCOR(MCOR); } } MessageBox.Show("您已成功保存验收单!", "提示"); this.Close(); } else { MessageBox.Show("保存失败!"); } } }