protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if ((Session["employeeID"] == null)) { // go back to the seach employee page Response.Redirect("~/Admin/EmployeeManagement/SearchEmployee.aspx"); } else { employeeID = Convert.ToInt32(Session["employeeID"]); employeeSearched = EmployeeManager.GetEmployeeByID(employeeID); // dislay the employee details DisplayEmployee(employeeSearched); // Get job description position = JobPositionManager.GetPositionByID(employeeSearched.JobPositionID); DisplayJobPosition(position); // With the employee id, get the address id for the Home Address // from the EmployeeAddress table homeAddress.AddressID = EmployeeAddressManager.GetAddressID(Convert.ToInt32(AddressType.Home), employeeSearched.EmployeeID); homeAddress = AddressManager.GetAddressById(homeAddress.AddressID); DisplayHomeAddress(homeAddress); } } }
protected void lnkSavePersonalInformationOnEdit_OnCommand(object sender, CommandEventArgs e) { //hide the modal popup mPopupEdit_PersonalInformation.Hide(); //get the new values from the form employeeSearched.Firstname = (fview_EditPersonalInformation.FindControl("txtFirstname") as TextBox).Text.Trim(); employeeSearched.Lastname = (fview_EditPersonalInformation.FindControl("txtLastname") as TextBox).Text.Trim(); employeeSearched.Email = (fview_EditPersonalInformation.FindControl("txtEmail") as TextBox).Text.Trim(); employeeSearched.Gender = (fview_EditPersonalInformation.FindControl("ddlGender") as DropDownList).Text.Trim(); employeeSearched.Homephone = (fview_EditPersonalInformation.FindControl("txtHomePhone") as TextBox).Text.Trim(); employeeSearched.Mobilephone = (fview_EditPersonalInformation.FindControl("txtMobilePhone") as TextBox).Text.Trim(); employeeSearched.EmergencyContact = (fview_EditPersonalInformation.FindControl("txtEmergencyContact") as TextBox).Text.Trim(); employeeSearched.EmergencyPhone1 = (fview_EditPersonalInformation.FindControl("txtEmergencyPhone1") as TextBox).Text.Trim(); employeeSearched.EmergencyPhone2 = (fview_EditPersonalInformation.FindControl("txtEmergencyPhone2") as TextBox).Text.Trim(); employeeSearched.Notes = (fview_EditPersonalInformation.FindControl("txtNotes") as TextBox).Text.Trim(); employeeSearched.ModifiedDate = DateTime.Now.ToLocalTime(); employeeSearched.JobPositionID = Convert.ToInt32((fview_EditPersonalInformation.FindControl("ddlJobTitle") as DropDownList).Text.Trim()); position.PositionID = Convert.ToInt32((fview_EditPersonalInformation.FindControl("ddlJobTitle") as DropDownList).Text.Trim()); //save the changes EmployeeManager.Save(employeeSearched); DisplayEmployee(employeeSearched); position = JobPositionManager.GetPositionByID(employeeSearched.JobPositionID); DisplayJobPosition(position); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable searchResultsDataTable = JobPositionManager.GetAll(); gviewPositions.DataSource = searchResultsDataTable; gviewPositions.DataBind(); } }
protected void gviewJobPosition_RowDeleting(object sender, GridViewDeleteEventArgs e) { int rowIndex = e.RowIndex; jobPosition.PositionID = Convert.ToInt32((gviewPositions.Rows[rowIndex].FindControl("lnkDeletePosition") as LinkButton).CommandArgument); //delete the position JobPositionManager.DeleteJobPosition(jobPosition); //refresh the page Response.Redirect("~/Admin/EmployeeManagement/ManageJobTitle.aspx"); }
protected void lnkEditPersonalInformation_OnCommand(object sender, CommandEventArgs e) { EmployeeList el = new EmployeeList(); el.Add(EmployeeManager.GetEmployeeByID(employeeSearched.EmployeeID)); JobPositionList jl = new JobPositionList(); jl.Add(JobPositionManager.GetPositionByID(employeeSearched.JobPositionID)); fview_EditPersonalInformation.DataSource = el; fview_EditPersonalInformation.DataBind(); this.mPopupEdit_PersonalInformation.Show(); }
protected void gviewPositions_RowDataBound(object sender, GridViewRowEventArgs e) { List <int> activePositionIDList = JobPositionManager.GetPositionIDsInUse(); if (e.Row.RowType == DataControlRowType.DataRow) { HiddenField hdnPositionID = (e.Row.FindControl("hdnPositionID") as HiddenField); int positionIDToBeDeleted = Convert.ToInt32(hdnPositionID.Value); if (activePositionIDList.Contains(positionIDToBeDeleted)) { //disable the delete button LinkButton lnkDeletePosition = (e.Row.FindControl("lnkDeletePosition") as LinkButton); lnkDeletePosition.Enabled = false; lnkDeletePosition.ForeColor = System.Drawing.Color.Gray; } } }
protected void lnkSave_OnCommand(object sender, CommandEventArgs e) { //clear previous messages lblJobPositionMessage.Text = ""; JobPosition job = new JobPosition(); job.PositionName = txtNewPosition.Text.Trim(); //check if position name already exist. If it does, do not add List <string> jobPositionsList = JobPositionManager.GetPositionNames(); if (jobPositionsList.Contains(job.PositionName.ToLower())) { //do not add lblJobPositionMessage.Text = " This position already exists!"; lblJobPositionMessage.ForeColor = System.Drawing.Color.Red; } else { //save job.PositionID = JobPositionManager.Save(job); Response.Redirect("~/Admin/EmployeeManagement/ManageJobTitle.aspx"); } }