Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (cmbxTables.Text)
            {
            case "Таблица поставщиков":
            {
                #region TableSup

                if (textBox1.Text == string.Empty || textBox2.Text == string.Empty ||
                    textBox3.Text == string.Empty || textBox4.Text == string.Empty ||
                    textBox5.Text == string.Empty || textBox6.Text == string.Empty ||
                    textBox7.Text == string.Empty || textBox8.Text == string.Empty)
                {
                    MessageBox.Show(@"Вы заполнили не все поля", @"Ошибка!!!");
                }
                else
                {
                    var listObjects = new List <TextBox>()
                    {
                        textBox1, textBox2, textBox3, textBox4, textBox5, textBox6, textBox7, textBox8
                    };
                    var listData = listObjects.Select(t => t.Text).ToList();

                    TableSupplier tableSupplier = new TableSupplier();
                    tableSupplier.Insert(listData);
                }

                break;
                #endregion
            }

            case "Таблица игр":
            {
                #region TableGames

                if (textBox1.Text == string.Empty || textBox2.Text == string.Empty ||
                    textBox3.Text == string.Empty || textBox4.Text == string.Empty ||
                    textBox5.Text == string.Empty || textBox6.Text == string.Empty)
                {
                    MessageBox.Show(@"Вы заполнили не все поля", @"Ошибка!!!");
                }
                else
                {
                    var listObjects = new List <TextBox>()
                    {
                        textBox1, textBox2, textBox3, textBox4, textBox5, textBox6
                    };
                    var listData = listObjects.Select(t => t.Text).ToList();

                    TableGames tableGames = new TableGames();
                    tableGames.Insert(listData);
                }

                break;

                #endregion
            }

            case "Таблица работников":
            {
                #region TableWorkers

                if (textBox1.Text == string.Empty || textBox2.Text == string.Empty ||
                    textBox3.Text == string.Empty || textBox4.Text == string.Empty ||
                    textBox5.Text == string.Empty || textBox6.Text == string.Empty ||
                    textBox7.Text == string.Empty || textBox8.Text == string.Empty ||
                    textBox9.Text == string.Empty)
                {
                    MessageBox.Show(@"Вы заполнили не все поля", @"Ошибка!!!");
                }
                else
                {
                    var listObjects = new List <TextBox>()
                    {
                        textBox1, textBox2, textBox3, textBox4, textBox5, textBox6, textBox7, textBox8, textBox9
                    };
                    var listData = listObjects.Select(t => t.Text).ToList();

                    TableWorkers tableWorkers = new TableWorkers();
                    tableWorkers.Insert(listData);
                }

                break;

                #endregion
            }

            case "Таблица клиентов":
            {
                #region TableClient

                if (textBox1.Text == string.Empty || textBox2.Text == string.Empty ||
                    textBox3.Text == string.Empty || textBox4.Text == string.Empty ||
                    textBox5.Text == string.Empty || textBox6.Text == string.Empty ||
                    textBox7.Text == string.Empty || textBox8.Text == string.Empty ||
                    textBox9.Text == string.Empty)
                {
                    MessageBox.Show(@"Вы заполнили не все поля", @"Ошибка!!!");
                }
                else
                {
                    var listObjects = new List <TextBox>()
                    {
                        textBox1, textBox2, textBox3, textBox4, textBox5, textBox6, textBox7, textBox8, textBox9
                    };
                    var listData = listObjects.Select(t => t.Text).ToList();

                    TableClient tableClient = new TableClient();
                    tableClient.Insert(listData);
                }

                break;

                #endregion
            }

            case "Таблица аксессуаров":
            {
                #region TableAccessory

                if (textBox1.Text == string.Empty || textBox2.Text == string.Empty ||
                    textBox3.Text == string.Empty)
                {
                    MessageBox.Show(@"Вы заполнили не все поля", @"Ошибка!!!");
                }
                else
                {
                    var listObjects = new List <TextBox>()
                    {
                        textBox1, textBox2, textBox3
                    };
                    var listData = listObjects.Select(t => t.Text).ToList();

                    TableAccessory tableAccessory = new TableAccessory();
                    tableAccessory.Insert(listData);
                }

                break;

                #endregion
            }

            case "Таблица покупок клиентов":
            {
                #region TableConnClient

                if (textBox1.Text == string.Empty || textBox2.Text == string.Empty ||
                    textBox3.Text == string.Empty || textBox4.Text == string.Empty ||
                    textBox5.Text == string.Empty)
                {
                    MessageBox.Show(@"Вы заполнили не все поля", @"Ошибка!!!");
                }
                else
                {
                    var listObjects = new List <TextBox>()
                    {
                        textBox1, textBox2, textBox3, textBox4, textBox5
                    };
                    var listData = listObjects.Select(t => t.Text).ToList();

                    TableConnClient tableConnClient = new TableConnClient();
                    tableConnClient.Insert(listData);
                }

                break;

                #endregion
            }
            }
        }