Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        FormsAuthenticationHelper.AuthenticateUserWithReturnUrl();
        connstring          = Client.ConnectionString(HttpContext.Current.Session["clientid"].ToString());
        PageTitle.InnerText = String.Format(Constant.TITLEFORMAT, "Search Result");
        if (!(IsPostBack))
        {
            if ((Session[Constant.SESSION_USERID] != null) && (Session[Constant.SESSION_USERTYPE] != null))
            {
                ViewState[Constant.SESSION_USERID] = Int32.Parse(Session[Constant.SESSION_USERID].ToString().Trim());
                int userID = Int32.Parse(ViewState[Constant.SESSION_USERID].ToString().Trim());

                int    usertype     = Int32.Parse(Session[Constant.SESSION_USERTYPE].ToString().Trim());
                string searchstring = "";
                int    searchType   = 1;
                if (Request.QueryString["searchstring"] != null)
                {
                    searchstring = Request.QueryString["searchstring"].ToString().Trim();
                }
                if (Request.QueryString["searchType"] != null)
                {
                    searchType = Int32.Parse(Request.QueryString["searchType"].ToString().Trim());
                }

                if ((searchType >= 1) && (searchType <= 6))
                {
                    if ((searchType >= 1) && (searchType <= 3))
                    {
                        gvSearchResultForItems.Columns[0].HeaderText = "Bid Reference No.";
                        gvSearchResultForItems.Columns[1].HeaderText = "Bid Items";
                    }
                    else
                    {
                        gvSearchResultForItems.Columns[0].HeaderText = "Auction Reference No.";
                        gvSearchResultForItems.Columns[1].HeaderText = "Auction Items";
                    }

                    gvSearchResultForItems.Visible = true;

//                    BidItemTransaction items = new BidItemTransaction();

                    DataTable dtItems = BidItemTransaction.QuerySearchedItemByItemDesc(connstring, searchType, searchstring, usertype, userID);

                    if (dtItems.Rows.Count > 0)
                    {
                        DataView dvItems = new DataView(dtItems);

                        gvSearchResultForItems.DataSource = dvItems;
                        gvSearchResultForItems.DataBind();
                    }
                    else
                    {
                        lblIsEmpty.Visible = true;
                        lblIsEmpty.Text    = "No matches for '" + searchstring + "' found.";
                    }
                }
                else if (searchType == 7)
                {
                    ProductsTransaction products = new ProductsTransaction();

                    DataTable dtProducts = products.QueryProductsViaName(connstring, searchstring);
                    // DataView dvProducts = new DataView(dtProducts);

                    if (dtProducts.Rows.Count > 0)
                    {
                        gvProducts.Visible = true;

                        gvProducts.DataSource = dtProducts;
                        gvProducts.DataBind();
                    }
                    else
                    {
                        lblIsEmpty.Visible = true;
                        lblIsEmpty.Text    = "No matches for '" + searchstring + "' found.";
                    }
                }
                else if (searchType == 8)
                {
                    CompanyTransaction vendor = new CompanyTransaction();

                    DataTable dtVendor = vendor.QueryVendorSearch(connstring, searchstring);

                    if (dtVendor.Rows.Count > 0)
                    {
                        DataView dvVendor = new DataView(dtVendor);

                        gvSuppliers.Visible    = true;
                        gvSuppliers.DataSource = dvVendor;
                        gvSuppliers.DataBind();
                    }
                    else
                    {
                        lblIsEmpty.Visible = true;
                        lblIsEmpty.Text    = "No matches for '" + searchstring + "' found.";
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        ViewState[Constant.SESSION_USERID] = Int32.Parse(Session[Constant.SESSION_USERID].ToString().Trim());
        int    userID   = Int32.Parse(ViewState[Constant.SESSION_USERID].ToString().Trim());
        string usertype = Session[Constant.SESSION_USERTYPE].ToString().Trim();

        if (Request.QueryString["usertype"] != null)
        {
            usertype = Request.QueryString["usertype"].ToString().Trim();
        }
        string searchstring = "";

        if (Request.QueryString["searchstring"] != null)
        {
            searchstring = Request.QueryString["searchstring"].ToString().Trim();
        }
        string searchType = "1";

        if (Request.QueryString["searchType"] != null)
        {
            searchType = Request.QueryString["searchType"].ToString().Trim();
        }

        if ((Int32.Parse(searchType) >= 1) && (Int32.Parse(searchType) <= 6))
        {
            if ((Int32.Parse(searchType) >= 1) && (Int32.Parse(searchType) <= 3))
            {
                gvSearchResultForItems.Columns[0].HeaderText = "Bid Reference No.";
                gvSearchResultForItems.Columns[1].HeaderText = "Bid Items";
            }
            else
            {
                gvSearchResultForItems.Columns[0].HeaderText = "Auction Reference No.";
                gvSearchResultForItems.Columns[1].HeaderText = "Auction Items";
            }

            gvSearchResultForItems.Visible = true;

            DataTable dtItems = BidItemTransaction.QuerySearchedItemByItemDesc(connstring, Int32.Parse(searchType), searchstring, Int32.Parse(usertype), userID);
            DataView  dvItems = new DataView(dtItems);

            gvSearchResultForItems.DataSource = dvItems;
            gvSearchResultForItems.PageIndex  = e.NewPageIndex;
            gvSearchResultForItems.DataBind();
        }
        else if (Int32.Parse(searchType) == 7)
        {
            ProductsTransaction products = new ProductsTransaction();

            DataTable dtProducts = products.QueryProductsViaName(connstring, searchstring);

            gvProducts.Visible = true;

            gvProducts.DataSource = dtProducts;
            gvProducts.PageIndex  = e.NewPageIndex;
            gvProducts.DataBind();
        }
        else if (Int32.Parse(searchType) == 8)
        {
            CompanyTransaction vendor = new CompanyTransaction();

            DataTable dtVendor = vendor.QueryVendorSearch(connstring, searchstring);
            DataView  dvVendor = new DataView(dtVendor);

            gvSuppliers.Visible = true;

            gvSuppliers.DataSource = dvVendor;
            gvSuppliers.PageIndex  = e.NewPageIndex;
            gvSuppliers.DataBind();
        }
    }