Exemple #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         //NEED SOME DATA TO TEST THE RESULT
         Values = new List <TestObject>();
         Values.Add(new TestObject()
         {
             Q = "test 1", C = true, E = true, R = true
         });
         Values.Add(new TestObject()
         {
             Q = "test 1", C = true, E = false, R = true
         });
         Values.Add(new TestObject()
         {
             Q = "test 1", C = true, E = true, R = false
         });
         Values.Add(new TestObject()
         {
             Q = "test 1", C = false, E = true, R = true
         });
         //BIND TO THE GRID
         SearchGrid.DataSource = Values;
         SearchGrid.DataBind();
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            var searchTerm = Request.QueryString["q"];

            SearchTerm.Text = searchTerm;

            var result = new List <ProductModel>();

            ProductModel Products = new ProductModel();

            Products.Searched = Request.QueryString["q"];


            var sqlString  = "SELECT * FROM Product";
            var connString = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            using (var conn = new SqlConnection(connString))
            {
                var command = new SqlCommand(sqlString, conn);
                command.Connection.Open();
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Products.ProductKey          = reader.GetInt32(0).ToString();
                        Products.ProductAlternateKey = reader.GetString(1);
                        Products.ProductName         = reader.GetString(5);
                        Products.StockLevel          = reader.GetInt16(9);
                    }
                    result.Add(Products);
                }
            }
            SearchGrid.DataSource = result.Where(p => p.ProductName.IndexOf(searchTerm, StringComparison.OrdinalIgnoreCase) >= 0);
            SearchGrid.DataBind();
        }
Exemple #3
0
        private void Search()
        {
            lblText.Visible = true;
            using (SqlConnection connection = DbHelper.GetConnection())
            {
                SqlCommand com = new SqlCommand("Search", connection)
                {
                    CommandType = CommandType.StoredProcedure
                };
                if (ddlCar.SelectedIndex != 0)
                {
                    com.Parameters.AddWithValue("@carid", ddlCar.SelectedValue);
                }
                if (ddlCompany.SelectedIndex != 0)
                {
                    com.Parameters.AddWithValue("@carid", ddlCompany.SelectedValue);
                }
                if (ddlColorType.SelectedIndex != 0)
                {
                    com.Parameters.AddWithValue("@typeid", ddlColorType.SelectedValue);
                }
                if (!string.IsNullOrEmpty(txtCode.Text.Trim()))
                {
                    var code = DbHelper.PersianToEnglish(txtCode.Text.Trim());
                    com.Parameters.AddWithValue("@code", code);
                }
                if (!string.IsNullOrEmpty(txtColorDesc1.Text.Trim()))
                {
                    com.Parameters.AddWithValue("@desc1", txtColorDesc1.Text.Trim());
                }
                if (!string.IsNullOrEmpty(txtColorDesc2.Text.Trim()))
                {
                    com.Parameters.AddWithValue("@desc2", txtColorDesc2.Text.Trim());
                }
                if (!string.IsNullOrEmpty(txtUsage.Text.Trim()))
                {
                    com.Parameters.AddWithValue("@usage", txtUsage.Text.Trim());
                }
                if (!string.IsNullOrEmpty(DatePicker1.Text))
                {
                    com.Parameters.AddWithValue("@date", DatePicker1.Date);
                }
                SqlDataAdapter da = new SqlDataAdapter(com);
                DataTable      dt = new DataTable();

                try
                {
                    da.Fill(dt);
                    SearchGrid.DataSource = dt.Rows.Count > 0 ? dt : null;
                    lblCount.Text         = dt.Rows.Count.ToString();
                    SearchGrid.DataBind();
                }
                catch (Exception ex)
                {
                    lblMessage.Text = "خطا" + ex.Message;
                }
            }
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var searchTerm = Request.QueryString["q"];

            SearchTerm.Text = searchTerm;
            var products = new Product().GetSampleProductList();

            SearchGrid.DataSource = products.Where(p => p.Name.IndexOf(searchTerm, StringComparison.OrdinalIgnoreCase) >= 0);
            SearchGrid.DataBind();
        }
