Example #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ProductSet productSet = new ProductSet();

            /* productSet.Author = textBoxAuthor.Text;
             * productSet.Name = textBoxName.Text;
             * productSet.GameName = textBoxGameName.Text;
             * productSet.NameOfficeSupply = textBoxNameOfficeSupply.Text;*/

            if (comboBoxType.SelectedIndex == 0)
            {
                productSet.Type   = 0;
                productSet.Author = textBoxAuthor.Text;
                productSet.Name   = textBoxName.Text;
                productSet.Prise  = Convert.ToInt32(textBoxPrise.Text);
            }
            else if (comboBoxType.SelectedIndex == 1)
            {
                productSet.Type     = 1;
                productSet.GameName = textBoxGameName.Text;
                productSet.Prise    = Convert.ToInt32(textBoxPrise.Text);
            }
            else
            {
                productSet.Type             = 2;
                productSet.NameOfficeSupply = textBoxNameOfficeSupply.Text;
                productSet.Prise            = Convert.ToInt32(textBoxPrise.Text);
            }

            Program.mpgc.ProductSet.Add(productSet);
            Program.mpgc.SaveChanges();
            ShowProductSet();
        }
Example #2
0
        private void listViewTableGames_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewTableGames.SelectedItems.Count == 1)
            {
                ProductSet productSet = listViewTableGames.SelectedItems[0].Tag as ProductSet;

                textBoxGameName.Text = productSet.GameName;
                textBoxPrise.Text    = productSet.Prise.ToString();
            }
            else
            {
                textBoxGameName.Text = "";
                textBoxPrise.Text    = "";
            }
        }
Example #3
0
        private void listViewOfficeSupplies_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewOfficeSupplies.SelectedItems.Count == 1)
            {
                ProductSet productSet = listViewOfficeSupplies.SelectedItems[0].Tag as ProductSet;

                textBoxNameOfficeSupply.Text = productSet.NameOfficeSupply;
                textBoxPrise.Text            = productSet.Prise.ToString();
            }
            else
            {
                textBoxNameOfficeSupply.Text = "";
                textBoxPrise.Text            = "";
            }
        }
Example #4
0
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxType.SelectedIndex == 0)
                {
                    if (listViewBooks.SelectedItems.Count == 1)
                    {
                        ProductSet productSet = listViewBooks.SelectedItems[0].Tag as ProductSet;

                        Program.mpgc.ProductSet.Remove(productSet);
                        Program.mpgc.SaveChanges();
                        ShowProductSet();
                    }
                    textBoxAuthor.Text = "";
                    textBoxName.Text   = "";
                }
                else if (comboBoxType.SelectedIndex == 1)
                {
                    if (listViewTableGames.SelectedItems.Count == 1)
                    {
                        ProductSet productSet = listViewTableGames.SelectedItems[0].Tag as ProductSet;

                        Program.mpgc.ProductSet.Remove(productSet);
                        Program.mpgc.SaveChanges();
                        ShowProductSet();
                    }
                    textBoxGameName.Text = "";
                }
                else
                {
                    ProductSet productSet = listViewOfficeSupplies.SelectedItems[0].Tag as ProductSet;

                    Program.mpgc.ProductSet.Remove(productSet);
                    Program.mpgc.SaveChanges();
                    ShowProductSet();
                }
                textBoxNameOfficeSupply.Text = "";
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись уже используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #5
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (comboBoxType.SelectedIndex == 0)
            {
                if (listViewBooks.SelectedItems.Count == 1)
                {
                    ProductSet productSet = listViewBooks.SelectedItems[0].Tag as ProductSet;

                    productSet.Author = textBoxAuthor.Text;
                    productSet.Name   = textBoxName.Text;
                    productSet.Prise  = Convert.ToInt32(textBoxPrise.Text);

                    Program.mpgc.SaveChanges();
                    ShowProductSet();
                }
            }
            else if (comboBoxType.SelectedIndex == 1)
            {
                if (listViewTableGames.SelectedItems.Count == 1)
                {
                    ProductSet productSet = listViewTableGames.SelectedItems[0].Tag as ProductSet;

                    productSet.GameName = textBoxGameName.Text;
                    productSet.Prise    = Convert.ToInt32(textBoxPrise.Text);

                    Program.mpgc.SaveChanges();
                    ShowProductSet();
                }
            }
            else
            {
                if (listViewOfficeSupplies.SelectedItems.Count == 1)
                {
                    ProductSet productSet = listViewOfficeSupplies.SelectedItems[0].Tag as ProductSet;

                    productSet.NameOfficeSupply = textBoxNameOfficeSupply.Text;
                    productSet.Prise            = Convert.ToInt32(textBoxPrise.Text);

                    Program.mpgc.SaveChanges();
                    ShowProductSet();
                }
            }
        }