protected void saveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { string name = employeeNameTextBox.Text; string email = emailAddressTextBox.Text; string mobileNumber = mobileNumberTextBox.Text; string district = districtTextBox.Text; string gender = genderDropDownList.SelectedItem.Text; DateTime dateOfBirth = DateTime.Parse(dateSelectTextBox.Text); int registrationNumber = Convert.ToInt32(registrationNumberTextBox.Text); Employee newEmployee = new Employee(name, email, mobileNumber, district, gender, dateOfBirth, registrationNumber); int departmentID = Int32.Parse(ddlDepartment.SelectedValue); newEmployee.DepartmentID = departmentID; newDepartMent.Employees.Add(newEmployee); if (employeeManagement.IsExist(newEmployee)) { msgLabel.Text = "Employee Id Already Exist"; msgLabel.ForeColor = Color.Red; registrationNumberTextBox.Focus(); } else { msgLabel.Text = employeeManagement.SendData(newEmployee); GetClear(); } } }