Exemple #1
0
        private void btn_SifremiUnuttumGonder_Click(object sender, EventArgs e)
        {
            Random        rastgele = new Random();
            StringBuilder sb       = new StringBuilder();

            for (int i = 0; i < 8; i++)
            {
                int ascii = rastgele.Next(32, 127);
                karakter = Convert.ToChar(ascii);
                sb.Append(karakter);
            }

            Random deneme  = new Random();
            string harfler = "ABCDEFGHIJKLMNOPRSTUVYZabcdefghijklmnoprstuvyz1234567890";
            string uret    = "";

            for (int i = 0; i < 6; i++)
            {
                uret += harfler[deneme.Next(harfler.Length)];
            }


            MailMessage ePosta = new MailMessage();

            ePosta.From = new MailAddress("*****@*****.**");
            ePosta.To.Add(textBox_Eposta.Text);
            ePosta.Subject = "parola yenile";
            ePosta.Body    = "Parola yenileme kodunuz : " + uret.ToString();
            SmtpClient smtp = new SmtpClient();

            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "otokondri123");
            smtp.Port        = 587;
            smtp.Host        = "smtp.gmail.com";
            smtp.EnableSsl   = true;
            object userState = ePosta;
            bool   kontrol   = true;

            try
            {
                smtp.SendAsync(ePosta, (object)ePosta);
                MessageBox.Show("Mail gönderildi.");
            }
            catch (SmtpException ex)
            {
                kontrol = false;
                System.Windows.Forms.MessageBox.Show(ex.Message, "Mail Gönderme Hatasi");
            }



            string islem = "select Id from tbl_Personel where Email = '" + textBox_Eposta.Text + "'";
            string id    = SqlConn.Id_Deger(islem);


            string insrt = "insert into ParolaYenile(Random,Personel_Id)values('" + uret + "','" + id + "')";

            SqlConn.Islemler(insrt);

            SifreYenileme ynl = new SifreYenileme();

            ynl.id = id;

            ynl.Show();
            this.Hide();
        }
Exemple #2
0
        private void button_Loginn(object sender, EventArgs e)
        {
            SqlConnection con;
            SqlCommand    cmd;
            SqlDataReader dr;

            string user = textBox_Personelid.Text;
            string pass = textBox_PersonelParola.Text;

            string islem = "select Id from tbl_Personel where Email = '" + textBox_Personelid.Text + "'";
            string id    = SqlConn.Id_Deger(islem);

            try
            {
                string    sorgu = "select Durum from ParolaYenile where Personel_Id='" + id + "' and Durum= '" + 'A' + "'";
                DataTable dtbl  = SqlConn.goster(sorgu);
                string    durum = dtbl.Rows[0]["Durum"].ToString();;

                if (durum == "A")
                {
                    MessageBox.Show("Daha önce parola yenileme isteği yolladınız, Lütfen mailinizi kontrol ediniz.");
                    SifreYenileme sfr = new SifreYenileme();
                    sfr.id = id;
                    sfr.Show();
                    //this.Hide();
                }

                else
                {
                    con = new SqlConnection("Data Source=DESKTOP-7L6TOHU;Initial Catalog=OtokondriOtomasyon;Persist Security Info=True;User ID=sa;Password=123456789");
                    cmd = new SqlCommand();
                    con.Open();
                    cmd.Connection  = con;
                    cmd.CommandText = "SELECT * FROM tbl_Personel where Email='" + textBox_Personelid.Text + "' AND Parola='" + textBox_PersonelParola.Text + "'";
                    dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        PersonelPanel PersonelPanelsec = new PersonelPanel();
                        PersonelPanelsec.personelid = textBox_Personelid.Text;
                        PersonelPanelsec.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Email veya şifrenizi kontrol ediniz.");
                    }
                    con.Close();
                }
            }
            catch
            {
                con = new SqlConnection("Data Source=DESKTOP-7L6TOHU;Initial Catalog=OtokondriOtomasyon;Persist Security Info=True;User ID=sa;Password=123456789");
                cmd = new SqlCommand();
                con.Open();
                cmd.Connection  = con;
                cmd.CommandText = "SELECT * FROM tbl_Personel where Email ='" + textBox_Personelid.Text + "' AND Parola='" + textBox_PersonelParola.Text + "'";
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    PersonelPanel PersonelPanelsec = new PersonelPanel();
                    PersonelPanelsec.personelid = textBox_Personelid.Text;
                    PersonelPanelsec.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Email veya şifrenizi kontrol ediniz.");
                }
                con.Close();
            }
        }