private void btnNewOrder_Click(object sender, EventArgs e) { try { string customerName = cbCustomers.Text; DateTime date = dtpDate.Value; if (!string.IsNullOrEmpty(customerName)) { Payment_Order order = new Payment_Order(); int customerId = (from c in ent.Customers where c.name == customerName select c.id).FirstOrDefault(); order.customer_id = customerId; order.Date = date; ent.Payment_Order.Add(order); ent.SaveChanges(); MessageBox.Show("Order Added!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); PaymentOrder_Load(sender, e); obj = new PaymentOrderInfo(order); obj.Show(); } else { MessageBox.Show("Enter Order Name!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnEditItems_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(txtOrderNumber.Text)) { int orderNumber = int.Parse(txtOrderNumber.Text); Payment_Order order = (from o in ent.Payment_Order where o.number == orderNumber select o).FirstOrDefault(); obj = new PaymentOrderInfo(order); obj.Show(); } else { MessageBox.Show("Select order first!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }