コード例 #1
0
      protected void Page_Load(object sender, EventArgs e)
      {
          if (Session["Name"] == null)
          {
              Response.Redirect("Home.aspx");
          }
          else
          {
              if (!Session["UserType"].Equals("Manager"))
              {
                  Response.Redirect("Home.aspx");
              }
              else
              {
                  if (!IsPostBack)
                  {
                      AddProduct part = sc.GetProduct(Convert.ToInt32(Request.QueryString["A"]));

                      pname.Value    = part.name;
                      price.Value    = Convert.ToString(part.price);
                      quantity.Value = part.Quant;
                      col.Value      = part.Col;
                      desc.Value     = part.desc;
                      type.Value     = part.type;
                      img.Value      = part.imgurl;
                  }
              }
          }
      }
コード例 #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            Form frmaddProduct = new AddProduct(currentSelectID);

            frmaddProduct.ShowDialog();
            refreshProducts();
        }
コード例 #3
0
        private void ListViewMenu_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UserControl usc = null;

            GridMain.Children.Clear();

            switch (((ListViewItem)((ListView)sender).SelectedItem).Name)
            {
            case "MyProduct":
                usc = new ControlMyProducts(manufacturer.ID_Manufacturer);
                GridMain.Children.Add(usc);
                break;

            case "Account":
                usc = new UserProfileControl(ref manufacturer);
                GridMain.Children.Add(usc);
                break;

            case "CreateProduct":
                usc = new AddProduct(manufacturer.ID_Manufacturer);
                GridMain.Children.Add(usc);
                break;

            default:
                break;
            }
        }
コード例 #4
0
        private void AddProductButton_Click(object sender, EventArgs e)
        {
            var addProductForm = new AddProduct();

            addProductForm.ShowDialog();
            InitializeProducts();//добавл для обновления комбобокса с продуктами
        }
コード例 #5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Form frmaddProduct = new AddProduct();

            frmaddProduct.ShowDialog();
            refreshProducts();
        }
コード例 #6
0
ファイル: CartActor.cs プロジェクト: eaba/AkkaNetFsmDemo
        private void Handle(AddProduct command)
        {
            var domainEvent = new ProductAdded(command.ProductName);

            //TODO: Handle persistence errors https://getakka.net/articles/persistence/event-sourcing.html#persistence-status-handling
            Persist(domainEvent, Apply);
        }
コード例 #7
0
        public async Task <ActionResult <AddProduct> > Add_Product(AddProduct productDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var pro = new Products()
            {
                Id    = productDTO.Product_Id,
                price = productDTO.Product_price,
                name  = productDTO.Product_name
            };
            await _context.Products.AddAsync(pro);

            await _context.SaveChangesAsync();

            var product_description = new Products_description()
            {
                Id                  = pro.Id,
                price               = pro.price,
                product_name        = pro.name,
                product_description = productDTO.Product_description
            };
            await _context.AddAsync(product_description);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProduct", new { id = pro.Id }, productDTO));
        }
コード例 #8
0
        public async Task Get_ShouldReturnOk_WhenProductExistsWithGivenId(string name, double calories,
                                                                          double proteins, double carbohydrates, double fats, string categoryName)
        {
            await AuthenticateAdminAsync();

            var addProduct = new AddProduct
            {
                Name          = name,
                Calories      = calories,
                Proteins      = proteins,
                Carbohydrates = carbohydrates,
                Fats          = fats,
                CategoryName  = categoryName
            };
            var createdProduct = await _client.CreatePostAsync("/api/products", addProduct);

            var response = await _client.GetAsync($"api/products/{createdProduct.Id}");

            response.EnsureSuccessStatusCode();
            response.StatusCode.ShouldBe(HttpStatusCode.OK);

            var returnedProduct = await response.Content.ReadAsAsync <ProductDto>();

            returnedProduct.Id.ShouldBe(createdProduct.Id);
            returnedProduct.Name.ShouldBe(createdProduct.Name);
        }
コード例 #9
0
        public async Task GetByName_ShouldReturnOk_WhenProductExists()
        {
            await AuthenticateAdminAsync();

            var addProduct = new AddProduct
            {
                Name          = "testProduct",
                Calories      = 100,
                Proteins      = 10,
                Carbohydrates = 15,
                Fats          = 15,
                CategoryName  = CategoryOfProductId.Meat.ToString()
            };

            await _client.PostAsJsonAsync("api/products", addProduct);

            var response = await _client.GetAsync($"api/products/{addProduct.Name}");

            response.EnsureSuccessStatusCode();
            response.StatusCode.ShouldBe(HttpStatusCode.OK);

            var product = await response.Content.ReadAsAsync <ProductDto>();

            product.Name.ShouldBe(addProduct.Name);
            product.Calories.ShouldBe(addProduct.Calories);
            product.Proteins.ShouldBe(addProduct.Proteins);
        }
