Ejemplo n.º 1
0
 private void BtnAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var queryVerify = $"{SQL_Customer.TableName} WHERE {SQL_Customer.Phone}='{TextBoxPhone.Text}' OR {SQL_Customer.Email}='{TextBoxMail.Text}'";
         if (Classes.Connection.Connection.SizeOf(Classes.Connection.Connection.GetAll(queryVerify)) == 0)
         {
             var querySelect = string.Format("SELECT max(ID_{0}) FROM {0}", SQL_Customer.TableName);
             var command     = Classes.Connection.Connection.GetUniqueCell(querySelect);
             var idCustomer  = command.ToString() == string.Empty ? 1 : Convert.ToInt32(command) + 1;
             Classes.Connection.Connection.Insert(SQL_Customer.TableName, idCustomer, TextBoxMail.Text, TextBoxName.Text, TextBoxPhone.Text);
             ModernDialog.ShowMessage(Transharp.GetTranslation("Box_SuccessAddCustomer", TextBoxName.Text), Transharp.GetTranslation("Box_AC_Success"),
                                      MessageBoxButton.OK);
             ShowCustomer(idCustomer, TextBoxMail.Text, TextBoxName.Text, TextBoxPhone.Text);
             TextBoxMail.Text = TextBoxPhone.Text = TextBoxName.Text = string.Empty;
         }
         else
         {
             ModernDialog.ShowMessage(Transharp.GetTranslation("Box_CustomerAlreadyExist"), Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK);
         }
     }
     catch
     {
         ModernDialog.ShowMessage(Transharp.GetTranslation("Box_DBFail"), Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK);
     }
 }
        private void ComboBoxCustomer_Loaded(object sender, EventArgs e)
        {
            //Traduction
            DC_ChooseCustomer.Text = Transharp.GetTranslation("DC_ChooseCustomer");
            LabelEstimate.Text     = Transharp.GetTranslation("DC_CustomerCE");
            LabelCommand.Text      = Transharp.GetTranslation("DC_CustomerCM");
            LabelPhone.Text        = Transharp.GetTranslation("DC_LabelPhone");
            LabelMail.Text         = Transharp.GetTranslation("DC_labelMail");
            BTN_Delete.Content     = Transharp.GetTranslation("DC_DeleteCustomer");
            BTN_Update.Content     = Transharp.GetTranslation("DC_UpdateCustomer");

            //Default Visibility

            PanelDevis.Children.Clear();
            ChangeVisibility(false);
            try
            {
                ComboBoxCustomer.Items.Clear();
                InitComboClient();
            }
            catch (Exception caught)
            {
                ModernDialog.ShowMessage(caught.Message, Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK);
            }
        }
Ejemplo n.º 3
0
        private void BTN_Sale_Click(object sender, EventArgs e)
        {
            var id     = ((Button)sender).Tag.ToString();
            var num    = Convert.ToInt32(id) - 1;
            var onSale = !ListMerchandise[num].OnSale ? 1 : 0;

            try
            {
                var query         = string.Format("UPDATE {0} SET {1} = {2} WHERE ID_{0} = {3}", SQL_Merchandise.TableName, SQL_Merchandise.OnSale, onSale, id);
                var commandeModif = Classes.Connection.Connection.Command(query);
                commandeModif.ExecuteNonQuery();
            }
            catch
            {
                ModernDialog.ShowMessage(Transharp.GetTranslation("Box_DBFail"), Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK);
            }
            finally
            {
                var nbMerchandise = ListMerchandise.Count;
                for (var i = 0; i < nbMerchandise; i++)
                {
                    if (ListMerchandise[i].ToString() != id)
                    {
                        continue;
                    }
                    ListMerchandise[i].OnSale = !ListMerchandise[i].OnSale;
                }
                SelectMarchandiseLike(string.Empty);
            }
        }
