private void Btn_search_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(tb_CustomerID.Text)) { MessageBox.Show("Please input 'CustomerID' "); } else { ArrayList arrayList = DataAccessCustomers.GetDataCustomer(tb_CustomerID.Text); string data = ""; int counter = 0; foreach (string list in arrayList) { counter = counter + 1; data = data + list + "\n"; } if (counter == 0) { MessageBox.Show("No member data found", "Member detail"); } else { MessageBox.Show(data, "Member detail"); } tb_CustomerID.Clear(); } }
private void Btn_edit_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(tb_CustomerID.Text)) //ถ้าในกล่องข้อความว่างเปล่า { MessageBox.Show("Please input 'Customer ID' "); } else if (String.IsNullOrEmpty(tb_CustomerName.Text)) { MessageBox.Show("Please input 'Name' "); } else if (String.IsNullOrEmpty(tb_CustomerAddress.Text)) { MessageBox.Show("Please input 'Address' "); } else if (String.IsNullOrEmpty(tb_CustomerEmail.Text)) { MessageBox.Show("Please input 'Email' "); } else { if (MessageBox.Show("Do you want to save changing ?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { DataAccessCustomers.UpdateData(tb_CustomerID.Text, tb_CustomerName.Text, tb_CustomerAddress.Text, tb_CustomerEmail.Text); MessageBox.Show("Update completed !!"); tb_CustomerAddress.Clear(); tb_CustomerEmail.Clear(); tb_CustomerName.Clear(); tb_CustomerID.Clear(); } } }
private void Btn_find_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(tb_find.Text)) { MessageBox.Show("Please input 'Customer ID' "); } else { ArrayList customerID = DataAccessCustomers.GetCustomerID(tb_find.Text); ArrayList customerName = DataAccessCustomers.GetCustomerName(tb_find.Text); ArrayList customerAddress = DataAccessCustomers.GetCustomerAddress(tb_find.Text); ArrayList customerEmail = DataAccessCustomers.GetCustomerEmail(tb_find.Text); string dataID = ""; int counter = 0; foreach (string listID in customerID) { counter = counter + 1; dataID = listID; } string dataName = ""; foreach (string listName in customerName) { dataName = listName; } string dataAddress = ""; foreach (string listAddress in customerAddress) { dataAddress = listAddress; } string dataEamil = ""; foreach (string listEmail in customerEmail) { dataEamil = listEmail; } if (counter == 0) { MessageBox.Show("No member data found", "Member detail"); } else { tb_CustomerID.Text = dataID; tb_CustomerName.Text = dataName; tb_CustomerAddress.Text = dataAddress; tb_CustomerEmail.Text = dataEamil; } } }
private void Btn_delete_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(tb_CustomerID.Text)) { MessageBox.Show("Please input CustomerID"); } else { if (MessageBox.Show("Do you want to delete CustomerID : " + tb_CustomerID.Text + " ?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { DataAccessCustomers.DeleteCustomerData(tb_CustomerID.Text); MessageBox.Show("Delete CustomerID : " + tb_CustomerID.Text + " complete", "Delete complete"); tb_CustomerID.Clear(); } } }
private void Btn_btn_BookOrder_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(tb_BookPrice.Text)) //ถ้าในกล่องข้อความว่างเปล่า { MessageBox.Show("Please choose the book"); } else if (String.IsNullOrEmpty(tb_BookQty.Text)) { MessageBox.Show("Please insert the quantity"); } else if (String.IsNullOrEmpty(tb_CustomerID.Text)) { MessageBox.Show("Please insert CustomerID"); } else { int keyCheck = 1; foreach (string list in DataAccessCustomers.CheckCustomerID()) { if (list == tb_CustomerID.Text) { keyCheck = 2; if (MessageBox.Show("คุณต้องการซื้อหนังสือ : " + tb_BookTitle.Text + "\n" + "จำนวน = " + tb_BookQty.Text + " เล่ม ใช่หรือไม่?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { DataAccessTransaction.AddData(tb_BookID.Text, tb_CustomerID.Text, tb_BookQty.Text, tb_TotalPrice.Text); MessageBox.Show("ลูกค้ารหัส : " + tb_CustomerID.Text + "\n" + "ทำการซื้อหนังสือรหัส : " + tb_BookID.Text + ", ชื่อ : " + tb_BookTitle.Text + "\n" + "จำนวน : " + tb_BookQty.Text + " เล่ม" + "\n" + "ราคา : " + tb_TotalPrice.Text + " บาท", "สรุปรายการขาย"); tb_BookID.Clear(); tb_BookQty.Clear(); tb_TotalPrice.Clear(); tb_CustomerID.Clear(); } break; } } if (keyCheck == 1) { MessageBox.Show("Customer ID : " + tb_CustomerID.Text + " not found"); tb_CustomerID.Clear(); } } }
private void Btn_add_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(tb_CustomerID.Text)) //ถ้าในกล่องข้อความว่างเปล่า { MessageBox.Show("Please input 'Customer ID' "); } else if (String.IsNullOrEmpty(tb_CustomerName.Text)) { MessageBox.Show("Please input 'Name' "); } else if (String.IsNullOrEmpty(tb_CustomerAddress.Text)) { MessageBox.Show("Please input 'Address' "); } else if (String.IsNullOrEmpty(tb_CustomerEmail.Text)) { MessageBox.Show("Please input 'Email' "); } else { int keyCheck = 1; foreach (string list in DataAccessCustomers.CheckCustomerID()) { if (list == tb_CustomerID.Text) { keyCheck = 2; MessageBox.Show("ID : " + list + " already exist"); break; } } if (keyCheck == 1) { DataAccessCustomers.AddData(tb_CustomerID.Text, tb_CustomerName.Text, tb_CustomerAddress.Text, tb_CustomerEmail.Text); MessageBox.Show("added ID " + tb_CustomerID.Text + " done"); tb_CustomerAddress.Clear(); tb_CustomerEmail.Clear(); tb_CustomerName.Clear(); tb_CustomerID.Clear(); } } }
private void Btn_show_Click(object sender, RoutedEventArgs e) { string data = ""; int counter = 0; foreach (string list in DataAccessCustomers.GetData()) { counter = counter + 1; data = data + list + "\n"; } if (counter == 0) { MessageBox.Show("No member data found", "Member detail"); } else { MessageBox.Show(data, "Member detail"); } }
public WindowCustomerMenu() { InitializeComponent(); DataAccessCustomers.InitializeCustomersDatabase(); }