コード例 #10
0
        public async Task Post_ShouldReturnCreatedResponse_WhenUserIsAdminAndDataIsValid()
        {
            await AuthenticateAdminAsync();

            var addProduct = new AddProduct
            {
                Name          = "testProduct",
                Calories      = 100,
                Proteins      = 10,
                Carbohydrates = 15,
                Fats          = 10,
                CategoryName  = "Meat"
            };
            var response = await _client.PostAsJsonAsync("/api/products", addProduct);

            response.EnsureSuccessStatusCode();
            response.StatusCode.ShouldBe(HttpStatusCode.Created);

            var createdProduct = await response.Content.ReadAsAsync <AddProduct>();

            createdProduct.Name.ShouldBe(addProduct.Name);
            createdProduct.Calories.ShouldBe(addProduct.Calories);
            createdProduct.Proteins.ShouldBe(addProduct.Proteins);
            createdProduct.Carbohydrates.ShouldBe(addProduct.Carbohydrates);
            createdProduct.Fats.ShouldBe(addProduct.Fats);
        }
コード例 #11
0
        public async Task Put_ShouldReturnOk_WhenUserIsAdminAndDataIsValid()
        {
            await AuthenticateAdminAsync();

            var addProduct = new AddProduct
            {
                Name          = "testProduct",
                Calories      = 100,
                Proteins      = 10,
                Carbohydrates = 15,
                Fats          = 10,
                CategoryName  = "Meat"
            };

            var createdProduct = await _client.CreatePostAsync("/api/products", addProduct);

            var updateProduct = new UpdateProduct
            {
                ProductId     = createdProduct.Id,
                Name          = createdProduct.Name,
                Calories      = createdProduct.Calories + 20,
                Proteins      = createdProduct.Proteins,
                Carbohydrates = createdProduct.Carbohydrates,
                Fats          = createdProduct.Fats,
                CategoryName  = createdProduct.CategoryName
            };

            var response = await _client.PutAsJsonAsync("/api/products", updateProduct);

            response.EnsureSuccessStatusCode();
            response.StatusCode.ShouldBe(HttpStatusCode.OK);
        }
コード例 #12
0
        private void MenuItem_Click_2(object sender, RoutedEventArgs e)
        {
            AddProduct addProduct = App.Container.Resolve <AddProduct>();

            addProduct.ShowDialog();
            dataGrid.Items.Refresh();
        }
コード例 #13
0
        public async Task <ActionResult> DisplayProducts()
        {
            List <Product>    lstProducts    = null;
            ProductOrder      productOrder   = new ProductOrder();
            List <AddProduct> lstAddProducts = new List <AddProduct>();

            string value = cache.StringGet("Products");

            if (null != value)
            {
                lstProducts = JsonConvert.DeserializeObject <List <Product> >(value);
            }
            else
            {
                lstProducts = await azureDocDBHelper.GetProducts();

                value = JsonConvert.SerializeObject(lstProducts);
                cache.StringSet("Products", value);
            }
            foreach (Product pd in lstProducts)
            {
                AddProduct addPd = new AddProduct();
                addPd.ProductId   = pd.ProductId;
                addPd.ProductName = pd.ProductName;
                addPd.UnitPrice   = pd.UnitPrice;
                lstAddProducts.Add(addPd);
            }
            productOrder.lstProducts = lstAddProducts;
            return(View(productOrder));
        }
コード例 #14
0
        private void Label12_Click(object sender, EventArgs e)
        {
            AddProduct a = new AddProduct();

            a.FormClosing += (sender2, e2) => check(sender2, e2, 3);
            a.ShowDialog();
        }
コード例 #15
0
        public async Task <ActionResult <AddProduct> > Add_Products(AddProduct productDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var product = new Product()
            {
                isbn  = productDTO.ISBN,
                price = productDTO.Product_price
            };
            await _context.Product.AddAsync(product);

            await _context.SaveChangesAsync();

            var product_description = new Product_description()
            {
                product_id          = product.id,
                product_name        = productDTO.Product_name,
                product_description = productDTO.Product_description
            };
            await _context.AddAsync(product_description);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProducts", new { id = product.id }, productDTO));
        }
