// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_VIEW"]) && Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_EDIT"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["client_id"] == null) || ((string)Request.QueryString["project_id"] == null) || ((string)Request.QueryString["work_id"] == null) || ((string)Request.QueryString["asset_id"] == null) || ((string)Request.QueryString["in_project"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in mr_comments.aspx"); } // Tag Page hdfCompanyId.Value = Session["companyID"].ToString(); hdfCurrentProjectId.Value = Request.QueryString["project_id"].ToString(); hdfCurrentClientId.Value = Request.QueryString["client_id"].ToString(); hdfInProject.Value = Request.QueryString["in_project"].ToString(); hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString(); hdfAdminPermission.Value = Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_ADMIN"]).ToString(); hdfWorkType.Value = "Manhole Rehabilitation"; hdfWorkId.Value = Request.QueryString["work_id"].ToString(); hdfAssetId.Value = Request.QueryString["asset_id"].ToString(); hdfUpdate.Value = "yes"; // ... Names for UserList string workType = hdfWorkType.Value.Trim(); int companyId = Int32.Parse(hdfCompanyId.Value); LoginGateway loginGateway = new LoginGateway(); loginGateway.LoadByLoginId(Convert.ToInt32(hdfLoginId.Value), companyId); hdfCreatedBy.Value = loginGateway.GetLastName(Convert.ToInt32(hdfLoginId.Value), companyId) + " " + loginGateway.GetFirstName(Convert.ToInt32(hdfLoginId.Value), companyId); // Prepare initial data Session.Remove("manholeRehabilitationCommentDetailsDummy"); // If coming from // ... mr_summary.aspx and mr_edit.aspx if (Request.QueryString["source_page"] == "mr_summary.aspx" || Request.QueryString["source_page"] == "mr_edit.aspx") { StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; manholeRehabilitationTDS = (ManholeRehabilitationTDS)Session["manholeRehabilitationTDS"]; int assetId = Int32.Parse(hdfAssetId.Value.Trim()); int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.Trim()); int workId = Int32.Parse(hdfWorkId.Value.Trim()); // ... If the project has works if (workId != 0) { ManholeRehabilitationCommentDetailsGateway manholeRehabilitationCommentDetailsGateway = new ManholeRehabilitationCommentDetailsGateway(manholeRehabilitationTDS); manholeRehabilitationCommentDetailsGateway.LoadAllByWorkIdWorkType(workId,companyId, "Manhole Rehabilitation"); ManholeRehabilitationCommentDetails manholeRehabilitationCommentDetailsForLoad = new ManholeRehabilitationCommentDetails(manholeRehabilitationCommentDetailsGateway.Data); manholeRehabilitationCommentDetailsForLoad.UpdateForProcess(); } // ... Store datasets Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS; Session["manholeRehabilitationCommentDetails"] = manholeRehabilitationTDS.CommentDetails; } } else { // Restore datasets manholeRehabilitationTDS = (ManholeRehabilitationTDS)Session["manholeRehabilitationTDS"]; manholeRehabilitationCommentDetails = manholeRehabilitationTDS.CommentDetails; // Store Session["manholeRehabilitationCommentDetails"] = manholeRehabilitationTDS.CommentDetails; } }
protected void grdComments_RowDataBound(object sender, GridViewRowEventArgs e) { if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || ((e.Row.RowState == DataControlRowState.Alternate)))) { if (((Label)e.Row.FindControl("lblUserId")).Text != "") { int loginId = Int32.Parse(hdfLoginId.Value); bool adminPermission = bool.Parse(hdfAdminPermission.Value); int rowUserId = Int32.Parse(((Label)e.Row.FindControl("lblUserId")).Text); if ((loginId == rowUserId) || (adminPermission)) { e.Row.FindControl("ibtnDelete").Visible = true; e.Row.FindControl("ibtnEdit").Visible = true; } else { e.Row.FindControl("ibtnDelete").Visible = false; e.Row.FindControl("ibtnEdit").Visible = false; } } } // Control values for edit if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)))) { int workId = Int32.Parse(((Label)e.Row.FindControl("lblWorkID")).Text.Trim()); int refId = Int32.Parse(((Label)e.Row.FindControl("lblRefID")).Text.Trim()); ManholeRehabilitationCommentDetailsGateway manholeRehabilitationCommentDetailsGateway = new ManholeRehabilitationCommentDetailsGateway(manholeRehabilitationTDS); string type = manholeRehabilitationCommentDetailsGateway.GetType(workId, refId); if (type != "Manhole Rehabilitation") { ((TextBox)e.Row.FindControl("tbxTypeEdit")).Visible = false; ((DropDownList)e.Row.FindControl("ddlTypeEdit")).SelectedValue = type; ((DropDownList)e.Row.FindControl("ddlTypeEdit")).Visible = true; } else { ((TextBox)e.Row.FindControl("tbxTypeEdit")).Text = type; ((TextBox)e.Row.FindControl("tbxTypeEdit")).Visible = true; ((DropDownList)e.Row.FindControl("ddlTypeEdit")).Visible = false; ((DropDownList)e.Row.FindControl("ddlTypeEdit")).SelectedValue = "Manhole Rehabilitation"; } } // Control value for footer comments if (e.Row.RowType == DataControlRowType.Footer) { // For Material ((DropDownList)e.Row.FindControl("ddlTypeNew")).SelectedValue = "Manhole Rehabilitation"; } }