void Rejestracja()
        {
            MySqlConnection polaczenie = new MySqlConnection("server=localhost; user=root; database=food; port=3306; pooling=false");
            MySqlCommand    komenda    = polaczenie.CreateCommand();
            MySqlCommand    komenda1   = polaczenie.CreateCommand();

            try
            {
                if (polaczenie.State == ConnectionState.Closed)
                {
                    polaczenie.Open();

                    string haslo = PasswordBox.Text;

                    using (MD5 hash = MD5.Create())
                    {
                        haslo = GetMd5Hash(hash, haslo);
                    }

                    komenda1.CommandText = string.Format("SELECT count(id) FROM data where Login='******'");
                    int wartosc = Convert.ToInt32(komenda1.ExecuteScalar());
                    if (wartosc == 1)
                    {
                        MessageBox.Show(String.Format("Login: {0}, already exists.", LoginBox.Text), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        komenda.CommandText = string.Format("INSERT INTO data(Login,Password,Resort,Street,NumerHouse) VALUES('{0}','{1}','{2}','{3}','{4}')", LoginBox.Text, haslo, ResortBox.Text, StreetBox.Text, HostNumberBox.Text);
                        if (komenda.ExecuteNonQuery() == 1)
                        {
                            MessageBox.Show("You have logged successfuly. Now you can Login!", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Login Error.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    HostNumberBox.Clear(); StreetBox.Clear(); ResortBox.Clear(); LoginBox.Clear(); PasswordBox.Clear(); LoginBox.Focus();
                }
            }
            catch (Exception ex)
            {
                string byk = string.Format("Problem register with user: \n{0}.", ex.Message);
                MessageBox.Show(byk, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (polaczenie.State == ConnectionState.Open)
                {
                    polaczenie.Close();
                }
            }
        }
Esempio n. 2
0
 private void Resetbutton_Click(object sender, EventArgs e)
 {
     PhonetextBox.Clear();
     Nametexbox.Clear();
     NotextBox.Clear();
     ApartmentBox.Clear();
     VillageBox.Clear();
     Soibox.Clear();
     StreetBox.Clear();
     SubdistBox.Clear();
     DistBox.Clear();
     ProvinceBox.Clear();
     DetailBox.Clear();
 }
Esempio n. 3
0
 private void button3_Click(object sender, EventArgs e)
 {
     ClientName.Clear();
     ClientSurname.Clear();
     ClientPatronymic.Clear();
     ClientPhone.Clear();
     HouseBox.Clear();
     StreetBox.Clear();
     CityBox.Clear();
     FlatBox.Clear();
     CategoryBox.Text     = "";
     ProductBox.Text      = "";
     ServiceType.Text     = "";
     numericUpDown1.Value = 1;
     CostBox.Clear();
     PreCost.Clear();
     dataGridView1.Rows.Clear();
     dateTimePicker2.Value = dateTimePicker1.Value;
 }