Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ProductGridView.EnableDynamicData(typeof(Product));
     //Bind product GridView
     ProductGridView.DataSource = ctx.Products.ToList <Product>();
     ProductGridView.DataBind();
 }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var productSubCategoryId = Request.QueryString["ProductSubCategoryId"];

            int id;

            if (!int.TryParse(productSubCategoryId, out id))
            {
                throw new ApplicationException("ID wasn't an integer");
            }

            var connString = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            var sqlString  = "GetProducts";

            using (var conn = new SqlConnection(connString))
            {
                using (var command = new SqlCommand(sqlString, conn))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@ProductSubCategoryID", SqlDbType.Int).Value = id;
                    command.Connection.Open();
                    ProductGridView.DataSource = command.ExecuteReader();
                    ProductGridView.DataBind();
                }
            }

            ProductCount.Text = ProductGridView.Rows.Count.ToString("n0");
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            var widgetService = new WidgetService();
            var prodService   = new ProductService();
            var gizmoService  = new GizmoService();

            var pwgVM = new ProdGizWidgetVM(
                widgetService.GetWidgets(),
                prodService.GetProducts(),
                gizmoService.GetGizmos()
                );

            WidgetGridView.DataSource = pwgVM.widgetList;
            WidgetGridView.DataBind();
            ProductGridView.DataSource = pwgVM.prodList;
            ProductGridView.DataBind();
            GizmoGridView.DataSource = pwgVM.gizmoList;
            GizmoGridView.DataBind();

            stopWatch.Stop();
            ElapsedTimeLabel.Text = String.Format("Elapsed time: {0}",
                                                  stopWatch.Elapsed.Milliseconds / 1000.0);
        }
Ejemplo n.º 4
0
 protected void ProductGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     ProductGridView.DataSource = OrganizationProducts;
     ProductGridView.PageIndex  = e.NewPageIndex;
     ProductGridView.DataBind();
     GlobalUtils.SetAccessToControls(this.Page, SaltShakerSession.CurrentRole);
 }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var prodService = new ProductService();

            ProductGridView.DataSource = prodService.GetProducts();
            ProductGridView.DataBind();
        }
Ejemplo n.º 6
0
        protected void ProductGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                GridViewRow row = ProductGridView.Rows[e.NewSelectedIndex];

                int partId = int.Parse((row.FindControl("PartID") as HiddenField).Value);
                var qutity = int.Parse((row.FindControl("Qutity") as TextBox).Text);

                if (qutity > 0)
                {
                    var securityController = new SecurityController();
                    var employeeId         = securityController.GetCurrentUserEmployeeId(User.Identity.Name);
                    if (employeeId != null || User.IsInRole("Administrators"))
                    {
                        throw new Exception("Employee or Administrators can't shopping");
                    }
                    else
                    {
                        var controller = new SalesController();
                        controller.AddToCart(User.Identity.Name, partId, qutity);
                        //Item.QuantityInCart != 0?Item.QuantityInCart.ToString():""
                        ProductGridView.DataBind();
                        CategoryGridView.DataBind();
                    }
                }
                else
                {
                    throw new Exception("Quantities should geater than 0");
                }
            }, "Successful", "you added a part");
        }
Ejemplo n.º 7
0
        void BindGrid(ApiResponse response)
        {
            DataTable dt = null;

            try
            {
                if (response.responseCode == ApiResponse.Success)
                {
                    dt = response.data as DataTable;
                }
                else if (response.responseCode == ApiResponse.NoDataFound)
                {
                    LblErrorMsg.Text    = "No Data Found";
                    LblErrorMsg.Visible = true;
                }
                else if (response.responseCode == ApiResponse.Exception)
                {
                    LblErrorMsg.Text    = "Api Error: " + response.error;
                    LblErrorMsg.Visible = true;
                }
            }
            catch (Exception ex)
            {
                LblErrorMsg.Text    = "Page Error: " + ex.Message;
                LblErrorMsg.Visible = true;
            }

            ProductGridView.DataSource = dt;
            ProductGridView.DataBind();
        }