Ejemplo n.º 4
0
        private void Text_Loaded(object sender, RoutedEventArgs e)
        {
            PanelMOTD.Children.Clear();
            string jsonMotd;

            try
            {
                //JsonMOTD = new WebClient().DownloadString(String.Format("http://billyhennin.github.io/Devis-Manager/MOTD{0}.json", Transharp.getCurrentLanguage()));

                var json = JObject.Parse(new WebClient().DownloadString("http://billyhennin.github.io/Devis-Manager/MOTD.json"));
                jsonMotd = $"{json["date"]} - {json["title"]}\r\n\r\n\t\t{json["tags"]}";
                //JsonMOTD = String.Format("{0} - {1}\r\n\r\n\t\t{2}\r\n\r\n[img]{3}[/img]", json["date"], json["title"], json["tags"], json["image"]);
            }
            catch
            {
                jsonMotd = Transharp.GetTranslation("Curl_Fail_MOTD");
            }

            var motd = $"\r\n{Transharp.GetTranslation("AB_MOTD1")}\r\n\r\n{Transharp.GetTranslation("AB_MOTD2")}\r\n\r\n\t{Transharp.GetTranslation("AB_MOTD3")}\r\n\t{Transharp.GetTranslation("AB_MOTD4")}\r\n\t{Transharp.GetTranslation("AB_MOTD5", "[url='https://github.com/BillyHennin/Devis-Manager']GitHub[/url]")}\r\n\r\n{Transharp.GetTranslation("AB_MOTD6")}\r\n\r\n\t{jsonMotd}";

            var panelMessage = new StackPanel();
            var border       = new Border
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Margin          = new Thickness(2, 2, 1, 0),
                BorderThickness = new Thickness(1),
                Child           = panelMessage
            };

            panelMessage.Children.Add(new BbCodeBlock {
                Margin = new Thickness(5, 2, 0, 0), BbCode = motd
            });
            PanelMOTD.Children.Add(border);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Methode is called when the page is initialized (so it's only called once)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ComboBoxClient_OnInitialized(object sender, EventArgs e)
 {
     //Try to initialized, if can't, show a messagebox
     try
     {
         //Get all customer in the database
         var command  = Classes.Connection.Connection.GetAll(SQL_Customer.TableName);
         var resultat = command.ExecuteReader();
         while (resultat.Read())
         {
             //Insert into the value into the combobox (every customer found in the database)
             ComboBoxClient.Items.Add(new ComboboxItemCustomer
             {
                 Text  = resultat[SQL_Customer.Name].ToString(),
                 Value =
                     new Classes.Customer(Convert.ToInt32(resultat[SQL_Customer.ID]), resultat[SQL_Customer.Name].ToString(),
                                          resultat[SQL_Customer.Phone].ToString(), resultat[SQL_Customer.Email].ToString())
             });
         }
         resultat.Close();
         ComboBoxClient.SelectedIndex = 0;
     }
     catch
     {
         ModernDialog.ShowMessage(Transharp.GetTranslation("Box_DBFail"), Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// When the user select another item in the ComboBoxCatergory, this method is called
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ComboBoxCategory_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     //Try to initialized, if can't, show a messagebox
     try
     {
         //Clearthe ComboBoxProduct
         ComboBoxProduct.Items.Clear();
         //Select every product that are 'onSale' and those who are in the selected category
         var query =
             $"{SQL_Merchandise.TableName} WHERE {SQL_Merchandise.OnSale} = 1 AND {SQL_Merchandise.Quantity} > 0 AND ID_{SQL_Category.TableName}={((ComboboxItemCategory) ComboBoxCategory.SelectedItem).Value.Id}";
         var command = Classes.Connection.Connection.GetAll(query);
         var result  = command.ExecuteReader();
         while (result.Read())
         {
             //Insert into the value into the combobox (every product returned with the query)
             ComboBoxProduct.Items.Add(new ComboboxItemMerchandise
             {
                 Text  = result[SQL_Merchandise.Name].ToString(),
                 Value =
                     new Classes.Merchandise(Convert.ToInt32(result[SQL_Merchandise.ID]), result[SQL_Merchandise.Name].ToString(),
                                             Convert.ToInt32(result[SQL_Merchandise.Price]), Convert.ToInt32(result[SQL_Merchandise.Quantity]),
                                             ((ComboboxItemCategory)ComboBoxCategory.SelectedItem).Value.Id)
             });
         }
         //Close the query
         result.Close();
         //Select the first product
         ComboBoxProduct.SelectedIndex = 0;
     }
     catch
     {
         ModernDialog.ShowMessage(Transharp.GetTranslation("Box_DBFail"), Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Method is called when the quantity is wrong (negative, decimal, string,  ....)
 /// </summary>
 private void ErrorCost()
 {
     //Change textblock by an error message
     AllPrice.Text = $"{Transharp.GetTranslation("All_Price")} {Transharp.GetTranslation("Box_Error")}";
     //Disable the add button
     BtnAdd.IsEnabled = false;
     //Put textblock and textbox in red
     AllPrice.Foreground = TextBoxEstimateQte.CaretBrush = TextBoxEstimateQte.SelectionBrush = TextBoxEstimateQte.BorderBrush = Brushes.Red;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Method that update the text language
 /// </summary>
 private void UpdateText()
 {
     EcTitle.Text            = Transharp.GetTranslation("EC_Title");
     EcChooseCategory.Text   = Transharp.GetTranslation("EC_ChooseCategory");
     EcAddMerchandise.Text   = Transharp.GetTranslation("EC_AddMerchandise");
     AllQte.Text             = Transharp.GetTranslation("All_QTE");
     AllPrice.Text           = Transharp.GetTranslation("All_Price");
     EcCustomer.Text         = Transharp.GetTranslation("EC_Customer");
     BtnAdd.Content          = Transharp.GetTranslation("BTN_Add");
     AjouterEstimate.Content = Transharp.GetTranslation("BTN_Create");
 }
Ejemplo n.º 9
0
        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;
        }
Ejemplo n.º 10
0
        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
            });
        }
Ejemplo n.º 11
0
        private void CustomerCreator_Loaded(object sender, RoutedEventArgs e)
        {
            //Traduction
            AC_Title.Text       = Transharp.GetTranslation("AC_Title");
            AC_AddCustomer.Text = Transharp.GetTranslation("AC_AddCustomer");
            AC_AddMail.Text     = Transharp.GetTranslation("AC_AddMail");
            AC_AddName.Text     = Transharp.GetTranslation("AC_AddName");
            AC_AddPhone.Text    = Transharp.GetTranslation("AC_AddPhone");
            BtnAdd.Content      = Transharp.GetTranslation("BTN_Add");

            //
            DisplayAll();
        }
Ejemplo n.º 12
0
        private void ShowCustomer(int id, string mail, string name, string phone)
        {
            var panelCustomer = new StackPanel();
            var thick         = new Thickness(5, 2, 0, 0);

            // New border
            var border = new Border
            {
                BorderBrush         = BtnAdd.BorderBrush,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Margin          = new Thickness(2, 2, 1, 0),
                BorderThickness = new Thickness(1),
                Width           = BorderCustomer.Width - 5,
                Child           = panelCustomer,
                Height          = 70
            };

            // Customer's name
            panelCustomer.Children.Add(new TextBlock {
                Margin = thick, Text = name, Height = 16
            });

            // Mail
            panelCustomer.Children.Add(new TextBlock {
                Text = mail, Margin = thick, Height = 16
            });

            // Phone
            panelCustomer.Children.Add(new TextBlock {
                Text = phone, Margin = thick, Height = 16
            });

            // Button
            var btnDelete = new Button
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                Content             = Transharp.GetTranslation("DC_DeleteCustomer"),
                Margin      = new Thickness(9, -30, 67, 50),
                BorderBrush = Brushes.Red,
                Tag         = id
            };

            panelCustomer.Children.Add(btnDelete);
            btnDelete.Click += BTN_Delete_Click;
            var newCustomer = new Classes.Customer(id, name, phone, mail);

            PanelCustomer.Children.Add(border);
            newCustomer.Border = border;
            ListCustomer.Add(newCustomer);
        }
Ejemplo n.º 13
0
 private void ModernWindow_Loaded(object sender, RoutedEventArgs e)
 {
     //Load every traduction for links
     Link_About.DisplayName              = Transharp.GetTranslation("Link_About");
     Link_Apparence.DisplayName          = Transharp.GetTranslation("Link_Apparence");
     Link_Param.DisplayName              = Transharp.GetTranslation("Link_Param");
     Link_CE.DisplayName                 = Transharp.GetTranslation("Link_CE");
     Link_CreateCE.DisplayName           = Transharp.GetTranslation("Link_CreateCE");
     Link_Customer.DisplayName           = Transharp.GetTranslation("Link_Customer");
     Link_DisplayCustomer.DisplayName    = Transharp.GetTranslation("Link_DisplayCustomer");
     Link_CreateCustomer.DisplayName     = Transharp.GetTranslation("Link_CreateCustomer");
     Link_Merchandise.DisplayName        = Transharp.GetTranslation("Link_Merchandise");
     Link_DisplayMerchandise.DisplayName = Transharp.GetTranslation("Link_DisplayMerchandise");
 }
Ejemplo n.º 14
0
        public SettingsAppearanceViewModel()
        {
            themes.Add(new Link {
                DisplayName = Transharp.GetTranslation("THM_Dark"), Source = AppearanceManager.DarkThemeSource
            });
            themes.Add(new Link {
                DisplayName = Transharp.GetTranslation("THM_Light"), Source = AppearanceManager.LightThemeSource
            });

            SelectedFontSize = AppearanceManager.Current.FontSize == FontSize.Large ? _fontLarge : _fontSmall;
            SyncThemeAndColor();

            AppearanceManager.Current.PropertyChanged += OnAppearanceManagerPropertyChanged;
        }
        private void ButtonDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Classes.Connection.Connection.Delete(SQL_Estimate.TableName, ((ComboboxItemCustomer)ComboBoxCustomer.SelectedItem).Value.Id, SQL_Customer.TableName);
                Classes.Connection.Connection.Delete(SQL_Customer.TableName, ((ComboboxItemCustomer)ComboBoxCustomer.SelectedItem).Value.Id);
            }
            catch
            {
                ModernDialog.ShowMessage(Transharp.GetTranslation("Box_DBFail"), Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK);
            }

            ComboBoxCustomer.Items.Clear();
            InitComboClient();
        }
