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; } } } }
private void btnEdit_Click(object sender, EventArgs e) { Form frmaddProduct = new AddProduct(currentSelectID); frmaddProduct.ShowDialog(); refreshProducts(); }
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; } }
private void AddProductButton_Click(object sender, EventArgs e) { var addProductForm = new AddProduct(); addProductForm.ShowDialog(); InitializeProducts();//добавл для обновления комбобокса с продуктами }
private void btnAdd_Click(object sender, EventArgs e) { Form frmaddProduct = new AddProduct(); frmaddProduct.ShowDialog(); refreshProducts(); }
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); }
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)); }
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); }
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); }
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); }
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); }
private void MenuItem_Click_2(object sender, RoutedEventArgs e) { AddProduct addProduct = App.Container.Resolve <AddProduct>(); addProduct.ShowDialog(); dataGrid.Items.Refresh(); }
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)); }
private void Label12_Click(object sender, EventArgs e) { AddProduct a = new AddProduct(); a.FormClosing += (sender2, e2) => check(sender2, e2, 3); a.ShowDialog(); }
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)); }
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; } }
/// <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()); } }
private void AddProduct(object sender, MouseButtonEventArgs e) { Window addProductWindow = new AddProduct(); addProductWindow.Topmost = true; addProductWindow.Show(); }
private void BtnCadProduct_Click(object sender, RoutedEventArgs e) { AddProduct addProduct = new AddProduct(); addProduct.Show(); this.Close(); }
private void btnPro_Click(object sender, EventArgs e) { AddProduct pro = new AddProduct(); this.FindForm().Close(); pro.Show(); }
private void PictureBox12_Click(object sender, EventArgs e) { AddProduct p = new AddProduct(); p.FormClosing += new FormClosingEventHandler(updAdminProductActions); p.Show(); }
public Task <Unit> Handle(AddProduct command, CancellationToken cancellationToken) { return(cartRepository.GetAndUpdate( command.CartId, cart => cart.AddProduct(productPriceCalculator, command.ProductItem), cancellationToken)); }
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)); }
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)); }
private void добавитьТоварToolStripMenuItem_Click(object sender, EventArgs e) { AddProduct addProduct = new AddProduct(); addProduct.FormClosed += WinFormClosed; addProduct.Show(); }
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); }
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"); } }
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); }
private void AddStockButton_Click(object sender, MouseEventArgs e) { AddProduct newStock = new AddProduct(); newStock.ShowDialog(); Cursor.Current = Cursors.Default; UpdateProductListView(); }
//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)); }
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(); } }