Ejemplo n.º 8
0
        private async Task LoadProductsAsync()
        {
            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadProductsAsync():Start"
            });

            ProductProxyService.ProductServiceClient client   = new ProductProxyService.ProductServiceClient();
            IList <ProductProxyService.Product>      products = await client.GetProductsTaskAsync();

            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadProductsAsync():End"
            });

            ProductGridView.DataSource = products.Take(10);
            ProductGridView.DataBind();

            ThreadGridView.DataSource = statistics;
            ThreadGridView.DataBind();

            TimeSpan ts = pageWatch.Elapsed;

            PageElapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                            ts.Hours, ts.Minutes, ts.Seconds,
                                            ts.Milliseconds / 10);
        }
Ejemplo n.º 9
0
        private async Task GetPWGsrvAsync()
        {
            var widgetService = new WidgetService();
            var prodService   = new ProductService();
            var gizmoService  = new GizmoService();

            var widgetTask = widgetService.GetWidgetsAsync();
            var prodTask   = prodService.GetProductsAsync();
            var gizmoTask  = gizmoService.GetGizmosAsync();

            await Task.WhenAll(widgetTask, prodTask, gizmoTask);

            var pwgVM = new ProdGizWidgetVM(
                widgetTask.Result,
                prodTask.Result,
                gizmoTask.Result
                );

            WidgetGridView.DataSource = pwgVM.widgetList;
            WidgetGridView.DataBind();
            ProductGridView.DataSource = pwgVM.prodList;
            ProductGridView.DataBind();
            GizmoGridView.DataSource = pwgVM.gizmoList;
            GizmoGridView.DataBind();
        }
Ejemplo n.º 10
0
        void PopulateGridView()
        {
            DataTable dtbl = new DataTable();

            using (SqlConnection con = new SqlConnection(CS)) //we use using to close the connection explicitly
            {
                con.Open();
                SqlDataAdapter sqlDa = new SqlDataAdapter("SELECT product.product_id as productID,product.product_name,product.product_detail, product.product_price,brand.brand_name,image.image FROM product INNER JOIN image ON product.product_id = image.product_id INNER JOIN brand ON product.brand_id=brand.brand_id", con);
                sqlDa.Fill(dtbl);
            }
            if (dtbl.Rows.Count > 0)
            {
                ProductGridView.DataSource = dtbl;
                ProductGridView.DataBind();
            }
            else
            {
                dtbl.Rows.Add(dtbl.NewRow());
                ProductGridView.DataSource = dtbl;
                ProductGridView.DataBind();
                ProductGridView.Rows[0].Cells.Clear();
                ProductGridView.Rows[0].Cells.Add(new TableCell());
                ProductGridView.Rows[0].Cells[0].ColumnSpan      = dtbl.Columns.Count;
                ProductGridView.Rows[0].Cells[0].Text            = "NO DATA FOUND...";
                ProductGridView.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
            }
        }
Ejemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection();

            conn.ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            /*SqlConnection conn = new SqlConnection(@"Data Source=(Local DB)\MSSQLLocalDB;
             *           AttachDbFilename=C:\Users\NIRALI P SHAH\source\repos\orderingapp\App_Data\Database1.mdf
             *           Integrated Security=True");*/
            try
            {
                using (conn)
                {
                    String     command = "select * from product ;";
                    SqlCommand cmd     = new SqlCommand(command, conn);
                    conn.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();
                    ProductGridView.DataSource = rdr;
                    ProductGridView.DataBind();

                    /*while (rdr.Read())
                     * {
                     *  ListItem item = new ListItem(rdr["pname"].ToString());
                     *  //item.Text = rdr["pname"].ToString();
                     *  //Response.Write("text=" + item.Text);
                     *  ListBox1.Items.Add(item);
                     * }*/
                }
            }
            catch (Exception err)
            {
                Error.Text = "error message:" + err.Message;
            }
        }
Ejemplo n.º 12
0
        private async Task GetProductSrvAsync()
        {
            var ProductService = new ProductService();
            var ProductList    = await ProductService.GetProductsAsync();

            ProductGridView.DataSource = ProductList;
            ProductGridView.DataBind();
        }
Ejemplo n.º 13
0
 protected void ProductGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     if (e.NewPageIndex > -1)
     {
         ProductGridView.PageIndex = e.NewPageIndex;
         ProductGridView.DataBind();
     }
 }
