private void btnCompanyUpdate_Click(object sender, EventArgs e) { string tempName; try { if (currentCompany == null) { lblresponse.Text = "No company chosen"; return; } tempName = txtCompanyName.Text; tempName = tempName.Trim(); if (String.IsNullOrEmpty(tempName)) { lblresponse.Text = "Name field is empty"; return; } currentCompany.Name = txtCompanyName.Text; CompanyController.Update(currentCompany); FillListWithAllCompanies(); lblresponse.Text = "Company updated"; } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } }
private void UpdateBranchButton_Click(object sender, EventArgs e) { string tempName; try { if (currentBransch == null) { lblresponse.Text = "No branch chosen"; return; } tempName = txtBranchName.Text; tempName = tempName.Trim(); if (String.IsNullOrEmpty(tempName)) { lblresponse.Text = "Name field is empty"; return; } currentBransch.Name = txtBranchName.Text; BranschController.UpdateBransch(currentBransch); FillListWithAllBranches(); lblresponse.Text = "Branch updated"; } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } }
private void updateCustButton_Click(object sender, EventArgs e) { string tempName; try { if (currentCustomer == null) { lblresponse.Text = "No customer chosen"; return; } tempName = txtCustName.Text; tempName = tempName.Trim(); if (String.IsNullOrEmpty(tempName)) { lblresponse.Text = "Name field is empty"; return; } currentCustomer.Name = txtCustName.Text; currentCustomer.EmployeeId = Int32.Parse(cmbEmployeesCustomer.Text); CustomerController.Update(currentCustomer); FillListWithAllCustomers(); lblresponse.Text = "Customer updated"; } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } }
private void updateEmp_Click(object sender, EventArgs e) { string tempName; try { if (currentEmployee == null) { lblresponse.Text = "No employee chosen"; return; } tempName = empNameTextBox.Text; tempName = tempName.Trim(); if (String.IsNullOrEmpty(tempName)) { lblresponse.Text = "Name field is empty"; return; } currentEmployee.Name = empNameTextBox.Text; currentEmployee.CompanyId = Int32.Parse(cmbCompanyEmployee.Text); EmployeeController.Update(currentEmployee); FillListWithAllEmployees(); lblresponse.Text = "Employee updated"; } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } }
private void CreateCustomerButton_Click(object sender, EventArgs e) { try { currentEmployee = cmbEmployeesCustomer.SelectedItem as Employee; if (cmbEmployeesCustomer.Text != "") { int empId = Int32.Parse(cmbEmployeesCustomer.Text); currentEmployee = EmployeeController.FindById(empId); } if (currentEmployee == null) { lblresponse.Text = "No Employee selected"; return; } String tempId = txtCustId.Text; tempId = tempId.Trim(); if (String.IsNullOrEmpty(tempId)) { lblresponse.Text = "Id box is empty"; return; } Customer cust = new Customer(); cust.CustomerId = Int32.Parse(tempId); cust.Name = txtCustName.Text; cust.Name = cust.Name.Trim(); cust.Employee = currentEmployee; if (cust.CustomerId < 0) { lblresponse.Text = "Id is less than 0"; return; } if (String.IsNullOrEmpty(cust.Name)) { lblresponse.Text = "You need to write a name"; return; } bool success = CustomerController.Create(cust); if (success) { lblresponse.Text = "Customer Created for " + currentEmployee.Name; } else { lblresponse.Text = "Failed to create Customer"; } } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } FillListWithAllCustomers(); }
private void createEmpButton_Click(object sender, EventArgs e) { try { String tempId = empIdTextBox.Text; tempId = tempId.Trim(); if (String.IsNullOrEmpty(tempId)) { lblresponse.Text = "Id box is empty"; return; } Employee emp = new Employee(); emp.EmployeeId = Int32.Parse(tempId); emp.Name = empNameTextBox.Text; emp.Name = emp.Name.Trim(); if (emp.EmployeeId < 0) { lblresponse.Text = "Id is less than 0"; return; } if (String.IsNullOrEmpty(emp.Name)) { lblresponse.Text = "You need to write a name"; return; } if (cmbCompanyEmployee.SelectedItem == null) { emp.CompanyId = 0; } else { emp.CompanyId = Int32.Parse(cmbCompanyEmployee.Text); } bool success = EmployeeController.Create(emp); if (success) { lblresponse.Text = "Employee Created"; } else { lblresponse.Text = "Failed to create Employee"; } } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } FillListWithAllEmployees(); }
private void dgv_CellClick(object sender, DataGridViewCellEventArgs e) { try { int empId = Int32.Parse(dgvEmployees.CurrentRow.Cells[0].Value.ToString()); currentEmployee = EmployeeController.FindById(empId); empIdTextBox.Text = currentEmployee.EmployeeId.ToString(); empNameTextBox.Text = currentEmployee.Name; } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } }
private void dgvBranches_CellClick(object sender, DataGridViewCellEventArgs e) { try { int branchId = Int32.Parse(dgvBranches.CurrentRow.Cells[0].Value.ToString()); currentBransch = BranschController.FindById(branchId); txtBranchId.Text = currentBransch.BranschId.ToString(); txtBranchName.Text = currentBransch.Name; dgvBranchCompanies.DataSource = BranschController.ReadAllCompaniesForABransch(currentBransch); } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } }
private void dgvCustomers_CellClick(object sender, DataGridViewCellEventArgs e) { try { CustomerClear(); int custId = Int32.Parse(dgvCustomers.CurrentRow.Cells[0].Value.ToString()); currentCustomer = CustomerController.FindById(custId); txtCustId.Text = currentCustomer.CustomerId.ToString(); txtCustName.Text = currentCustomer.Name; cmbEmployeesCustomer.SelectedText = currentCustomer.EmployeeId.ToString(); } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } }
private void CreateBranchButton_Click(object sender, EventArgs e) { try { String tempId = txtBranchId.Text; tempId = tempId.Trim(); if (String.IsNullOrEmpty(tempId)) { lblresponse.Text = "Id box is empty"; return; } Bransch bransch = new Bransch(); bransch.BranschId = Int32.Parse(tempId); bransch.Name = txtBranchName.Text; bransch.Name = bransch.Name.Trim(); if (bransch.BranschId < 0) { lblresponse.Text = "Id is less than 0"; return; } if (String.IsNullOrEmpty(bransch.Name)) { lblresponse.Text = "You need to write a name"; return; } bool success = BranschController.CreateBransch(bransch); FillListWithAllBranches(); if (success) { lblresponse.Text = "Bransch Created"; } else { lblresponse.Text = "Failed to create Bransch"; } } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } FillListWithAllEmployees(); }
private void dgvCompanies_CellClick(object sender, DataGridViewCellEventArgs e) { try { CompanyClear(); int companyId = Int32.Parse(dgvCompanies.CurrentRow.Cells[0].Value.ToString()); currentCompany = CompanyController.FindById(companyId); txtCompanyId.Text = currentCompany.RegComp_Id.ToString(); txtCompanyName.Text = currentCompany.Name; cmbCompanyBranch.SelectedText = currentCompany.BranschId.ToString(); dgvCompaniesEmployees.DataSource = CompanyController.ReadAllEmployeesForACompany(currentCompany); } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } }
private void btnCompanyCreate_Click(object sender, EventArgs e) { try { String tempId = txtCompanyId.Text; tempId = tempId.Trim(); if (String.IsNullOrEmpty(tempId)) { lblresponse.Text = "Id box is empty"; return; } Registered_Company rc = new Registered_Company(); rc.RegComp_Id = Int32.Parse(tempId); rc.Name = txtCompanyName.Text; rc.BranschId = Int32.Parse(cmbCompanyBranch.SelectedItem.ToString()); if (rc.BranschId < 0) { lblresponse.Text = "Id is less than 0"; return; } if (String.IsNullOrEmpty(rc.Name)) { lblresponse.Text = "You need to write a name"; return; } bool success = CompanyController.CreateRegistered_Company(rc); if (success) { lblresponse.Text = "Company Created"; } else { lblresponse.Text = "Failed to create company"; } } catch (Exception ex) { lblresponse.Text = ErrorHandlern.HandleExceptions(ex); } FillListWithAllCompanies(); }