コード例 #1
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            int number = 0;

            using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
            {
                if (productListView.SelectedValue != null && Convert.ToInt32(txtQuantity.Text) != 0)
                {
                    var product = ctx.Products.Select(x => x).Where(x => x.ID == (int)productListView.SelectedValue).FirstOrDefault();
                    foreach (var item in myProductinKars)
                    {
                        if (item.ProductinKarID == product.ID)
                        {
                            number++;
                        }
                    }
                    if (number == 1)
                    {
                        MessagBoxInfo.Show("The product is already in the shopping car", MessagBoxInfo.CmessageBoxTitle.Info);
                    }
                    else
                    {
                        myProductinKars.Add(new ProductinKar(Convert.ToInt32(txtQuantity.Text), (double)product.Inkoopprijs, product.ID, product.Naam, (int)product.LeverancierID, (double)product.Marge, (double)product.BTW, product.Eenheid));
                    }
                }
                ctx.SaveChanges();
            }
            lbShoppingCart.ItemsSource       = null;
            lbShoppingCart.SelectedValuePath = "ProductinKarID";
            lbShoppingCart.ItemsSource       = myProductinKars;
            updateTotalPrice();
        }
コード例 #2
0
        public static DialogResult Show(string message, CmessageBoxTitle title)
        {
            myMessageBoxInfo = new MessagBoxInfo();
            myMessageBoxInfo.txtMessagebx.Text = message;
            //myMessageBoxInfo.btnOk = myMessageBoxInfo.GetMessageButton(btnOk);
            myMessageBoxInfo.txtTitel.Text = myMessageBoxInfo.GetTitle(title);
            //icon
            switch (title)
            {
            case CmessageBoxTitle.Info:
                myMessageBoxInfo.iconMsg.Kind       = MaterialDesignThemes.Wpf.PackIconKind.InfoCircle;
                myMessageBoxInfo.iconMsg.Foreground = Brushes.Blue;
                break;

            case CmessageBoxTitle.Warning:
                myMessageBoxInfo.iconMsg.Kind       = MaterialDesignThemes.Wpf.PackIconKind.Warning;
                myMessageBoxInfo.iconMsg.Foreground = Brushes.Yellow;
                break;

            case CmessageBoxTitle.Error:
                myMessageBoxInfo.iconMsg.Kind       = MaterialDesignThemes.Wpf.PackIconKind.Error;
                myMessageBoxInfo.iconMsg.Foreground = Brushes.DarkRed;
                break;

            default:
                break;
            }
            myMessageBoxInfo.ShowDialog();
            return(result);
        }
コード例 #3
0
        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            if (productListView.SelectedValue != null)
            {
                using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
                {
                    var bestel = ctx.BestellingProducts.Select(x => x).ToList();
                    if (bestel.Contains(productListView.SelectedValue))
                    {
                        var bestelingId = ctx.BestellingProducts.Select(x => x).Where(x => x.ProductID == (int)productListView.SelectedValue).FirstOrDefault();
                        ctx.BestellingProducts.RemoveRange(ctx.BestellingProducts.Where(x => x.ProductID == (int)productListView.SelectedValue)).FirstOrDefault();
                        ctx.Bestellings.RemoveRange(ctx.Bestellings.Where(x => x.ID == bestelingId.BestellingID));
                        ctx.Products.RemoveRange(ctx.Products.Where(p => p.ID == (int)productListView.SelectedValue)).FirstOrDefault();
                    }
                    else
                    {
                        ctx.Products.RemoveRange(ctx.Products.Where(p => p.ID == (int)productListView.SelectedValue)).FirstOrDefault();
                    }

                    System.Windows.Forms.DialogResult result = MyMessageBox.Show("Are you sure want to delet the product?", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        MessagBoxInfo.Show("Product successfully deleted", MessagBoxInfo.CmessageBoxTitle.Info);
                        ctx.SaveChanges();
                    }
                }
            }
            updateListView();
        }