Ejemplo n.º 16
0
        private void BTN_Delete_Click(object sender, EventArgs e)
        {
            var id    = ((Button)sender).Tag.ToString();
            var query = string.Format("SELECT {0} FROM {1} WHERE ID_{1} = {2}", SQL_Customer.Name, SQL_Customer.TableName, id);
            var name  = Classes.Connection.Connection.GetUniqueCell(query);

            if (ModernDialog.ShowMessage(Transharp.GetTranslation("Box_DeleteCustomer", name), Transharp.GetTranslation("Box_AskDelete"), MessageBoxButton.YesNo)
                != MessageBoxResult.Yes)
            {
                return;
            }
            Classes.Connection.Connection.Delete(SQL_Estimate.TableName, id, SQL_Customer.TableName);
            Classes.Connection.Connection.Delete(SQL_Customer.TableName, id);
            DisplayAll();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Method is called when the quantity changed and when the page is loaded
        /// </summary>
        private void QuantityChanged()
        {
            //init quantity
            _itemSelectedQuantity = 0;

            //If the text in the TextBoxEstimateQte is a valid int, if not, call ErrorCost()
            if (IsInt(TextBoxEstimateQte.Text))
            {
                //Convert it to a int
                var newQuantity = Convert.ToInt32(TextBoxEstimateQte.Text);

                //If it's less or equals to 0 call the method ErrorCost()
                if (newQuantity <= 0)
                {
                    ErrorCost();
                }
                else
                {
                    //If there isn't product selected call the method ErrorCost()
                    if (ComboBoxProduct.Items.Count == 0)
                    {
                        ErrorCost();
                    }
                    else
                    {
                        _itemSelectedQuantity = newQuantity;
                        _itemSelectedPrice    = (((ComboboxItemMerchandise)ComboBoxProduct.SelectedItem).Value.Price * newQuantity);
                        AllPrice.Foreground   = LabelTotalPrix.Foreground;
                        AllPrice.Text         = $"{Transharp.GetTranslation("All_Price")} {_itemSelectedPrice}€";
                        var convertFromString = ColorConverter.ConvertFromString(Settings.Default.AccentColor);
                        if (convertFromString != null)
                        {
                            TextBoxEstimateQte.BorderBrush    =
                                TextBoxEstimateQte.CaretBrush = TextBoxEstimateQte.SelectionBrush = new SolidColorBrush((Color)convertFromString);
                        }
                        BtnAdd.IsEnabled = true;
                    }
                }
            }
            else
            {
                ErrorCost();
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// When the user click on BTNAddEstimate, this method is called
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BTNAddEstimate_click(object sender, RoutedEventArgs e)
        {
            //Initialising this var
            var numberEstimate = 0;

            try
            {
                //As there isn't auto inc in oracle so here's an "auto inc" like
                var querySelect   = string.Format("SELECT max(ID_{0}), max({1}) FROM {0}", SQL_Estimate.TableName, SQL_Estimate.NumberDevis);
                var oracleCommand = Classes.Connection.Connection.Command(querySelect);
                var result        = oracleCommand.ExecuteReader();
                var sizeList      = ListMerchandise.Count;
                while (result.Read())
                {
                    var idEstimate = result[0].ToString() == string.Empty ? 1 : Convert.ToInt32(result[0]) + 1;
                    numberEstimate = result[1].ToString() == string.Empty ? 1 : Convert.ToInt32(result[1]) + 1;
                    //For each product in the estimate, add it to the database
                    for (var i = 0; i < sizeList; i++)
                    {
                        Classes.Connection.Connection.Insert(SQL_Estimate.TableName, _estimate.Customer.Id, _estimate[i].Id, ((idEstimate) + i), _estimate[i].Quantity,
                                                             DateTime.Now.ToString("dd/MM/yy"), _estimate[i].Price, (numberEstimate));
                    }
                }
                result.Close();

                //Show success message
                ModernDialog.ShowMessage(Transharp.GetTranslation("Box_SuccessAdd", numberEstimate, _totalCost), Transharp.GetTranslation("Box_CE_Success"),
                                         MessageBoxButton.OK);

                //Reset the page
                BtnAdd.Content = Transharp.GetTranslation("BTN_Add");
                PanelEstimate.Children.Clear();
                ListMerchandise.Clear();
                _totalCost                = 0;
                LabelTotalPrix.Text       = string.Empty;
                AjouterEstimate.IsEnabled = false;
            }
            catch
            {
                ModernDialog.ShowMessage(Transharp.GetTranslation("Box_DBFail"), Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK);
            }
        }
 private void InitComboClient()
 {
     try
     {
         var resultat = Classes.Connection.Connection.GetAll(SQL_Customer.TableName).ExecuteReader();
         while (resultat.Read())
         {
             ComboBoxCustomer.Items.Add(new ComboboxItemCustomer
             {
                 Text  = resultat[2].ToString(),
                 Value = new Classes.Customer(Convert.ToInt32(resultat[0]), resultat[2].ToString(), resultat[3].ToString(), resultat[1].ToString())
             });
         }
         resultat.Close();
     }
     catch
     {
         ModernDialog.ShowMessage(Transharp.GetTranslation("Box_DBFail"), Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK);
     }
 }
        private void ButtonUpdate_Click(object sender, RoutedEventArgs e)
        {
            var customer = ((ComboboxItemCustomer)ComboBoxCustomer.SelectedItem).Value;

            try
            {
                Classes.Connection.Connection.Update(SQL_Customer.TableName, customer.Id, new[, ] {
                    { SQL_Customer.Phone, TextPhone.Text }, { SQL_Customer.Email, TextMail.Text }
                });
            }
            catch
            {
                ModernDialog.ShowMessage(Transharp.GetTranslation("Box_DBFail"), Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK);
            }
            finally
            {
                customer.Phone = TextPhone.Text;
                customer.Email = TextMail.Text;
                ModernDialog.ShowMessage(Transharp.GetTranslation("Box_SuccessUpdate", customer.Name), Transharp.GetTranslation("Box_Update_Success_Title"),
                                         MessageBoxButton.OK);
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// When the user click on the BTNAddFeed button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BTNAddFeed_click(object sender, RoutedEventArgs e)
        {
            var text          = $"{ComboBoxCategory.Text} - {ComboBoxProduct.Text}";
            var nbMerchandise = _estimate.GetList.Count;

            for (var i = 0; i < nbMerchandise; i++)
            {
                //If the product is already in the estimate call UpdateEstimate with its key on the estimate and with 'null' as id
                if (_estimate[i].Name != text)
                {
                    continue;
                }
                UpdateEstimate(i, null);
                return;
            }
            //call the method AddMerchandise
            AddMerchandise(((ComboboxItemMerchandise)ComboBoxProduct.SelectedItem).Value.Id, text, _itemSelectedQuantity, _itemSelectedPrice,
                           ((ComboboxItemMerchandise)ComboBoxProduct.SelectedItem).Value.CategoryId);
            AjouterEstimate.IsEnabled = true;
            //Change the button to 'Modify'
            BtnAdd.Content = Transharp.GetTranslation("BTN_Modify");
        }
Ejemplo n.º 22
0
        /// <summary>
        /// When the user select another item in the ComboBoxProduct, this method is called
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComboBoxProduct_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //Change by default the text of the button
            BtnAdd.Content = Transharp.GetTranslation("BTN_Add");
            try
            {
                //Switch the value of _itemSelectedQuantity (quantity of item the user wants)
                switch (_itemSelectedQuantity)
                {
                //If it's 0, then call ErrorCost()
                case 0:
                    ErrorCost();
                    break;

                //If the value is correct :
                default:
                    //Multiply the price of the selected item by the quantity
                    _itemSelectedPrice = ((ComboboxItemMerchandise)ComboBoxProduct.SelectedItem).Value.Price * Convert.ToInt32(TextBoxEstimateQte.Text);
                    //Show it
                    AllPrice.Text = $"{Transharp.GetTranslation("All_Price")} {_itemSelectedPrice}€";

                    //If the selected product is already in the estimate, show "modify" instead of "add" in the button
                    var nbMerchandise = _estimate.GetList.Count;
                    for (var i = 0; i < nbMerchandise; i++)
                    {
                        if (_estimate[i].Id == ((ComboboxItemMerchandise)ComboBoxProduct.SelectedItem).Value.Id)
                        {
                            BtnAdd.Content = Transharp.GetTranslation("BTN_Modify");
                        }
                    }
                    break;
                }
            }
            catch (Exception caught)
            {
                Console.WriteLine(caught.Message);
                Console.Read();
            }
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Methode is called when the page is initialized (so it's only called once)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ComboBoxCategory_Initialized(object sender, EventArgs e)
 {
     //Try to initialized, if can't, show a messagebox
     try
     {
         //Insert into the value into the combobox (every category found in the database)
         var command  = Classes.Connection.Connection.GetAll(SQL_Category.TableName);
         var resultat = command.ExecuteReader();
         while (resultat.Read())
         {
             ComboBoxCategory.Items.Add(new ComboboxItemCategory
             {
                 Text  = resultat[SQL_Category.Title].ToString(),
                 Value = new Classes.Category(Convert.ToInt32(resultat[SQL_Category.ID]), resultat[SQL_Category.Title].ToString())
             });
         }
         resultat.Close();
     }
     catch
     {
         ModernDialog.ShowMessage(Transharp.GetTranslation("Box_DBFail"), Transharp.GetTranslation("Box_Error"), MessageBoxButton.OK);
     }
 }
Ejemplo n.º 24
0
        private void ComboBoxLang_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var newLang = ComboBoxLang.SelectedItem.ToString();

            switch (newLang)
            {
            case "French":
                Transharp.SetCurrentLanguage(Transharp.LangsEnum.French);
                break;

            case "English":
                Transharp.SetCurrentLanguage(Transharp.LangsEnum.English);
                break;

            default:
                Transharp.SetCurrentLanguage(Transharp.LangsEnum.English);
                newLang = "English";
                break;
            }
            SelectionTextBlock.Text = Transharp.GetTranslation("PM_SelectionLanguage");

            Settings.Default.Language = newLang;
        }
Ejemplo n.º 25
0
        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);
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="idUpdate">Null if delete</param>
        /// <param name="idDelete">Null if update</param>
        private void UpdateEstimate(int?idUpdate, int?idDelete)
        {
            //Initialising vars
            var listMerchandiseN2 = new List <Classes.Merchandise>();

            BtnAdd.Content      = Transharp.GetTranslation("BTN_Add");
            _totalCost          = 0;
            LabelTotalPrix.Text = string.Empty;

            var nbMerchandise = _estimate.GetList.Count;

            for (var i = 0; i < nbMerchandise; i++)
            {
                if (idUpdate.HasValue)
                {
                    if (i == idUpdate.Value)
                    {
                        var text            = $"{ComboBoxCategory.Text} - {ComboBoxProduct.Text}";
                        var merchandiseCost = _itemSelectedPrice;
                        listMerchandiseN2.Add(new Classes.Merchandise(((ComboboxItemMerchandise)ComboBoxProduct.SelectedItem).Value.Id, text, _itemSelectedQuantity,
                                                                      merchandiseCost, ((ComboboxItemMerchandise)ComboBoxProduct.SelectedItem).Value.CategoryId));
                    }
                    else
                    {
                        listMerchandiseN2.Add(ListMerchandise[i]);
                    }
                }
                else
                {
                    if (ListMerchandise[i].ToString() != idDelete.ToString())
                    {
                        listMerchandiseN2.Add(ListMerchandise[i]);
                    }
                }
            }
            if (idDelete.HasValue)
            {
                nbMerchandise -= 1;
            }

            for (var i = 0; i < nbMerchandise; i++)
            {
                if (listMerchandiseN2[i].Id == ((ComboboxItemMerchandise)ComboBoxProduct.SelectedItem).Value.Id)
                {
                    BtnAdd.Content = Transharp.GetTranslation("BTN_Modify");
                }
            }

            PanelEstimate.Children.Clear();
            _estimate.GetList.Clear();

            for (var i = 0; i < nbMerchandise; i++)
            {
                AddMerchandise(listMerchandiseN2[i].Id, listMerchandiseN2[i].Name, listMerchandiseN2[i].Quantity, listMerchandiseN2[i].Price,
                               listMerchandiseN2[i].CategoryId);
            }
            listMerchandiseN2.Clear();
            if (_estimate.GetList.Count == 0)
            {
                AjouterEstimate.IsEnabled = false;
            }
        }
Ejemplo n.º 27
0
        /// <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 UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     TextBlockApparence.Text = Transharp.GetTranslation("Link_Apparence");
     TextBlockTheme.Text     = Transharp.GetTranslation("THM_Theme");
     TextBlockTextSize.Text  = Transharp.GetTranslation("THM_TextSize");
 }
Ejemplo n.º 30
0
 private void MenuParametre_Loaded(object sender, RoutedEventArgs e)
 {
     SelectionTextBlock.Text = Transharp.GetTranslation("PM_SelectionLanguage");
 }