private void Add_Click(object sender, EventArgs e) { warning.Text = $" "; addForm1 form2 = new addForm1(); form2.ShowDialog(); if (form2.isSuccess == true) { if (OrderService.InquireNo(orderList, form2.order.OrderNo) != null) { warning.Text = $"已经存在订单{form2.order.OrderNo}"; } else { OrderService.addOrder(orderList, form2.order); } } this.OrderDataSource.ResetBindings(false); }
private void Inquire_Click(object sender, EventArgs e) { if (InquiryChoose.SelectedItem != null) { if (inquiryBox.Text == "") { warning.Text = ""; } else { this.inquiryState = true; //进入查询模式 quitInquiry.Enabled = true; Add.Enabled = false; //查询模式下无法添加订单 switch (InquiryChoose.SelectedIndex) { case 0: if (OrderService.InquireNo(orderList, inquiryBox.Text) != null) { inquiryResultList = orderList.Where(s => s.OrderNo == inquiryBox.Text).ToList(); OrderDataSource.DataSource = inquiryResultList; //更新查询结果 this.OrderDataSource.ResetBindings(false); } else { OrderDataSource.DataSource = null; ItemDataSource.DataSource = null; } //未找到则显示为空 break; case 1: if (OrderService.InquireClientName(orderList, inquiryBox.Text) != null) { inquiryResultList = OrderService.InquireClientName(orderList, inquiryBox.Text); OrderDataSource.DataSource = inquiryResultList; this.OrderDataSource.ResetBindings(false); } else { OrderDataSource.DataSource = null; ItemDataSource.DataSource = null; } break; case 2: if (OrderService.InquireProductName(orderList, inquiryBox.Text) != null) { inquiryResultList = OrderService.InquireProductName(orderList, inquiryBox.Text); OrderDataSource.DataSource = inquiryResultList; this.OrderDataSource.ResetBindings(false); } else { OrderDataSource.DataSource = null; ItemDataSource.DataSource = null; } break; } } } else { warning.Text = "请选择查询方式"; } }