Example #1
0
        /// <summary>
        /// SaveForEdit
        /// </summary>
        /// <param name="viewId">viewId</param>
        /// <param name="loginId">loginId</param>
        /// <param name="name">name</param>
        /// <param name="type">type</param>
        /// <param name="logic">logic</param>
        /// <param name="sqlCommand">sqlCommand</param>
        /// <param name="workType">workType</param>
        /// <param name="companyId">companyId</param>
        public void SaveForEdit(int viewId, int loginId, string name, string type, string logic, string sqlCommand, string workType, int companyId, string newName, string newType)
        {
            WorkViewGateway workViewGateway = new WorkViewGateway();
            workViewGateway.LoadByViewId(viewId, companyId);

            int originalViewId = viewId;
            int originalLoginId = workViewGateway.GetLoginId(viewId);
            string originalName = workViewGateway.GetName(viewId);
            string originalType = workViewGateway.GetType(viewId);
            string originalLogic = workViewGateway.GetLogic(viewId);
            string originalSqlCommand = workViewGateway.GetSqlCommand(viewId);
            string originalWorkType = workViewGateway.GetWorkType(viewId);
            bool originalDeleted = workViewGateway.GetDeleted(viewId);
            int originalCompanyId = workViewGateway.GetCompanyId(viewId);

            UpdateDirect(originalViewId, originalLoginId, originalName, originalType, originalLogic, originalSqlCommand, originalWorkType, originalDeleted, originalCompanyId, viewId, loginId, newName, newType, logic, sqlCommand, workType, false, companyId);
        }
        protected void btnViewDelete_Click(object sender, EventArgs e)
        {
            int viewId = Int32.Parse(ddlView.SelectedValue.Trim());
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            if (!Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_DELETE"]))
            {
                WorkViewGateway workViewGateway = new WorkViewGateway();
                workViewGateway.LoadByViewId(viewId, companyId);
                string viewType = workViewGateway.GetType(viewId);

                if (viewType == "Global")
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }
            }

            UpdateDatabaseForViews();

            // ... For view ddl
            string workType = hdfWorkType.Value;
            int loginId = Convert.ToInt32(Session["loginID"]);
            string viewTypeGlobal = "";
            string viewTypePersonal = "Personal";

            // Global Views check
            if (Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_VIEW"]))
            {
                viewTypeGlobal = "Global";
            }

            WorkViewList workViewList = new WorkViewList();
            workViewList.LoadAndAddItem(workType, viewTypeGlobal, viewTypePersonal, loginId, companyId);
            ddlView.DataSource = workViewList.Table;
            ddlView.DataValueField = "ViewID";
            ddlView.DataTextField = "Name";
            ddlView.DataBind();
            ddlView.SelectedIndex = 1;
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["work_type"] == null) || ((string)Request.QueryString["view_id"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in view_edit.aspx");
                }

                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_VIEWS_EDIT"])))
                {
                    if ((string)Request.QueryString["work_type"] == "Rehab Assessment")
                    {
                        if (!(Convert.ToBoolean(Session["sgLFS_CWP_REHABASSESSMENT_VIEW"])))
                        {
                            Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                        }
                    }

                    if ((string)Request.QueryString["work_type"] == "Full Length Lining")
                    {
                        if (!(Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_VIEW"])))
                        {
                            Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                        }
                    }

                    if ((string)Request.QueryString["work_type"] == "Junction Lining")
                    {
                        if (!(Convert.ToBoolean(Session["sgLFS_CWP_JUNCTIONLINING_VIEW"])))
                        {
                            Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                        }
                    }

                    if ((string)Request.QueryString["work_type"] == "Point Repairs")
                    {
                        if (!(Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_VIEW"])))
                        {
                            Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                        }
                    }

                    if ((string)Request.QueryString["work_type"] == "Manhole Rehabilitation")
                    {
                        if (!(Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_VIEW"])))
                        {
                            Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                        }
                    }
                }

                // Tag page
                hdfWorkType.Value = (string)Request.QueryString["work_type"];
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfViewId.Value = (string)Request.QueryString["view_id"];
                hdfProjectId.Value = (string)Request.QueryString["project_id"];
                int viewId = int.Parse(hdfViewId.Value);
                int companyId = int.Parse(hdfCompanyId.Value);
                hdfUpdate.Value = "no";

                // Security check for global views
                if (!(Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_EDIT"])))
                {
                    if ((string)Request.QueryString["work_type"] == "Rehab Assessment")
                    {
                        if (Convert.ToBoolean(Session["sgLFS_CWP_REHABASSESSMENT_VIEW"]))
                        {
                            WorkViewGateway workViewGateway = new WorkViewGateway();
                            workViewGateway.LoadByViewId(Int32.Parse(hdfViewId.Value), Int32.Parse(hdfCompanyId.Value));
                            string viewType = workViewGateway.GetType(Int32.Parse(hdfViewId.Value));

                            if (viewType == "Global")
                            {
                                Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                            }
                        }
                    }

                    if ((string)Request.QueryString["work_type"] == "Full Length Lining")
                    {
                        if (Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_VIEW"]))
                        {
                            WorkViewGateway workViewGateway = new WorkViewGateway();
                            workViewGateway.LoadByViewId(Int32.Parse(hdfViewId.Value), Int32.Parse(hdfCompanyId.Value));
                            string viewType = workViewGateway.GetType(Int32.Parse(hdfViewId.Value));

                            if (viewType == "Global")
                            {
                                Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                            }
                        }
                    }

                    if ((string)Request.QueryString["work_type"] == "Junction Lining")
                    {
                        if (Convert.ToBoolean(Session["sgLFS_CWP_JUNCTIONLINING_VIEW"]))
                        {
                            WorkViewGateway workViewGateway = new WorkViewGateway();
                            workViewGateway.LoadByViewId(Int32.Parse(hdfViewId.Value), Int32.Parse(hdfCompanyId.Value));
                            string viewType = workViewGateway.GetType(Int32.Parse(hdfViewId.Value));

                            if (viewType == "Global")
                            {
                                Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                            }
                        }
                    }

                    if ((string)Request.QueryString["work_type"] == "Point Repairs")
                    {
                        if (Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_VIEW"]))
                        {
                            WorkViewGateway workViewGateway = new WorkViewGateway();
                            workViewGateway.LoadByViewId(Int32.Parse(hdfViewId.Value), Int32.Parse(hdfCompanyId.Value));
                            string viewType = workViewGateway.GetType(Int32.Parse(hdfViewId.Value));

                            if (viewType == "Global")
                            {
                                Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                            }
                        }
                    }

                    if ((string)Request.QueryString["work_type"] == "Manhole Rehabilitation")
                    {
                        if (Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_VIEW"]))
                        {
                            WorkViewGateway workViewGateway = new WorkViewGateway();
                            workViewGateway.LoadByViewId(Int32.Parse(hdfViewId.Value), Int32.Parse(hdfCompanyId.Value));
                            string viewType = workViewGateway.GetType(Int32.Parse(hdfViewId.Value));

                            if (viewType == "Global")
                            {
                                Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                            }
                        }
                    }
                }

                ViewState["columnsToDisplayPageIndex"] = 0;
                ViewState["sortPageIndex"] = 0;

                Session.Remove("workTypeViewDisplay");
                Session.Remove("workTypeViewDisplayDummy");
                Session.Remove("workViewDisplayTemp");
                Session.Remove("workViewDisplay");
                Session.Remove("workViewConditionNew");
                Session.Remove("workViewConditionTemp");
                Session.Remove("workViewConditionNewDummy");
                Session.Remove("workViewConditionTempDummy");

                // Prepare initial data
                // ... For view type
                WorkViewTypeList workViewTypeList = new WorkViewTypeList(new DataSet());
                workViewTypeList.LoadAndAddItem("(Select a type)", int.Parse(hdfCompanyId.Value));
                ddlType.DataSource = workViewTypeList.Table;
                ddlType.DataValueField = "Type";
                ddlType.DataTextField = "Type";
                ddlType.DataBind();
                ddlType.SelectedIndex = 0;

                // ... Global Views check
                if (!Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_VIEW"]))
                {
                    ddlType.Items.Remove("Global");
                }

                // If coming from
                // ... ra_navigator.aspx, ra_navigator2.aspx, fl_navigator.aspx, fl_navigator2.aspx, jl_navigator.aspx, jl_navigator2.aspx, pr_navigator.aspx or pr_navigator2.aspx, , mr_navigator.aspx, mr_navigator2.aspx
                if ((Request.QueryString["source_page"] == "ra_navigator.aspx") || (Request.QueryString["source_page"] == "ra_navigator2.aspx") || (Request.QueryString["source_page"] == "fl_navigator.aspx") || (Request.QueryString["source_page"] == "fl_navigator2.aspx") || (Request.QueryString["source_page"] == "jl_navigator.aspx") || (Request.QueryString["source_page"] == "jl_navigator2.aspx") || (Request.QueryString["source_page"] == "pr_navigator.aspx") || (Request.QueryString["source_page"] == "pr_navigator2.aspx") || (Request.QueryString["source_page"] == "mr_navigator.aspx") || (Request.QueryString["source_page"] == "mr_navigator2.aspx"))
                {
                    // ... For Grids
                    workViewTDS = new WorkViewTDS();

                    workTypeViewDisplay = new WorkViewTDS.LFS_WORK_TYPE_VIEW_DISPLAYDataTable();
                    workTypeViewSort = new WorkViewTDS.LFS_WORK_TYPE_VIEW_SORTDataTable();
                    workViewDisplayTemp = new WorkViewTDS.WorkViewDisplayTempDataTable();
                    workViewSortTemp = new WorkViewTDS.WorkViewSortTempDataTable();
                    workViewConditionNew = new WorkViewTDS.WorkViewConditionNewDataTable();
                    workViewConditionTemp = new WorkViewTDS.WorkViewConditionTempDataTable();

                    // Initiaize view data
                    // ... Loading views and data
                    WorkViewGateway workViewGateway = new WorkViewGateway(workViewTDS);
                    workViewGateway.LoadByViewId(viewId, companyId);
                    tbxName.Text = workViewGateway.GetName(viewId);
                    ddlType.SelectedValue = workViewGateway.GetType(viewId);

                    // ... Store datasets
                    Session["workTypeViewDisplay"] = workTypeViewDisplay;
                    Session["workTypeViewSort"] = workTypeViewSort;
                    Session["workViewDisplayTemp"] = workViewDisplayTemp;
                    Session["workViewSortTemp"] = workViewSortTemp;
                    Session["workViewConditionNew"] = workViewConditionNew;
                    Session["workViewConditionTemp"] = workViewConditionTemp;
                }

                // StepSection1In
                wzViews.ActiveStepIndex = 0;
                StepBeginIn();
            }
            else
            {
                // Restore datasets
                workViewTDS = (WorkViewTDS)Session["workViewTDS"];

                workTypeViewDisplay = (WorkViewTDS.LFS_WORK_TYPE_VIEW_DISPLAYDataTable)Session["workTypeViewDisplay"];
                workTypeViewSort = (WorkViewTDS.LFS_WORK_TYPE_VIEW_SORTDataTable)Session["workTypeViewSort"];
                workViewDisplayTemp = (WorkViewTDS.WorkViewDisplayTempDataTable)Session["workViewDisplayTemp"];
                workViewSortTemp = (WorkViewTDS.WorkViewSortTempDataTable)Session["workViewSortTemp"];
                workViewConditionNew = (WorkViewTDS.WorkViewConditionNewDataTable)Session["workViewConditionNew"];
                workViewConditionTemp = (WorkViewTDS.WorkViewConditionTempDataTable)Session["workViewConditionTemp"];
            }

            // control for postback
            hdfTag.Value = DateTime.Now.ToLongTimeString();
        }