protected void grdPointRepairs_RowDataBound(object sender, GridViewRowEventArgs e) { if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)))) { // Initialize values Guid id = new Guid(((Label)e.Row.FindControl("lblId")).Text); int refId = Int32.Parse(((Label)e.Row.FindControl("lblRefId")).Text); int companyId = Int32.Parse(((Label)e.Row.FindControl("lblCOMPANY_ID")).Text); AddRecordPointRepairsGateway addRecordPointRepairsGateway = new AddRecordPointRepairsGateway(addRecordTDS); // ... for direction if (addRecordPointRepairsGateway.GetDirection(id, refId, companyId) != "") { ((DropDownList)e.Row.FindControl("ddlDirectionEdit")).SelectedValue = addRecordPointRepairsGateway.GetDirection(id, refId, companyId); } else { ((DropDownList)e.Row.FindControl("ddlDirectionEdit")).SelectedIndex = 4; } // ... for MhShoot if (addRecordPointRepairsGateway.GetMHShot(id, refId, companyId) != "") { ((DropDownList)e.Row.FindControl("ddlMhShotEdit")).SelectedValue = addRecordPointRepairsGateway.GetMHShot(id, refId, companyId); } else { ((DropDownList)e.Row.FindControl("ddlMhShotEdit")).SelectedIndex = 2; } // ... For Install Date if (addRecordPointRepairsGateway.Table.Rows.Count > 0) { if (addRecordPointRepairsGateway.GetInstallDate(id, refId, companyId).HasValue) { ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateEdit")).SelectedDate = (DateTime)addRecordPointRepairsGateway.GetInstallDate(id, refId, companyId); } } } if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate)))) { // Validation of permissions if (Convert.ToBoolean(Session["sgLFS_APP_EDIT"])) { // Button Validation e.Row.FindControl("ibtnEdit").Visible = true; e.Row.FindControl("ibtnDelete").Visible = true; } else { // Button validation e.Row.FindControl("ibtnEdit").Visible = false; e.Row.FindControl("ibtnDelete").Visible = false; } } if (e.Row.RowType == DataControlRowType.Footer) { if (Convert.ToBoolean(Session["sgLFS_APP_EDIT"])) { // Initialize variables ((DropDownList)e.Row.FindControl("ddlMhShotFooter")).SelectedIndex = 2; ((DropDownList)e.Row.FindControl("ddlDirectionFooter")).SelectedIndex = 4; // If the limit is reached AddRecordPointRepairs addRecordPointRepairs = new AddRecordPointRepairs(addRecordTDS); string newDetailId = addRecordPointRepairs.GetNewPointRepairsDetailId(addRecordTDS); if (newDetailId == "-1") { ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxLinerDistanceFooter")).Visible = false; ((CheckBox)e.Row.FindControl("ddlDirectionFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxLtMhFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxVtMhFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxSizeFooter")).Visible = false; ((DropDownList)e.Row.FindControl("ddlMhShotFooter")).Visible = false; ((CheckBox)e.Row.FindControl("ckbxExptraRepairFooter")).Visible = false; ((CheckBox)e.Row.FindControl("ckbxCancelledFooter")).Visible = false; ((CheckBox)e.Row.FindControl("ckbxApprovedFooter")).Visible = false; ((CheckBox)e.Row.FindControl("ckbxNotApprovedFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxCommentFooter")).Visible = false; e.Row.FindControl("ibtnAdd").Visible = false; lblMaxNumber.Visible = true; } else { ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = true; ((TextBox)e.Row.FindControl("tbxLinerDistanceFooter")).Visible = true; ((DropDownList)e.Row.FindControl("ddlDirectionFooter")).Visible = true; ((TextBox)e.Row.FindControl("tbxLtMhFooter")).Visible = true; ((TextBox)e.Row.FindControl("tbxVtMhFooter")).Visible = true; ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = true; ((TextBox)e.Row.FindControl("tbxSizeFooter")).Visible = true; ((DropDownList)e.Row.FindControl("ddlMhShotFooter")).Visible = true; ((CheckBox)e.Row.FindControl("ckbxExptraRepairFooter")).Visible = true; ((CheckBox)e.Row.FindControl("ckbxCancelledFooter")).Visible = true; ((CheckBox)e.Row.FindControl("ckbxApprovedFooter")).Visible = true; ((CheckBox)e.Row.FindControl("ckbxNotApprovedFooter")).Visible = true; ((TextBox)e.Row.FindControl("tbxCommentFooter")).Visible = true; e.Row.FindControl("ibtnAdd").Visible = true; lblMaxNumber.Visible = false; } } else { ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxLinerDistanceFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxDirectionFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxLtMhFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxVtMhFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxSizeFooter")).Visible = false; ((DropDownList)e.Row.FindControl("ddlMhShotFooter")).Visible = false; ((CheckBox)e.Row.FindControl("ckbxExptraRepairFooter")).Visible = false; ((CheckBox)e.Row.FindControl("ckbxCancelledFooter")).Visible = false; ((CheckBox)e.Row.FindControl("ckbxApprovedFooter")).Visible = false; ((CheckBox)e.Row.FindControl("ckbxNotApprovedFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxCommentFooter")).Visible = false; e.Row.FindControl("ibtnAdd").Visible = false; lblMaxNumber.Visible = false; } } }
protected void grdPointRepairs_RowDataBound(object sender, GridViewRowEventArgs e) { if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)))) { // Initialize values Guid id = new Guid(((Label)e.Row.FindControl("lblId")).Text); int refId = Int32.Parse(((Label)e.Row.FindControl("lblRefId")).Text); int companyId = Int32.Parse(((Label)e.Row.FindControl("lblCOMPANY_ID")).Text); AddRecordPointRepairsGateway addRecordPointRepairsGateway = new AddRecordPointRepairsGateway(addRecordTDS); if (addRecordPointRepairsGateway.Table.Rows.Count > 0) { if (addRecordPointRepairsGateway.GetInstallDate(id, refId, companyId).HasValue) { ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateEdit")).SelectedDate = (DateTime)addRecordPointRepairsGateway.GetInstallDate(id, refId, companyId); } } } if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate)))) { if (Convert.ToBoolean(Session["sgLFS_APP_EDIT"])) { // Button Validation e.Row.FindControl("ibtnEdit").Visible = true; e.Row.FindControl("ibtnDelete").Visible = true; } else { // Button validation e.Row.FindControl("ibtnEdit").Visible = false; e.Row.FindControl("ibtnDelete").Visible = false; } } if (e.Row.RowType == DataControlRowType.Footer) { if (Convert.ToBoolean(Session["sgLFS_APP_EDIT"])) { // If the limit is reached AddRecordPointRepairs addRecordPointRepairs = new AddRecordPointRepairs(addRecordTDS); string newDetailId = addRecordPointRepairs.GetNewPointRepairsDetailId(addRecordTDS); if (newDetailId == "-1") { ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxRepairSizeFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxCostFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxReinstatesFooter")).Visible = false; e.Row.FindControl("ibtnAdd").Visible = false; lblMaxNumber.Visible = true; } else { ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = true; ((TextBox)e.Row.FindControl("tbxRepairSizeFooter")).Visible = true; ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = true; ((TextBox)e.Row.FindControl("tbxCostFooter")).Visible = true; ((TextBox)e.Row.FindControl("tbxReinstatesFooter")).Visible = true; e.Row.FindControl("ibtnAdd").Visible = true; lblMaxNumber.Visible = false; } } else { ((RadDatePicker)e.Row.FindControl("tkrdpInstallDateFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxRepairSizeFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxDistanceFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxCostFooter")).Visible = false; ((TextBox)e.Row.FindControl("tbxReinstatesFooter")).Visible = false; e.Row.FindControl("ibtnAdd").Visible = false; lblMaxNumber.Visible = false; } } }