Exemple #5
0
        private void Search()
        {
            using (SqlConnection connection = DbHelper.GetConnection())
            {
                SqlCommand com = new SqlCommand("Search", connection)
                {
                    CommandType = CommandType.StoredProcedure
                };
                if (ddlCar.SelectedIndex != 0)
                {
                    com.Parameters.AddWithValue("@carid", ddlCar.SelectedValue);
                }
                if (ddlCompany.SelectedIndex != 0)
                {
                    com.Parameters.AddWithValue("@carid", ddlCompany.SelectedValue);
                }
                if (ddlColorType.SelectedIndex != 0)
                {
                    com.Parameters.AddWithValue("@typeid", ddlColorType.SelectedValue);
                }
                if (!string.IsNullOrEmpty(txtCode.Text.Trim()))
                {
                    com.Parameters.AddWithValue("@code", txtCode.Text);
                }
                if (!string.IsNullOrEmpty(txtDesc.Text.Trim()))
                {
                    com.Parameters.AddWithValue("@desc", txtDesc.Text);
                }
                SqlDataAdapter da = new SqlDataAdapter(com);
                DataSet        ds = new DataSet();

                try
                {
                    da.Fill(ds, "search");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        SearchGrid.DataSource = ds.Tables["search"];
                    }
                    else
                    {
                        lblMessage.Text       = "رنگی با این مشخصات پیدا نشد";
                        SearchGrid.DataSource = null;
                    }
                    SearchGrid.DataBind();
                }
                catch (Exception ex)
                {
                    lblMessage.Text = "خطا" + ex.Message;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var searchTerm = Request.Unvalidated.QueryString["q"];

            if (!Regex.IsMatch(searchTerm, @"^[\p{L} \.\-]+$"))
            {
                throw new ApplicationException("Search term is not allowed");
            }

            SearchTerm.Text = AntiXssEncoder.HtmlEncode(searchTerm, true);
            var products = new Product().GetSampleProductList();

            SearchGrid.DataSource = products.Where(p => p.Name.IndexOf(searchTerm, StringComparison.OrdinalIgnoreCase) >= 0);
            SearchGrid.DataBind();
        }
Exemple #7
0
        void FormatGrid()
        {
            if (SearchGrid.Rows.Count == 0)
            {
                DataTable DT = Data2.Connection.D_Supplier.Get_AllShort(UserId);
                if (DT != null)
                {
                    SearchGrid.DataSource = DT;
                    SearchGrid.DataBind();
                }



                for (int a = 0; a < SearchGrid.Rows.Count; a++)
                {
                    HyperLink HLEdit = new HyperLink();
                    HLEdit.Text        = "Editar";
                    HLEdit.NavigateUrl = "/MyManager/Proveedores?edt=" + SearchGrid.Rows[a].Cells[0].Text.ToString();
                    HyperLink HLDelete = new HyperLink();
                    HLDelete.Text        = "Borrar";
                    HLDelete.NavigateUrl = "/MyManager/Proveedores?del=" + SearchGrid.Rows[a].Cells[0].Text.ToString();
                    HtmlGenericControl HTMLSeparator = new HtmlGenericControl("span");

                    SearchGrid.Rows[a].Cells[4].Controls.Add(HLEdit);
                    SearchGrid.Rows[a].Cells[4].Controls.Add(HLDelete);
                    SearchGrid.Rows[a].Cells[4].CssClass = "AtroxDarkLink";
                }

                IClientCapability MyCLient = ClientCapabilityProvider.CurrentClientCapability;
                if (MyCLient.IsMobile)
                {
                    SearchGrid.Columns[3].Visible = false;
                    SearchGrid.Columns[4].Visible = false;
                    for (int a = 0; a < SearchGrid.Rows.Count; a++)
                    {
                        string t_Telephone = SearchGrid.Rows[a].Cells[2].Text;
                        SearchGrid.Rows[a].Cells[2].Text = "";
                        HyperLink HLTelephone = new HyperLink();
                        HLTelephone.Text        = t_Telephone;
                        HLTelephone.NavigateUrl = "tel:" + t_Telephone;
                        SearchGrid.Rows[a].Cells[2].Controls.Add(HLTelephone);
                    }
                }
            }
        }
        protected void Search_btn_Click(object sender, EventArgs e)
        {
            string column  = SearchByProperty.SelectedValue;
            string seeking = Seeking_str.Text;

            var adminRepo = new Repository();

            adminRepo.OpenConnection(connection_str);
            SearchPackage paket = new SearchPackage();

            paket.criterion = column;
            paket.value     = seeking;

            var books = adminRepo.WantedBooksByCriterion(paket);

            adminRepo.CloseConnection();

            SearchGrid.DataSource = books;
            SearchGrid.DataBind();
        }
Exemple #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["q"] != null)
            {
                var searchTerm = Request.QueryString["q"];

                //searchTerm = searchTerm.ToLower().Replace("script", "");

                //SearchTerm.Text = System.Web.Security.AntiXss.AntiXssEncoder.HtmlEncode(searchTerm, false);


                SearchTerm.Text = System.Web.Security.AntiXss.AntiXssEncoder.HtmlEncode(searchTerm, false);


                //SearchTerm.Text = searchTerm;

                NORTHWNDEntities nwe = new NORTHWNDEntities();
                var products         = nwe.Products.ToList();

                SearchGrid.DataSource = products.Where(p => p.ProductName.IndexOf(searchTerm, StringComparison.OrdinalIgnoreCase) >= 0);
                SearchGrid.DataBind();
            }
            Response.AppendHeader("X-XSS-Protection", "0");
        }
Exemple #10
0
 protected void SearchGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     Search();
     SearchGrid.PageIndex = e.NewPageIndex;
     SearchGrid.DataBind();
 }