コード例 #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AddProduct p = sc.GetProduct(Convert.ToInt32(Request.QueryString["ID"]));

            if (Session["Name"] != null)
            {
                ADDTOCART.Visible = false;
                string display = "";
                display += "<div class='col-sm-4'><div class='product-image-wrapper'>";
                display += "<div class='single-products'><div class='productinfo text-center'>";
                display += "<a href='#'>";
                display += "<img src='" + p.imgurl + "' alt='' /><h2>R" + p.price + "</h2></a>";
                display += "<h>Name: " + p.name + "</h><br><h>Description: " + p.desc + "</h><br><a href='Cart.aspx?ProductID=" + Convert.ToInt32(Request.QueryString["ID"]) + "&Qty=1'>AddToCart</a></div></div></div></div>";
                display += "<br/>";
                display += "<br/>";
                display += "<br/>";
                Session["ProductID"] = Convert.ToInt32(Request.QueryString["ID"]);
                product.InnerHtml   += display;
            }
            else
            {
                string display = "";
                display += "<div class='col-sm-4'><div class='product-image-wrapper'>";
                display += "<div class='single-products'><div class='productinfo text-center'>";
                display += "<a href='#'>";
                display += "<img src='" + p.imgurl + "' alt='' /><h2>R" + p.price + "</h2></a>";
                display += "<h>Name: " + p.name + "</h><br><h>Description: " + p.desc + "</h></div></div></div></div>";
                display += "<br/>";
                display += "<br/>";
                display += "<br/>";

                product.InnerHtml += display;
            }
        }