コード例 #4
0
 private void btnJasonCreat_Click(object sender, RoutedEventArgs e)
 {
     using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
     {
         var           products     = ctx.Products.Select(x => x);
         List <object> listProducts = new List <object>();
         foreach (var item in products)
         {
             Product productList = new Product()
             {
                 ID            = item.ID,
                 Naam          = item.Naam,
                 Marge         = item.Marge,
                 Eenheid       = item.Eenheid,
                 BTW           = item.BTW,
                 LeverancierID = item.LeverancierID,
                 CategorieID   = item.CategorieID,
                 Inkoopprijs   = item.Inkoopprijs,
                 InStock       = item.InStock
             };
             listProducts.Add(productList);
         }
         JsonCreat(listProducts);
         MessagBoxInfo.Show("Template created", MessagBoxInfo.CmessageBoxTitle.Info);
     }
 }
コード例 #5
0
 private void btnRemove_Click(object sender, RoutedEventArgs e)
 {
     if (listViewOrder.SelectedValue != null)
     {
         using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
         {
             var bestelingProd = ctx.BestellingProducts.Select(x => x).ToList();
             if (bestelingProd.Contains(listViewOrder.SelectedValue))
             {
                 System.Windows.Forms.DialogResult result = MyMessageBox.Show("Are you sure you want to delete the order and all the datas? ", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                 if (result == System.Windows.Forms.DialogResult.Yes)
                 {
                     var bestProd = ctx.BestellingProducts.RemoveRange(ctx.BestellingProducts.Where(x => x.BestellingID == (int)listViewOrder.SelectedValue));
                     var best     = ctx.Bestellings.RemoveRange(ctx.Bestellings.Where(x => x.ID == (int)listViewOrder.SelectedValue));
                     MessagBoxInfo.Show("Data successfully deleted", MessagBoxInfo.CmessageBoxTitle.Info);
                     ctx.SaveChanges();
                     updateTheList();
                 }
             }
             else
             {
                 var best1 = ctx.Bestellings.RemoveRange(ctx.Bestellings.Where(x => x.ID == (int)listViewOrder.SelectedValue));
                 ctx.SaveChanges();
                 updateTheList();
             }
         }
     }
 }
コード例 #6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MessagBoxInfo.Show($"Thank {loggedInUser.Voornaam + " " + loggedInUser.Achternaam} for watching the application", MessagBoxInfo.CmessageBoxTitle.Info);
            Shopping myshopping = new Shopping(loggedInUser);

            this.Close();
            myshopping.ShowDialog();
        }
コード例 #7
0
        private void btnAddSave_Click(object sender, RoutedEventArgs e)
        {
            if (chekText(true))
            {
                do
                {
                    using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
                    {
                        try
                        {
                            var sup = ctx.Leveranciers.Where(x => x.Company == txtCompany.Text && x.Contactpersoon == txtContactPerson.Text).Count();

                            if (sup == 0)
                            {
                                ctx.Leveranciers.Add(new Leverancier()
                                {
                                    Contactpersoon = txtContactPerson.Text,
                                    Company        = txtCompany.Text,
                                    Telefoonnummer = txtPhone.Text,
                                    Emailadres     = txtEmail.Text,
                                    Straatnaam     = txtStreet.Text,
                                    Huisnummer     = Convert.ToInt32(txtHouseNumber.Text),
                                    Bus            = Convert.ToInt32(txtMailbox.Text),
                                    Postcode       = Convert.ToInt32(txtZipcode.Text),
                                    Gemeente       = txtTown.Text
                                });
                                string newSuppplier = $"{txtCompany.Text}\n" +
                                                      $"{txtContactPerson.Text}\n" +
                                                      $"{txtPhone.Text}\n" +
                                                      $"{txtEmail.Text}\n" +
                                                      $"{txtStreet.Text} {txtHouseNumber.Text} {txtMailbox.Text}\n" +
                                                      $"{txtZipcode.Text}\n" +
                                                      $"{txtTown.Text}";
                                System.Windows.Forms.DialogResult result = MessagBoxInfo.Show(newSuppplier, MessagBoxInfo.CmessageBoxTitle.Info);
                                if (result == System.Windows.Forms.DialogResult.OK)
                                {
                                    ctx.SaveChanges();
                                    updateTheList();
                                    hidePanel();
                                }
                            }
                            else
                            {
                                MessagBoxInfo.Show("Company is already exist", MessagBoxInfo.CmessageBoxTitle.Error);
                            }
                        }
                        catch (Exception)
                        {
                            MessagBoxInfo.Show("Something wrong", MessagBoxInfo.CmessageBoxTitle.Warning);
                        }
                    }
                } while (false);
            }
            else
            {
                MessagBoxInfo.Show("Something missing", MessagBoxInfo.CmessageBoxTitle.Warning);
            }
        }
