public static void EditGoods(ClassGoods n_goods) //приймає об'єкт класу ClassGoods в якому заповнені всі поля крім providerID і goodsID { ClassGoods goods_to_edit = new ClassGoods(); string p_id = СheckProvider(n_goods._provider, n_goods._provider_phone); string g_id = CheckGoods(n_goods._name, n_goods._category, n_goods._valid_date, n_goods._short_description, n_goods._note); goods_to_edit._id = n_goods._id; goods_to_edit.goodsID = g_id; goods_to_edit._creation_date = n_goods._creation_date; goods_to_edit._count = n_goods._count; goods_to_edit._price = n_goods._price; goods_to_edit.providerID = p_id; goods_to_edit._date_in = n_goods._date_in; goods_to_edit._storage = n_goods._storage; int index = -1; for (int i = 0; i < AllGoodsDB.Count; i++) { if (AllGoodsDB[i]._id == goods_to_edit._id) { index = i; break; } } AllGoodsDB[index] = goods_to_edit; explainGoodsDB(index); File.RefreshGoodsDBFile(); }
private void Edit_Click(object sender, RoutedEventArgs e) { if (vgGoods.SelectedItem == null) { return; } ClassGoods g = (ClassGoods)vgGoods.SelectedItem; AddEditWindow w = new AddEditWindow(); w.editingID = g._id; w.Owner = Application.Current.MainWindow; w.WindowStartupLocation = WindowStartupLocation.CenterOwner; w.GName.Text = g._name; Main.FillAddEditCategories(w, g._category); Main.FillAddEditValidDate(w, g._valid_date); w.MadeDate.Text = g._creation_date; w.Count.Text = g._count; w.Price.Text = g._price; Main.FillAddEditProvider(w, g._provider); w.ProviderPhone.Text = g._provider_phone; w.InDate.Text = g._date_in; Main.FillAddEditStorage(w, g._storage); w.Desc.Text = g._short_description; w.Note.Text = g._note; w.Title = "Редагувати товар"; w.AddEditButton.Content = "Зберегти"; SelectedGoods s = new SelectedGoods(vcbCat.SelectedValue.ToString(), vcbItem.SelectedValue.ToString(), vgGoods.SelectedIndex); //Nullable<bool> dialogResult = w.ShowDialog(); if (!(bool)w.ShowDialog()) { vgGoods.Focus(); return; } Application.Current.MainWindow.UpdateLayout(); Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; g._name = w.GName.Text; g._category = w.Category.Text; g._valid_date = w.Valid.Text; g._creation_date = w.MadeDate.Text; g._count = w.Count.Text; g._price = w.Price.Text; g._provider = w.Provider.Text; g._provider_phone = w.ProviderPhone.Text; g._date_in = w.InDate.Text; g._storage = w.Storage.Text; g._short_description = w.Desc.Text; g._note = w.Note.Text; Main.EditGoods(g); FillCategoryCombobox(); //VcbItem_SelectionChanged(vcbItem, null); s.Restore(); vgGoods.Focus(); Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow; }
public ClassGoods(ClassGoods obj) { id = obj.id; goodsID = obj.goodsID; creation_date = obj.category; count = obj.count; price = obj.price; providerID = obj.providerID; date_in = obj.date_in; storage = obj.storage; }
private void Remove_Click(object sender, RoutedEventArgs e) { ClassGoods g = (ClassGoods)vgGoods.SelectedItem; MessageBoxResult result = MessageBox.Show("Дійсно видалити товар ID = " + g._id + "?", "Goods", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { Main.AllGoodsDB.RemoveAt(Main.AllGoodsDB.IndexOf(g)); VcbItem_SelectionChanged(vcbItem, null); File.RefreshGoodsDBFile(); vgGoods.Focus(); } }
private void New_Click(object sender, RoutedEventArgs e) { AddEditWindow w = new AddEditWindow(); w.Owner = Application.Current.MainWindow; w.WindowStartupLocation = WindowStartupLocation.CenterOwner; Main.FillAddEditCategories(w); Main.FillAddEditValidDate(w); Main.FillAddEditProvider(w); Main.FillAddEditStorage(w); w.Title = "Додати товар"; w.AddEditButton.Content = "Додати"; if (!(bool)w.ShowDialog()) { vgGoods.Focus(); return; } Application.Current.MainWindow.UpdateLayout(); Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; ClassGoods g = new ClassGoods(); g._name = w.GName.Text; g._category = w.Category.Text; g._valid_date = w.Valid.Text; g._creation_date = w.MadeDate.Text; g._count = w.Count.Text; g._price = w.Price.Text; g._provider = w.Provider.Text; g._provider_phone = w.ProviderPhone.Text; g._date_in = w.InDate.Text; g._storage = w.Storage.Text; g._short_description = w.Desc.Text; g._note = w.Note.Text; Main.AddNewGoodsToDB(g); FillCategoryCombobox(); //VcbItem_SelectionChanged(vcbItem, null); vgGoods.Focus(); vgGoods.SelectedIndex = vgGoods.Items.Count - 1; Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow; }
public static string AddNewGoodsToDB(ClassGoods n_goods) //приймає об'єкт класу ClassGoods в якому заповнені всі поля крім id, providerID і goodsID { ClassGoods goods_to_add = new ClassGoods(); string p_id = СheckProvider(n_goods._provider, n_goods._provider_phone); string g_id = CheckGoods(n_goods._name, n_goods._category, n_goods._valid_date, n_goods._short_description, n_goods._note); int amount = AllGoodsDB.Count; int new_id = Convert.ToInt32(AllGoodsDB[amount - 1]._id) + 1; goods_to_add._id = new_id.ToString(); goods_to_add.goodsID = g_id; goods_to_add._creation_date = n_goods._creation_date; goods_to_add._count = n_goods._count; goods_to_add._price = n_goods._price; goods_to_add.providerID = p_id; goods_to_add._date_in = n_goods._date_in; goods_to_add._storage = n_goods._storage; AllGoodsDB.Add(goods_to_add); explainGoodsDB(AllGoodsDB.Count - 1); File.RefreshGoodsDBFile(); return(goods_to_add._id); }