private void btn_UpdateShow_Click(object sender, EventArgs e) { try { CustController cust = new CustController(); Customer c; if (dataGridView1.SelectedCells.Count > 0 && txt_custID.Text == "") { DataGridViewRow selectedRow = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex]; c = cust.GetCustomer(Convert.ToInt32(selectedRow.Cells["CustomerID"].Value.ToString())); txt_custID.Text = c.customerID.ToString(); } else { c = cust.GetCustomer(Convert.ToInt32(txt_custID.Text)); } txt_updateName.Text = c.name; txt_updateAdress.Text = c.adress; txt_updateZip.Text = c.zipCode.ToString(); } catch { } }
private void btn_OrderChoose_Click(object sender, EventArgs e) { int orderID; int customerID; if (dataGridView1.SelectedCells.Count > 0) { DataGridViewRow selectedRow = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex]; orderID = Convert.ToInt32(selectedRow.Cells["OrdreID"].Value); customerID = Convert.ToInt32(selectedRow.Cells["CustomerID"].Value); CustController cust = new CustController(); UC_Order1.ShowCustInfo(cust.GetCustomer(customerID)); UC_Order1.txt_orderID.Text = orderID.ToString(); UC_Order1.dataGridView1.DataSource = order.GetAllProductLines(orderID); this.Controls.Clear(); this.InitializeComponent(); UC_Order1.BringToFront(); UC_Order1.cbb_discount.Text = "0"; double pris = order.TotalPrice(Convert.ToDouble(UC_Order1.cbb_discount.Text), Convert.ToInt32(orderID)); UC_Order1.lbl_pris.Text = $"{pris:C}"; } else { MessageBox.Show("Ingen ordre valgt"); } }
private void btn_newOrder_Click(object sender, EventArgs e) { try { order.CreateOrder(Convert.ToInt32(txt_custID.Text)); o = order.GetLastOrder(); txt_orderID.Text = o.ordreID.ToString(); dataGridView1.DataSource = order.GetAllProductLines(o.ordreID); CustController cust = new CustController(); Customer c = cust.GetCustomer(o.customerID); ShowCustInfo(c); } catch { MessageBox.Show("Angiv gyldigt kundenummer"); } }
private void btn_chooseSelected_Click(object sender, EventArgs e) { if (dataGridView1.SelectedCells.Count > 0) { int customerID = 0; if (dataGridView1.SelectedCells.Count > 0) { DataGridViewRow selectedRow = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex]; customerID = Convert.ToInt32(selectedRow.Cells["CustomerID"].Value.ToString()); } UC_Cust1.txt_custID.Text = customerID.ToString(); CustController cust = new CustController(); UC_Cust1.ShowCustInfo(cust.GetCustomer(customerID)); this.Controls.Clear(); this.InitializeComponent(); UC_Cust1.BringToFront(); } }