コード例 #8
0
 private void btnAddSave_Click(object sender, RoutedEventArgs e)
 {
     using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
     {
         if (chekErrorsText(true))
         {
             do
             {
                 try
                 {
                     ctx.Klants.Add(new Klant()
                     {
                         Voornaam       = txtFirstName.Text,
                         Achternaam     = txtLastName.Text,
                         Straatnaam     = txtStreet.Text,
                         Huisnummer     = Convert.ToInt32(txtHouseNumber.Text),
                         Bus            = Convert.ToInt32(txtMailbox.Text),
                         Postcode       = Convert.ToInt32(txtZipcode.Text),
                         Gemeente       = txtTown.Text,
                         Telefoonnummer = txtPhone.Text,
                         Emailadres     = txtEmail.Text,
                         AangemaaktOp   = Convert.ToDateTime(DateTimePicker.Text),
                         Opmerking      = txtComment.Text
                     });
                     var klant = ctx.Klants.Select(x => x).Where(y => y.Voornaam == txtFirstName.Text && y.Achternaam == txtLastName.Text).Count();
                     if (klant == 0)
                     {
                         MessagBoxInfo.Show("New Customer", MessagBoxInfo.CmessageBoxTitle.Info);
                         ctx.SaveChanges();
                         UpdateListView();
                         hidePanel();
                     }
                     else
                     {
                         MessagBoxInfo.Show("De customer alredy exist", MessagBoxInfo.CmessageBoxTitle.Error);
                     }
                 }
                 catch
                 {
                     MessagBoxInfo.Show("Something wrong", MessagBoxInfo.CmessageBoxTitle.Error);
                 }
             } while (false);
         }
         else
         {
             MessagBoxInfo.Show("Something missing", MessagBoxInfo.CmessageBoxTitle.Error);
         }
     }
 }