Ejemplo n.º 14
0
    protected void ProductDetailsViewSqlDataSource_Inserted(object sender, SqlDataSourceStatusEventArgs e)
    {
        System.Data.Common.DbCommand command = e.Command;

        ProductDetailsViewSqlDataSource.SelectParameters["ProductID"].DefaultValue = command.Parameters["@ProductID"].Value.ToString();

        ProductGridView.DataBind();
        ProductDetailsView.DataBind();
    }
Ejemplo n.º 15
0
 protected void ContinueShoppingButton_Click(object sender, EventArgs e)
 {
     PartCatelogPanel.Visible  = true;
     PurchaseInfoPanel.Visible = false;
     NavigationPanel.Visible   = false;
     ViewCartPanel.Visible     = false;
     PlaceOrderPanel.Visible   = false;
     ProductGridView.DataBind();
 }
Ejemplo n.º 16
0
        private void BindGridView()
        {
            Collection <MixERP.Net.Common.Models.Transactions.ProductDetailsModel> table = this.GetTable();

            ProductGridView.DataSource = table;
            ProductGridView.DataBind();

            this.ShowTotals();
        }
Ejemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var productSubCategoryId = Request.QueryString["ProductSubCategoryId"];
            int id;
            //if (!int.TryParse(productSubCategoryId, out id)) { throw new ApplicationException("ID wasn't an integer."); }

            var connString = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            // Unsafe string concat
            var sqlString = "SELECT * FROM Product WHERE ProductSubCategoryID = " + productSubCategoryId;

            using (var conn = new SqlConnection(connString))
            {
                using (var command = new SqlCommand(sqlString, conn))
                {
                    command.Connection.Open();
                    ProductGridView.DataSource = command.ExecuteReader();
                    ProductGridView.DataBind();
                }
            }

            /*//Paramatarised input
             * var sqlString = "SELECT * FROM Product WHERE ProductSubCategoryID = @ProductSubCategoryId";
             * using (var conn = new SqlConnection(connString))
             * {
             *  using (var command = new SqlCommand(sqlString, conn))
             *  {
             *      command.Parameters.Add("@ProductSubcategoryId", SqlDbType.VarChar).Value = productSubCategoryId;
             *      command.Connection.Open();
             *      ProductGridView.DataSource = command.ExecuteReader();
             *      ProductGridView.DataBind();
             *  }
             * }*/

            /*//Stored procedure input
             * var sqlString = "GetProducts";
             * using (var conn = new SqlConnection(connString))
             * {
             *  using (var command = new SqlCommand(sqlString, conn))
             *  {
             *      command.CommandType = CommandType.StoredProcedure;
             *      command.Parameters.Add("@ProductSubcategoryId", SqlDbType.VarChar).Value = productSubCategoryId;
             *      //command.Parameters.Add("@ProductSubcategoryId", SqlDbType.Int).Value = id;
             *      command.Connection.Open();
             *      ProductGridView.DataSource = command.ExecuteReader();
             *      ProductGridView.DataBind();
             *  }
             * }*/

            var dc = new InjectionEntities();

            /*ProductGridView.DataSource = dc.Products.Where(p => p.ProductSubcategoryID == id).ToList();
             * //ProductGridView.DataSource = dc.Products.Where(p => p.ProductSubcategoryID == productSubCategoryId).ToList();
             * ProductGridView.DataBind();*/

            ProductCount.Text = ProductGridView.Rows.Count.ToString("n0");
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["username"] == null)
     {
         Response.Redirect("LoginForm.aspx");
     }
     ProductGridView.DataSource = repo.getAllProducts();
     ProductGridView.DataBind();
 }
Ejemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var    productSubCategoryId = Request.QueryString["ProductSubCategoryId"];
            string userAgent            = Request.Headers.GetValues("User-Agent")[0];

            var connString         = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            var sqlUserAgentString = "SELECT * FROM UserAgents WHERE UserAgent = N'" + userAgent + "'";

            using (var conn = new SqlConnection(connString))
            {
                using (var command = new SqlCommand(sqlUserAgentString, conn))
                {
                    command.Connection.Open();
                    SqlDataReader dr = command.ExecuteReader();
                    if (dr == null)
                    {
                        var        insertString = "INSERT INTO [dbo].[UserAgents] ([UserAgent])  VALUES (N'" + userAgent + "')";
                        SqlCommand sc           = new SqlCommand(insertString, new SqlConnection(connString));
                        sc.ExecuteNonQuery();
                    }
                }
            }

            if (productSubCategoryId != null)
            {
                //productSubCategoryId = productSubCategoryId.ToUpper().Replace("SELECT", "");
                //productSubCategoryId = productSubCategoryId.ToUpper().Replace("UPDATE", "");
                //productSubCategoryId = productSubCategoryId.ToUpper().Replace("INSERT", "");
                //productSubCategoryId = productSubCategoryId.ToUpper().Replace("DELETE", "");
                //productSubCategoryId = productSubCategoryId.ToUpper().Replace("WHERE", "");
                //productSubCategoryId = productSubCategoryId.ToUpper().Replace("FROM", "");

                injectionEntities ie = new injectionEntities();
                int?pID = int.Parse(productSubCategoryId);
                ProductGridView.DataSource = ie.Products.Where(p => p.ProductSubcategoryID == pID).ToList();
                ProductGridView.DataBind();


                var sqlString = "SELECT Name, ProductNumber, ListPrice FROM Product WHERE ProductSubCategoryID = " + productSubCategoryId;
                using (var conn = new SqlConnection(connString))
                {
                    using (var command = new SqlCommand(sqlString, conn))
                    {
                        command.Connection.Open();
                        ProductGridView.DataSource = command.ExecuteReader();
                        ProductGridView.DataBind();
                    }
                }

                ProductCount.Text = ProductGridView.Rows.Count.ToString("n0");
            }
        }
Ejemplo n.º 20
0
 private void BindingProductData()
 {
     try
     {
         List <DataAccessLayer.Modelo.Product> listProduct = logicData.GetProductList();
         ProductGridView.DataSource = listProduct;
         ProductGridView.DataBind();
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Stopwatch loadWatch = new Stopwatch();

            loadWatch.Start();


            pageWatch.Start();
            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "Page Load:Start"
            });

            //RegisterAsyncTask(new PageAsyncTask(LoadProductsAsync));
            RegisterAsyncTask(new PageAsyncTask(async() => {
                statistics.Add(new Statistic {
                    ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadProductsAsync():Start"
                });

                ProductProxyService.ProductServiceClient client = new ProductProxyService.ProductServiceClient();
                IList <ProductProxyService.Product> products    = await client.GetProductsTaskAsync();
                statistics.Add(new Statistic {
                    ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadProductsAsync():End"
                });

                ProductGridView.DataSource = products.Take(10);
                ProductGridView.DataBind();

                ThreadGridView.DataSource = statistics;
                ThreadGridView.DataBind();

                TimeSpan ts1    = pageWatch.Elapsed;
                PageElapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                ts1.Hours, ts1.Minutes, ts1.Seconds,
                                                ts1.Milliseconds / 10);
            }));


            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "Page Load::End"
            });


            TimeSpan ts = loadWatch.Elapsed;

            LoadElapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                            ts.Hours, ts.Minutes, ts.Seconds,
                                            ts.Milliseconds / 10);
        }
Ejemplo n.º 22
0
        private void LoadProducts()
        {
            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadProducts():Start"
            });

            ProductProxyService.ProductServiceClient client   = new ProductProxyService.ProductServiceClient();
            IList <ProductProxyService.Product>      products = client.GetProducts();

            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadProducts():End"
            });

            ProductGridView.DataSource = products.Take(10);
            ProductGridView.DataBind();
        }
Ejemplo n.º 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var productSubCategoryId = Request.QueryString["ProductSubCategoryId"];

            int id;

            if (!int.TryParse(productSubCategoryId, out id))
            {
                throw new ApplicationException("ID wasn't an integer");
            }

            var dc = new InjectionEntities();

            ProductGridView.DataSource = dc.Products.Where(p => p.ProductSubcategoryID == id).ToList();
            ProductGridView.DataBind();

            ProductCount.Text = ProductGridView.Rows.Count.ToString("n0");
        }
