private async void button8_Click(object sender, EventArgs e) { var brand = await _brandManager.GetByName(cboBrand.Text); var category = await _categoryManager.GetByName(cboCategory.Text); if (brand == null) { brand = new Brand(); } if (category == null) { category = new Category(); } ProductDTO product = new ProductDTO() { AutomaticCode = chkCode.Checked, AvailableStockStr = txtAvailableStock.Text, Brand = Convert.ToString(brand.BrandID), Category = Convert.ToString(category.CategoryID), Code = txtCode.Text, CostStr = txtCost.Text, MarkUpStr = txtMarkup.Text, Name = txtName.Text, SalesPriceStr = txtSalesPrice.Text, AutomaticSalesPrice = chkSalesPrice.Checked }; var result = await _productManager.Add(product); if (!result.IsSuccess) { MessageBox.Show(result.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { ProductAudit productAudit = new ProductAudit() { Quantity = Convert.ToDecimal(txtAvailableStock.Text), UserCreatedID = Global.User.UserID, ProductID = result.ID, DateCreated = DateTime.Now }; await _productAuditManager.Add(productAudit); MessageBox.Show($@"Product { txtName.Text } added.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } }
public async Task <Result> Add(ProductAudit productAudit) { var result = new Result(); var sql = $@"INSERT INTO ProductAudit (ProductID, Quantity, DateCreated, UserCreatedID) VALUES (@ProductID, @Quantity, GETDATE(), @UserCreatedID)"; var r = await _repositoryNgPinas.ExecuteAsync(sql, new { ProductID = productAudit.ProductID, Quantity = productAudit.Quantity, UserCreatedID = productAudit.UserCreatedID }); result.IsSuccess = r > 0; return(result); }