private void Btnupdatec_Click(object sender, RoutedEventArgs e) { Customer cust = new Customer(); CustomerValidations cv = new CustomerValidations(); cust.CustomerID = int.Parse(txtCId.Text.ToString()); cust.CustomerName = txtCName.Text.ToString(); cust.EmailID = txtCEmail.Text.ToString(); cust.PhoneNumber = long.Parse(txtCPhone.Text.ToString()); cust.Address = txtCAddress.Text.ToString(); bool updateStatus = cv.UpdateCustomer_BLL(cust); if (updateStatus) { MessageBox.Show("Customer Details Updated"); gridCustomer.Visibility = Visibility.Hidden; txtCId.Clear(); txtCName.Clear(); txtCEmail.Clear(); txtCPhone.Clear(); txtCAddress.Clear(); } else { MessageBox.Show("Customer Cannot be Updated"); } }
private void Btndeletec_Click(object sender, RoutedEventArgs e) { try { Customer cust = new Customer(); CustomerValidations cv = new CustomerValidations(); int cid = int.Parse(txtCId.Text.ToString()); bool deleteStatus = cv.DeleteCustomer_BLL(cid); if (deleteStatus) { MessageBox.Show("Customer Details Deleted"); gridEmployee.Visibility = Visibility.Hidden; txtCId.Clear(); txtCName.Clear(); txtCPhone.Clear(); txtCEmail.Clear(); txtCAddress.Clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void BtnMainSearch_Click(object sender, RoutedEventArgs e) { if (rbEmployee.IsChecked == true) { Employee emp = new Employee(); EmployeeValidations ev = new EmployeeValidations(); int eid = int.Parse(txtSearch.Text); emp = ev.SearchEmployee_BLL(eid); if (emp != null) { txtEId.Text = emp.EmployeeID.ToString(); txtEName.Text = emp.EmployeeName; txtDesgn.Text = emp.Designation; txtPhone.Text = emp.PhoneNumber.ToString(); txtEmail.Text = emp.EmailID; txtAddress.Text = emp.Address; txtDL.Text = emp.DrivingLicenseNumber; gridEmployee.Visibility = Visibility.Visible; } else { MessageBox.Show("Employee Not Found"); } } else if (rbCustomer.IsChecked == true) { Customer cust = new Customer(); CustomerValidations cv = new CustomerValidations(); int cid = int.Parse(txtSearch.Text); cust = cv.SearchCustomer_BLL(cid); if (cust != null) { txtCId.Text = cust.CustomerID.ToString(); txtCName.Text = cust.CustomerName; txtCEmail.Text = cust.EmailID; txtCPhone.Text = cust.PhoneNumber.ToString(); txtCAddress.Text = cust.Address; gridCustomer.Visibility = Visibility.Visible; } else { MessageBox.Show("Customer Not Found"); } } else { gridEmployee.Visibility = Visibility.Hidden; gridCustomer.Visibility = Visibility.Hidden; MessageBox.Show("Select Employee or Customer"); } }
//Sign Up for Customer private void Btn_SignUp_Click(object sender, RoutedEventArgs e) { try { StringBuilder sb = new StringBuilder(); Customer cust = new Customer(); cust.CustomerName = txt_Name.Text.ToString(); cust.EmailID = txt_Email.Text; if (txt_PhoneNumber.Text == string.Empty) { sb.Append("Enter Valid Phone Number!" + Environment.NewLine); } else { cust.PhoneNumber = long.Parse(txt_PhoneNumber.Text.ToString()); } cust.Address = txt_Address.Text; Users users = new Users(); users.LoginID = (txt_LoginID.Text); users.Password = txt_Password.Password.ToString(); users.Role = "Customer"; CustomerValidations cv = new CustomerValidations(); if (cv.AddCustomer_BLL(cust, users) != 0) { MessageBox.Show("Customer Details are added"); MainWindow mw = new MainWindow(); mw.Show(); Close(); } else { throw new CustomerException("Enter details are not correct"); } } catch (CustomerException ex) { MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//Sign Up for Customer private void Btn_SignUp_Click(object sender, RoutedEventArgs e) { Customer cust = new Customer(); cust.CustomerName = txt_Name.Text.ToString(); cust.EmailID = txt_Email.Text; cust.PhoneNumber = long.Parse(txt_PhoneNumber.Text); cust.Address = txt_Address.Text; Users users = new Users(); users.LoginID = (txt_LoginID.Text); users.Password = txt_Password.Password.ToString(); users.Role = "Customer"; //users.EmployeeID = 0; CustomerValidations cv = new CustomerValidations(); try { if (cv.AddCustomer_BLL(cust, users) != 0) { MessageBox.Show("Customer Details are added"); CustomerHome ch = new CustomerHome(); ch.Show(); Close(); } else { throw new CustomerException("Enter details are not correct"); } } catch (CustomerException ex) { MessageBox.Show(ex.Message); } }