Ejemplo n.º 1
0
 private void btnRegister_Click(object sender, EventArgs e)
 {
     if (!validator.IsValidEmail(txtEmail.Text))
     {
         MessageBox.Show("Please enter a valid email address");
     }
     if (txtContactNumber.TextLength < 10)
     {
         MessageBox.Show("Please enter a valid phone number");
     }
     if (txtName.Text.Length <= 3)
     {
         MessageBox.Show("Please enter a valid name");
     }
     if (txtSurname.Text.Length <= 3)
     {
         MessageBox.Show("Please enter a valid surname");
     }
     if (txtAddress.Text.Length < 10)
     {
         MessageBox.Show("Please enter a valid address");
     }
     if (txtPassword.Text != txtConfirmPassword.Text)
     {
         MessageBox.Show("Password do not match");
     }
     if (validator.IsValidEmail(txtEmail.Text) && txtContactNumber.TextLength > 10 && txtAddress.Text.Length > 10 && txtSurname.Text.Length > 3 && txtName.Text.Length > 3 && txtPassword.Text == txtConfirmPassword.Text)
     {
         clientLogic.createClient(new Bronze(id: null, firstName: txtName.Text, lastName: txtSurname.Text, phoneNumber: txtContactNumber.Text, address: txtAddress.Text, email: txtEmail.Text), authenticationLogic.Encipher(txtPassword.Text, 12));
         MessageBox.Show("Successfully Registered!");
     }
 }
Ejemplo n.º 2
0
 private void btnAddEmployee_Click(object sender, EventArgs e)
 {
     if (!validator.IsValidEmail(txtEmail.Text))
     {
         MessageBox.Show("Please enter a valid email address");
     }
     if (txtContactNumber.TextLength < 10)
     {
         MessageBox.Show("Please enter a valid phone number");
     }
     if (txtName.Text.Length <= 3)
     {
         MessageBox.Show("Please enter a valid name");
     }
     if (txtSurname.Text.Length <= 3)
     {
         MessageBox.Show("Please enter a valid surname");
     }
     if (txtVATID.Text.Length < 10)
     {
         MessageBox.Show("Please enter a valid VAT ID");
     }
     if (txtPassword.Text != txtConfirmPassword.Text)
     {
         MessageBox.Show("Password do not match");
     }
     if (cmbEmployeeType.SelectedIndex == -1)
     {
         MessageBox.Show("Please select an employee type");
     }
     if (validator.IsValidEmail(txtEmail.Text) && txtContactNumber.TextLength >= 10 && txtVATID.Text.Length >= 10 && txtSurname.Text.Length >= 3 && txtName.Text.Length >= 3 && txtPassword.Text == txtConfirmPassword.Text && cmbEmployeeType.SelectedIndex >= 0)
     {
         if (cmbEmployeeType.SelectedIndex == 0)
         {
             employeeLogic.addEmplpoyee(employee: new CallCenterStaff(id: null, firstName: txtName.Text, lastName: txtSurname.Text, phoneNumber: txtContactNumber.Text, email: txtEmail.Text, new Pay("", 600), vatID: txtVATID.Text), password: txtPassword.Text, type: cmbEmployeeType.Text);
             MessageBox.Show(string.Format("Call Centre Staff {0} {1} created!", txtName.Text, txtSurname.Text));
         }
         else
         {
             AuthenticationBusinessLogic authenticationBusinessLogic = new AuthenticationBusinessLogic();
             employeeLogic.addEmplpoyee(employee: new TechnicalStaff(id: null, firstName: txtName.Text, lastName: txtSurname.Text, phoneNumber: txtContactNumber.Text, email: txtEmail.Text, new Pay("", 600), vatID: txtVATID.Text), password: authenticationBusinessLogic.Encipher(txtPassword.Text, 12), type: cmbEmployeeType.Text);
             MessageBox.Show(string.Format("Technician {0} {1} created!", txtName.Text, txtSurname.Text));
         }
     }
 }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txt_UserName.Text == "" || txt_Password.Text == "")
            {
                MessageBox.Show("Please provide User Name and Password");
                return;
            }
            try
            {
                AuthenticationBusinessLogic authLogic       = new AuthenticationBusinessLogic();
                Dictionary <string, string> userAuthDetails = authLogic.Authenticate(txt_UserName.Text, authenticationLogic.Encipher(txt_Password.Text, 12));

                if (userAuthDetails != null)
                {
                    EmployeeBusinessLogic employeeBusinessLogic = new EmployeeBusinessLogic();

                    switch (userAuthDetails["userType"])
                    {
                    case "CallCentre":
                        List <Employee> callCentreDetails = employeeBusinessLogic.searchEmployeesByParamater(employeeSearchParamaters.id, employeeType.callCenter, userAuthDetails["id"]);
                        this.Hide();
                        FrmCallCenter frmCallCenter = new FrmCallCenter(callCentreDetails[0]);
                        frmCallCenter.Show();
                        break;

                    case "Technician":
                        List <Employee> technicianDetails = employeeBusinessLogic.searchEmployeesByParamater(employeeSearchParamaters.id, employeeType.technician, userAuthDetails["id"]);

                        List <Employee> stanbyEmployees = employeeBusinessLogic.employeesOnStandBy(employeeType.technician);

                        if (stanbyEmployees.FindIndex(employee => employee.Id == technicianDetails[0].Id) >= 0)
                        {
                            AvailableJobsScreen availableJobsScreen = new AvailableJobsScreen(technicianDetails[0]);
                            this.Hide();
                            availableJobsScreen.Show();
                        }
                        else
                        {
                            Job       currentJob = jobLogic.getJobsBySearchParamater(jobSearchParamaters.employeeID, technicianDetails[0].Id).Except(jobLogic.getJobsBySearchParamater(jobSearchParamaters.status, "Completed")).ToList()[0];
                            JobScreen jobScreen  = new JobScreen(job: currentJob, employee: technicianDetails[0]);
                            this.Hide();
                            jobScreen.Show();
                        }
                        break;

                    case "Client":
                        ClientBusinessLogic clientBusinessLogic = new ClientBusinessLogic();
                        List <Client>       clientDetails       = clientBusinessLogic.searchClientByParameter(clientSearchParameter.id, userAuthDetails["id"]);

                        FrmClientSatisfaction clientSatisfaction = new FrmClientSatisfaction(clientDetails[0]);
                        this.Hide();
                        clientSatisfaction.Show();
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }