private void Display(string text, Classes.Merchandise newMerchandise) { var panelMerchandise = new StackPanel(); var thick = new Thickness(5, 2, 0, 0); // New border var border = new Border { BorderBrush = BorderEstimate.BorderBrush, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(2, 2, 1, 0), BorderThickness = new Thickness(1), Width = BorderEstimate.Width - 5, Child = panelMerchandise, Height = 70 }; PanelMerchandise.Children.Add(border); // Merchandise's name panelMerchandise.Children.Add(new TextBlock { Text = text, Margin = thick, Height = 16 }); // Quantity panelMerchandise.Children.Add(new TextBlock { Text = Transharp.GetTranslation("DM_Stock", newMerchandise.Quantity), Margin = new Thickness(5, 2, 0, 0), Height = 16 }); // Price panelMerchandise.Children.Add(new TextBlock { Text = $"{newMerchandise.Price}€", Margin = thick, Height = 16 }); var btnSale = new Button { HorizontalAlignment = HorizontalAlignment.Right, Content = newMerchandise.OnSale ? Transharp.GetTranslation("DM_OnSale") : Transharp.GetTranslation("DM_NotOnSale"), Margin = new Thickness(9, -30, 67, 50), BorderBrush = newMerchandise.OnSale ? Brushes.Lime : Brushes.Red, Tag = newMerchandise }; // Delete button panelMerchandise.Children.Add(btnSale); btnSale.Click += BTN_Sale_Click; newMerchandise.Border = border; }
private void SelectMarchandiseLike(string merchandise) { var result = false; PanelMerchandise.Children.Clear(); var nbMerchandise = ListMerchandise.Count; for (var i = 0; i < nbMerchandise; i++) { if (!ListMerchandise[i].Name.ToLower().Contains(merchandise.ToLower()) && !ListMerchandise[i].Price.ToString(CultureInfo.InvariantCulture).Contains(merchandise) && !ListMerchandise[i].Quantity.ToString(CultureInfo.InvariantCulture).Contains(merchandise)) { continue; } var id = ListMerchandise[i].Id; var text = ListMerchandise[i].Name; var newMerchandise = new Classes.Merchandise(id, text, ListMerchandise[i].Quantity, ListMerchandise[i].Price, ListMerchandise[i].CategoryId) { OnSale = ListMerchandise[i].OnSale }; result = true; Display(text, newMerchandise); } if (result) { return; } var panelMerchandise = new StackPanel(); // New border var border = new Border { HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(2, 2, 1, 0), BorderThickness = new Thickness(1), Width = BorderEstimate.Width - 5, Child = panelMerchandise, Height = 100 }; PanelMerchandise.Children.Add(border); // Merchandise's name panelMerchandise.Children.Add(new TextBlock { Text = Transharp.GetTranslation("DM_SearchNull"), Margin = new Thickness(5, 2, 0, 0), Height = 40, TextAlignment = TextAlignment.Center }); }
private void Page_Loaded(object sender, RoutedEventArgs e) { DM_Merchandise.Text = Transharp.GetTranslation("DM_Merchandise"); PanelMerchandise.Children.Clear(); ListMerchandise.Clear(); try { var oCommand = Classes.Connection.Connection.GetAll(SQL_Merchandise.TableName); var resultat = oCommand.ExecuteReader(); while (resultat.Read()) { var category = string.Empty; var query = String.Format("SELECT {0} FROM {1} WHERE ID_{1} = {2}", SQL_Category.Title, SQL_Category.TableName, resultat[SQL_Category.ID]); var commandCategory = Classes.Connection.Connection.Command(query); var resultatCategory = commandCategory.ExecuteReader(); while (resultatCategory.Read()) { category = resultatCategory[SQL_Category.Title].ToString(); } var text = $"{category} - {resultat[SQL_Merchandise.Name]}"; var newMerchandise = new Classes.Merchandise(Convert.ToInt32(resultat[SQL_Merchandise.ID]), text, Convert.ToInt32(resultat[SQL_Merchandise.Quantity]), Convert.ToInt32(resultat[SQL_Merchandise.Price]), Convert.ToInt32(resultat[SQL_Category.ID])) { OnSale = Convert.ToBoolean(resultat[SQL_Merchandise.OnSale]) }; Display(text, newMerchandise); ListMerchandise.Add(newMerchandise); } resultat.Close(); } catch { ModernDialog.ShowMessage(Transharp.GetTranslation("Box_DBFail"), Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK); } }
/// <summary> /// Method which show a merchandise on the grid /// </summary> /// <param name="id">merchandise's id</param> /// <param name="name">merchandise's name</param> /// <param name="quantity">quantity of the merchandise the user wants</param> /// <param name="price">merchandise's price</param> /// <param name="category">merchandise's category</param> private void AddMerchandise(int id, string name, int quantity, double price, int category) { //Create a new panel var panelMerchandise = new StackPanel(); var newMerchandise = new Classes.Merchandise(id, name, quantity, price, category); //Init default thick var thick = new Thickness(5, 2, 0, 0); //Get default color var convertFromString = ColorConverter.ConvertFromString(Settings.Default.AccentColor); if (convertFromString != null) { //Create a graphical border var border = new Border { BorderBrush = new SolidColorBrush((Color)convertFromString), HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(2, 2, 1, 0), BorderThickness = new Thickness(1), Width = BorderEstimate.Width - 6, Child = panelMerchandise, Height = 70 }; // Merchandise's name textblock panelMerchandise.Children.Add(new TextBlock { HorizontalAlignment = HorizontalAlignment.Left, Margin = thick, Text = name, Height = 16 }); // Merchandise's price textblock panelMerchandise.Children.Add(new TextBlock { Text = $"{price}€", HorizontalAlignment = HorizontalAlignment.Left, Margin = thick, Height = 16 }); // Merchandise's quantity textblock panelMerchandise.Children.Add(new TextBlock { Text = $"{Transharp.GetTranslation("EC_Quantity")} : {quantity.ToString(CultureInfo.InvariantCulture)}", HorizontalAlignment = HorizontalAlignment.Left, Margin = thick, Height = 16 }); // Delete button var btnDelete = new Button { HorizontalAlignment = HorizontalAlignment.Right, Content = Transharp.GetTranslation("EC_DeleteMerchandise"), Margin = new Thickness(9, -30, 67, 50), BorderBrush = Brushes.Red, Tag = newMerchandise }; //Add to the panel panelMerchandise.Children.Add(btnDelete); btnDelete.Click += BTN_Delete_Click; newMerchandise.Border = border; PanelEstimate.Children.Add(border); } _estimate.GetList.Add(newMerchandise); _totalCost += price; LabelTotalPrix.Text = Transharp.GetTranslation("All_Total", _totalCost); }
private void ComboBoxCustomer_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Besoin d'avoir cette ligne car l'event est fire au changement de page if ((ComboboxItemCustomer)ComboBoxCustomer.SelectedItem == null) { return; } var selectedCustomer = ((ComboboxItemCustomer)ComboBoxCustomer.SelectedItem).Value; ComboBoxEstimate.Items.Clear(); PanelDevis.Children.Clear(); var totalPrice = 0; var nbEstimate = 1; var date = DateTime.Now; try { // Récupération de tous les devis fais par le client séléctionné var param = new Dictionary <string, object> { { "idClient", selectedCustomer.Id } }; var command = Classes.Connection.Connection.CommandStored("GetAllEstimateOfCustomer", param); var resultCommand = command.ExecuteReader(); while (resultCommand.Read()) { var query2 = string.Format( "SELECT {0}.ID_{0}, {0}.{1}, {2}.{3}, {2}.{4}, {2}.{5}, {0}.ID_{7} FROM {0}, {2} WHERE {2}.ID_{0} = {0}.ID_{0} AND {2}.{6} = {8}", SQL_Merchandise.TableName, SQL_Merchandise.Name, SQL_Estimate.TableName, SQL_Estimate.PriceMerchandise, SQL_Estimate.Quantity, SQL_Estimate.Day, SQL_Estimate.NumberDevis, SQL_Category.TableName, resultCommand[0]); var command2 = Classes.Connection.Connection.Command(query2); var resultatMerchandise = command2.ExecuteReader(); var listMerchandise2 = new List <Classes.Merchandise>(); while (resultatMerchandise.Read()) { totalPrice += Convert.ToInt32(resultatMerchandise[2]); date = Convert.ToDateTime(resultatMerchandise[4]); var merchandise = new Classes.Merchandise(Convert.ToInt32(resultatMerchandise[0]), resultatMerchandise[1].ToString(), Convert.ToInt32(resultatMerchandise[3]), Convert.ToInt32(resultatMerchandise[2]) / Convert.ToInt32(resultatMerchandise[3]), Convert.ToInt32(resultatMerchandise[5])); listMerchandise2.Add(merchandise); } resultatMerchandise.Close(); var estimate2 = new Estimate(listMerchandise2) { TotalPrice = totalPrice, Date = date }; ComboBoxEstimate.Items.Add(new ComboboxItemEstimate { Text = Transharp.GetTranslation("DC_ComboBoxCustomer", nbEstimate, date.ToShortDateString(), totalPrice), Value = estimate2 }); nbEstimate++; totalPrice = 0; } resultCommand.Close(); // Maj de l'interface TextMail.Text = selectedCustomer.Email; TextPhone.Text = selectedCustomer.Phone; } catch (Exception caught) { ModernDialog.ShowMessage(caught.Message, Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK); } finally { ChangeVisibility(true); PanelDevis.Children.Clear(); var panelMerchandise = new StackPanel(); // New border var border = new Border { HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(2, 2, 1, 0), BorderThickness = new Thickness(1), Width = BorderDevis.Width - 5, Child = panelMerchandise, Height = 100 }; PanelDevis.Children.Add(border); // Merchandise's name panelMerchandise.Children.Add(new TextBlock { Text = Transharp.GetTranslation("DM_SearchNull"), Margin = new Thickness(5, 2, 0, 0), Height = 40, TextAlignment = TextAlignment.Center }); } }
private void ComboBoxEstimate_SelectionChanged(object sender, SelectionChangedEventArgs e) { PanelDevis.Children.Clear(); if (ComboBoxEstimate.Items.Count == 0) { return; } var listMarchandise = ((ComboboxItemEstimate)ComboBoxEstimate.SelectedItem).Value.GetList; var taille = listMarchandise.Count; for (var i = 0; i < taille; i++) { var categoryString = string.Empty; var query = String.Format("SELECT {1} FROM {0} WHERE ID_{0} = {2}", SQL_Category.TableName, SQL_Category.Title, listMarchandise[i].CategoryId); var commandCategory = Classes.Connection.Connection.Command(query); var resultatCategory = commandCategory.ExecuteReader(); while (resultatCategory.Read()) { categoryString = resultatCategory[0].ToString(); } var text = $"{categoryString} - {listMarchandise[i].Name}"; var qte = listMarchandise[i].Quantity; var prixMarchandise = listMarchandise[i].Price; var category = listMarchandise[i].CategoryId; var item = new Classes.Merchandise(listMarchandise[i].Id, text, qte, prixMarchandise, category); var panelMarchandise = new StackPanel(); var thick = new Thickness(5, 2, 0, 0); // New border var bordure = new Border { BorderBrush = ComboBoxCustomer.BorderBrush, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(2, 2, 1, 0), BorderThickness = new Thickness(1), Width = BorderDevis.Width - 5, Child = panelMarchandise, Height = 70 }; // Merchandise's name panelMarchandise.Children.Add(new TextBlock { Margin = thick, Text = text, Height = 16 }); // Quantity panelMarchandise.Children.Add(new TextBlock { Text = Transharp.GetTranslation("DC_Command", qte.ToString(CultureInfo.InvariantCulture)), Margin = thick, Height = 16 }); // Price panelMarchandise.Children.Add(new TextBlock { Text = $"{prixMarchandise.ToString(CultureInfo.InvariantCulture)}€", Margin = thick, Height = 16 }); item.Border = bordure; PanelDevis.Children.Add(bordure); _estimate.GetList.Add(item); } }