示例#1
0
        private void Добавить_Click(object sender, EventArgs e)
        {
            string d  = "";
            string d1 = "";
            string d3 = "";

            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                if (comboBox1.Text == dataGridView1[1, i].Value.ToString())
                {
                    d = dataGridView1[0, i].Value.ToString();
                }
            }
            for (int i = 0; i < dataGridView2.Rows.Count - 1; i++)
            {
                if (comboBox2.Text == dataGridView2[1, i].Value.ToString())
                {
                    d1 = dataGridView2[0, i].Value.ToString();
                }
            }
            if (textBox1.Text.Length != 0 && textBox2.Text.Length != 0 && comboBox1.Text.Length != 0 && comboBox1.Text.Length != 0)
            {
                try

                {
                    QueryDataBase qb = new QueryDataBase();
                    qb.InsertData("INSERT INTO seance ( id_film, id_hall, time_seance, price) VALUES (" + d + ", " + d1 + ",'" + textBox1.Text + "','" + textBox2.Text + "');");
                    dataGridView3.Rows.Clear();
                    QueryDataBase qb3   = new QueryDataBase();
                    string[]      Rows2 = qb.GetData(" SELECT id_seance FROM cinema.seance;");
                    foreach (string line in Rows2)
                    {
                        string[] columns = line.Split(';');
                        dataGridView3.Rows.Add(columns);
                    }

                    for (int i = 0; i < dataGridView3.Rows.Count - 1; i++)
                    {
                        d3 = dataGridView3[0, i].Value.ToString();
                    }
                    QueryDataBase qb2 = new QueryDataBase();
                    qb.InsertData("INSERT INTO timetable (id_seance,date_timetable)  VALUES (" + d3 + ",'" + maskedTextBox1.Text + "');");
                    MessageBox.Show("Добавление прошло успешно");
                }
                catch (MySql.Data.MySqlClient.MySqlException)
                { MessageBox.Show("Нельзя удалить пользователя"); }
            }
            else
            {
                MessageBox.Show("Заполните поля");
            }
        }
示例#2
0
 private void Добавить_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "Кассир")
     {
         i = 1;
     }
     if (comboBox1.Text == "Администратор")
     {
         i = 2;
     }
     if (comboBox1.Text == "Старший администратор")
     {
         i = 3;
     }
     if (textBox1.Text.Length != 0 && textBox2.Text.Length != 0 && comboBox1.Text.Length != 0 && maskedTextBox1.Text.Length != 0 && textBox3.Text.Length != 0)
     {
         try
         {
             QueryDataBase qb = new QueryDataBase();
             qb.InsertData("INSERT INTO `cinema`.`employees` ( `surname`, `name_employees`, `patronicym`, `id_position`, `phone`) VALUES  ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + i + "','" + maskedTextBox1.Text + "');");
             MessageBox.Show("Добавление прошло успешно");
         }
         catch (MySql.Data.MySqlClient.MySqlException) { MessageBox.Show("Неправильный формат данных"); }
     }
     else
     {
         MessageBox.Show("Заполните поля");
     }
 }
示例#3
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Length != 0 && textBox2.Text.Length != 0 && comboBox1.Text.Length != 0 && textBox3.Text.Length != 0 && textBox4.Text.Length != 0 && textBox5.Text.Length != 0 && textBox6.Text.Length != 0 && textBox7.Text.Length != 0 && comboBox1.Text.Length != 0)
     {
         try
         {
             QueryDataBase qb = new QueryDataBase();
             qb.InsertData("INSERT INTO `cinema`.`film` (`name_film`, `lasting`, `producer`, `description`, `limitation`, `genre`, `Main_male_role`, `Main_female_role`) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "', '" + textBox3.Text + "', '" + textBox7.Text + "', '" + textBox6.Text + "', '" + comboBox1.Text + "', '" + textBox4.Text + "', '" + textBox5.Text + "');");
             MessageBox.Show("Добавление прошло успешно");
         }
         catch (MySql.Data.MySqlClient.MySqlException) { MessageBox.Show("Неправильный формат данных"); }
     }
     else
     {
         MessageBox.Show("Заполните поля");
     }
 }
