public string addProcuct(ProductAddProperty addProperty) { if (addProperty.Quantity > 0) { if (codeIsExist(addProperty.ProductCode)) { int update = aStore.update(addProperty); if (update > 0) { return("<p class='text-success'>Product Update Successfully</p>"); } else { return("<p class='text-danger'>Problem Something</p>"); } } int rowCount = aStore.addProcuct(addProperty); if (rowCount > 0) { return("<p class='text-success'>Product Add Successfully</p>"); } else { return("<p class='text-danger'>Fail to Product Add</p>"); } } return("<p class='text-warning'>Positive Number</p>"); }
protected void productAddButton_Click(object sender, EventArgs e) { ProductAddProperty addProperty = new ProductAddProperty(); Regex reg = new Regex("[^0-9]"); if (String.IsNullOrEmpty(productCodeTextbox.Text)) { msgLabel.Text = "<p class='text-danger' >Product Code Empty!</p>"; return; } if (String.IsNullOrEmpty(descriptionTextBox.Text)) { msgLabel.Text = "<p class='text-danger' >Description Empty!</p>"; return; } if (String.IsNullOrEmpty(quantityTextBox.Text)) { msgLabel.Text = "<p class='text-danger' >Quantity Empty!</p>"; return; } else if (productCodeTextbox.Text.Length < 3) { msgLabel.Text = "<p class='text-danger' >Product Code At Lest 3 Character!</p>"; return; } if (reg.IsMatch(quantityTextBox.Text.ToString())) { msgLabel.Text = "<p class='text-danger' >Quantity Problem!</p>"; return; } else { addProperty.ProductCode = productCodeTextbox.Text; addProperty.Description = descriptionTextBox.Text; addProperty.Quantity = Convert.ToInt32(quantityTextBox.Text); msgLabel.Text = aLogic.addProcuct(addProperty); } }