예제 #1
0
        private void OK_Click(object sender, EventArgs e)
        {
            if (PIB.Text.Length == 0 || Passport.Text.Length == 0 || Summ.Text.Length == 0)
            {
                MessageBox.Show("Всі поля мають бути заповнені!");
            }
            else
            {
                string pib       = PIB.Text;
                int    passport  = int.Parse(Passport.Text);
                string operation = Operation.SelectedItem.ToString();
                string valuta    = Currency.SelectedItem.ToString();
                float  summ      = float.Parse(Summ.Text);

                DB db = new DB();

                DataTable table  = new DataTable();
                DataTable table2 = new DataTable();

                MySqlDataAdapter adapter = new MySqlDataAdapter();

                MySqlCommand query  = new MySqlCommand("INSERT INTO `clients`(`id`, `PIB`, `passport`, `operation`, `valuta`, `summ`) VALUES ('','" + pib + "','" + passport + "','" + operation + "','" + valuta + "','" + summ + "')", db.GetConnection());
                MySqlCommand query2 = new MySqlCommand("SELECT `Buy`,`Sell` FROM `exchangerate` WHERE `title` = '" + valuta + "'", db.GetConnection());

                adapter.SelectCommand = query;
                adapter.Fill(table);
                adapter.SelectCommand = query2;
                adapter.Fill(table2);

                SummUAH.Visible = true;
                label3.Visible  = true;

                float[,] values = new float[table2.Rows.Count, table2.Columns.Count];
                for (int i = 0; i < table2.Rows.Count; i++)
                {
                    DataRow row = table2.Rows[i];
                    for (int j = 0; j < table2.Columns.Count; j++)
                    {
                        values[i, j] = (float)row[j];
                    }
                }

                float result = values[0, 0] * summ;

                SummUAH.Text = result.ToString();

                PIB.Clear();
                Passport.Clear();
                Summ.Clear();
                Operation.SelectedItem = "Купівля";
                Currency.SelectedItem  = 0;
            }
        }
예제 #2
0
        // расчет
        private void work_Click(object sender, EventArgs e)
        {
            Summ.Clear();
            Numbers.Clear();

            int k,
                Sum;

            // проверка конвертации
            if (Int32.TryParse(Koll.Text, out k) == true)
            {
                // вызов функии из библиотеки
                Sum       = Lib_1.RandomAmount.Go(k, Numbers);
                Summ.Text = Sum.ToString();
            }

            else
            {
                Koll.Clear();
                MessageBox.Show("Введите корректное значение!");
            }
        }
예제 #3
0
 // изменение входного текстбокса
 private void sourceK_TextChanged(object sender, EventArgs e)
 {
     Summ.Clear();
     Numbers.Clear();
     Koll.Clear();
 }
예제 #4
0
 // сброс
 private void reset_Click(object sender, EventArgs e)
 {
     Summ.Clear();
     Numbers.Clear();
     Koll.Clear();
 }