private void btnSubmit_Click(object sender, EventArgs e) { MenuBusinessLogic menuBusinessLogic = new MenuBusinessLogic(); OrderBusinessLogic orderBusinessLogic = new OrderBusinessLogic(); MORBusinessLogic mORBusinessLogic = new MORBusinessLogic(); Order order = new Order(); bool flag = orderBusinessLogic.IscontainOrder(txbOrderNumber.Text.Trim()); if (flag) { MessageBox.Show("订单已存在!", "提示"); return; } if (dataGridView1.Rows[0].Cells[0].Value == null) { MessageBox.Show("订单不能为空!", "提示"); return; } if (dataGridView1.Rows[cellRowIndex].Cells[0].Value != null && dataGridView1.Rows[cellRowIndex].Cells[3].Value == null) { MessageBox.Show("数量不能为空!", "提示"); return; } if (dataGridView1.Rows[cellRowIndex].Cells[0].Value == null && dataGridView1.Rows[cellRowIndex].Cells[3].Value != null) { MessageBox.Show("请填写菜品!", "提示"); return; } order.OrderID = Guid.NewGuid().ToString(); order.OrderNumber = txbOrderNumber.Text.Trim(); order.Department = txbDepartment.Text.Trim(); order.Creator = txbCreater.Text.Trim(); order.InputDate = Convert.ToDateTime(txbOrderDate.Text.Trim()); order.TotalMoney = Convert.ToDouble(this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[7].Value); order.Status = "未发送"; orderBusinessLogic.AddOrder(order); int count = dataGridView1.Rows.Count; for (int i = 0; i < count - 1; i++) { if (dataGridView1.Rows[i].Cells[0].Value != null && dataGridView1.Rows[i].Cells[3].Value != null) { string menuName = dataGridView1.Rows[i].Cells[0].Value.ToString(); Model.Menu menu = menuBusinessLogic.GetMenuByName(menuName); MenuOrder_R MOR = new MenuOrder_R(); MOR.MenuOrderID = Guid.NewGuid().ToString(); MOR.OrderID = order.OrderID; MOR.MenuName = menu.MenuName; MOR.Unit = menu.Unit; MOR.InputDate = Convert.ToDateTime(txbOrderDate.Text.Trim()); MOR.Money = Convert.ToDouble(dataGridView1.Rows[i].Cells[7].Value); MOR.Quote = menu.MenuQuote; MOR.Rate = menu.MenuRate; MOR.Price = menu.MenuPrice; MOR.Count = Convert.ToDouble(dataGridView1.Rows[i].Cells[3].Value); //MOR.Remark = null; mORBusinessLogic.AddMOR(MOR); } } MessageBox.Show("提交成功!", "提示"); }