/// <summary> /// Display Header When GridView Empty with proper message /// </summary> /// <param name="objListSort">EmptyList</param> private void ShowHeaderWhenEmptyGrid() { try { //set header visible gvProfessionalCourses.ShowHeader = true; //Create empty datasource for Grid view and bind ProfessionalDetailsCollection.Add(new BusinessEntities.ProfessionalDetails()); gvProfessionalCourses.DataSource = ProfessionalDetailsCollection; gvProfessionalCourses.DataBind(); //Calculate number of columns in Grid view used for column Span int columnsCount = gvProfessionalCourses.Columns.Count; //clear all the cells in the row gvProfessionalCourses.Rows[0].Cells.Clear(); //add a new blank cell gvProfessionalCourses.Rows[0].Cells.Add(new TableCell()); gvProfessionalCourses.Rows[0].Cells[0].Text = NO_RECORDS_FOUND_MESSAGE; gvProfessionalCourses.Rows[0].Cells[0].Wrap = false; gvProfessionalCourses.Rows[0].Cells[0].Width = Unit.Percentage(10); } catch (RaveHRException ex) { LogErrorMessage(ex); } catch (Exception ex) { RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME, "ShowHeaderWhenEmptyGrid", EventIDConstants.RAVE_HR_PROJECTS_PRESENTATION_LAYER); LogErrorMessage(objEx); } }
/// <summary> /// Handles the Click event of the btnAdd control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnAdd_Click(object sender, EventArgs e) { Rave.HR.BusinessLayer.Employee.ProfessionalDetails objProfessionalDetailsBAL; if (ValidateControls()) { BusinessEntities.ProfessionalDetails objProfessionalDetails = new BusinessEntities.ProfessionalDetails(); objProfessionalDetailsBAL = new Rave.HR.BusinessLayer.Employee.ProfessionalDetails(); if (gvProfessionalCourses.Rows[0].Cells[0].Text == NO_RECORDS_FOUND_MESSAGE) { ProfessionalDetailsCollection.Clear(); } // 26864-Ambar-Start // Code to accept only one decimal point bool is_decimal_point = false; string str_current_char = null, strScore = txtScore.Text; if ((strScore != string.Empty) || (strScore != null) || (strScore != "")) { for (int i = 0; i < txtScore.Text.Length; i++) { str_current_char = strScore.Substring(i, 1); if ((str_current_char == ".")) { if (is_decimal_point) { lblMessage.Text = "<font color=RED>" + "Percentage can contain only one decimal point." + "</font>"; return; } else { is_decimal_point = true; } } } } // 26864-Ambar-End objProfessionalDetails.CourseName = txtCourseName.Text; objProfessionalDetails.InstitutionName = txtInstituteName.Text; objProfessionalDetails.PassingYear = txtYearofPassing.Text; objProfessionalDetails.Score = txtScore.Text; objProfessionalDetails.EMPId = int.Parse(EMPId.Value); objProfessionalDetails.Mode = 1; ProfessionalDetailsCollection.Add(objProfessionalDetails); objProfessionalDetailsBAL.AddProfessionalDetails(objProfessionalDetails); this.PopulateGrid(objProfessionalDetails.EMPId); this.ClearControls(); lblMessage.Text = "Professional Courses saved successfully."; } }
/// <summary> /// Handles the Click event of the btnUpdate control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnUpdate_Click(object sender, EventArgs e) { Rave.HR.BusinessLayer.Employee.ProfessionalDetails objProfessionalDetailsBAL; if (ValidateControls()) { int rowIndex = 0; int deleteRowIndex = -1; objProfessionalDetailsBAL = new Rave.HR.BusinessLayer.Employee.ProfessionalDetails(); BusinessEntities.ProfessionalDetails objProfessionalDetails = new BusinessEntities.ProfessionalDetails(); // 26864-Ambar-Start // Code to accept only one decimal point bool is_decimal_point = false; string str_current_char = null, strScore = txtScore.Text; if ((strScore != string.Empty) || (strScore != null) || (strScore != "")) { for (int i = 0; i < txtScore.Text.Length; i++) { str_current_char = strScore.Substring(i, 1); if ((str_current_char == ".")) { if (is_decimal_point) { lblMessage.Text = "<font color=RED>" + "Percentage can contain only one decimal point." + "</font>"; return; } else { is_decimal_point = true; } } } } // 26864-Ambar-End if (ViewState[DELETEROWINDEX] != null) { deleteRowIndex = Convert.ToInt32(ViewState[DELETEROWINDEX].ToString()); } //Update the grid view according the row, which is selected for editing. if (ViewState[ROWINDEX] != null) { rowIndex = Convert.ToInt32(ViewState[ROWINDEX].ToString()); if (deleteRowIndex != -1 && deleteRowIndex < rowIndex) { rowIndex--; } Label ProfessionalId = (Label)gvProfessionalCourses.Rows[rowIndex].FindControl(PROFESSIONALID); Label Mode = (Label)gvProfessionalCourses.Rows[rowIndex].FindControl(MODE); gvProfessionalCourses.Rows[rowIndex].Cells[0].Text = txtCourseName.Text; gvProfessionalCourses.Rows[rowIndex].Cells[1].Text = txtInstituteName.Text; gvProfessionalCourses.Rows[rowIndex].Cells[2].Text = txtYearofPassing.Text; gvProfessionalCourses.Rows[rowIndex].Cells[3].Text = txtScore.Text; if (int.Parse(ProfessionalId.Text) == 0) { Mode.Text = "1"; } else { Mode.Text = "2"; } ImageButton btnImg = (ImageButton)gvProfessionalCourses.Rows[rowIndex].FindControl(IMGBTNDELETE); btnImg.Enabled = true; ViewState[ROWINDEX] = null; ViewState[DELETEROWINDEX] = null; } for (int i = 0; i < ProfessionalDetailsCollection.Count; i++) { objProfessionalDetails = (BusinessEntities.ProfessionalDetails)ProfessionalDetailsCollection.Item(i); Label ProfessionalId = (Label)gvProfessionalCourses.Rows[i].FindControl(PROFESSIONALID); Label Mode = (Label)gvProfessionalCourses.Rows[i].FindControl(MODE); objProfessionalDetails.ProfessionalId = int.Parse(ProfessionalId.Text); objProfessionalDetails.EMPId = int.Parse(EMPId.Value); objProfessionalDetails.CourseName = gvProfessionalCourses.Rows[i].Cells[0].Text; objProfessionalDetails.InstitutionName = gvProfessionalCourses.Rows[i].Cells[1].Text; objProfessionalDetails.PassingYear = gvProfessionalCourses.Rows[i].Cells[2].Text; objProfessionalDetails.Score = gvProfessionalCourses.Rows[i].Cells[3].Text; objProfessionalDetails.Mode = int.Parse(Mode.Text); } this.DoDataBind(); objProfessionalDetailsBAL.UpdateProfessionalDetails(objProfessionalDetails); //Clear all the fields after inserting row into gridview this.ClearControls(); btnAddRow.Visible = true; btnCancel.Visible = true; btnUpdateRow.Visible = false; btnCancelRow.Visible = false; //Enabling all the edit buttons. for (int i = 0; i < gvProfessionalCourses.Rows.Count; i++) { ImageButton btnImgEdit = (ImageButton)gvProfessionalCourses.Rows[i].FindControl(IMGBTNEDIT); btnImgEdit.Enabled = true; } lblMessage.Text = "Professional Courses updated successfully."; } }
/// <summary> /// Handles the RowDeleting event of the gvProfessionalCourses control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewDeleteEventArgs"/> instance containing the event data.</param> protected void gvProfessionalCourses_RowDeleting(object sender, GridViewDeleteEventArgs e) { int deleteRowIndex = 0; int rowIndex = -1; Boolean Flag = false; Rave.HR.BusinessLayer.Employee.ProfessionalDetails objProfessionalDetailsBAL; BusinessEntities.ProfessionalDetails objProfessionalDetails = new BusinessEntities.ProfessionalDetails(); objProfessionalDetailsBAL = new Rave.HR.BusinessLayer.Employee.ProfessionalDetails(); deleteRowIndex = e.RowIndex; objProfessionalDetails = (BusinessEntities.ProfessionalDetails)ProfessionalDetailsCollection.Item(deleteRowIndex); if (objProfessionalDetails.Mode == 1) { Flag = true; } objProfessionalDetails.Mode = 3; if (ViewState[PROFESSIONALDETAILSDELETE] != null) { BusinessEntities.RaveHRCollection objDeleteProfessionalDetailsCollection = (BusinessEntities.RaveHRCollection)ViewState[PROFESSIONALDETAILSDELETE]; objDeleteProfessionalDetailsCollection.Add(objProfessionalDetails); ViewState[PROFESSIONALDETAILSDELETE] = objDeleteProfessionalDetailsCollection; } else { BusinessEntities.RaveHRCollection objDeleteProfessionalDetailsCollection1 = new BusinessEntities.RaveHRCollection(); objDeleteProfessionalDetailsCollection1.Add(objProfessionalDetails); ViewState[PROFESSIONALDETAILSDELETE] = objDeleteProfessionalDetailsCollection1; } ProfessionalDetailsCollection.RemoveAt(deleteRowIndex); ViewState[DELETEROWINDEX] = deleteRowIndex; DoDataBind(); objProfessionalDetailsBAL.DeleteProfessionalDetails(objProfessionalDetails); if (ViewState[ROWINDEX] != null) { rowIndex = Convert.ToInt32(ViewState[ROWINDEX].ToString()); //check edit index with deleted index if edit index is greater than or equal to delete index then rowindex decremented. if (rowIndex != -1 && deleteRowIndex <= rowIndex) { rowIndex--; //store the rowindex in viewstate. ViewState[ROWINDEX] = rowIndex; } ImageButton btnImg = (ImageButton)gvProfessionalCourses.Rows[rowIndex].FindControl(IMGBTNDELETE); btnImg.Enabled = false; //Disabling all the edit buttons. for (int i = 0; i < gvProfessionalCourses.Rows.Count; i++) { if (rowIndex != i) { ImageButton btnImgEdit = (ImageButton)gvProfessionalCourses.Rows[i].FindControl(IMGBTNEDIT); btnImgEdit.Enabled = false; } } } lblMessage.Text = "Professional Courses deleted successfully."; HfIsDataModified.Value = string.Empty; }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { //Clearing the error label lblError.Text = string.Empty; lblMessage.Text = string.Empty; btnAddRow.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return ButtonClickValidate();"); btnUpdateRow.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return ButtonClickValidate();"); txtCourseName.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtCourseName.ClientID + "','" + imgCourseName.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHABET_WITHSPACE + "');"); imgCourseName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanCourseName.ClientID + "','" + Common.CommonConstants.MSG_ONLY_ALPHABET + "');"); imgCourseName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanCourseName.ClientID + "');"); txtInstituteName.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtInstituteName.ClientID + "','" + imgInstituteName.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHABET_WITHSPECIALCHAR + "');"); imgInstituteName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanInstituteName.ClientID + "','" + Common.CommonConstants.MSG_ALPHABET_SPECIALCHAR + "');"); imgInstituteName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanInstituteName.ClientID + "');"); txtYearofPassing.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtYearofPassing.ClientID + "','" + imgYearofPassing.ClientID + "','" + Common.CommonConstants.VALIDATE_NUMERIC_FUNCTION + "');"); imgYearofPassing.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanYearofPassing.ClientID + "','" + Common.CommonConstants.MSG_NUMERIC + "');"); imgYearofPassing.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanYearofPassing.ClientID + "');"); imgScore.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanScore.ClientID + "','" + Common.CommonConstants.MSG_ALPHA_NUMERIC + "');"); imgScore.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanScore.ClientID + "');"); if (!ValidateURL()) { Response.Redirect(CommonConstants.INVALIDURL, false); } if (Session[Common.SessionNames.EMPLOYEEDETAILS] != null) { employee = (BusinessEntities.Employee)Session[Common.SessionNames.EMPLOYEEDETAILS]; } if (employee != null) { employeeID = employee.EMPId; lblempName.Text = employee.FirstName.ToUpper() + " " + employee.LastName.ToUpper(); } if (!IsPostBack) { Session[SessionNames.PAGEMODE] = Common.MasterEnum.PageModeEnum.View; this.PopulateGrid(employeeID); } if (gvProfessionalCourses.Rows[0].Cells[0].Text == NO_RECORDS_FOUND_MESSAGE) { ProfessionalDetailsCollection.Clear(); ShowHeaderWhenEmptyGrid(); } // Get logged-in user's email id AuthorizationManager objRaveHRAuthorizationManager = new AuthorizationManager(); UserRaveDomainId = objRaveHRAuthorizationManager.getLoggedInUser(); UserMailId = UserRaveDomainId.Replace("co.in", "com"); arrRolesForUser = RaveHRAuthorizationManager.getRolesForUser(objRaveHRAuthorizationManager.getLoggedInUser()); if (UserMailId.ToLower() == employee.EmailId.ToLower() || arrRolesForUser.Contains(AuthorizationManagerConstants.ROLEHR)) { if (Session[SessionNames.PAGEMODE] != null) { PageMode = Session[SessionNames.PAGEMODE].ToString(); if (PageMode == Common.MasterEnum.PageModeEnum.View.ToString() && IsPostBack == false && gvProfessionalCourses.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE) { Professionaldetails.Enabled = false; btnEdit.Visible = true; btnEditCancel.Visible = true; btnCancel.Visible = false; btnAddRow.Visible = false; if (gvProfessionalCourses.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE) { //Enabling all the edit buttons. for (int i = 0; i < gvProfessionalCourses.Rows.Count; i++) { ImageButton btnImgEdit = (ImageButton)gvProfessionalCourses.Rows[i].FindControl(IMGBTNEDIT); btnImgEdit.Enabled = false; ImageButton btnImgDelete = (ImageButton)gvProfessionalCourses.Rows[i].FindControl(IMGBTNDELETE); btnImgDelete.Enabled = false; } } } } } else { Professionaldetails.Enabled = false; } SavedControlVirtualPath = "~/EmployeeMenuUC.ascx"; ReloadControl(); }