/// <summary> /// Display Header When GridView Empty with proper message /// </summary> /// <param name="objListSort">EmptyList</param> private void ShowHeaderWhenEmptyGrid() { try { //set header visible gvVisaDetails.ShowHeader = true; //Create empty datasource for Grid view and bind VisaDetailsCollection.Add(new BusinessEntities.VisaDetails()); gvVisaDetails.DataSource = VisaDetailsCollection; gvVisaDetails.DataBind(); //Calculate number of columns in Grid view used for column Span int columnsCount = gvVisaDetails.Columns.Count; //clear all the cells in the row gvVisaDetails.Rows[0].Cells.Clear(); //add a new blank cell gvVisaDetails.Rows[0].Cells.Add(new TableCell()); gvVisaDetails.Rows[0].Cells[0].Text = NO_RECORDS_FOUND_MESSAGE; gvVisaDetails.Rows[0].Cells[0].Wrap = false; gvVisaDetails.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) { if (ValidateVisaControls()) { BusinessEntities.VisaDetails objVisaDetails = new BusinessEntities.VisaDetails(); if (gvVisaDetails.Rows[0].Cells[0].Text == NO_RECORDS_FOUND_MESSAGE) { VisaDetailsCollection.Clear(); } objVisaDetails.CountryName = txtCountryName.Text; objVisaDetails.VisaType = txtVisaType.Text; objVisaDetails.ExpiryDate = Convert.ToDateTime(ucDatePickerVisaExpiryDate.Text); objVisaDetails.Mode = 1; VisaDetailsCollection.Add(objVisaDetails); this.DoDataBind(); this.ClearControls(); btnAddRow.Text = CommonConstants.BTN_AddRow; HfIsDataModified.Value = CommonConstants.YES; } }
/// <summary> /// Handles the SelectedIndexChanged event of the rbtnValidVisa 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 rbtnValidVisa_SelectedIndexChanged(object sender, EventArgs e) { if (rbtnValidVisa.SelectedItem.Text == CommonConstants.YES) { divVisaDetails.Visible = true; if (gvVisaDetails.Rows[0].Cells[0].Text == NO_RECORDS_FOUND_MESSAGE) { VisaDetailsCollection.Clear(); ShowHeaderWhenEmptyGrid(); } } else { divVisaDetails.Visible = false; } }
/// <summary> /// Handles the RowDeleting event of the gvVisaDetails 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 gvVisaDetails_RowDeleting(object sender, GridViewDeleteEventArgs e) { int deleteRowIndex = 0; int rowIndex = -1; Boolean Flag = false; BusinessEntities.VisaDetails objVisaDetails = new BusinessEntities.VisaDetails(); deleteRowIndex = e.RowIndex; objVisaDetails = (BusinessEntities.VisaDetails)VisaDetailsCollection.Item(deleteRowIndex); if (objVisaDetails.Mode == 1) { Flag = true; } objVisaDetails.Mode = 3; if (ViewState[VISADETAILSDELETE] != null) { BusinessEntities.RaveHRCollection objDeleteVisaDetailsCollection = (BusinessEntities.RaveHRCollection)ViewState[VISADETAILSDELETE]; objDeleteVisaDetailsCollection.Add(objVisaDetails); ViewState[VISADETAILSDELETE] = objDeleteVisaDetailsCollection; } else { BusinessEntities.RaveHRCollection objDeleteVisaDetailsCollection1 = new BusinessEntities.RaveHRCollection(); objDeleteVisaDetailsCollection1.Add(objVisaDetails); ViewState[VISADETAILSDELETE] = objDeleteVisaDetailsCollection1; } VisaDetailsCollection.RemoveAt(deleteRowIndex); ViewState[DELETEROWINDEX] = deleteRowIndex; DoDataBind(); 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)gvVisaDetails.Rows[rowIndex].FindControl(IMGBTNDELETE); btnImg.Enabled = false; //Disabling all the edit buttons. for (int i = 0; i < gvVisaDetails.Rows.Count; i++) { if (rowIndex != i) { ImageButton btnImgEdit = (ImageButton)gvVisaDetails.Rows[i].FindControl(IMGBTNEDIT); btnImgEdit.Enabled = false; } } } if (gvVisaDetails.Rows[0].Cells[0].Text == NO_RECORDS_FOUND_MESSAGE && Flag == true) { btnAddRow.Text = CommonConstants.BTN_Save; } HfIsDataModified.Value = CommonConstants.YES; }
/// <summary> /// Handles the Click event of the btnUpdateRow 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 btnUpdateRow_Click(object sender, EventArgs e) { if (ValidateVisaControls()) { int rowIndex = 0; int deleteRowIndex = -1; 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 VisaId = (Label)gvVisaDetails.Rows[rowIndex].FindControl(VISAID); Label Mode = (Label)gvVisaDetails.Rows[rowIndex].FindControl(MODE); gvVisaDetails.Rows[rowIndex].Cells[0].Text = txtCountryName.Text; gvVisaDetails.Rows[rowIndex].Cells[1].Text = txtVisaType.Text; gvVisaDetails.Rows[rowIndex].Cells[2].Text = ucDatePickerVisaExpiryDate.Text; if (int.Parse(VisaId.Text) == 0) { Mode.Text = "1"; } else { Mode.Text = "2"; } ImageButton btnImg = (ImageButton)gvVisaDetails.Rows[rowIndex].FindControl(IMGBTNDELETE); btnImg.Enabled = true; ViewState[ROWINDEX] = null; ViewState[DELETEROWINDEX] = null; } for (int i = 0; i < VisaDetailsCollection.Count; i++) { BusinessEntities.VisaDetails objVisaDetails = new BusinessEntities.VisaDetails(); objVisaDetails = (BusinessEntities.VisaDetails)VisaDetailsCollection.Item(i); Label VisaId = (Label)gvVisaDetails.Rows[i].FindControl(VISAID); Label Mode = (Label)gvVisaDetails.Rows[i].FindControl(MODE); objVisaDetails.VisaId = int.Parse(VisaId.Text); objVisaDetails.EMPId = int.Parse(EMPId.Value); objVisaDetails.CountryName = gvVisaDetails.Rows[i].Cells[0].Text; objVisaDetails.VisaType = gvVisaDetails.Rows[i].Cells[1].Text; objVisaDetails.ExpiryDate = Convert.ToDateTime(gvVisaDetails.Rows[i].Cells[2].Text); objVisaDetails.Mode = int.Parse(Mode.Text); } //Clear all the fields after inserting row into gridview this.ClearControls(); btnAddRow.Visible = true; btnUpdateRow.Visible = false; btnCancelRow.Visible = false; //Enabling all the edit buttons. for (int i = 0; i < gvVisaDetails.Rows.Count; i++) { ImageButton btnImgEdit = (ImageButton)gvVisaDetails.Rows[i].FindControl(IMGBTNEDIT); btnImgEdit.Enabled = true; } HfIsDataModified.Value = CommonConstants.YES; } }
/// <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();"); btnSave.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return SaveButtonClickValidate();"); txtCountryName.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtCountryName.ClientID + "','" + imgCountryName.ClientID + "','" + Common.CommonConstants.VALIDATE_ISALPHABET + "');"); imgCountryName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanCountryName.ClientID + "','" + Common.CommonConstants.MSG_ONLY_ALPHABET + "');"); imgCountryName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanCountryName.ClientID + "');"); txtVisaType.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtVisaType.ClientID + "','" + imgVisaType.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHABET_WITHSPACE + "');"); imgVisaType.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanVisaType.ClientID + "','" + Common.CommonConstants.MSG_ONLY_ALPHABET + "');"); imgVisaType.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanVisaType.ClientID + "');"); ucDatePickerExpiryDate.Attributes.Add(CommonConstants.EVENT_ONBLUR, "javascript:ValidateControl('" + ucDatePickerExpiryDate.ClientID + "','','');"); ucDatePickerExpiryDate.Attributes.Add(ReadOnly, ReadOnly); ucDatePickerVisaExpiryDate.Attributes.Add(CommonConstants.EVENT_ONBLUR, "javascript:ValidateControl('" + ucDatePickerVisaExpiryDate.ClientID + "','','');"); ucDatePickerVisaExpiryDate.Attributes.Add(ReadOnly, ReadOnly); ucDatePickerIssueDate.Attributes.Add(CommonConstants.EVENT_ONBLUR, "javascript:ValidateControl('" + ucDatePickerIssueDate.ClientID + "','','');"); ucDatePickerIssueDate.Attributes.Add(ReadOnly, ReadOnly); txtPassportNo.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtPassportNo.ClientID + "','" + imgPassportNo.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHA_NUMERIC_FUNCTION + "');"); //CR - 28321 - Passport Application Number Sachin - Start txtPassportAppNo.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtPassportNo.ClientID + "','" + imgPassportNo.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHA_NUMERIC_FUNCTION + "');"); //CR - 28321 - Passport Application Number Sachin - End //txtPassportNo.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return Max_Length1();"); //imgPassportNo.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanPassportNo.ClientID + "','" + Common.CommonConstants.MSG_ALPHA_NUMERIC + "');"); //imgPassportNo.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanPassportNo.ClientID + "');"); txtIssuePlace.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtIssuePlace.ClientID + "','" + imgIssuePlace.ClientID + "','" + Common.CommonConstants.VALIDATE_ISALPHABET + "');"); imgIssuePlace.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanIssuePlace.ClientID + "','" + Common.CommonConstants.MSG_ONLY_ALPHABET + "');"); imgIssuePlace.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanIssuePlace.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.PopulateControl(); this.PopulateGrid(employeeID); } if (gvVisaDetails.Rows[0].Cells[0].Text == NO_RECORDS_FOUND_MESSAGE) { VisaDetailsCollection.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) { if (!string.IsNullOrEmpty(txtPassportNo.Text)) { passportdetails.Enabled = false; visaDetails.Enabled = false; rbtnValidPassport.Enabled = false; lblValidPassport.Enabled = false; btnEdit.Visible = true; btnSave.Visible = false; } else { passportdetails.Enabled = true; visaDetails.Enabled = true; rbtnValidPassport.Enabled = true; lblValidPassport.Enabled = true; btnEdit.Visible = false; btnSave.Visible = true; } } } } else { passportdetails.Enabled = false; btnEdit.Visible = false; btnCancel.Visible = false; btnAddRow.Visible = false; visaDetails.Enabled = false; btnSave.Visible = false; rbtnValidPassport.Enabled = false; lblValidPassport.Enabled = false; } SavedControlVirtualPath = "~/EmployeeMenuUC.ascx"; ReloadControl(); }