Exemple #1
0
 //
 //On click of Add button, validates, adds Employee & displays assigned Employee ID
 //
 private void register_Click(object sender, EventArgs e)
 {
     Employee emp = new Employee();
     emp.first_Name = firstNameText.Text.ToString();
     emp.last_Name = lastNameText.Text.ToString();
     emp.birthdate = birthdatePicker.Value;
     emp.hire_Date = hireDatePicker.Value;
     emp.address = addressText.Text.ToString();
     emp.city = cityText.Text.ToString();
     emp.region = regionText.Text;
     string temp = emp.birthdate + "";
     emp.password = temp.Substring(0, 10);
     if (postalCodeText.TextLength == 0)
         emp.postalCode = 9999999;
     else
         emp.postalCode = Convert.ToInt32(postalCodeText.Text);
     emp.country = countryText.Text.ToString();
     emp.mobile_Number = mobileText.Text.ToString();
     emp.password = passwordText.Text.ToString();
     string confirm = confirmPasswordText.Text.ToString();
     emp.type = 2;
     EmployeeBS cs = new EmployeeBS();
     string feedback = cs.addEmployee(emp,confirm);
     if (feedback.Contains("successfully"))
     {
         DialogResult result = MessageBox.Show(feedback + "   Click Ok to go to Home Page. Click Cancel to Logout", "Add Employee", MessageBoxButtons.OKCancel);
         if (result == DialogResult.OK)
         {
         //    EmpHome f = new EmpHome(emp);
         //    this.Close();
         //    f.Show();
             ParentForm f = new ParentForm(emp);
             this.Close();
             f.Show();
         }
         else if (result == DialogResult.Cancel)
         {
             Application.Exit();
         }
     }
     else
         MessageBox.Show(feedback,"Error",MessageBoxButtons.OK);
 }
Exemple #2
0
        //
        //Ong click on Login: Validates Employee ID, password,type and navigates to appropriate Home page
        //
        private void login_Click(object sender, EventArgs e)
        {
            Employee l = new Employee();
            l.employee_Id = userNameText.Text.ToString();
            l.password = passwordText.Text.ToString();

            if (adminRadioButton.Checked)
            {
                l.type = 1;
                string feed = b.validateLogin(l);
                if (feed.Equals("true"))
                {
                    AdminHome f = new AdminHome(l);
                    this.MdiParent.Hide();
                    this.Close();
                    f.Show();
                }
                else
                {
                    MessageBox.Show(feed,"Login Error");
                }
            }
            else if (employeeRadioButton.Checked)
            {
                l.type = 2;
                string feed = b.validateLogin(l);
                if (feed.Equals("true"))
                {
                    ParentForm f2 = new ParentForm(l);
                    this.MdiParent.Hide();
                    this.Close();
                    f2.Show();
                }
                else
                {
                    MessageBox.Show(feed, "Login Error");
                }
            }
        }