/// <summary> /// ibtnManageEmployeeSave_Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ibtnManageEmployeeSave_Click(object sender, EventArgs e) { try { if (!FormValidation()) { return; } string dtFormat = _dateFormat; DateTime dTime; // Create a new Employee Object _currentEmployee = new EmployeeDL(); // Set whether Add / Edit if (txtEmployeeID.Text.ToString() != "0") { _currentEmployee = new EmployeeDL(Convert.ToInt32(txtEmployeeID.Text), true); _currentEmployee.EmployeeAddresses.Clear(); _currentEmployee.AddEditOption = 1; } else { _currentEmployee.AddEditOption = 0; _currentEmployee.RoleID = Convert.ToInt32(ddlRole.SelectedValue.ToString()); } _currentEmployee.EmployeeID = Convert.ToInt32(txtEmployeeID.Text); // Assign Values to the Company Object _currentEmployee.CompanyID = _companyID; _currentEmployee.EmployeeCode = txtEmployeeCode.Text; _currentEmployee.Initial = txtEmployeeInitial.Text; _currentEmployee.FName = txtEmployeeName.Text; _currentEmployee.GenderID = Convert.ToInt32(ddlGender.SelectedValue.ToString()); _currentEmployee.DepartmentID = Convert.ToInt32(ddlDepartment.SelectedValue.ToString()); dTime = DateTime.ParseExact(txtDOB.Text, _dateFormat, null); _currentEmployee.Dob = dTime; dTime = DateTime.ParseExact(txtDOJ.Text, _dateFormat, null); _currentEmployee.Doj = dTime; _currentEmployee.OfficeEmailID = txtOfficeMailID.Text; _currentEmployee.CreatorUserID = _userID; // _currentEmployee.ModifierUserID = _userID; DataSet dsEmployee = _currentEmployee.GetEmployeeListByEmployeeCode(_currentEmployee.EmployeeCode, _currentEmployee.CompanyID); if ((dsEmployee.Tables[0].Rows.Count > 0) && (_currentEmployee.AddEditOption == 0)) { lblMessage.Text = "EmployeeCode already exists."; mpeManageEmployee.Show(); return; } // Add / Edit the Company TransactionResult result; _currentEmployee.ScreenMode = ScreenMode.Add; result = _currentEmployee.Commit(); // Display the Status - Whether successfully saved or not System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script>alert('" + result.Message.ToString() + ".');"); sb.Append("</script>"); ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false); // If successful get and display the saved Company if (result.Status == TransactionStatus.Success) { GetEmployeeDetails("", Convert.ToBoolean(rblReportOption.SelectedValue)); ClearText(); lblPopupHeading.Text = "Add Employee"; } trRole.Visible = true; txtEmployeeCode.Enabled = true; } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("ManageEmployee.aspx", "", "ibtnManageEmployeeSave_Click", ex.Message.ToString(), new ACEConnection()); } }