コード例 #9
0
 private void btnRemove_Click(object sender, RoutedEventArgs e)
 {
     if (listViewOrderProduct.SelectedValue != null)
     {
         using  (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
         {
             System.Windows.Forms.DialogResult result = MyMessageBox.Show("Are you sure want to delet the product?", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
             if (result == System.Windows.Forms.DialogResult.Yes)
             {
                 var bestPro = ctx.BestellingProducts.RemoveRange(ctx.BestellingProducts.Where(x => x.BestellingProductID == (int)listViewOrderProduct.SelectedValue)).FirstOrDefault();
                 ctx.SaveChanges();
                 MessagBoxInfo.Show("Data successfully deleted", MessagBoxInfo.CmessageBoxTitle.Info);
                 fillTheList();
             }
         }
     }
 }
コード例 #10
0
 private void btnRemove_Click(object sender, RoutedEventArgs e)
 {
     if (listViewPersonLid.SelectedValue != null)
     {
         using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
         {
             var bestelingperson = ctx.Bestellings.Select(x => x).ToList();
             if (bestelingperson.Contains(listViewPersonLid.SelectedValue))
             {
                 var selectPerson       = ctx.Personeelslids.Select(x => x).Where(x => x.ID == (int)listViewPersonLid.SelectedValue).FirstOrDefault();
                 var selectOrde         = ctx.Bestellings.Select(x => x).Where(x => x.PersoneelslidID == selectPerson.ID).FirstOrDefault();
                 var selectOrderProduct = ctx.BestellingProducts.Select(x => x).Where(x => x.BestellingID == selectOrde.ID).FirstOrDefault();
                 System.Windows.Forms.DialogResult result = MyMessageBox.Show("Are you sure you want to delete the user and all the datas and orders?", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                 if (result == System.Windows.Forms.DialogResult.Yes)
                 {
                     var ord    = ctx.BestellingProducts.RemoveRange(ctx.BestellingProducts.Where(x => x.BestellingID == selectOrderProduct.BestellingID));
                     var order  = ctx.Bestellings.RemoveRange(ctx.Bestellings.Where(x => x.PersoneelslidID == selectPerson.ID));
                     var person = ctx.Personeelslids.RemoveRange(ctx.Personeelslids.Where(x => x.ID == (int)listViewPersonLid.SelectedValue)).FirstOrDefault();
                     MessagBoxInfo.Show(selectPerson.Voornaam + " " + selectPerson.Achternaam + " " + "successfully deleted", MessagBoxInfo.CmessageBoxTitle.Info);
                     ctx.SaveChanges();
                 }
                 else
                 {
                     System.Windows.Forms.DialogResult result2 = MyMessageBox.Show("Would you like to delete only the person", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                     if (result == System.Windows.Forms.DialogResult.Yes)
                     {
                         var person = ctx.Personeelslids.RemoveRange(ctx.Personeelslids.Where(x => x.ID == (int)listViewPersonLid.SelectedValue)).FirstOrDefault();
                         ctx.SaveChanges();
                     }
                 }
             }
             else
             {
                 System.Windows.Forms.DialogResult result2 = MyMessageBox.Show("Are you sure you want to delete the user?", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                 if (result2 == System.Windows.Forms.DialogResult.Yes)
                 {
                     var person = ctx.Personeelslids.RemoveRange(ctx.Personeelslids.Where(x => x.ID == (int)listViewPersonLid.SelectedValue)).FirstOrDefault();
                     ctx.SaveChanges();
                 }
             }
         }
         updateTheList();
         hideEditform();
     }
 }
コード例 #11
0
        // le kell frisiteni az osszes listat
        private void btnOrder_Click(object sender, RoutedEventArgs e)
        {
            using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
            {
                if (cmbCustomer.SelectedValue != null && myProductinKars.Count() != 0)
                {
                    System.Windows.Forms.DialogResult result = MyMessageBox.Show("Do you confirm the order?", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        ctx.Bestellings.Add(new Bestelling()
                        {
                            PersoneelslidID = loggedInUser.ID,
                            KlantID         = (int)cmbCustomer.SelectedValue,
                            LeverancierID   = null,
                            DatumOpgemaakt  = DateTime.Now
                        });

                        ctx.SaveChanges();
                        var lastBesttelingId = ctx.Bestellings.Select(x => x.ID).Max();
                        foreach (var item in myProductinKars)
                        {
                            ctx.BestellingProducts.Add(new BestellingProduct()
                            {
                                BestellingID = lastBesttelingId,
                                ProductID    = item.ProductinKarID,
                                Pieces       = item.Quantity
                            });
                            var product = ctx.Products.Select(x => x).Where(x => x.ID == item.ProductinKarID).FirstOrDefault();
                            product.InStock = product.InStock - item.Quantity;
                            ctx.SaveChanges();
                        }
                        myProductinKars.Clear();
                        txtQuantity.Text   = 0.ToString();
                        txtPrice.Text      = string.Empty;
                        txtTotalPrice.Text = string.Empty;
                        updateShoppingList();
                        MessagBoxInfo.Show("Order successful", MessagBoxInfo.CmessageBoxTitle.Info);
                    }
                }
                else
                {
                    MessagBoxInfo.Show("Something missing", MessagBoxInfo.CmessageBoxTitle.Error);
                }
            }
        }
コード例 #12
0
        private void btnAddNew_Click(object sender, RoutedEventArgs e)
        {
            using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
            {
                if (chekText(true))
                {
                    do
                    {
                        try
                        {
                            bool uniekPerson = ctx.Personeelslids.Where(x => x.Username == txtUsername.Text).Count() == 0 ? true : false;
                            if (uniekPerson)
                            {
                                ctx.Personeelslids.Add(new Personeelslid()
                                {
                                    Achternaam = txtLastname.Text,
                                    Voornaam   = txtFirstname.Text,
                                    Username   = txtUsername.Text,
                                    Password   = txtPassword.Text,
                                    Usertype   = cmbUsertype.SelectedItem.ToString()
                                });

                                MessagBoxInfo.Show($"{txtUsername.Text} successfully created", MessagBoxInfo.CmessageBoxTitle.Info);
                                ctx.SaveChanges();
                                updateTheList();
                                hideEditform();
                            }
                            else
                            {
                                MessagBoxInfo.Show("The user already exists", MessagBoxInfo.CmessageBoxTitle.Warning);
                            }
                        }
                        catch
                        {
                            MessagBoxInfo.Show("Something wrong", MessagBoxInfo.CmessageBoxTitle.Error);
                        }
                    } while (false);
                }
                else
                {
                    MessagBoxInfo.Show("Something missing", MessagBoxInfo.CmessageBoxTitle.Error);
                }
            }
        }
コード例 #13
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (chekErrorsText(true))
            {
                do
                {
                    try
                    {
                        using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
                        {
                            var klant = ctx.Klants.Select(x => x).Where(x => x.ID == (int)listViewCustomer.SelectedValue).FirstOrDefault();

                            klant.Voornaam       = txtFirstName.Text;
                            klant.Achternaam     = txtLastName.Text;
                            klant.Straatnaam     = txtStreet.Text;
                            klant.Huisnummer     = Convert.ToInt32(txtHouseNumber.Text);
                            klant.Bus            = Convert.ToInt32(txtMailbox.Text);
                            klant.Postcode       = Convert.ToInt32(txtZipcode.Text);
                            klant.Gemeente       = txtTown.Text;
                            klant.Telefoonnummer = txtPhone.Text;
                            klant.Emailadres     = txtEmail.Text;
                            klant.AangemaaktOp   = Convert.ToDateTime(DateTimePicker.Text);
                            klant.Opmerking      = txtComment.Text;
                            System.Windows.Forms.DialogResult result = MyMessageBox.Show("Are you sure you want to change it?", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                            if (result == System.Windows.Forms.DialogResult.Yes)
                            {
                                ctx.SaveChanges();
                                MessagBoxInfo.Show("Succesful", MessagBoxInfo.CmessageBoxTitle.Info);
                            }
                            UpdateListView();
                            hidePanel();
                        }
                    }
                    catch
                    {
                        MessagBoxInfo.Show("Something wrong", MessagBoxInfo.CmessageBoxTitle.Error);
                    }
                } while (false);
            }
            else
            {
                MessagBoxInfo.Show("Something missing", MessagBoxInfo.CmessageBoxTitle.Error);
            }
        }
コード例 #14
0
 private void btnPlusQuantity_Click(object sender, RoutedEventArgs e)
 {
     if (productListView.SelectedValue != null && txtQuantity.Text != string.Empty)
     {
         using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
         {
             var selectProduct = ctx.Products.Select(x => x).Where(x => x.ID == (int)productListView.SelectedValue).FirstOrDefault();
             if (selectProduct.InStock > Convert.ToInt32(txtQuantity.Text))
             {
                 int number = Convert.ToInt32(txtQuantity.Text);
                 number++;
                 txtQuantity.Text = number.ToString();
             }
             else
             {
                 MessagBoxInfo.Show("We have " + selectProduct.InStock.ToString(), MessagBoxInfo.CmessageBoxTitle.Error);
             }
         }
     }
 }
コード例 #15
0
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     if (chekText(true))
     {
         do
         {
             try
             {
                 using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
                 {
                     var sup = ctx.Leveranciers.Select(x => x).Where(y => y.ID == (int)supportList.SelectedValue).FirstOrDefault();
                     sup.Contactpersoon = txtContactPerson.Text;
                     sup.Company        = txtCompany.Text;
                     sup.Telefoonnummer = txtPhone.Text;
                     sup.Emailadres     = txtEmail.Text;
                     sup.Straatnaam     = txtStreet.Text;
                     sup.Huisnummer     = Convert.ToInt32(txtHouseNumber.Text);
                     sup.Bus            = Convert.ToInt32(txtMailbox.Text);
                     sup.Postcode       = Convert.ToInt32(txtZipcode.Text);
                     sup.Gemeente       = txtTown.Text;
                     System.Windows.Forms.DialogResult result = MessagBoxInfo.Show("Are you sure you want to change it?", MessagBoxInfo.CmessageBoxTitle.Info);
                     if (result == System.Windows.Forms.DialogResult.OK)
                     {
                         MessagBoxInfo.Show("Succesful", MessagBoxInfo.CmessageBoxTitle.Info);
                         ctx.SaveChanges();
                         updateTheList();
                         hidePanel();
                     }
                 }
             }
             catch (Exception)
             {
                 MessagBoxInfo.Show("Something wrong", MessagBoxInfo.CmessageBoxTitle.Warning);
             }
         } while (false);
     }
     else
     {
         MessagBoxInfo.Show("Something missing", MessagBoxInfo.CmessageBoxTitle.Warning);
     }
 }
コード例 #16
0
 private void btnAddSave_Click(object sender, RoutedEventArgs e)
 {
     using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
     {
         if (chekErrors(true))
         {
             do
             {
                 try
                 {
                     ctx.Products.Add(new Product()
                     {
                         Naam           = txtName.Text,
                         Inkoopprijs    = Convert.ToInt32(txtPurchasePrice.Text),
                         Marge          = Convert.ToInt32(txtMargin.Text),
                         Eenheid        = txtUnit.Text,
                         BTW            = Convert.ToInt32(txtBtw.Text),
                         InStock        = Convert.ToInt32(txtInstock.Text),
                         Foto           = txtSource.Text,
                         Specifications = txtSpecifications.Text,
                         LeverancierID  = (int)cmbSupplier.SelectedValue,
                         CategorieID    = (int)cmbCategory.SelectedValue
                     });
                     ctx.SaveChanges();
                     updateListView();
                     MessagBoxInfo.Show("New product successfully added to the warehouse.", MessagBoxInfo.CmessageBoxTitle.Info);
                     hideGrid();
                 }
                 catch
                 {
                     MessagBoxInfo.Show("Something wrong", MessagBoxInfo.CmessageBoxTitle.Error);
                 }
             } while (false);
         }
         else
         {
             MessagBoxInfo.Show("Something missing", MessagBoxInfo.CmessageBoxTitle.Error);
         }
     }
 }
コード例 #17
0
 private void btneditJson_Click(object sender, RoutedEventArgs e)
 {
     using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
     {
         var            jsonPro      = File.ReadAllText("json_supplier.Json");
         List <Product> listProducts = JsonConvert.DeserializeObject <List <Product> >(jsonPro);
         foreach (var item in listProducts)
         {
             var selectProduct = ctx.Products.Single(x => x.ID == item.ID);
             selectProduct.Naam          = item.Naam;
             selectProduct.Marge         = item.Marge;
             selectProduct.Eenheid       = item.Eenheid;
             selectProduct.BTW           = item.BTW;
             selectProduct.LeverancierID = item.LeverancierID;
             selectProduct.CategorieID   = item.CategorieID;
             selectProduct.Inkoopprijs   = item.Inkoopprijs;
             selectProduct.InStock       = item.InStock;
             ctx.SaveChanges();
         }
     }
     MessagBoxInfo.Show("Successfully edited", MessagBoxInfo.CmessageBoxTitle.Info);
 }
コード例 #18
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (chekErrors(true))
            {
                using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
                {
                    var product = ctx.Products.Select(x => x).Where(x => x.ID == (int)productListView.SelectedValue).FirstOrDefault();
                    do
                    {
                        try
                        {
                            product.Naam           = txtName.Text;
                            product.Inkoopprijs    = Convert.ToInt32(txtPurchasePrice.Text);
                            product.Marge          = Convert.ToInt32(txtMargin.Text);
                            product.Eenheid        = txtUnit.Text;
                            product.BTW            = Convert.ToInt32(txtBtw.Text);
                            product.InStock        = Convert.ToInt32(txtInstock.Text);
                            product.Foto           = txtSource.Text;
                            product.Specifications = txtSpecifications.Text;
                            product.LeverancierID  = (int)cmbSupplier.SelectedValue;
                            product.CategorieID    = (int)cmbCategory.SelectedValue;

                            System.Windows.Forms.DialogResult result = MyMessageBox.Show("Are you sure you want to change it?", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                            if (result == System.Windows.Forms.DialogResult.Yes)
                            {
                                ctx.SaveChanges();
                                MessagBoxInfo.Show("Succesful", MessagBoxInfo.CmessageBoxTitle.Info);
                            }
                            updateListView();
                            hideGrid();
                        }
                        catch
                        {
                            MessagBoxInfo.Show("Something wrong", MessagBoxInfo.CmessageBoxTitle.Error);
                        }
                    } while (false);
                }
            }
        }
コード例 #19
0
 private void btnLogin_Click(object sender, RoutedEventArgs e)
 {
     using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
     {
         Personeelslid selectUser = ctx.Personeelslids.Where(x => x.Username == txtUsersName.Text && x.Password == txtPassword.Password).FirstOrDefault();
         if (selectUser != null)
         {
             loginUser = selectUser.Username;
             txtPassword.Clear();
             txtUsersName.Clear();
             WelcomMessageBox.Show(loginUser);
             MainMenu mainMenu = new MainMenu(selectUser);
             mainMenu.txtUserName.Text = $"Hello {loginUser}";
             this.Close();
             mainMenu.ShowDialog();
         }
         else
         {
             MessagBoxInfo.Show("This username and password cannot be found", MessagBoxInfo.CmessageBoxTitle.Error);
         }
     }
 }
コード例 #20
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
            {
                var select = ctx.Personeelslids.Select(x => x).Where(x => x.ID == (int)listViewPersonLid.SelectedValue).FirstOrDefault();
                if (chekText(true))
                {
                    do
                    {
                        try
                        {
                            select.Voornaam   = txtFirstname.Text;
                            select.Achternaam = txtLastname.Text;
                            select.Username   = txtUsername.Text;
                            select.Password   = txtPassword.Text;
                            select.Usertype   = cmbUsertype.SelectedItem.ToString();

                            System.Windows.Forms.DialogResult result = MyMessageBox.Show("Are you sure you want to change it? ", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                            if (result == System.Windows.Forms.DialogResult.Yes)
                            {
                                MessagBoxInfo.Show("Succesful", MessagBoxInfo.CmessageBoxTitle.Info);
                                ctx.SaveChanges();
                                hideEditform();
                            }
                        }
                        catch
                        {
                            MessagBoxInfo.Show("Something wrong", MessagBoxInfo.CmessageBoxTitle.Error);
                        }
                    } while (false);
                }
                else
                {
                    MessagBoxInfo.Show("Something missing", MessagBoxInfo.CmessageBoxTitle.Error);
                }
            }
        }
コード例 #21
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
            {
                if (listViewOrder.SelectedValue != null && chekText(true))
                {
                    do
                    {
                        try
                        {
                            var select = ctx.Bestellings.Select(x => x).Where(x => x.ID == (int)listViewOrder.SelectedValue).FirstOrDefault();
                            select.KlantID         = (int)cmbKlant.SelectedValue;
                            select.PersoneelslidID = (int)cmbPersonmember.SelectedValue;
                            select.LeverancierID   = (int)cmbSupplier.SelectedValue;
                            select.DatumOpgemaakt  = Convert.ToDateTime(dtDatum.Text);

                            System.Windows.Forms.DialogResult result = MyMessageBox.Show("Are you sure you want to change the data?", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                            if (result == System.Windows.Forms.DialogResult.Yes)
                            {
                                ctx.SaveChanges();
                                hidePanel();
                                updateTheList();
                                MessagBoxInfo.Show("Succesful", MessagBoxInfo.CmessageBoxTitle.Info);
                            }
                        }
                        catch
                        {
                            MessagBoxInfo.Show("Something wring", MessagBoxInfo.CmessageBoxTitle.Error);
                        }
                    } while (false);
                }
                else
                {
                    MessagBoxInfo.Show("Something missing", MessagBoxInfo.CmessageBoxTitle.Error);
                }
            }
        }
コード例 #22
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
     {
         if (lbProduct.SelectedValue != null)
         {
             var product = ctx.Products.Select(x => x).Where(x => x.ID == (int)lbProduct.SelectedValue).FirstOrDefault();
             if (product.InStock >= Convert.ToInt32(txtQuantity.Text) && Convert.ToInt32(txtQuantity.Text) != 0)
             {
                 myProductinKars.Add(new ProductinKar(Convert.ToInt32(txtQuantity.Text), (double)product.Inkoopprijs , product.ID, product.Naam, (int)product.LeverancierID,(double)product.Marge,(double)product.BTW, product.Eenheid));
                 product.InStock = product.InStock - Convert.ToInt32(txtQuantity.Text);
             }
             else
             {
                 MessagBoxInfo.Show("We have " + product.InStock.ToString(), MessagBoxInfo.CmessageBoxTitle.Error);
             }
         }
         ctx.SaveChanges();
     }
     lbShoppingCart.ItemsSource = null;
     lbShoppingCart.SelectedValuePath = "ProductinKarID";
     lbShoppingCart.ItemsSource = myProductinKars;
     updateTotalPrice();
 }
コード例 #23
0
 private void btnRemove_Click(object sender, RoutedEventArgs e)
 {
     using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2())
     {
         if (listViewCustomer.SelectedValue != null)
         {
             var selectedKlant = ctx.Klants.Select(x => x).Where(x => x.ID == (int)listViewCustomer.SelectedValue).FirstOrDefault();
             var besteling     = ctx.Bestellings.Select(x => x).ToList();
             if (besteling.Contains(listViewCustomer.SelectedValue))
             {
                 var besteling2 = ctx.Bestellings.Select(x => x).Where(x => x.KlantID == selectedKlant.ID).FirstOrDefault();
                 System.Windows.Forms.DialogResult result = MyMessageBox.Show("Are you sure you want to delete and all data with it?", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                 if (result == System.Windows.Forms.DialogResult.Yes)
                 {
                     var bestelingProd  = ctx.BestellingProducts.RemoveRange(ctx.BestellingProducts.Where(x => x.BestellingID == besteling2.ID));
                     var bestelinRemove = ctx.Bestellings.RemoveRange(ctx.Bestellings.Where(x => x.KlantID == selectedKlant.ID));
                     var klant          = ctx.Klants.RemoveRange(ctx.Klants.Where(x => x.ID == (int)listViewCustomer.SelectedValue)).FirstOrDefault();
                     ctx.SaveChanges();
                     UpdateListView();
                     MessagBoxInfo.Show("Customer successfully deleted", MessagBoxInfo.CmessageBoxTitle.Info);
                 }
             }
             else
             {
                 System.Windows.Forms.DialogResult result = MyMessageBox.Show("Are you sure you want to delete?", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No);
                 if (result == System.Windows.Forms.DialogResult.Yes)
                 {
                     var klant2 = ctx.Klants.RemoveRange(ctx.Klants.Where(x => x.ID == (int)listViewCustomer.SelectedValue)).FirstOrDefault();
                     ctx.SaveChanges();
                     UpdateListView();
                     MessagBoxInfo.Show("Customer successfully deleted", MessagBoxInfo.CmessageBoxTitle.Info);
                 }
             }
         }
     }
 }
コード例 #24
0
 private void btnHelp_Click(object sender, RoutedEventArgs e)
 {
     MessagBoxInfo.Show("Antal Palfi\n [email protected]", MessagBoxInfo.CmessageBoxTitle.Info);
 }