コード例 #17
0
        /// <summary>
        /// Executes the edit command
        /// </summary>
        public void EditProductExecute()
        {
            try
            {
                if (Product != null)
                {
                    AddProduct addProduct = new AddProduct(Product);
                    addProduct.ShowDialog();

                    // Save update to string
                    string productUpdateText = "Updated " + product.ProductName + ", code " + product.ProductCode + ", quantity " + product.Quantity + ", price " + product.Price;

                    StoredProduct   = service.GetAllProducts().Where(product => product.Stored == true).ToList();
                    UnstoredProduct = service.GetAllProducts().Where(product => product.Stored == false).ToList();

                    // Save to file only if the data was updated
                    if ((addProduct.DataContext as AddProductViewModel).IsUpdateProduct == true)
                    {
                        service.Notify(productUpdateText);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #18
0
ファイル: MainWindow.xaml.cs プロジェクト: korzonkiee/store
        private void AddProduct(object sender, MouseButtonEventArgs e)
        {
            Window addProductWindow = new AddProduct();

            addProductWindow.Topmost = true;
            addProductWindow.Show();
        }
コード例 #19
0
        private void BtnCadProduct_Click(object sender, RoutedEventArgs e)
        {
            AddProduct addProduct = new AddProduct();

            addProduct.Show();
            this.Close();
        }
コード例 #20
0
        private void btnPro_Click(object sender, EventArgs e)
        {
            AddProduct pro = new AddProduct();

            this.FindForm().Close();
            pro.Show();
        }
コード例 #21
0
ファイル: Administrar.cs プロジェクト: JoseGamerPT/Retail2
        private void PictureBox12_Click(object sender, EventArgs e)
        {
            AddProduct p = new AddProduct();

            p.FormClosing += new FormClosingEventHandler(updAdminProductActions);
            p.Show();
        }
コード例 #22
0
 public Task <Unit> Handle(AddProduct command, CancellationToken cancellationToken)
 {
     return(cartRepository.GetAndUpdate(
                command.CartId,
                cart => cart.AddProduct(productPriceCalculator, command.ProductItem),
                cancellationToken));
 }
コード例 #23
0
        public async Task <IActionResult> Post([FromBody] AddProduct command)
        {
            var Id = Guid.NewGuid();
            await _productService.AddAsync(Id, command.Name, command.Amount, command.Price, command.ProducerName, command.CategoryName, command.Description, command.BrandTag);

            return(Json(Id));
        }
コード例 #24
0
        public ActionResult Add()
        {
            var model = new AddProduct();

            try
            {
                model.Price                 = "0";
                model.Discount              = "0";
                model.BrandSelectOptions    = DropDownListOption.GetBrandOptions();
                model.CategorySelectOptions = DropDownListOption.GetCategoryOptions();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);

                // Write error log
                var log = new Log();
                log.LogDate = DateTime.Now;
                log.Action  = "Product - Add()";
                log.Tags    = "Error";
                log.Message = ex.ToString();
                db.Logs.Add(log);
            }
            return(View(model));
        }
コード例 #25
0
ファイル: MainWindow.cs プロジェクト: p1zza/VaporStoreClub
        private void добавитьТоварToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddProduct addProduct = new AddProduct();

            addProduct.FormClosed += WinFormClosed;
            addProduct.Show();
        }
コード例 #26
0
        public AddProduct FindCategoryAndProducts(int id)
        {
            AddProduct AddProduct = new AddProduct();

            Category category = dbContext.Categories
                                .Include(cat => cat.Products)
                                .ThenInclude(prod => prod.Product)
                                .FirstOrDefault(c => c.CategoryId == id);

            List <Product> existing = dbContext.Products
                                      .Include(prod => prod.Categories)
                                      .Where(cat => cat.Categories
                                             .Any(cate => cate.CategoryId == id))
                                      .ToList();

            List <Product> available = dbContext.Products
                                       .Include(prod => prod.Categories)
                                       .Where(cat => cat.Categories
                                              .All(cate => cate.CategoryId != id))
                                       .ToList();

            AddProduct.Category  = category;
            AddProduct.Available = available;
            AddProduct.Existing  = existing;

            return(AddProduct);
        }
コード例 #27
0
ファイル: Form4.cs プロジェクト: PiotrO9/Projekty
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            List <TextBox> listOfTextBoxes = new List <TextBox>();

            listOfTextBoxes.Add(txtBoxB);
            listOfTextBoxes.Add(txtBoxT);
            listOfTextBoxes.Add(txtBoxW);

            bool[] arrayOFStatements = new bool[3];

            int i = 0;

            foreach (var txtBox in listOfTextBoxes)
            {
                if (txtBox.Text == string.Empty)
                {
                    arrayOFStatements[i] = false;
                }
                else if (float.TryParse(txtBox.Text, out float result) == false)
                {
                    arrayOFStatements[i] = false;
                }
                else
                {
                    arrayOFStatements[i] = true;
                }
                i++;
            }

            bool resultOfCheck = CheckIfAllStatementsAreTrue.CheckIfAllStatementsAreTrueMethod(arrayOFStatements);

            if (resultOfCheck == true && txtBoxName.Text != string.Empty)
            {
                // Kod dodania produktu

                string[] datasToConvert = new string[6];

                datasToConvert[0] = txtBoxName.Text;
                datasToConvert[1] = txtBoxB.Text;
                datasToConvert[2] = txtBoxT.Text;
                datasToConvert[3] = txtBoxW.Text;
                datasToConvert[4] = txtBoxKcal.Text;

                if (txtBoxBarCode.Text == string.Empty)
                {
                    datasToConvert[5] = "0";
                }
                else
                {
                    datasToConvert[5] = txtBoxBarCode.Text;
                }

                AddProduct.AddProductMethod(datasToConvert);
            }
            else
            {
                MessageBox.Show("Wprowadzono nieprawidłowe dane");
            }
        }
コード例 #28
0
        public static void Setup(TestContext ctx)
        {
            RefreshDatabase();
            _command = new AddProduct("Name", "Description", new decimal(1.99));
            var sut = new ProductService(new EntityFrameworkRepository(DbContext), new EntityFrameworkProductLocator(DbContext));

            sut.Execute(_command);
        }
コード例 #29
0
        private void AddStockButton_Click(object sender, MouseEventArgs e)
        {
            AddProduct newStock = new AddProduct();

            newStock.ShowDialog();
            Cursor.Current = Cursors.Default;
            UpdateProductListView();
        }
コード例 #30
0
        //POST : /api/products
        public async Task <ActionResult> Post([FromBody] AddProduct command)
        {
            await DispatchAsync(command);

            _logger.LogInfo($"Product with name: {command.Name} added.");

            return(CreatedAtAction(nameof(Get), new { id = command.Id }, command));
        }
コード例 #31
0
ファイル: Program.cs プロジェクト: niki-funky/Telerik_Academy
    static void Main()
    {
        AddProduct example = new AddProduct();
        try
        {
            example.ConnectToDB();

            // Insert new project in the "Projects" table
            int newProjectId = example.InsertProject("Yabulki",
                1, 1, "njqkolko", 12.10m, 10, 1, 10, false);
            Console.WriteLine("Inserted new project. " +
                "ProjectID = {0}", newProjectId);
        }
        finally
        {
            example.DisconnectFromDB();
        }
    }