Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            ActiveForm.Hide();
            SponsorForm sf = new SponsorForm();

            sf.ShowDialog();
            Close();
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string str;

            string [] str1;
            str  = comboBox1.Text;
            str1 = str.Split(' ');
            SqlConnClass scc = new SqlConnClass();
            SponsorForm  sf  = this;

            scc.CharityForRunner(sf, str1[0]);
        }
        public SponsorForm()
        {
            InitializeComponent();
            label19.Text = "$" + textBox2.Text;
            SponsorForm  sf  = this;
            SqlConnClass scc = new SqlConnClass();

            scc.ConectRunnerFoeSponsor(sf);

            tm.Tick    += timer1_Tick;
            tm.Interval = 1000;
            tm.Enabled  = true;
            tm.Start();
        }
        public void CharityForRunner(SponsorForm sf, string str)
        {
            string          connStr = "server=localhost;user=root;database=pafenov;password="******"SELECT CharityName FROM registration JOIN charity ON registration.CharityId = Charity.CharityId WHERE registration.RunnerId = " + str;
            MySqlCommand    command = new MySqlCommand(sql, conn);
            MySqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                sf.label20.Text = reader[0].ToString();
            }
            reader.Close();
            conn.Close();
        }
        public void ConectRunnerFoeSponsor(SponsorForm sf)
        {
            string          connStr = "server=localhost;user=root;database=pafenov;password="******"SELECT runner.RunnerId, user.FirstName, user.LastName, country.CountryName FROM user JOIN runner ON user.Email = runner.Email JOIN country ON runner.CountryCode = country.CountryCode";
            MySqlCommand    command = new MySqlCommand(sql, conn);
            MySqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                sf.comboBox1.Items.Add(reader[0].ToString() + " " + reader[1].ToString() + " " + reader[2].ToString() + " " + reader[3].ToString());
            }
            reader.Close();
            conn.Close();
        }
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "" || comboBox1.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || textBox7.Text == "" || label19.Text == "$0")
     {
         MessageBox.Show("Какие то поля не заполнены либо сумма равна 0!");
     }
     else
     {
         string   str;
         string[] str1;
         str  = comboBox1.Text;
         str1 = str.Split(' ');
         SqlConnClass scc = new SqlConnClass();
         SponsorForm  sf  = this;
         scc.SponsorAddRec(sf, str1[0], textBox1.Text, textBox2.Text);
         //scc.CharityForRunner(sf, str1[0]);
         ActiveForm.Hide();
         SponsConfirm sc = new SponsConfirm(comboBox1.Text, label20.Text, label19.Text);
         sc.ShowDialog();
         Close();
     }
 }
        public void SponsorAddRec(SponsorForm sf, string str, string name, string sum)
        {
            string          connStr = "server=localhost;user=root;database=pafenov;password="******"SELECT RegistrationId FROM registration WHERE RunnerId = " + str;

            MySqlCommand    command = new MySqlCommand(sql, conn);
            MySqlDataReader reader  = command.ExecuteReader();
            string          regid   = "";

            while (reader.Read())
            {
                regid = reader[0].ToString();
            }
            string sql1 = "INSERT INTO sponsorship(SponsorName,RegistrationId,Amount) VALUES('" + name + "', '" + regid + "', '" + sum + "')";

            reader.Close();
            command = new MySqlCommand(sql1, conn);
            command.ExecuteNonQuery();

            conn.Close();
        }