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(); } } } }
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(); }
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(); }
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); } }
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(); } }
// 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); } } }
private void btnEcs_Click(object sender, RoutedEventArgs e) { using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2()) { foreach (var item in myProductinKars) { var product = ctx.Products.Select(x => x).Where(x => x.ID == item.ProductinKarID).FirstOrDefault(); product.InStock = product.InStock + item.Quantity; ctx.SaveChanges(); } } System.Windows.Application.Current.Shutdown(); }
private void btnRemove_Click(object sender, RoutedEventArgs e) { if (supportList.SelectedValue != null) { using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2()) { var productSup = ctx.Products.Select(x => x).Where(x => x.LeverancierID == (int)supportList.SelectedValue).FirstOrDefault(); var bestelSup = ctx.Bestellings.Select(x => x).ToList(); var bestelingPro = ctx.BestellingProducts.Select(x => x).ToList(); if (bestelSup.Contains(supportList.SelectedValue)) { var selectBest = ctx.Bestellings.Select(x => x).Where(x => x.LeverancierID == (int)supportList.SelectedValue).FirstOrDefault(); System.Windows.Forms.DialogResult result1 = MyMessageBox.Show("Are you sure you want to delete and all data with it?", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No); if (result1 == System.Windows.Forms.DialogResult.Yes) { var bestProremove = ctx.BestellingProducts.RemoveRange(ctx.BestellingProducts.Where(x => x.BestellingID == selectBest.ID)); var bestRemove = ctx.Bestellings.RemoveRange(ctx.Bestellings.Where(x => x.LeverancierID == (int)supportList.SelectedValue)); // select product //if (bestelingPro.Contains(productSup)) //{ //} var selectSup = ctx.Leveranciers.RemoveRange(ctx.Leveranciers.Where(x => x.ID == (int)supportList.SelectedValue)).FirstOrDefault(); ctx.SaveChanges(); updateTheList(); } } var selec = ctx.Leveranciers.RemoveRange(ctx.Leveranciers.Where(x => x.ID == (int)supportList.SelectedValue)).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) { ctx.SaveChanges(); updateTheList(); } } } }
private void btnOrder_Click(object sender, RoutedEventArgs e) { using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2()) { if (cmbKlant.SelectedValue != null && lbShoppingCart.Items != null) { ctx.Bestellings.Add(new Bestelling() { PersoneelslidID = loggedInUser.ID, KlantID = (int)cmbKlant.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 }); ctx.SaveChanges(); } } myProductinKars.Clear(); txtInfo.Text = string.Empty; txtQuantity.Text = string.Empty; txtTaxPrice.Text = string.Empty; txtTotalPrice.Text = string.Empty; txtTotalPriceWithTax.Text = string.Empty; updateShoppingList(); } }
private void btnBack_Click(object sender, RoutedEventArgs e) { using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2()) { foreach (var item in myProductinKars) { var product = ctx.Products.Select(x => x).Where(x => x.ID == item.ProductinKarID).FirstOrDefault(); product.InStock = product.InStock + item.Quantity; ctx.SaveChanges(); } } MainMenu mainMenu = new MainMenu(loggedInUser); mainMenu.ShowDialog(); }
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); } } }
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); } } } } }
private void btnLogout_Click(object sender, RoutedEventArgs e) { using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2()) { foreach (var item in myProductinKars) { var product = ctx.Products.Select(x => x).Where(x => x.ID == item.ProductinKarID).FirstOrDefault(); product.InStock = product.InStock + item.Quantity; ctx.SaveChanges(); } } MainWindow mainwindow = new MainWindow(); var myWindow = Window.GetWindow(this); myWindow.Close(); mainwindow.ShowDialog(); }
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(); } } } }
private void btnReg_Click(object sender, RoutedEventArgs e) { using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2()) { ctx.Personeelslids.Add(new Personeelslid { Username = txtUserName.Text.ToString(), Password = txtPassword.Password.ToString(), Usertype = cmbUserType.SelectedItem.ToString() }); ctx.SaveChanges(); } //MessageBox.Show($"New user successfully created\n" + // $"{txtUserName.Text}\n" + // $"{txtPassword.Password.ToString()}\n" + // $"{cmbUserType.SelectedItem.ToString()}"); DialogResult = true; }
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); } } }
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); } }
private void btnDelete_Click(object sender, RoutedEventArgs e) { using (IndividueelProjectEntities2 ctx = new IndividueelProjectEntities2()) { if (lbShoppingCart.SelectedIndex != -1) { var product = ctx.Products.Select(x => x).Where(x => x.ID == (int)lbShoppingCart.SelectedValue).FirstOrDefault(); System.Windows.Forms.DialogResult result = MyMessageBox.Show("are you sure you want delete from shopping cart", MyMessageBox.CMessageBoxButton.Yes, MyMessageBox.CMessageBoxButton.No); if (result == System.Windows.Forms.DialogResult.Yes) { product.InStock = Convert.ToInt32((lbShoppingCart.SelectedItem as ProductinKar).Quantity) + product.InStock; myProductinKars.RemoveAt(lbShoppingCart.SelectedIndex); ctx.SaveChanges(); } } } updateShoppingList(); updateTotalPrice(); }
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); } }
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); } } }
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); }
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); } } }
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); } } }
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); } } }
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(); }