private void OyCik_btn_Click(object sender, EventArgs e)
        {
            if (sayac >= 10)
            {
                mysqlconn.Open();
                string       query = "UPDATE kullanicilar SET OyVermeDurumu='Verdi' WHERE UserID=@ID;";
                MySqlCommand cmd   = new MySqlCommand(query, mysqlconn);
                cmd.Parameters.AddWithValue("@ID", ID);

                int result = cmd.ExecuteNonQuery();
                mysqlconn.Close();

                this.Hide();
                AnaEkran form = new AnaEkran(username);
                form.ShowDialog();
                this.Close();
            }

            else
            {
                MessageBox.Show("Üyeliğin Tamamlanması için en az 10 kere Oy vermeniz gerekli!!", "SİSTEM", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void giris_btn_Click_1(object sender, EventArgs e)
        {
            mysqlconn.Open();
            string       query = "SELECT KullaniciAdi FROM kullanicilar WHERE KullaniciAdi=@user AND Sifre=@sifre;";
            MySqlCommand cmd   = new MySqlCommand(query, mysqlconn);

            cmd.Parameters.AddWithValue("@user", KullanıcıGiris_txt.Text.ToString());
            cmd.Parameters.AddWithValue("@sifre", SifreGiris_txt.Text.ToString());

            string result = (string)cmd.ExecuteScalar();

            if (result != null)
            {
                MessageBox.Show("Giriş Başarılı!", "SİSTEM", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //*********************************************kitap tavsiye kodları için gerekli*************************************************
                Kullanici_Adi = KullanıcıGiris_txt.Text.ToString();

                MySqlCommand Create_table = new MySqlCommand("CREATE TABLE IF NOT EXISTS " + Kullanici_Adi + "(" +
                                                             "`ISBN` VARCHAR(50)" +
                                                             "" +
                                                             "" +
                                                             "" +
                                                             "" +
                                                             "" +
                                                             ");", mysqlconn);
                int sonuc = Create_table.ExecuteNonQuery();

                //tablo adlarını tutmak için gerekli!
                string path = @"C:\Users\Cenk\Desktop\Proje\YazLab1-Proje\Tablolar.txt";
                if (!File.Exists(path))
                {
                    File.Create(path);
                }

                File.AppendAllText(@"C:\Users\Cenk\Desktop\Proje\YazLab1-Proje\Tablolar.txt", Kullanici_Adi + Environment.NewLine);
                mysqlconn.Close();

                //**************************************************************************************************************************

                mysqlconn.Open();
                string       query2 = "SELECT OyVermeDurumu FROM kullanicilar WHERE KullaniciAdi=@user AND Sifre=@sifre;";
                MySqlCommand cmd2   = new MySqlCommand(query2, mysqlconn);
                cmd2.Parameters.AddWithValue("@user", KullanıcıGiris_txt.Text.ToString());
                cmd2.Parameters.AddWithValue("@sifre", SifreGiris_txt.Text.ToString());

                string result2 = (string)cmd2.ExecuteScalar();

                if (result2.Equals("Verdi"))
                {
                    mysqlconn.Close();
                    this.Hide();
                    AnaEkran form2 = new AnaEkran(Kullanici_Adi);
                    form2.ShowDialog();
                    this.Close();
                }

                else if (result2.Equals("Vermedi"))
                {
                    string       query3 = "SELECT UserID FROM kullanicilar WHERE KullaniciAdi=@user AND Sifre=@sifre;";
                    MySqlCommand cdm3   = new MySqlCommand(query3, mysqlconn);
                    cdm3.Parameters.AddWithValue("@user", KullanıcıGiris_txt.Text.ToString());
                    cdm3.Parameters.AddWithValue("@sifre", SifreGiris_txt.Text.ToString());

                    int result3 = (int)cdm3.ExecuteScalar();

                    mysqlconn.Close();
                    this.Hide();
                    OyVermeFormu form = new OyVermeFormu(result3, Kullanici_Adi);
                    form.ShowDialog();
                    this.Close();
                }
            }

            else
            {
                MessageBox.Show("Böyle bir Kullanıcı Yok!", "SİSTEM", MessageBoxButtons.OK, MessageBoxIcon.Error);
                mysqlconn.Close();
            }
        }