private string ValidTextBox(object sender) { string listError = null; var box = (TextBox)sender; var name = box.Name.Substring(1); switch (box.Name) { case "xCodeBar": try { if ((RepositoryProduct.GetXElementByBarcode(long.Parse(box.Text).ToString()) != null) || (box.Text.Length < 5)) { listError = ("the CodeBare is not correct"); } } catch { listError = ("the CodeBare is not correct"); } break; case "xName": if ((RepositoryProduct.GetXElementByElementName("Name", box.Text.Trim().ToUpper()) != null) || (box.Text.Length < 2)) { listError = ("the Name is not correct"); } break; case "xTare": case "xPrice": case "xQTY": case "xContenance": case "xUnit_contenance": decimal decimalValue; if (!decimal.TryParse(box.Text, out decimalValue)) { listError = (string.Format("the {0} is not correct", name)); } break; } box.Foreground = (listError != null) ? new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 0, 0)) : new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0)); ((Label)FindName("l" + box.Name)).Foreground = box.Foreground; return(listError); }
private static PriceGrosType[] Get(Guid[] g) { var res = new PriceGrosType[g.Length]; for (var i = 0; i < res.Length; i++) { var x = RepositoryProduct.GetXElementByElementName("CustomerId", g[i].ToString()); var procent = (decimal)(Pro.DiscountValue) / 100; var prix = x.GetXElementValue("price").ToDecimal(); res[i] = new PriceGrosType(x.GetXElementValue("cusumerIdRealStock").ToGuid(), x.GetXElementValue("CustomerId").ToGuid(), prix + prix * procent); } return(res); }
private static PriceGrosType[] GetGros(Guid[] g) { var res = new PriceGrosType[g.Length]; for (var i = 0; i < res.Length; i++) { var x = RepositoryProduct.GetXElementByElementName("CustomerId", g[i].ToString()); var pg = x.GetXElementValue("priceGros").ToDecimal(); decimal procent = Pro.DiscountValue; pg = pg + (pg * procent / 100); var tva1 = RepositoryTva.GetById(x.GetXElementValue("tva").ToInt()); var tva = PrixOnlyTva(pg, tva1); pg = pg + tva; res[i] = new PriceGrosType(x.GetXElementValue("cusumerIdRealStock").ToGuid(), x.GetXElementValue("CustomerId").ToGuid(), pg); } return(res); }
private string ValidTextBox(object sender) { _listError = null; var box = sender as TextBox; if (box != null) { var tb = box; switch (tb.Name) { case "xCodeBar": try { XElement x = (RepositoryProduct.GetXElementByBarcode(xCodeBar.Text)); if (x != null) { if ((x.Element("CodeBare").Value != Product.CodeBare)) { _listError = ("Ce Nom de produit existe déjà"); } } } catch { _listError = ("Code-barres EAN incorrect"); } break; case "xName": try { XElement x = (RepositoryProduct.GetXElementByElementName("Name", tb.Text.Trim().ToUpper())); if (x != null) { if ((x.Element("Name").Value != Product.Name)) { _listError = ("Ce Nom de produit existe déjà"); } } } catch { _listError = ("Ce Nom de produit existe déjà"); } break; case "xPrice": try { decimal d = decimal.Parse(tb.Text.Replace(".", ",")); } catch { _listError = ("Le prix incorrect"); } break; } tb.Foreground = (_listError != null) ? new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 0, 0)) : new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0)); ((Label)FindName("l" + tb.Name)).Foreground = tb.Foreground; } var comboBox = sender as ComboBox; if (comboBox != null) { var cb = comboBox; _listError = cb.SelectedItem == null ? "Vérifier tous les domaines" : null; cb.Foreground = (_listError != null) ? new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 0, 0)) : new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0)); ((Label)FindName("l" + cb.Name)).Foreground = cb.Foreground; } return(_listError); }
private string ValidTextBox(object sender) { string listError = null; var box = sender as TextBox; if (box != null) { var tb = box; var name = tb.Name; switch (name) { case "xCodeBar": try { var x = RepositoryProduct.GetXElementByBarcode(tb.Text); if ((x != null) || (tb.Text.Length < 0)) { if ((x != null) && (x.GetXElementValue("CodeBare") == tb.Text)) { listError = Properties.Resources.LabelEanAlreadyExists; } } } catch { listError = Properties.Resources.LabelIncorrectEAN; } break; case "xName": if (string.IsNullOrEmpty(tb.Text)) { listError = $"{((FrameworkElement) sender).ToolTip} {Properties.Resources.LabelIncorrect}"; } else { var element = RepositoryProduct.GetXElementByElementName("Name", tb.Text.Trim().ToUpper()); if (tb.Text.Length < 2) { try { if (element.GetXElementValue("Name") == tb.Text) { listError = "Nom"; } } catch { listError = Properties.Resources.LabelNameAlreadyExists; } } } break; case "xPrice": case "xQTY": case "xContenance": case "xStockCount": decimal decimalValue; if (!decimal.TryParse(tb.Text.Replace(".", ","), out decimalValue)) { listError = $"{((FrameworkElement) sender).ToolTip} {Properties.Resources.LabelIncorrect}"; } break; case "xUnit_contenance": case "xTare": int intValue; if (!int.TryParse(tb.Text, out intValue)) { listError = $"{((FrameworkElement) sender).ToolTip} {Properties.Resources.LabelIncorrect}"; } break; } tb.Foreground = listError != null ? new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 0, 0)) : new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0)); var findName = (Label)FindName("l" + tb.Name); if (findName != null) { findName.Foreground = tb.Foreground; } } var comboBox = sender as ComboBox; if (comboBox != null) { var cb = comboBox; listError = cb.SelectedItem == null ? $"{((FrameworkElement) sender).ToolTip} {Properties.Resources.LabelIncorrect}" : null; cb.Foreground = listError != null ? new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 0, 0)) : new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0)); var findName = (Label)FindName("l" + cb.Name); if (findName != null) { findName.Foreground = cb.Foreground; } } return(listError); }