示例#1
0
        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;
        }
示例#2
0
 public static void FillAddEditStorage(AddEditWindow f, string selected = "")
 {
     f.Storage.Items.Clear();
     foreach (ClassGoods g in AllGoodsDB)
     {
         if (f.Storage.Items.IndexOf(g._storage) == -1)
         {
             f.Storage.Items.Add(g._storage);
         }
     }
     if (selected != "")
     {
         f.Storage.SelectedIndex = f.Storage.Items.IndexOf(selected);
     }
 }
示例#3
0
 public static void FillAddEditProvider(AddEditWindow f, string selected = "")
 {
     f.Provider.Items.Clear();
     foreach (ProviderID g in AllProviders)
     {
         if (f.Provider.Items.IndexOf(g.name) == -1)
         {
             f.Provider.Items.Add(g.name);
         }
     }
     if (selected != "")
     {
         f.Provider.SelectedIndex = f.Provider.Items.IndexOf(selected);
     }
 }
示例#4
0
 public static void FillAddEditValidDate(AddEditWindow f, string selected = "")
 {
     f.Valid.Items.Clear();
     foreach (ClassGoods g in AllGoodsDB)
     {
         if (f.Valid.Items.IndexOf(g._valid_date) == -1)
         {
             f.Valid.Items.Add(g._valid_date);
         }
     }
     if (selected != "")
     {
         f.Valid.SelectedIndex = f.Valid.Items.IndexOf(selected);
     }
 }
示例#5
0
 public static void FillAddEditCategories(AddEditWindow f, string selected = "")
 {
     f.Category.Items.Clear();
     foreach (ClassGoods g in AllGoodsDB)
     {
         if (f.Category.Items.IndexOf(g._category) == -1)
         {
             f.Category.Items.Add(g._category);
         }
     }
     if (selected != "")
     {
         f.Category.SelectedIndex = f.Category.Items.IndexOf(selected);
     }
 }
示例#6
0
        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;
        }