示例#1
0
        private void button5_Click(object sender, EventArgs e)
        {
            string password = textBox3.Text;

            if (password != "" && password != "пароль")
            {
                try
                {
                    string          sql  = "SELECT FIO FROM admin WHERE password='******';";
                    MySqlConnection conn = DBUtils.GetDBConnection();
                    conn.Open();
                    MySqlCommand    command = new MySqlCommand(sql, conn);
                    MySqlDataReader reader  = command.ExecuteReader();
                    if (reader.Read())
                    {
                        MessageBox.Show(reader[0].ToString());
                        admin form = new admin(reader[0].ToString());
                        form.Show();
                    }
                    else
                    {
                        MessageBox.Show("Вы ввели неверный логин или пароль!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    reader.Close();
                    conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Вы ввели неккоректные данные!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (vyborcard == false)
                {
                    MessageBox.Show("Выберите карту для пополнения!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (vybordeposit == false)
                    {
                        MessageBox.Show("Выберите депозит!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        if (textBox1.Text == "")
                        {
                            MessageBox.Show("Введите сумму депозита!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            if (kod.ToString() != textBox2.Text)
                            {
                                MessageBox.Show("Вы ввели неверный код!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                string summazapyataya = textBox1.Text;
                                if (Convert.ToDouble(summazapyataya) < Convert.ToDouble(min_vznos) || Convert.ToDouble(summazapyataya) > Convert.ToDouble(max_vznos))
                                {
                                    MessageBox.Show("Сумма депозита должна быть в диапазоне от " + min_vznos + " до " + max_vznos + " " + valytadeposit + " !", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                                else
                                {
                                    string          sql   = "SELECT ostatok,valyta FROM bank_card,valyta WHERE id_card=" + mas_id_card[id_selected] + " AND valyta.id_valyta=(SELECT id_valyta FROM bank_card WHERE id_card=" + mas_id_card[id_selected] + ")";
                                    MySqlConnection conn1 = DBUtils.GetDBConnection();
                                    conn1.Open();
                                    MySqlCommand    command1 = new MySqlCommand(sql, conn1);
                                    MySqlDataReader reader1  = command1.ExecuteReader();
                                    reader1.Read();
                                    string ostatok = reader1[0].ToString();
                                    valytacard = reader1[1].ToString();
                                    ostatok    = ostatok.Replace('.', ',');
                                    reader1.Close();
                                    conn1.Close();

                                    if (valytacard == valytadeposit)
                                    {
                                        if (Convert.ToDouble(ostatok) >= Convert.ToDouble(summazapyataya))
                                        {
                                            ostatok = Convert.ToString(Convert.ToDouble(ostatok) - Convert.ToDouble(summazapyataya));
                                            ostatok = ostatok.Replace(',', '.');
                                            sql     = "UPDATE bank_card SET ostatok='" + ostatok + "' WHERE id_card=" + mas_id_card[id_selected];
                                            conn1   = DBUtils.GetDBConnection();
                                            conn1.Open();
                                            command1 = new MySqlCommand(sql, conn1);
                                            reader1  = command1.ExecuteReader();
                                            reader1.Read();
                                            reader1.Close();
                                            conn1.Close();

                                            sql   = "SELECT id_deposit_dopolnitelnaya FROM deposit_dopolnitelnaya ORDER BY id_deposit_dopolnitelnaya DESC";
                                            conn1 = DBUtils.GetDBConnection();
                                            conn1.Open();
                                            command1 = new MySqlCommand(sql, conn1);
                                            reader1  = command1.ExecuteReader();
                                            reader1.Read();
                                            string id_last_deposit = Convert.ToString(Convert.ToInt32(reader1[0]) + 1);
                                            reader1.Close();
                                            conn1.Close();

                                            string symma         = summazapyataya.Replace(',', '.');
                                            string id_valytacard = "";
                                            if (valytacard == "BYN")
                                            {
                                                id_valytacard = "1";
                                            }
                                            if (valytacard == "RUB")
                                            {
                                                id_valytacard = "2";
                                            }
                                            if (valytacard == "EUR")
                                            {
                                                id_valytacard = "3";
                                            }
                                            if (valytacard == "USD")
                                            {
                                                id_valytacard = "4";
                                            }
                                            sql   = "INSERT INTO history(id_client, id_card, datetime, summa, information_history,id_valyta) VALUES ('" + id_client + "','" + mas_id_card[id_selected] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + symma + "','Открытие депозита " + comboBox1.SelectedItem.ToString() + "'," + id_valytacard + ")";
                                            conn1 = DBUtils.GetDBConnection();
                                            conn1.Open();
                                            command1 = new MySqlCommand(sql, conn1);
                                            reader1  = command1.ExecuteReader();
                                            reader1.Read();
                                            reader1.Close();
                                            conn1.Close();

                                            string data_vidachi      = DateTime.Now.ToString("yyyy-MM-dd");
                                            string data_okonchianiya = DateTime.Now.AddDays(Convert.ToDouble(srok_deposit)).ToString("yyyy-MM-dd");
                                            string snytie            = DateTime.Now.AddDays(30).ToString("yyyy-MM-dd");
                                            if (snyatie == "YES")
                                            {
                                                sql   = "INSERT INTO deposit_dopolnitelnaya(id_deposit_dopolnitelnaya, id_client, id_deposit, data_vidachi, data_okonchianiya, snytie, summa, data_raschet, nakopleniya) VALUES (" + id_last_deposit + "," + id_client + "," + id_deposit + ",'" + data_vidachi + "','" + data_okonchianiya + "','" + snytie + "','" + symma + "',NULL,'0')";
                                                conn1 = DBUtils.GetDBConnection();
                                                conn1.Open();
                                                command1 = new MySqlCommand(sql, conn1);
                                                reader1  = command1.ExecuteReader();
                                                reader1.Read();
                                                reader1.Close();
                                                conn1.Close();
                                                this.Close();
                                                MessageBox.Show("Открыт новый депозит!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                            }
                                            else
                                            {
                                                sql   = "INSERT INTO deposit_dopolnitelnaya(id_deposit_dopolnitelnaya, id_client, id_deposit, data_vidachi, data_okonchianiya, snytie, summa, data_raschet, nakopleniya) VALUES (" + id_last_deposit + "," + id_client + "," + id_deposit + ",'" + data_vidachi + "','" + data_okonchianiya + "',NULL,'" + symma + "',NULL,'0')";
                                                conn1 = DBUtils.GetDBConnection();
                                                conn1.Open();
                                                command1 = new MySqlCommand(sql, conn1);
                                                reader1  = command1.ExecuteReader();
                                                reader1.Read();
                                                reader1.Close();
                                                conn1.Close();
                                                this.Close();
                                                MessageBox.Show("Открыт новый депозит!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Недостаточно средств!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        }
                                    }
                                    else
                                    {
                                        if (valytadeposit == "BYN")
                                        {
                                            if (valytacard == "RUB")
                                            {
                                                summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) / Convert.ToDouble(RUB) * 100);
                                            }
                                            if (valytacard == "EUR")
                                            {
                                                summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) / Convert.ToDouble(EUR));
                                            }
                                            if (valytacard == "USD")
                                            {
                                                summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) / Convert.ToDouble(USD));
                                            }
                                        }
                                        else
                                        {
                                            if (valytadeposit == "RUB")
                                            {
                                                summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) / 100 * Convert.ToDouble(RUB));
                                            }
                                            if (valytadeposit == "EUR")
                                            {
                                                summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) * Convert.ToDouble(EUR));
                                            }
                                            if (valytadeposit == "USD")
                                            {
                                                summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) * Convert.ToDouble(USD));
                                            }
                                            if (valytacard == "RUB")
                                            {
                                                summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) / Convert.ToDouble(RUB) * 100);
                                            }
                                            if (valytacard == "EUR")
                                            {
                                                summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) / Convert.ToDouble(EUR));
                                            }
                                            if (valytacard == "USD")
                                            {
                                                summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) / Convert.ToDouble(USD));
                                            }
                                        }
                                        if (Convert.ToDouble(ostatok) >= Convert.ToDouble(summazapyataya))
                                        {
                                            DialogResult dialog = MessageBox.Show("Для продолжения необходимо произвести обмен валют.\r\nОбмен будет произведен по следующему курсу:\r\n100 Российских рублей =" + RUB + " Белорусских рублей\r\nДоллар США =" + USD + " Белорусских рублей\r\nЕвро =" + EUR + " Белорусских рублей", "Сообщение", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                                            if (dialog == DialogResult.Yes)
                                            {
                                                ostatok = Convert.ToString(Convert.ToDouble(ostatok) - Convert.ToDouble(summazapyataya));
                                                ostatok = ostatok.Replace(',', '.');
                                                sql     = "UPDATE bank_card SET ostatok='" + ostatok + "' WHERE id_card=" + mas_id_card[id_selected];
                                                conn1   = DBUtils.GetDBConnection();
                                                conn1.Open();
                                                command1 = new MySqlCommand(sql, conn1);
                                                reader1  = command1.ExecuteReader();
                                                reader1.Read();
                                                reader1.Close();
                                                conn1.Close();

                                                sql   = "SELECT id_deposit_dopolnitelnaya FROM deposit_dopolnitelnaya ORDER BY id_deposit_dopolnitelnaya DESC";
                                                conn1 = DBUtils.GetDBConnection();
                                                conn1.Open();
                                                command1 = new MySqlCommand(sql, conn1);
                                                reader1  = command1.ExecuteReader();
                                                reader1.Read();
                                                string id_last_deposit = Convert.ToString(Convert.ToInt32(reader1[0]) + 1);
                                                reader1.Close();
                                                conn1.Close();

                                                string symma         = textBox1.Text.Replace(',', '.');
                                                string id_valytacard = "";
                                                if (valytacard == "BYN")
                                                {
                                                    id_valytacard = "1";
                                                }
                                                if (valytacard == "RUB")
                                                {
                                                    id_valytacard = "2";
                                                }
                                                if (valytacard == "EUR")
                                                {
                                                    id_valytacard = "3";
                                                }
                                                if (valytacard == "USD")
                                                {
                                                    id_valytacard = "4";
                                                }
                                                sql   = "INSERT INTO history(id_client, id_card, datetime, summa, information_history,id_valyta) VALUES ('" + id_client + "','" + mas_id_card[id_selected] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + symma + "','Открытие депозита " + comboBox1.SelectedItem.ToString() + "'," + id_valytacard + ")";
                                                conn1 = DBUtils.GetDBConnection();
                                                conn1.Open();
                                                command1 = new MySqlCommand(sql, conn1);
                                                reader1  = command1.ExecuteReader();
                                                reader1.Read();
                                                reader1.Close();
                                                conn1.Close();

                                                string data_vidachi      = DateTime.Now.ToString("yyyy-MM-dd");
                                                string data_okonchianiya = DateTime.Now.AddDays(Convert.ToDouble(srok_deposit)).ToString("yyyy-MM-dd");
                                                string snytie            = DateTime.Now.AddDays(30).ToString("yyyy-MM-dd");
                                                if (snyatie == "YES")
                                                {
                                                    sql   = "INSERT INTO deposit_dopolnitelnaya(id_deposit_dopolnitelnaya, id_client, id_deposit, data_vidachi, data_okonchianiya, snytie, summa, data_raschet, nakopleniya) VALUES (" + id_last_deposit + "," + id_client + "," + id_deposit + ",'" + data_vidachi + "','" + data_okonchianiya + "','" + snytie + "','" + symma + "',NULL,'0')";
                                                    conn1 = DBUtils.GetDBConnection();
                                                    conn1.Open();
                                                    command1 = new MySqlCommand(sql, conn1);
                                                    reader1  = command1.ExecuteReader();
                                                    reader1.Read();
                                                    reader1.Close();
                                                    conn1.Close();
                                                    this.Close();
                                                    MessageBox.Show("Открыт новый депозит!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                                }
                                                else
                                                {
                                                    sql   = "INSERT INTO deposit_dopolnitelnaya(id_deposit_dopolnitelnaya, id_client, id_deposit, data_vidachi, data_okonchianiya, snytie, summa, data_raschet, nakopleniya) VALUES (" + id_last_deposit + "," + id_client + "," + id_deposit + ",'" + data_vidachi + "','" + data_okonchianiya + "',NULL,'" + symma + "',NULL,'0')";
                                                    conn1 = DBUtils.GetDBConnection();
                                                    conn1.Open();
                                                    command1 = new MySqlCommand(sql, conn1);
                                                    reader1  = command1.ExecuteReader();
                                                    reader1.Read();
                                                    reader1.Close();
                                                    conn1.Close();
                                                    this.Close();
                                                    MessageBox.Show("Открыт новый депозит!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Недостаточно средств!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message.ToString(), exc.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "Оплатить")
            {
                if (textBox3.Text != "" && textBox3.Text != "0")
                {
                    if (textBox2.Text != "")
                    {
                        if (textBox2.Text == kod.ToString())
                        {
                            try
                            {
                                string summazapyataya   = textBox3.Text;
                                string summatocka       = summazapyataya.Replace(',', '.');
                                string summazapyataya1  = summazapyataya;
                                string ostatokzapyataya = ostatok.Replace('.', ',');
                                bool   flag             = false;
                                if (valytacard == "BYN")
                                {
                                    if (Convert.ToDouble(summazapyataya) < Convert.ToDouble(ostatokzapyataya))
                                    {
                                        string          str   = "UPDATE bank_card SET ostatok=ostatok-'" + summatocka + "' WHERE id_card=" + mas_id_card[id_selected];
                                        MySqlConnection conn1 = DBUtils.GetDBConnection();
                                        conn1.Open();
                                        MySqlCommand    command1 = new MySqlCommand(str, conn1);
                                        MySqlDataReader reader1  = command1.ExecuteReader();
                                        reader1.Read();
                                        reader1.Close();
                                        conn1.Close();

                                        string          sql1       = "SELECT vystavleno FROM plategi_dopolnitelnaya WHERE id_plateg_dopolnitelnaya=" + id_plateg_dopolnitelnaya;
                                        MySqlConnection connection = DBUtils.GetDBConnection();
                                        connection.Open();
                                        MySqlCommand    comm = new MySqlCommand(sql1, connection);
                                        MySqlDataReader read = comm.ExecuteReader();
                                        read.Read();
                                        string vystavleno = (Convert.ToDouble(read[0].ToString().Replace('.', ',')) - Convert.ToDouble(summazapyataya)).ToString().Replace(',', '.');
                                        if (Convert.ToDouble(vystavleno.Replace('.', ',')) < 0)
                                        {
                                            vystavleno = "0";
                                        }
                                        read.Close();
                                        connection.Close();

                                        str   = "UPDATE plategi_dopolnitelnaya SET vystavleno='" + vystavleno + "' WHERE id_plateg_dopolnitelnaya=" + id_plateg_dopolnitelnaya;
                                        conn1 = DBUtils.GetDBConnection();
                                        conn1.Open();
                                        command1 = new MySqlCommand(str, conn1);
                                        reader1  = command1.ExecuteReader();
                                        reader1.Read();
                                        reader1.Close();
                                        conn1.Close();

                                        str   = "INSERT INTO history(id_client, id_plateg, id_card, datetime, summa, information_history,id_valyta) VALUES ('" + id_client + "','" + id_plateg + "','" + mas_id_card[id_selected] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + summatocka + "','Оплата " + naznachenie + " " + scet + "',1)";
                                        conn1 = DBUtils.GetDBConnection();
                                        conn1.Open();
                                        command1 = new MySqlCommand(str, conn1);
                                        reader1  = command1.ExecuteReader();
                                        reader1.Read();
                                        reader1.Close();
                                        conn1.Close();
                                        flag = true;
                                    }
                                    else
                                    {
                                        MessageBox.Show("Недостаточно средств!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                }
                                else
                                {
                                    if (valytacard == "RUB")
                                    {
                                        summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) / Convert.ToDouble(RUB) * 100);
                                    }
                                    if (valytacard == "EUR")
                                    {
                                        summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) / Convert.ToDouble(EUR));
                                    }
                                    if (valytacard == "USD")
                                    {
                                        summazapyataya = Convert.ToString(Convert.ToDouble(summazapyataya) / Convert.ToDouble(USD));
                                    }

                                    if (Convert.ToDouble(summazapyataya) < Convert.ToDouble(ostatokzapyataya))
                                    {
                                        DialogResult dialog = MessageBox.Show("Для продолжения необходимо произвести обмен валют.\r\nОбмен будет произведен по следующему курсу:\r\n100 Российских рублей =" + RUB + " Белорусских рублей\r\nДоллар США =" + USD + " Белорусских рублей\r\nЕвро =" + EUR + " Белорусских рублей", "Сообщение", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                                        if (dialog == DialogResult.Yes)
                                        {
                                            summatocka = summazapyataya.Replace(',', '.');
                                            string          str   = "UPDATE bank_card SET ostatok=ostatok-'" + summatocka + "' WHERE id_card=" + mas_id_card[id_selected];
                                            MySqlConnection conn1 = DBUtils.GetDBConnection();
                                            conn1.Open();
                                            MySqlCommand    command1 = new MySqlCommand(str, conn1);
                                            MySqlDataReader reader1  = command1.ExecuteReader();
                                            reader1.Read();
                                            reader1.Close();
                                            conn1.Close();

                                            string          sql1       = "SELECT vystavleno FROM plategi_dopolnitelnaya WHERE id_plateg_dopolnitelnaya=" + id_plateg_dopolnitelnaya;
                                            MySqlConnection connection = DBUtils.GetDBConnection();
                                            connection.Open();
                                            MySqlCommand    comm = new MySqlCommand(sql1, connection);
                                            MySqlDataReader read = comm.ExecuteReader();
                                            read.Read();
                                            string vystavleno = (Convert.ToDouble(read[0].ToString().Replace('.', ',')) - Convert.ToDouble(summazapyataya1)).ToString().Replace(',', '.');
                                            if (Convert.ToDouble(vystavleno.Replace('.', ',')) < 0)
                                            {
                                                vystavleno = "0";
                                            }
                                            read.Close();
                                            connection.Close();

                                            str   = "UPDATE plategi_dopolnitelnaya SET vystavleno='" + vystavleno + "' WHERE id_plateg_dopolnitelnaya=" + id_plateg_dopolnitelnaya;
                                            conn1 = DBUtils.GetDBConnection();
                                            conn1.Open();
                                            command1 = new MySqlCommand(str, conn1);
                                            reader1  = command1.ExecuteReader();
                                            reader1.Read();
                                            reader1.Close();
                                            conn1.Close();

                                            summatocka = summazapyataya1.Replace(',', '.');
                                            str        = "INSERT INTO history(id_client, id_plateg, id_card, datetime, summa, information_history,id_valyta) VALUES ('" + id_client + "','" + id_plateg + "','" + mas_id_card[id_selected] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + summatocka + "','Оплата " + naznachenie + " " + scet + "',1)";
                                            conn1      = DBUtils.GetDBConnection();
                                            conn1.Open();
                                            command1 = new MySqlCommand(str, conn1);
                                            reader1  = command1.ExecuteReader();
                                            reader1.Read();
                                            reader1.Close();
                                            conn1.Close();
                                            flag = true;
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Недостаточно средств!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                }
                                if (flag == true)
                                {
                                    Random random = new Random();
                                    doc_content += "Карт-чек №" + random.Next(100000000, 999999999) + "\r\n";
                                    doc_content += DateTime.Now + "\r\nБанковская карточка: " + number_card + "\r\nНомер плательщика: " + random.Next(100000000, 999999999);
                                    doc_content += "\r\nПолучатель платежа: \"Унитарное \r\nпредприятие \"Компания\"\"\r\n\r\n";
                                    doc_content += naznachenie + "\r\n" + str_scet + ": " + scet + "\r\n";
                                    if (FIO != "")
                                    {
                                        doc_content += "ФИО: " + FIO + "\r\n";
                                    }
                                    if (adres != "")
                                    {
                                        doc_content += "Адрес: " + adres + "\r\n";
                                    }
                                    if (id_plateg == "280" || id_plateg == "281" || id_plateg == "282")
                                    {
                                        doc_content += "Фамилия: " + textBox4.Text + "\r\n";
                                        doc_content += "Имя: " + textBox5.Text + "\r\n";
                                        doc_content += "Отчество: " + textBox6.Text + "\r\n";
                                    }
                                    doc_content += "Сумма: " + summazapyataya1 + " BYN\r\n\r\nНомер услуги: " + nomer_uslygi + "\r\n№ операции: " + random.Next(100000000, 999999999) + "\r\n";

                                    string          sqlhistory  = "SELECT id_history FROM history ORDER BY id_history DESC";
                                    MySqlConnection connhistory = DBUtils.GetDBConnection();
                                    connhistory.Open();
                                    MySqlCommand    commandhistory = new MySqlCommand(sqlhistory, connhistory);
                                    MySqlDataReader readerhistory  = commandhistory.ExecuteReader();
                                    readerhistory.Read();
                                    doc_name = readerhistory[0].ToString();
                                    readerhistory.Close();
                                    connhistory.Close();

                                    Microsoft.Office.Interop.Word._Application app = new Microsoft.Office.Interop.Word.Application();
                                    Microsoft.Office.Interop.Word.Document     doc = app.Documents.Add();
                                    doc.Paragraphs[1].Range.Text = doc_content;
                                    Clipboard.SetImage(pictureBox1.Image);
                                    doc.Paragraphs[doc.Paragraphs.Count].Range.Paste();
                                    app.Visible = false;
                                    doc.SaveAs2(@"D:\Колледж\4 КУРС\ПРАКТИКА\интернет-банкинг\история\" + doc_name + ".docx");
                                    doc.Close();
                                    app.Quit();

                                    panel2.Visible   = false;
                                    panel3.Visible   = true;
                                    label6.Text      = doc_content;
                                    pictureBox1.Top  = label6.Top + label6.Height + 5;
                                    groupBox1.Height = pictureBox1.Height + label6.Height + 40;
                                    groupBox1.Width  = label6.Width + 15;
                                    Height           = groupBox1.Height + 200;
                                    panel3.Height    = Height - 70;
                                    Width            = Width - 100;
                                }
                            }
                            catch (Exception exc)
                            {
                                MessageBox.Show(exc.Message.ToString(), exc.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Вы ввели неверный код!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Введите код подтверждения!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("Введите сумму платежа!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            if (button1.Text == "Далее")
            {
                str_scet = label1.Text;
                string          sql  = "SELECT FIO,adres,vystavleno,id_plateg_dopolnitelnaya FROM plategi_dopolnitelnaya WHERE id_plateg=" + id_plateg + " AND litsevoy_scet=" + textBox1.Text;
                MySqlConnection conn = DBUtils.GetDBConnection();
                conn.Open();
                MySqlCommand    command = new MySqlCommand(sql, conn);
                MySqlDataReader reader  = command.ExecuteReader();
                if (reader.Read())
                {
                    textBox1.Visible = false;
                    scet             = textBox1.Text;
                    FIO = reader[0].ToString();
                    if (FIO != "")
                    {
                        label2.Text    = "ФИО: " + FIO;
                        label2.Visible = true;
                    }
                    else
                    {
                        label2.Text  = "";
                        label3.Top   = label2.Top;
                        label1.Top   = label3.Top + label3.Height + 15;
                        textBox3.Top = label3.Top + label3.Height + 15;
                        panel1.Top   = label1.Top + label1.Height + 30;
                        button1.Top  = panel1.Top + panel1.Height + 30;
                    }
                    adres = reader[1].ToString();
                    if (adres != "")
                    {
                        label3.Text   += adres;
                        label3.Visible = true;
                    }
                    else
                    {
                        label3.Text  = "";
                        label1.Top   = label3.Top;
                        textBox3.Top = label3.Top;
                        panel1.Top   = label1.Top + label1.Height + 30;
                        button1.Top  = panel1.Top + panel1.Height + 30;
                    }
                    textBox3.Text  = reader[2].ToString();
                    label1.Text    = "Сумма";
                    button1.Text   = "Оплатить";
                    panel1.Visible = true;
                    if (number_phone == "")
                    {
                        label4.Text        = "PIN-код";
                        linkLabel1.Visible = false;
                    }
                    id_plateg_dopolnitelnaya = reader[3].ToString();
                    textBox1.Visible         = false;
                    textBox3.Visible         = true;

                    if (id_plateg == "280" || id_plateg == "281" || id_plateg == "282")
                    {
                        panel4.Visible = true;
                        panel4.Top     = label1.Top;
                        label1.Top     = panel4.Top + panel4.Height + 15;
                        textBox3.Top   = panel4.Top + panel4.Height + 15;
                        panel1.Top     = label1.Top + label1.Height + 70;
                        button1.Top    = panel1.Top + panel1.Height;
                    }
                    Height = button1.Top + button1.Height + 150;
                }
                else
                {
                    MessageBox.Show("Вы ввели несуществующий номер!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                reader.Close();
                conn.Close();
            }
        }
示例#4
0
 private void plategi_Load(object sender, EventArgs e)
 {
     ActiveControl = textBox1;
     Text          = "Оплата " + naznachenie;
     if (naznachenie == "Дополнительное занятие" || naznachenie == "Сдача экзамена" || naznachenie == "Топливо" || naznachenie == "Автомобиль для экзамена" || naznachenie == "Обучение" || naznachenie == "Общежитие" || naznachenie == "Byfly,ZALA,Максифон,Умный дом" || naznachenie == "Единый Таможенный тариф ЕАЭС")
     {
         label1.Text = "Номер договора";
     }
     if (naznachenie == "Питание" || naznachenie == "Учебники" || naznachenie == "Кружки")
     {
         label1.Text = "Номер учащегося";
     }
     if (naznachenie == "Телефон" || naznachenie == "По № телефона")
     {
         label1.Text    = "Номер телефона";
         label2.Text    = "Введите 9 цифр номера телефона\r\nв формате: 29ххххххх, 33ххххххх,\r\n25ххххххх, 44ххххххх";
         label2.Visible = true;
     }
     if (naznachenie == "velcom - voka" || naznachenie == "velcom - Домашний интернет и ТВ" || naznachenie == "Интернет" || naznachenie == "Абонентская плата" || naznachenie == "Водоснабжение" || naznachenie == "Газоснабжение" || naznachenie == "Коммунальные платежи" || naznachenie == "Электроэнергия")
     {
         label1.Text = "Лицевой счет";
     }
     if (naznachenie == "Компьютерные услуги" || naznachenie == "Практический экзамен на авто" || naznachenie == "Практический экзамен на мото" || naznachenie == "Теоретический экзамен" || naznachenie == "Замена номера автомобиля" || naznachenie == "Выдача транзита" || naznachenie == "Замена номера мото/прицепа" || naznachenie == "Изготовление номеров" || naznachenie == "Регистрация автомобиля" || naznachenie == "Регистрация мотоцикла/прицепа")
     {
         label1.Text = "Идентификационный \r\nномер";
     }
     if (naznachenie == "Госпошлина" || naznachenie == "Разрешение")
     {
         label1.Text    = "Серия и номер\r\nтехпаспорта ТС";
         label2.Text    = "Введите серию и номер \r\nсвидетельства о гос.регистрации\r\nтранспортного средства\r\n(например: АБВ012345)";
         label2.Visible = true;
     }
     if (naznachenie == "Пополнение счета")
     {
         label1.Text = "Номер игрового счета";
     }
     if (label2.Visible == false)
     {
         label1.Top   = label2.Top;
         textBox1.Top = label2.Top;
         button1.Top  = label1.Top + label1.Height + 60;
     }
     Height = button1.Top + button1.Height + 150;
     for (int i = 0; i < col_cards; i++)
     {
         try
         {
             string          str  = "SELECT type_card,name,valyta,number_card,ostatok,raschetnaya,number_phone,PIN FROM bank_card,type,type_card,valyta WHERE type_card.id_type_card=(SELECT type FROM type WHERE id_type=(SELECT id_type FROM bank_card WHERE id_card=" + mas_id_card[i] + ")) AND type.id_type=(SELECT id_type FROM bank_card WHERE id_card=" + mas_id_card[i] + ") AND valyta.id_valyta=(SELECT id_valyta FROM bank_card WHERE id_card=" + mas_id_card[i] + ") AND id_card =" + mas_id_card[i];
             MySqlConnection conn = DBUtils.GetDBConnection();
             conn.Open();
             MySqlCommand    command = new MySqlCommand(str, conn);
             MySqlDataReader reader  = command.ExecuteReader();
             reader.Read();
             string ostatok1 = reader[4].ToString();
             ostatok1 = Convert.ToString(Convert.ToDouble(ostatok1) - Convert.ToDouble(ostatok1) % 0.01);
             string[] mas = new string[10];
             mas = reader[3].ToString().Split(' ');
             comboBox1.Items.Add(reader[0].ToString() + " " + reader[1].ToString() + " " + mas[0] + "**** ****" + mas[3] + " остаток:" + ostatok1 + " " + reader[2].ToString());
             if (reader[5].ToString() == "YES")
             {
                 comboBox1.SelectedIndex = i;
                 id_selected             = i;
                 valytacard   = reader[2].ToString();
                 ostatok      = reader[4].ToString();
                 number_card  = mas[0] + "**** ****" + mas[3];
                 number_phone = reader[6].ToString();
                 kod          = Convert.ToInt32(reader[7]);
             }
             reader.Close();
             conn.Close();
         }
         catch (Exception exc)
         {
             MessageBox.Show(exc.Message.ToString(), exc.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (shag == 1)
            {
                string number_card = textBox1.Text;
                string FIO         = textBox2.Text;
                if (number_card != "" && number_card != "XXXX-XXXX-XXXX-XXXX" && FIO != "" && FIO != "Иванов Иван Иванович")
                {
                    try
                    {
                        string          sql  = "SELECT id_card,PIN FROM bank_card WHERE number_card='" + number_card + "' AND FIO='" + FIO + "';";
                        MySqlConnection conn = DBUtils.GetDBConnection();
                        conn.Open();
                        MySqlCommand    command = new MySqlCommand(sql, conn);
                        MySqlDataReader reader  = command.ExecuteReader();
                        if (reader.Read())
                        {
                            id  = reader[0].ToString();
                            PIN = reader[1].ToString();
                        }
                        else
                        {
                            MessageBox.Show("Вы ввели неверные данные!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        reader.Close();
                        conn.Close();

                        if (id != null)
                        {
                            sql  = "SELECT id_client FROM bank_card WHERE id_card='" + id + "';";
                            conn = DBUtils.GetDBConnection();
                            conn.Open();
                            command = new MySqlCommand(sql, conn);
                            reader  = command.ExecuteReader();
                            reader.Read();
                            if (reader[0].ToString() == "" || reader[0].ToString() == "0")
                            {
                                shag             = 2;
                                label1.Text      = "Шаг 2: подтверждение карты";
                                label2.Text      = "PIN-код (4 цифры)";
                                textBox1.Text    = "XXXX";
                                textBox1.Width   = 70;
                                textBox2.Visible = false;
                                label3.Visible   = false;
                                button1.Location = new Point(135, 265);
                                this.Height      = 360;
                            }
                            else
                            {
                                MessageBox.Show("Пользователь с такой картой уже зарегистрирован!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }

                        reader.Close();
                        conn.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Введите данные!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                return;
            }
            if (shag == 2)
            {
                if (textBox1.Text != "" && textBox1.Text != "XXXX")
                {
                    if (PIN == textBox1.Text)
                    {
                        shag             = 3;
                        label1.Text      = "Шаг 3: выбор логина и пароля";
                        label2.Text      = "Логин";
                        label3.Text      = "Пароль (минимум 8 символов)";
                        textBox1.Text    = "";
                        textBox1.Width   = 170;
                        textBox2.Text    = "";
                        textBox2.Width   = 170;
                        textBox2.Visible = true;
                        label3.Visible   = true;
                        button1.Location = new Point(142, 362);
                        button1.Text     = "Зарегистрироваться";
                        this.Height      = 440;
                    }
                    else
                    {
                        popytki--;
                        if (popytki > 0)
                        {
                            MessageBox.Show("Введен неверный PIN-код! \r\n Количество оставшихся попыток" + popytki, "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            MessageBox.Show("Введен неверный PIN-код 3 раза! \r\n Регистрация прекращена" + popytki, "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            this.Close();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Введите PIN-код!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                return;
            }
            if (shag == 3)
            {
                if (textBox1.Text != "" && textBox2.Text != "")
                {
                    try
                    {
                        string          sql  = "SELECT id_client FROM client WHERE login='******';";
                        MySqlConnection conn = DBUtils.GetDBConnection();
                        conn.Open();
                        MySqlCommand    command = new MySqlCommand(sql, conn);
                        MySqlDataReader reader  = command.ExecuteReader();
                        if (reader.Read())
                        {
                            MessageBox.Show("Пользователь с таким логином уже существует!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            reader.Close();
                            conn.Close();
                        }
                        else
                        {
                            reader.Close();
                            conn.Close();

                            string sql_last_id = "SELECT id_client FROM client ORDER BY id_client DESC ;"; //определение последнего id в таблице client
                            conn.Open();
                            command = new MySqlCommand(sql_last_id, conn);
                            reader  = command.ExecuteReader();
                            reader.Read();
                            int last_id = Convert.ToInt32(reader[0]) + 1;
                            reader.Close();
                            conn.Close();

                            sql  = "INSERT INTO client(id_client,login,password) VALUES ('" + last_id + "','" + textBox1.Text + "','" + textBox2.Text + "');"; //создание записи в таблице client
                            conn = DBUtils.GetDBConnection();
                            conn.Open();
                            command = new MySqlCommand(sql, conn);
                            reader  = command.ExecuteReader();
                            reader.Read();
                            reader.Close();
                            conn.Close();

                            sql  = "UPDATE bank_card SET id_client=" + last_id; //создание записи в таблице client
                            conn = DBUtils.GetDBConnection();
                            conn.Open();
                            command = new MySqlCommand(sql, conn);
                            reader  = command.ExecuteReader();
                            reader.Read();
                            reader.Close();
                            conn.Close();

                            MessageBox.Show("Вы успешно зарегистрированы!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            this.Close();
                            main.Show();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Введите данные!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
        void vivoddeposit(string sql, string sql1)
        {
            try
            {
                panel1.Controls.Clear();
                label10.Visible = false;
                int             col_deposit = 0;
                MySqlConnection conn        = DBUtils.GetDBConnection();
                conn.Open();
                MySqlCommand    command = new MySqlCommand(sql, conn);
                MySqlDataReader reader  = command.ExecuteReader();
                reader.Read();
                col_deposit = Convert.ToInt32(reader[0]);
                reader.Close();
                conn.Close();

                if (col_deposit != 0)
                {
                    PictureBox[] picturebox  = new PictureBox[20];
                    Label[]      name        = new Label[20];
                    Label[]      valyta      = new Label[20];
                    Label[]      procent     = new Label[20];
                    Label[]      srok        = new Label[20];
                    Label[]      summa       = new Label[20];
                    Label[]      information = new Label[20];
                    Button[]     button      = new Button[20];

                    int coord    = 50;
                    int coordtop = 75;

                    name[0]        = new Label();
                    valyta[0]      = new Label();
                    procent[0]     = new Label();
                    srok[0]        = new Label();
                    summa[0]       = new Label();
                    information[0] = new Label();
                    panel1.Controls.Add(name[0]);
                    panel1.Controls.Add(valyta[0]);
                    panel1.Controls.Add(procent[0]);
                    panel1.Controls.Add(srok[0]);
                    panel1.Controls.Add(summa[0]);
                    panel1.Controls.Add(information[0]);

                    conn = DBUtils.GetDBConnection();
                    conn.Open();
                    command = new MySqlCommand(sql1, conn);
                    reader  = command.ExecuteReader();
                    for (int i = 1; i <= col_deposit; i++)
                    {
                        int coordleft = 20;
                        picturebox[i]  = new PictureBox();
                        name[i]        = new Label();
                        valyta[i]      = new Label();
                        procent[i]     = new Label();
                        srok[i]        = new Label();
                        summa[i]       = new Label();
                        information[i] = new Label();
                        button[i]      = new Button();

                        picturebox[i].Width  = 125;
                        name[i].Width        = 200;
                        valyta[i].Width      = 150;
                        procent[i].Width     = 100;
                        srok[i].Width        = 100;
                        summa[i].Width       = 250;
                        information[i].Width = 200;
                        button[i].Width      = 120;



                        picturebox[i].Height  = 80;
                        name[i].Height        = 80;
                        information[i].Height = 80;
                        button[i].Height      = 40;
                        summa[i].Height       = 80;

                        button[i].FlatStyle = 0;
                        button[i].FlatAppearance.BorderColor = Color.Black;
                        button[i].Font      = new Font("Tahoma", 10, FontStyle.Bold);
                        button[i].ForeColor = Color.White;

                        picturebox[i].Top  = coord;
                        name[i].Top        = coordtop;
                        valyta[i].Top      = coordtop;
                        procent[i].Top     = coordtop;
                        srok[i].Top        = coordtop;
                        summa[i].Top       = coordtop;
                        information[i].Top = coordtop;
                        button[i].Top      = coordtop;

                        picturebox[i].Left  = coordleft;
                        coordleft          += picturebox[i].Width + 20;
                        name[0].Left        = coordleft;
                        name[i].Left        = coordleft;
                        coordleft          += name[i].Width + 20;
                        valyta[0].Left      = coordleft;
                        valyta[i].Left      = coordleft;
                        coordleft          += valyta[i].Width + 20;
                        procent[0].Left     = coordleft;
                        procent[i].Left     = coordleft;
                        coordleft          += procent[i].Width + 20;
                        srok[0].Left        = coordleft;
                        srok[i].Left        = coordleft;
                        coordleft          += srok[i].Width + 20;
                        summa[0].Left       = coordleft;
                        summa[i].Left       = coordleft;
                        coordleft          += summa[i].Width + 20;
                        information[0].Left = coordleft;
                        information[i].Left = coordleft;
                        coordleft          += information[i].Width + 20;
                        button[i].Left      = coordleft;
                        button[i].BackColor = Color.Red;
                        coordleft          += button[i].Width + 20;
                        panel1.Width        = coordleft;

                        button[i].Name                      = "btn" + i;
                        button[i].Click                    += ButtonOnClick;
                        button[i].Text                      = "Оформить";
                        name[i].TextAlign                   = ContentAlignment.TopCenter;
                        valyta[i].TextAlign                 = ContentAlignment.TopCenter;
                        procent[i].TextAlign                = ContentAlignment.TopCenter;
                        srok[i].TextAlign                   = ContentAlignment.TopCenter;
                        summa[i].TextAlign                  = ContentAlignment.TopCenter;
                        information[i].TextAlign            = ContentAlignment.TopCenter;
                        picturebox[i].BackgroundImageLayout = ImageLayout.Center;

                        panel1.Controls.Add(picturebox[i]);
                        panel1.Controls.Add(name[i]);
                        panel1.Controls.Add(valyta[i]);
                        panel1.Controls.Add(procent[i]);
                        panel1.Controls.Add(srok[i]);
                        panel1.Controls.Add(summa[i]);
                        panel1.Controls.Add(information[i]);
                        panel1.Controls.Add(button[i]);
                        coord    += picturebox[i].Height + 20;
                        coordtop += picturebox[i].Height + 20;

                        reader.Read();
                        name[i].Text = reader[2].ToString();
                        if (reader[1].ToString() == "1")
                        {
                            valyta[i].Text = "Белорусский рубль";
                        }
                        if (reader[1].ToString() == "2")
                        {
                            valyta[i].Text = "Российский рубль";
                        }
                        if (reader[1].ToString() == "3")
                        {
                            valyta[i].Text = "Евро";
                        }
                        if (reader[1].ToString() == "4")
                        {
                            valyta[i].Text = "Доллар США";
                        }
                        procent[i].Text               = reader[4].ToString() + " %";
                        srok[i].Text                  = reader[3].ToString() + " дней";
                        summa[i].Text                 = "Минимальная сумма депозита: " + reader[5].ToString() + "\r\n" + "Максимальная сумма депозита: " + reader[6].ToString();
                        information[i].Text           = reader[9].ToString();
                        picturebox[i].BackgroundImage = Image.FromFile(reader[10].ToString());
                    }
                    reader.Close();
                    conn.Close();

                    name[0].Width        = name[1].Width;
                    valyta[0].Width      = valyta[1].Width;
                    procent[0].Width     = procent[1].Width;
                    srok[0].Width        = srok[1].Width;
                    summa[0].Width       = summa[1].Width;
                    information[0].Width = information[1].Width;

                    name[0].Text        = "Название";
                    valyta[0].Text      = "Валюта";
                    procent[0].Text     = "Процентная ставка";
                    srok[0].Text        = "Срок";
                    summa[0].Text       = "Минимальная-максимальная сумма";
                    information[0].Text = "Дополнительная информация";

                    name[0].TextAlign        = ContentAlignment.MiddleCenter;
                    valyta[0].TextAlign      = ContentAlignment.MiddleCenter;
                    procent[0].TextAlign     = ContentAlignment.MiddleCenter;
                    srok[0].TextAlign        = ContentAlignment.MiddleCenter;
                    summa[0].TextAlign       = ContentAlignment.MiddleCenter;
                    information[0].TextAlign = ContentAlignment.MiddleCenter;

                    panel1.Height = (picturebox[1].Height + 20) * col_deposit + 50;
                    this.Width    = panel1.Width + 100;

                    void ButtonOnClick(object sender1, EventArgs eventArgs)
                    {
                        try
                        {
                            var a = (Button)sender1;
                            if (a != null)
                            {
                                int b = Convert.ToInt32(a.Name.Replace("btn", ""));

                                string          str   = "SELECT id_deposit FROM deposit WHERE name_deposit='" + name[b].Text + "';";
                                MySqlConnection conn1 = DBUtils.GetDBConnection();
                                conn1.Open();
                                MySqlCommand    command1 = new MySqlCommand(str, conn1);
                                MySqlDataReader reader1  = command1.ExecuteReader();
                                reader1.Read();
                                int  id      = Convert.ToInt32(reader1[0]);
                                bool warning = false;
                                for (int i = 1; i <= col_deposit; i++)
                                {
                                    if (mas_id_deposit[i] == id)
                                    {
                                        MessageBox.Show("Данный тип депозита уже открыт!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        warning = true;
                                    }
                                }
                                if (warning == false)
                                {
                                    depositopen form = new depositopen(mas_id_card, mas_id_deposit, col_cards, col_deposit, id_client, RUB, EUR, USD);
                                    form.Show();
                                    form.comboBox1.SelectedItem = name[b].Text;
                                }
                                reader1.Close();
                                conn1.Close();
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    label10.Visible = true;
                    label10.Top     = button1.Top + button1.Height + 70;
                    this.Width      = 1220;
                    panel1.Width    = 1000;
                    panel1.Height   = 100;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#7
0
        private void vivod(bool flag, string delete)
        {
            try
            {
                string sql  = "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '" + tablitsa + "';"; //получение кол-ва столбцов таблицы
                string sql1 = "DESCRIBE " + tablitsa + ";";                                                             //получение списка имен столбцов
                string sql2 = "SELECT COUNT(*) FROM " + tablitsa + ";";                                                 //получение кол-ва строк таблицы

                MySqlConnection conn = DBUtils.GetDBConnection();
                conn.Open();
                MySqlCommand    command = new MySqlCommand(sql, conn);
                MySqlDataReader reader  = command.ExecuteReader();
                reader.Read();
                int colstolbec = Convert.ToInt32(reader[0].ToString());
                reader.Close();
                conn.Close();

                conn.Open();
                command = new MySqlCommand(sql2, conn);
                reader  = command.ExecuteReader();
                reader.Read();
                int colstrok = Convert.ToInt32(reader[0].ToString());
                reader.Close();
                conn.Close();

                conn.Open();
                string[] namestolbec = new string[colstolbec];
                command = new MySqlCommand(sql1, conn);
                reader  = command.ExecuteReader();
                int k = 0;
                while (reader.Read())
                {
                    namestolbec[k] = reader[0].ToString();
                    k++;
                }
                reader.Close();
                conn.Close();
                dataGridView1.RowCount    = colstrok;
                dataGridView1.ColumnCount = colstolbec;
                for (int i = 0; i < colstolbec; i++)
                {
                    dataGridView1.Columns[i].HeaderText = namestolbec[i];
                }

                if (flag)
                {
                    for (int i = Convert.ToInt32(delete); i <= colstrok; i++)
                    {
                        string sqlupdate = "UPDATE " + tablitsa + " SET " + dataGridView1.Columns[0].HeaderText + "=" + i + " WHERE " + dataGridView1.Columns[0].HeaderText + "=" + (i + 1);
                        conn.Open();
                        command = new MySqlCommand(sqlupdate, conn);
                        reader  = command.ExecuteReader();
                        reader.Read();
                        reader.Close();
                        conn.Close();
                    }
                }

                string sql3 = "SELECT * FROM " + tablitsa + " ORDER BY " + dataGridView1.Columns[0].HeaderText + ";"; //получение содержимого таблицы
                conn.Open();
                command = new MySqlCommand(sql3, conn);
                reader  = command.ExecuteReader();
                int a = 0;
                while (reader.Read())
                {
                    for (int i = 0; i < colstolbec; i++)
                    {
                        dataGridView1.Rows[a].Cells[i].Value = reader[i].ToString();
                    }
                    a++;
                }
                reader.Close();
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (vyborsystem == false)
                {
                    MessageBox.Show("Выберите платежную систему!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (vyborvalyta == false)
                    {
                        MessageBox.Show("Выберите валюту!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        if (vyborsrok == false)
                        {
                            MessageBox.Show("Выберите срок действия карты!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            string[] mas = new string[5];
                            mas = type_card.Split(' ');
                            string type = "";
                            string name = "";
                            for (int i = 1; i < mas.Length; i++)
                            {
                                if (i != mas.Length - 1)
                                {
                                    name += mas[i] + " ";
                                }
                                else
                                {
                                    name += mas[i];
                                }
                            }
                            if (mas[0] == "Visa")
                            {
                                type = "1";
                            }
                            if (mas[0] == "MasterCard")
                            {
                                type = "2";
                            }
                            if (mas[0] == "Maestro")
                            {
                                type = "3";
                            }
                            string          sql   = "SELECT FIO,type.id_type FROM bank_card,type WHERE id_client='" + id_client + "' AND type.type='" + type + "' AND type.name='" + name + "'";
                            MySqlConnection conn1 = DBUtils.GetDBConnection();
                            conn1.Open();
                            MySqlCommand    command1 = new MySqlCommand(sql, conn1);
                            MySqlDataReader reader1  = command1.ExecuteReader();
                            reader1.Read();
                            string FIO = reader1[0].ToString();
                            type = reader1[1].ToString();
                            reader1.Close();
                            conn1.Close();

                            sql   = "SELECT id_card FROM bank_card ORDER BY id_card DESC";
                            conn1 = DBUtils.GetDBConnection();
                            conn1.Open();
                            command1 = new MySqlCommand(sql, conn1);
                            reader1  = command1.ExecuteReader();
                            reader1.Read();
                            string id_card = (Convert.ToInt32(reader1[0]) + 1).ToString();
                            reader1.Close();
                            conn1.Close();

                            string srok_deystviya = DateTime.Now.AddYears(Convert.ToInt32(srok)).ToString("yyyy-MM-dd");

                            string randomizer()
                            {
                                string number_card = "";
                                Random random      = new Random();
                                int    number1     = random.Next(1000, 9999);
                                int    number2     = random.Next(1000, 9999);
                                int    number3     = random.Next(1000, 9999);
                                int    number4     = random.Next(1000, 9999);

                                number_card = number1.ToString() + " " + number2.ToString() + " " + number3.ToString() + " " + number4.ToString();

                                sql   = "SELECT number_card FROM bank_card WHERE number_card='" + number_card + "'";
                                conn1 = DBUtils.GetDBConnection();
                                conn1.Open();
                                command1 = new MySqlCommand(sql, conn1);
                                reader1  = command1.ExecuteReader();
                                if (reader1.Read())
                                {
                                    reader1.Close();
                                    conn1.Close();
                                    randomizer();
                                }
                                else
                                {
                                    reader1.Close();
                                    conn1.Close();
                                }
                                return(number_card);
                            }
                            Random random1 = new Random();
                            int    PIN     = random1.Next(1000, 9999);

                            sql   = "INSERT INTO bank_card(id_card, id_client, id_type, id_valyta, FIO, number_card, ostatok, srok_deystviya, PIN) VALUES ('" + id_card + "','" + id_client + "','" + type + "','" + valyta + "','" + FIO + "','" + randomizer() + "','0','" + srok_deystviya + "','" + PIN + "')";
                            conn1 = DBUtils.GetDBConnection();
                            conn1.Open();
                            command1 = new MySqlCommand(sql, conn1);
                            reader1  = command1.ExecuteReader();
                            reader1.Read();
                            reader1.Close();
                            conn1.Close();


                            this.Close();
                            MessageBox.Show("Получена новая карта " + type_card + "!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message.ToString(), exc.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }