Exemplo n.º 1
0
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            String gender = null;

            if (rdoMale.Checked && !rdoFemale.Checked)
            {
                gender = "male";
            }
            else if (!rdoMale.Checked && rdoFemale.Checked)
            {
                gender = "female";
            }
            else
            {
                MessageBox.Show("Please Select a gender!");
                return;
            }

            Person          person  = new Person();
            EmployeeAddress address = new EmployeeAddress();

            person.setFirstName(txtFirstName.Text);
            person.setMiddleName(txtMiddleName.Text);
            person.setLastName(txtLastName.Text);
            person.setCNIC(txtCNIC.Text);
            person.setGender(gender);
            person.setEmail(txtEmail.Text);
            person.setDateOfBirth(dateTimePickerDob.Value);
            address.setCity(txtCity.Text);
            address.setCountry(txtCountry.Text);
            address.setHouseNo(txtHouseNo.Text);
            address.setStreet(txtStreet.Text);
            address.setZipCode(int.Parse(txtZipCode.Text));
            address.setProvince(txtProvince.Text);
            Employee emp = new Employee();

            emp.setPersonalInformation(person);
            emp.setAddress(address);
            emp.setDesignation(txtDesignation.Text);
            emp.setRank(txtRank.Text);
            emp.setQualification(txtQualification.Text);
            emp.setPassword(txtPassword.Text);
            emp.setSalary(int.Parse(txtSalary.Text));
            emp.setDateOfHire(dateTimePickerDoh.Value);
            emp.setEmp_id(int.Parse(txtID.Text));
            Database db = new Database();

            if (db.editProfile(emp))
            {
                MessageBox.Show("Employee Successfully Registered!");
            }
            else
            {
                MessageBox.Show("Unable to register employee!");
            }
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            String gender = null;

            if (rdoMale.Checked && !rdoFemale.Checked)
            {
                gender = "male";
            }
            else if (!rdoMale.Checked && rdoFemale.Checked)
            {
                gender = "female";
            }
            else if (rdoMale.Checked && rdoFemale.Checked)
            {
                MessageBox.Show("Error Invalid Selection: Select only one gender!");
                return;
            }
            else
            {
                MessageBox.Show("Please Select a gender!");
                return;
            }

            Person          person  = new Person();
            EmployeeAddress address = new EmployeeAddress();

            person.setFirstName(txtFirstName.Text);
            person.setMiddleName(txtMiddleName.Text);
            person.setLastName(txtLastName.Text);
            String[] phoneNo = { txtPhoneNo1.Text, txtPhoneNo2.Text, txtPhoneNo3.Text };
            String[] cellNo  = { txtCellNo1.Text, txtCellNo2.Text, txtCellNo3.Text };
            person.setPhoneNo(phoneNo);
            person.setCellNo(cellNo);
            person.setCNIC(txtCNIC.Text);
            person.setGender(gender);
            person.setEmail(txtEmail.Text);
            person.setDateOfBirth(dateTimePickerDob.Value);
            address.setCity(txtCity.Text);
            address.setCountry(txtCountry.Text);
            address.setHouseNo(txtHouseNo.Text);
            address.setStreet(txtStreet.Text);
            address.setZipCode(int.Parse(txtZipCode.Text));
            address.setProvince(txtProvince.Text);
            Employee emp = new Employee();

            emp.setPersonalInformation(person);
            emp.setAddress(address);
            emp.setDesignation(txtDesignation.Text);
            emp.setRank(txtRank.Text);
            emp.setQualification(txtQualification.Text);
            emp.setPassword(txtPassword.Text);
            emp.setSalary(int.Parse(txtSalary.Text));
            emp.setDateOfHire(dateTimePickerDoh.Value);
            Database db = new Database();

            if (db.insertEmployee(emp))
            {
                MessageBox.Show("Employee Successfully Registered! Wait for approval");
                this.Hide();
                frmMainPanel mainPanel = new frmMainPanel();
                mainPanel.Show();
            }
            else
            {
                MessageBox.Show("Unable to register employee!");
            }
        }