// //Add private void btAddProduct_Click(object sender, EventArgs e) { if (AcceptText()) { // // Add Bill if (od.checkID(cbBillID.Text)) { OrderBIll bill = new OrderBIll(); bill.orderID = cbBillID.Text; bill.customer = cd.getObject(cbCustomerID.EditValue.ToString()); bill.employee = ed.getObject(cbEmployee.EditValue.ToString()); bill.orderDate = DateOrder.DateTime; bill.payType = cbPayType.SelectedIndex; bill.total = long.Parse(txTotal.Text); od.AddObject(bill); cbBillID.Properties.Items.Add(cbBillID.Text); } if (String.IsNullOrEmpty(cbProductID.Text)) { cbProductID.Focus(); MessageBox.Show("Please choose a product", "Waring!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // // Add Detail Bill if (!detail.checkID(cbBillID.Text, cbProductID.Text)) { MessageBox.Show("ID is unavaillable,Please choose another!", "Warring", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } OrderBillDetail d = new OrderBillDetail(); d.orderBill = od.getObject(cbBillID.Text); d.product = pd.getObject(cbProductID.Text); d.quantily = Convert.ToInt16(txQuantily.Text); d.discount = Convert.ToInt16(txDiscount.Text); d.price = long.Parse(txPrice.Text); detail.AddObject(d); gridControl1.DataSource = detail.getTable(cbBillID.Text); // // Update Total Money txTotal.Text = od.getTotalMoney(cbBillID.Text); txQuantily.Properties.MaxValue = 1; } }
// // Select a Bill private void cbBillID_EditValueChanged(object sender, EventArgs e) { OrderBIll bill = od.getObject(cbBillID.Text); if (bill != null) { DateOrder.DateTime = bill.orderDate; cbEmployee.Text = bill.employee.Name; cbCustomerID.Text = bill.customer.Name; cbPayType.SelectedIndex = bill.payType; gridControl1.DataSource = detail.getTable(cbBillID.Text); txTotal.Text = bill.total.ToString(); btPrint.Enabled = true; } else { TextBillReset(); btPrint.Enabled = false; } }