示例#4
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text != "" && comboBox2.Text != "" && comboBox3.Text != "" && comboBox4.Text != "" && textBox1.Text != "" && textBox2.Text != "" && comboBox7.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "")
            {
                try

                {
                    string d  = "";
                    string d2 = "";
                    for (int i = 0; i < dataGridView2.Rows.Count - 1; i++)
                    {
                        if (comboBox7.Text == dataGridView2[1, i].Value.ToString())
                        {
                            d = dataGridView2[0, i].Value.ToString();
                        }
                    }

                    QueryDataBase qb = new QueryDataBase();
                    qb.InsertData("INSERT INTO `cinema`.`tab` (`id_employees`, `date_sale`, `time_sale`) VALUES ('" + d + "', '" + textBox1.Text + "', '" + textBox2.Text + "');");

                    string[] Rows6 = qb.GetData("SELECT id_tab FROM cinema.tab where date_sale ='" + textBox1.Text + "' and time_sale = '" + textBox2.Text + "';");
                    foreach (string line in Rows6)
                    {
                        string[] columns = line.Split(';');
                        dataGridView7.Rows.Add(columns);
                    }
                    d2 = dataGridView7[0, 0].Value.ToString();
                    for (int i = 0; i < Rows.Length; i++)
                    {
                        string[] Rows5 = qb.GetData("SELECT id_place FROM cinema.place p join hall h on p.id_hall=h.id_hall where h.name_hall='" + comboBox4.Text + "' and p.row_place='" + Rows[i] + "' and p.place='" + Places[i] + "';");

                        foreach (string line in Rows5)
                        {
                            string[] columns = line.Split(';');
                            dataGridView8.Rows.Add(columns);
                        }
                    }
                    for (int i = 0; i < dataGridView8.Rows.Count - 1; i++)
                    {
                        qb.InsertData("INSERT INTO `cinema`.`ticket` (`id_tab`, `id_timetable`, `id_place`) VALUES ('" + d2 + "', '" + ind + "', '" + dataGridView8[0, i].Value.ToString() + "');");
                    }
                }
                catch (MySql.Data.MySqlClient.MySqlException) { }
                catch (NullReferenceException) { }
                MessageBox.Show("Продажа прошла успешно ");
                System.IO.FileStream   fs           = new System.IO.FileStream(@"C:\Users\PC\Desktop\Cinema\1.txt", System.IO.FileMode.Create);
                System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(fs);

                try
                {
                    streamWriter.WriteLine("           Чек");
                    streamWriter.WriteLine("==========================");
                    streamWriter.WriteLine("Дата продажи - " + textBox1.Text);
                    streamWriter.WriteLine("Время продажи - " + textBox2.Text);
                    streamWriter.WriteLine("Продавец - " + comboBox7.Text);
                    streamWriter.WriteLine("==========================");
                    streamWriter.WriteLine("Фильм - " + comboBox1.Text);
                    streamWriter.WriteLine("Дата Сеанса - " + comboBox2.Text);
                    streamWriter.WriteLine("Время Сеанса - " + comboBox3.Text);
                    streamWriter.WriteLine("Зал - " + comboBox4.Text);
                    streamWriter.WriteLine("Количество Билетов - " + kolB);
                    streamWriter.WriteLine("Цена - " + textBox5.Text);
                    streamWriter.WriteLine("==========================");
                    streamWriter.Close();
                    fs.Close();

                    MessageBox.Show("Чек успешно сохранен");
                }
                catch
                {
                    MessageBox.Show("Ошибка при сохранении файла!");
                }

                System.IO.FileStream   fs1         = new System.IO.FileStream(@"C:\Users\PC\Desktop\Cinema\2.txt", System.IO.FileMode.Create);
                System.IO.StreamWriter streamWrite = new System.IO.StreamWriter(fs1);
                for (int i = 0; i < kolB; i++)
                {
                    try
                    {
                        streamWrite.WriteLine("           Билет");
                        streamWrite.WriteLine("==========================");
                        streamWrite.WriteLine("Фильм - " + comboBox1.Text);
                        streamWrite.WriteLine("Дата Сеанса - " + comboBox2.Text);
                        streamWrite.WriteLine("Время Сеанса - " + comboBox3.Text);
                        streamWrite.WriteLine("Зал - " + comboBox4.Text);
                        streamWrite.WriteLine("Ряд " + Rows[i]);
                        streamWrite.WriteLine("Место " + Places[i]);
                        streamWrite.WriteLine("Цена - " + dataGridView9[0, 0].Value.ToString());
                        streamWrite.WriteLine("==========================");
                    }
                    catch
                    {
                        MessageBox.Show("Ошибка при сохранении файла!");
                    }
                }
                MessageBox.Show("Билет успешно сохранен");
                streamWrite.Close();
                fs1.Close();
            }
            else
            {
                MessageBox.Show("Заполните поля");
            }
        }