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) { if (txtCNIC.Text.Equals("") || txtEmail.Text.Equals("") || txtFirstName.Text.Equals("") || txtLastName.Text.Equals("") || (rdoFemale.Checked == false && rdoMale.Checked == false) || dateTimePickerDob.Value.Date > DateTime.Today.Date) { MessageBox.Show("Error fields are empty!"); } else { Passenger passenger = new Passenger(); Person person = new Person(); person.setCNIC(txtCNIC.Text); person.setDateOfBirth(dateTimePickerDob.Value.Date); person.setEmail(txtEmail.Text); person.setFirstName(txtFirstName.Text); person.setLastName(txtLastName.Text); person.setMiddleName(txtMiddleName.Text); if (rdoFemale.Checked) { person.setGender("Female"); } else if (rdoMale.Checked) { person.setGender("Male"); } passenger.setPersonalInformation(person); Database db = new Database(); if (db.addPassenger(passenger)) { MessageBox.Show("Passenger Successfully added!"); passenger.setPid(db.getPassengerID(txtCNIC.Text)); frmAddTicket frm = new frmAddTicket(emp, passenger); this.Hide(); frm.Show(); } else { MessageBox.Show("Unable to add passenger!"); } } }
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!"); } }