Ejemplo n.º 24
0
        protected void btGo_Click(object sender, EventArgs e)
        {
            var productSubCategoryId = ddlCategory.SelectedValue;

            if (productSubCategoryId != null)
            {
                var connString = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                var sqlString  = "SELECT * FROM Product WHERE ProductSubCategoryID = " + productSubCategoryId;
                using (var conn = new SqlConnection(connString))
                {
                    using (var command = new SqlCommand(sqlString, conn))
                    {
                        command.Connection.Open();
                        ProductGridView.DataSource = command.ExecuteReader();
                        ProductGridView.DataBind();
                    }
                }
            }
        }
Ejemplo n.º 25
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            var connString = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            using (var conn = new SqlConnection(connString))
            {
                using (var command = new SqlCommand("SearchProducts", conn))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@SearchTerm", SqlDbType.VarChar).Value = SearchTerm.Text;
                    command.Connection.Open();
                    ProductGridView.DataSource = command.ExecuteReader();
                    ProductGridView.DataBind();
                }
            }

            ProductCount.Text   = ProductGridView.Rows.Count.ToString("n0");
            SearchPanel.Visible = true;
        }
Ejemplo n.º 26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var productSubCategoryId = Request.QueryString["ProductSubCategoryId"];

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

            using (var conn = new SqlConnection(connString))
            {
                using (var command = new SqlCommand(sqlString, conn))
                {
                    command.Connection.Open();
                    ProductGridView.DataSource = command.ExecuteReader();
                    ProductGridView.DataBind();
                }
            }

            ProductCount.Text = ProductGridView.Rows.Count.ToString("n0");
        }
Ejemplo n.º 27
0
        protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            //int productSubCategoryId = int.Parse(ddlCategory.SelectedValue);
            var productSubCategoryId = ddlCategory.SelectedValue;

            if (productSubCategoryId != null)
            {
                var connstring = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                var sqlstring  = "select * from product where productsubcategoryid = " + productSubCategoryId;
                using (var conn = new SqlConnection(connstring))
                {
                    using (var command = new SqlCommand(sqlstring, conn))
                    {
                        command.Connection.Open();
                        ProductGridView.DataSource = command.ExecuteReader();
                        ProductGridView.DataBind();
                    }
                }
            }
        }
Ejemplo n.º 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string CS = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                SqlCommand cmd = new SqlCommand("Select * from tblProduct; Select * from tblProductCategories", con);
                con.Open();
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    ProductGridView.DataSource = rdr;
                    ProductGridView.DataBind();
                    while (rdr.NextResult())
                    {
                        CategoriesGridView.DataSource = rdr;
                        CategoriesGridView.DataBind();
                    }
                }
            }
        }
Ejemplo n.º 29
0
 protected void Page_Load(object sender, EventArgs e)
 {
     MessageUserControl.TryRun(() => {
         //have your log in yte
         if (!Request.IsAuthenticated)
         {
             ProductGridView.Columns[0].Visible = false;
             ProductGridView.Columns[2].Visible = false;
             var controller      = new SalesController();
             AllPartsAmount.Text = controller.getAllPartsAmount().ToString();
         }
         else
         {
             UserName.Value = User.Identity.Name;
             ProductGridView.Columns[0].Visible = true;
             ProductGridView.Columns[2].Visible = true;
             var controller      = new SalesController();
             AllPartsAmount.Text = controller.getAllPartsAmount().ToString();
             ProductGridView.DataBind();
         }
     });
 }
Ejemplo n.º 30
0
        protected void CartInfoGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                var controller = new SalesController();
                var cartItemId = 0;
                switch (e.CommandName)
                {
                case "Delete":
                    cartItemId = int.Parse(e.CommandArgument.ToString());
                    controller.DeleteCartItem(cartItemId);
                    ProductGridView.DataBind();
                    break;

                case "Update":
                    cartItemId   = int.Parse(e.CommandArgument.ToString().Split(';')[0]);
                    var idx      = int.Parse(e.CommandArgument.ToString().Split(';')[1]);
                    var quantity = int.Parse((CartInfoGridView.Rows[idx].FindControl("QutityChanged") as TextBox).Text);
                    controller.UpdateCartItem(cartItemId, quantity);
                    ProductGridView.DataBind();
                    break;
                }
            });
        }