private void btn_AddOrder_Click(object sender, EventArgs e) { bool check = InsertErrorManager.OrderChecker(txt_Customer.Text, comboBox_StoreNames.Text, comboBox1.Text, dateTimePicker.Text, txt_Total.Text); if (check == true) { MessageBox.Show("All field must be filled"); } else { int total = Convert.ToInt32(txt_Total.Text); string orderCode = DaoOrder.AddNewOrder(txt_Customer.Text, comboBox_StoreNames.Text, comboBox1.Text, dateTimePicker.Text, total); int count = datGridView_Items.Rows.Count - 1; for (int i = 0; i < count; i++) { string name = datGridView_Items.Rows[i].Cells[0].Value.ToString(); string strquantity = datGridView_Items.Rows[i].Cells[1].Value.ToString(); string strprice = datGridView_Items.Rows[i].Cells[2].Value.ToString(); int quantity = Convert.ToInt32(strquantity); int price = Convert.ToInt32(strprice); DaoItems.AddItem(name, quantity, price, orderCode); } MessageBox.Show("Order Added, Order Code:" + orderCode); } }
void FillStores() { var list = DaoOrder.FillComboStaff(); foreach (string store in list) { combo_Username.Items.Add(store); } }
void FillStaff() { var list = DaoOrder.FillComboStaff(); foreach (string store in list) { comboBox1.Items.Add(store); } }
void FillStores() { var list = DaoOrder.FillComboStore(); foreach (string store in list) { comboBox_StoreNames.Items.Add(store); } }
private void btn_ModOrder_Click(object sender, EventArgs e) { SetCode = txt_Code.Text; this.WindowState = FormWindowState.Minimized; DisplayAddOrder newForm = new DisplayAddOrder(); newForm.ShowDialog(); txt_Code.Text = null; dataGridView_mod.DataSource = null; dataGridView_mod.Rows.Clear(); dataGridView_mod.DataSource = DaoOrder.OrderFiller(); this.WindowState = FormWindowState.Normal; }
private void DisplayAddOrder_Load(object sender, EventArgs e) { string orderCode = YourOrders.SetCode; this.TopMost = true; if (String.IsNullOrEmpty(orderCode) == false) { txt_OrderCode.Text = orderCode; btn_AddOrder.Hide(); dataGridView2.Hide(); dataGridView2.DataSource = DaoItems.OrderedItems(orderCode); int count = dataGridView2.Rows.Count - 1; for (int i = 0; i < count; i++) { string name = dataGridView2.Rows[i].Cells[0].Value.ToString(); string strquantity = dataGridView2.Rows[i].Cells[1].Value.ToString(); string strtotalprice = dataGridView2.Rows[i].Cells[2].Value.ToString(); int quantity = Convert.ToInt32(strquantity); double dprice = Convert.ToDouble(strtotalprice); int price = Convert.ToInt32(dprice); datGridView_Items.Rows.Add(name, quantity, price, "Delete"); int Total = datGridView_Items.Rows.Cast <DataGridViewRow>() .Sum(t => Convert.ToInt32(t.Cells[2].Value)); txt_Total.Text = Total.ToString(); } dataGridView2.DataSource = DaoOrder.OrderData(orderCode); string id = dataGridView2.Rows[0].Cells[0].Value.ToString(); string storeName = dataGridView2.Rows[0].Cells[1].Value.ToString(); string staffName = dataGridView2.Rows[0].Cells[2].Value.ToString(); string date = dataGridView2.Rows[0].Cells[3].Value.ToString(); txt_Customer.Text = id; comboBox_StoreNames.Text = storeName; comboBox1.Text = staffName; dateTimePicker.Text = date; } else { btn_Modify.Hide(); dataGridView2.Hide(); txt_OrderCode.Hide(); lbl_OrderCode.Hide(); } }
private void btn_ChangeOrder_Click(object sender, EventArgs e) { bool val = InsertErrorManager.OrderChecker(txt_Customer.Text, comboBox_StoreNames.Text, comboBox1.Text, dateTimePicker.Text, txt_Total.Text); if (val == false) { MessageBox.Show("All field must be filled"); } else { int total = Convert.ToInt32(txt_Total.Text); string orderCode = YourOrders.SetCode; if (DaoOrder.UpdateOrder(txt_Customer.Text, comboBox_StoreNames.Text, comboBox1.Text, dateTimePicker.Text, txt_OrderCode.Text)) { DaoItems.DeleteItemsByCode(orderCode); int count = datGridView_Items.Rows.Count - 1; for (int i = 0; i < count; i++) { string name = datGridView_Items.Rows[i].Cells[0].Value.ToString(); string strquantity = datGridView_Items.Rows[i].Cells[1].Value.ToString(); string strprice = datGridView_Items.Rows[i].Cells[2].Value.ToString(); int quantity = Convert.ToInt32(strquantity); int price = Convert.ToInt32(strprice); DaoItems.AddItem(name, quantity, price, orderCode); } MessageBox.Show("Order Saved, Order Code:" + orderCode); } else { MessageBox.Show("Error during the update, try check customer id again"); } } }
public ServiceOrder() { DaoOrder = new DaoOrder(); }
public YourOrders() { InitializeComponent(); dataGridView_mod.DataSource = DaoOrder.OrderFiller(); }