Exemplo n.º 1
0
        private void LoadSearch(int _search)
        {
            lblTitle.Text = "Search Results";
            ds            = oAsset.GetSearch(_search);
            if (ds.Tables[0].Rows.Count > 0)
            {
                panResult.Visible = true;
                lblSearch.Text    = _search.ToString();
                string strSort = "";
                if (Request.QueryString["sort"] != null && Request.QueryString["sort"] != "")
                {
                    strSort = "&sort=" + Request.QueryString["sort"];
                }
                btnPrint.Attributes.Add("onclick", "return OpenWindow('NEW_WINDOW','/frame/print_asset_search.aspx?sid=" + _search.ToString() + strSort + "');");
                if (ds.Tables[0].Rows[0]["userid"].ToString() == intProfile.ToString())
                {
                    string strSearch = ds.Tables[0].Rows[0]["type"].ToString();
                    switch (strSearch)
                    {
                    case "1":
                        if (ds.Tables[0].Rows[0]["name"].ToString().Trim() != "")
                        {
                            lblResults.Text = "Device Name LIKE "" + ds.Tables[0].Rows[0]["name"].ToString().Trim() + """;
                        }
                        if (ds.Tables[0].Rows[0]["serial"].ToString().Trim() != "")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text = "Serial Number LIKE "" + ds.Tables[0].Rows[0]["serial"].ToString().Trim() + """;
                        }
                        if (ds.Tables[0].Rows[0]["asset"].ToString().Trim() != "")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text = "Asset Tag LIKE "" + ds.Tables[0].Rows[0]["asset"].ToString().Trim() + """;
                        }
                        break;

                    case "2":
                        if (ds.Tables[0].Rows[0]["classid"].ToString().Trim() != "0")
                        {
                            lblResults.Text = "Class = "" + oClasses.Get(Int32.Parse(ds.Tables[0].Rows[0]["classid"].ToString().Trim()), "name") + """;
                        }
                        if (ds.Tables[0].Rows[0]["environmentid"].ToString().Trim() != "0")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Environment = "" + oEnvironment.Get(Int32.Parse(ds.Tables[0].Rows[0]["environmentid"].ToString().Trim()), "name") + """;
                        }
                        break;

                    case "3":
                        string strPlatform = ds.Tables[0].Rows[0]["platformid"].ToString().Trim();
                        if (strPlatform != "" && strPlatform != "0")
                        {
                            lblResults.Text = "Platform = "" + oPlatform.GetName(Int32.Parse(strPlatform)) + """;
                        }
                        string strType = ds.Tables[0].Rows[0]["typeid"].ToString().Trim();
                        if (strType != "" && strType != "0")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Asset Type = "" + oType.Get(Int32.Parse(strType), "name") + """;
                        }
                        string strModel = ds.Tables[0].Rows[0]["modelid"].ToString().Trim();
                        if (strModel != "" && strModel != "0")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Model = "" + oModel.Get(Int32.Parse(strModel), "name") + """;
                        }
                        break;

                    case "4":
                        string strDepot = ds.Tables[0].Rows[0]["depotid"].ToString().Trim();
                        if (strDepot != "" && strDepot != "0")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Depot = "" + oDepot.Get(Int32.Parse(strDepot), "name") + """;
                        }
                        break;
                    }
                    ds           = oAsset.GetSearchResults(_search);
                    lblPage.Text = "1";
                    lblSort.Text = "";
                    if (Request.QueryString["page"] != null && Request.QueryString["page"] != "")
                    {
                        lblPage.Text = Request.QueryString["page"];
                    }
                    if (Request.QueryString["sort"] != null && Request.QueryString["sort"] != "")
                    {
                        lblSort.Text = Request.QueryString["sort"];
                    }
                    lblTopPaging.Text = "";
                    LoadPaging(Int32.Parse(lblPage.Text), lblSort.Text);
                }
                else
                {
                    panDenied.Visible = true;
                }
            }
            else
            {
                panDenied.Visible = true;
            }
        }
Exemplo n.º 2
0
        private void LoadSearch(int _search)
        {
            Asset        oAsset       = new Asset(intProfile, dsnAsset);
            Classes      oClasses     = new Classes(intProfile, dsn);
            Environments oEnvironment = new Environments(intProfile, dsn);
            Platforms    oPlatform    = new Platforms(intProfile, dsn);
            Types        oType        = new Types(intProfile, dsn);
            Models       oModel       = new Models(intProfile, dsn);
            Depot        oDepot       = new Depot(intProfile, dsn);
            DataSet      ds           = oAsset.GetSearch(_search);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["userid"].ToString() == intProfile.ToString())
                {
                    string strSearch = ds.Tables[0].Rows[0]["type"].ToString();

                    switch (strSearch)
                    {
                    case "N":
                        if (ds.Tables[0].Rows[0]["name"].ToString().Trim() != "")
                        {
                            lblResults.Text = "Device Name LIKE "" + ds.Tables[0].Rows[0]["name"].ToString().Trim() + """;
                        }
                        if (ds.Tables[0].Rows[0]["serial"].ToString().Trim() != "")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text = "Serial Number LIKE "" + ds.Tables[0].Rows[0]["serial"].ToString().Trim() + """;
                        }
                        if (ds.Tables[0].Rows[0]["asset"].ToString().Trim() != "")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text = "Asset Tag LIKE "" + ds.Tables[0].Rows[0]["asset"].ToString().Trim() + """;
                        }
                        break;

                    case "C":
                        if (ds.Tables[0].Rows[0]["classid"].ToString().Trim() != "0")
                        {
                            lblResults.Text = "Class = "" + oClasses.Get(Int32.Parse(ds.Tables[0].Rows[0]["classid"].ToString().Trim()), "name") + """;
                        }
                        if (ds.Tables[0].Rows[0]["environmentid"].ToString().Trim() != "0")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Environment = "" + oEnvironment.Get(Int32.Parse(ds.Tables[0].Rows[0]["environmentid"].ToString().Trim()), "name") + """;
                        }
                        break;

                    case "T":
                        string strPlatform = ds.Tables[0].Rows[0]["platformid"].ToString().Trim();
                        if (strPlatform != "" && strPlatform != "0")
                        {
                            lblResults.Text = "Platform = "" + oPlatform.GetName(Int32.Parse(strPlatform)) + """;
                        }
                        string strType = ds.Tables[0].Rows[0]["typeid"].ToString().Trim();
                        if (strType != "" && strType != "0")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Asset Type = "" + oType.Get(Int32.Parse(strType), "name") + """;
                        }
                        string strModel = ds.Tables[0].Rows[0]["modelid"].ToString().Trim();
                        if (strModel != "" && strModel != "0")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Model = "" + oModel.Get(Int32.Parse(strModel), "name") + """;
                        }
                        break;

                    case "D":
                        string strDepot = ds.Tables[0].Rows[0]["depotid"].ToString().Trim();
                        if (strDepot != "" && strDepot != "0")
                        {
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Depot = "" + oDepot.Get(Int32.Parse(strDepot), "name") + """;
                        }
                        break;
                    }
                    ds = oAsset.GetSearchResults(_search);
                    DataView dv = ds.Tables[0].DefaultView;
                    if (Request.QueryString["sort"] != null)
                    {
                        dv.Sort = Request.QueryString["sort"];
                    }
                    rptView.DataSource = dv;
                    rptView.DataBind();
                    lblNone.Visible = (rptView.Items.Count == 0);
                }
            }
        }