Пример #1
0
        /// <summary>
        /// GetNextId
        /// </summary>
        /// <param name="flNavigatorTDS">flNavigatorTDS</param>
        /// <param name="currentAssetId">currentAssetId</param>
        /// <returns>nextAssetId</returns>
        public static int GetNextId(FlNavigatorTDS flNavigatorTDS, int currentAssetId)
        {
            int nextAssetId = currentAssetId;

            for (int i = 0; i < flNavigatorTDS.FlNavigator.DefaultView.Count; i++)
            {
                if ((int)flNavigatorTDS.FlNavigator.DefaultView[i]["AssetID"] == currentAssetId)
                {
                    if (i == flNavigatorTDS.FlNavigator.DefaultView.Count - 1)
                    {
                        nextAssetId = currentAssetId;
                    }
                    else
                    {
                        nextAssetId = (int)flNavigatorTDS.FlNavigator.DefaultView[i + 1]["AssetID"];
                    }
                    break;
                }
            }

            return nextAssetId;
        }
Пример #2
0
        /// <summary>
        /// GetPreviousId
        /// </summary>
        /// <param name="flNavigatorTDS">flNavigatorTDS</param>
        /// <param name="currentAssetId">currentAssetId</param>
        /// <returns>prevAssetId</returns>
        public static int GetPreviousId(FlNavigatorTDS flNavigatorTDS, int currentAssetId)
        {
            int prevAssetId = currentAssetId;

            for (int i = 0; i < flNavigatorTDS.FlNavigator.DefaultView.Count; i++)
            {
                if ((int)flNavigatorTDS.FlNavigator.DefaultView[i]["AssetID"] == currentAssetId)
                {
                    if (i == 0)
                    {
                        prevAssetId = currentAssetId;
                    }
                    else
                    {
                        prevAssetId = (int)flNavigatorTDS.FlNavigator.DefaultView[i - 1]["AssetID"];
                    }

                    break;
                }
            }

            return prevAssetId;
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                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.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["client_id"] == null) || ((string)Request.QueryString["project_id"] == null) )
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in fl_navigator2.aspx");
                }

                // Tag Page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfCurrentProjectId.Value = Request.QueryString["project_id"].ToString();
                hdfCurrentClientId.Value = Request.QueryString["client_id"].ToString();
                hdfWorkType.Value = "Full Length Lining";

                // Prepare initial data
                // ... For sortByList
                odsSortByList.DataBind();
                ddlSortBy.DataSourceID = "odsSortByList";
                ddlSortBy.DataValueField = "SortID";
                ddlSortBy.DataTextField = "Name";
                ddlSortBy.DataBind();

                // ... For
                odsViewForDisplayList.DataBind();
                ddlCondition1.DataSourceID = "odsViewForDisplayList";
                ddlCondition1.DataValueField = "ConditionID";
                ddlCondition1.DataTextField = "Name";
                ddlCondition1.DataBind();

                // ... For view ddl
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                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;

                WorkTypeViewSubAreaList workTypeViewSubAreaList = new WorkTypeViewSubAreaList();
                workTypeViewSubAreaList.LoadAndAddItem("Full Length Lining", Int32.Parse(hdfCompanyId.Value), int.Parse(hdfCurrentProjectId.Value), "(All)");
                ddlSubArea.DataSource = workTypeViewSubAreaList.Table;
                ddlSubArea.DataValueField = "SubArea";
                ddlSubArea.DataTextField = "SubArea";
                ddlSubArea.DataBind();

                // ... for client
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString());

                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                // ... for project
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                string name = projectGateway.GetName(currentProjectId);
                if (name.Length > 23) name = name.Substring(0, 20) + "...";
                lblTitleProjectName.Text = " > Project: " + name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")";

                // If coming from
                // ... fl_navigator.aspx or fl_navigator2.aspx
                if ((Request.QueryString["source_page"] == "fl_navigator.aspx") || (Request.QueryString["source_page"] == "fl_navigator2.aspx"))
                {
                    RestoreNavigatorState();

                    flNavigatorTDS = (FlNavigatorTDS)Session["flNavigatorTDS"];
                }

                // ... fl_edit.aspx, fl_summary.aspx or fl_delete.aspx
                if ((Request.QueryString["source_page"] == "fl_edit.aspx") || (Request.QueryString["source_page"] == "fl_summary.aspx") || (Request.QueryString["source_page"] == "fl_delete.aspx"))
                {
                    RestoreNavigatorState();

                    if (Request.QueryString["update"] == "no")
                    {
                        flNavigatorTDS = (FlNavigatorTDS)Session["flNavigatorTDS"];
                    }
                    else
                    {
                        // ... Delete store data
                        Session.Contents.Remove("flNavigatorTDS");

                        // ... Search data with updates
                        if (hdfBtnOrigin.Value == "Search")
                        {
                            flNavigatorTDS = SubmitSearch();
                        }
                        else
                        {
                            if (hdfBtnOrigin.Value == "Go")
                            {
                                flNavigatorTDS = SubmitSearchForViews();
                            }
                        }

                        // ... store datasets
                        Session["flNavigatorTDS"] = flNavigatorTDS;
                    }
                }

                // ... fl_delete.aspx, fl_summary.aspx or fl_edit.aspx
                if ((Request.QueryString["source_page"] == "fl_delete.aspx") || (Request.QueryString["source_page"] == "fl_summary.aspx") || (Request.QueryString["source_page"] == "fl_edit.aspx"))
                {
                    if (flNavigatorTDS.FlNavigator.Rows.Count == 0)
                    {
                        string url = "./fl_navigator.aspx?source_page=fl_navigator2.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value + "&work_type=" + hdfWorkType.Value + GetNavigatorState() + "&no_results=yes";
                        Response.Redirect(url);
                    }
                }

                // For the grid
                grdFLNavigator.DataSource = flNavigatorTDS.FlNavigator;
                grdFLNavigator.DataBind();

                //... for the total rows
                if (flNavigatorTDS.FlNavigator.Rows.Count > 0)
                {
                    lblTotalRows.Text = "Total Rows: " + flNavigatorTDS.FlNavigator.Rows.Count;
                    lblTotalRows.Visible = true;
                }
                else
                {
                    lblTotalRows.Visible = false;
                }
            }
            else
            {
                // Restore TDS
                flNavigatorTDS = (FlNavigatorTDS)Session["flNavigatorTDS"];

                // ... for the total rows
                if (flNavigatorTDS.FlNavigator.Rows.Count > 0)
                {
                    lblTotalRows.Text = "Total Rows: " + flNavigatorTDS.FlNavigator.Rows.Count;
                    lblTotalRows.Visible = true;
                }
                else
                {
                    lblTotalRows.Visible = false;
                }
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Page.Validate();

            if (Page.IsValid)
            {
                // Tag Page
                hdfBtnOrigin.Value = "Search";

                string url = "";

                // Delete store data
                Session.Contents.Remove("flNavigatorTDS");

                // Get data from DA gateway
                flNavigatorTDS = SubmitSearch();

                // Show results
                if (flNavigatorTDS.FlNavigator.Rows.Count > 0)
                {
                    // ... Store data
                    Session["flNavigatorTDS"] = flNavigatorTDS;

                    // ... Go to the results page
                    url = "./fl_navigator2.aspx?source_page=fl_navigator2.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value  + GetNavigatorState();
                }
                else
                {
                    // ... Go to the search page
                    url = "./fl_navigator.aspx?source_page=fl_navigator2.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value + "&work_type=" + hdfWorkType.Value + GetNavigatorState() + "&no_results=yes";
                }

                Response.Redirect(url);
            }
        }
Пример #5
0
 /// <summary>
 /// InitData
 /// </summary>
 protected override void InitData()
 {
     _data = new FlNavigatorTDS();
 }