/// <summary> /// Validation /// </summary> /// <param name="textBox"></param> /// <returns></returns> private bool IsNameEmpty() { bool isNameEmpty = false; isNameEmpty = VerificationHelper.IsInputBoxEmpty(txtName); return(isNameEmpty); }
private void btnUpdate_Click(object sender, EventArgs e) { if (VerificationHelper.IsInputBoxEmpty(txtProductTypeName)) { return; } int productTypeId = _editId; string productTypeName = txtProductTypeName.Text.Trim(); ProductType productType = new ProductType() { ProductTypeId = productTypeId, ProductTypeName = productTypeName }; productTypeService.Update(productType); ResetUIInputtdData(); }
/// <summary> /// Add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { if (VerificationHelper.IsInputBoxEmpty(txtName)) { return; } if (_productService.IsNameExisted(txtName.Text.Trim())) { MessageBox.Show("This " + txtName.Text.Trim() + " already exists."); } else { string name = txtName.Text.Trim(); string specification = txtSpecification.Text.Trim(); int categoryId = (int)cboCategory.SelectedValue; int supplierId = _supplierId; decimal.TryParse(txtPurchasedPrice.Text.Trim(), out Decimal purchasedPrice); decimal.TryParse(txtSellingPrice.Text.Trim(), out Decimal sellingPrice); DateTime purchasedDate = dtpPurchasedDate.Value; DateTime expirationDate = dtpExpirationDate.Value; string description = txtDescription.Text.Trim(); Product product = new Product() { Name = name, Specification = specification, CategoryId = categoryId, SupplierId = supplierId, PurchasedPrice = purchasedPrice, SellingPrice = sellingPrice, PurchasedDate = purchasedDate, ExpirationDate = expirationDate, Description = description }; _productService.Add(product); } ResetUIInputtdData(); }
/// <summary> /// Add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { if (VerificationHelper.IsInputBoxEmpty(txtProductTypeName)) { return; } if (productTypeService.IsProductTypeNameExisted(txtProductTypeName.Text.Trim())) { MessageBox.Show("This " + txtProductTypeName.Text.Trim() + " already exists."); } else { var productType = new ProductType() { ProductTypeName = txtProductTypeName.Text }; productTypeService.Add(productType); } ResetUIInputtdData(); }