private void BtnAddNew_Click(object sender, EventArgs e) { ProductViewModel viewModel = new ProductViewModel() { NameText = txtName.Text, PriceText = txtPrice.Text, PhotoPathText = txtPhotoPath.Text }; AddNewProduct?.Invoke(this, viewModel); }
private void AcceptBtn_Click(object sender, EventArgs e) { if (Id != 0) { UpdateProduct.Invoke(sender, EventArgs.Empty); } else { AddNewProduct.Invoke(sender, EventArgs.Empty); } UpdateDataGridView(); ClearGroupBoxFields(); }
private void btnAddproduct_Click(object sender, EventArgs e) { string pname = txtproductName.Text; string ptype = cboType.SelectedItem.ToString(); // instance of class and call a method AddNewProduct ap = new AddNewProduct(pname, ptype); ap.AddProdToDb(); MessageBox.Show("product added to database"); txtproductName.Clear(); cboType.SelectedIndex = -1; }
public ActionResult Create(AddNewProduct newProductCommand) { MyShopWebApplication.CommandService.Execute(newProductCommand); return RedirectToAction("List", "Product"); }
public ActionResult Create() { var command = new AddNewProduct(); return View(command); }
private async void btnAddInvoice_OnClick(object sender, RoutedEventArgs e) { if (this.cbxGroupList.SelectedIndex < 1) { await this.ShowMessageAsync("SAVE INVOICE", "Please select a group!"); return; } if (this.txtPrice.Text == String.Empty) { await this.ShowMessageAsync("SAVE INVOICE", "Price cannot be empty!"); return; } double price; if (!double.TryParse(this.txtPrice.Text, out price)) { await this.ShowMessageAsync("SAVE INVOICE", "Enter a valid price!"); return; } var groupId = this._groupList[this.cbxGroupList.SelectedIndex].GroupId; var userId = this._userId; var time = DateTime.Now.ToString(CultureInfo.InvariantCulture); var invoice = new Invoice { GroupId = groupId, UserId = userId, BuyDate = time, IsExpired = false, Price = price }; var add = new AddNewInvoice(this._dbo); if (add.Insert(invoice)) { await this.ShowMessageAsync("SAVE INVOICE", "Inovice Saved!"); var invoiceId = add.GetLastInvoiceId(); if (this._productList.Count > 0) { // eger product eklenmisse kaydet var saveProduct = new AddNewProduct(this._dbo); if (saveProduct.Insert(this._productList, invoiceId)) { await this.ShowMessageAsync("SAVE PRODUCTS", "Products Saved!"); ClearInvoiceScreen(); } else { await this.ShowMessageAsync("SAVE PRODUCTS", "Something gone wrong!"); } } } else { await this.ShowMessageAsync("SAVE INVOICE", "Something gone wrong!"); } }