Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
fix regex for numeric fields and insertion in database
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinoMensio committed Jun 28, 2017
1 parent 71595f5 commit cdad6a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ServerApplicationWPF/ServerApplicationWPF/AddProduct.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public AddProduct(Product product, DataManager dataManager)

private void IntNumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
Regex regex = new Regex("\\d+");
Regex regex = new Regex("\\d");
e.Handled = !regex.IsMatch(e.Text);
}
private void PriceNumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
Regex regex = new Regex("(\\d+)([.,]?)(\\d?\\d?)");
Regex regex = new Regex("[\\d,]");
e.Handled = !regex.IsMatch(e.Text);
}

Expand Down
2 changes: 1 addition & 1 deletion ServerApplicationWPF/ServerApplicationWPF/DBConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void insertProduct(Product product)
cmd.Parameters.AddWithValue("@productId", product.ID);
cmd.Parameters.AddWithValue("@barcode", product.Barcode);
cmd.Parameters.AddWithValue("@name", product.Product_name);
cmd.Parameters.AddWithValue("@price", product.Price);
cmd.Parameters.AddWithValue("@price", double.Parse(product.Price));
cmd.Parameters.AddWithValue("@storeQty", product.StoreQty);
cmd.Parameters.AddWithValue("@warehouseQty", product.WarehouseQty);
cmd.Parameters.AddWithValue("@points", product.Points);
Expand Down

0 comments on commit cdad6a9

Please sign in to comment.