コード例 #1
0
 protected void btnGonder_Click(object sender, EventArgs e)
 {
     hata = false;
     if (txtUser.Text.Trim() == "" && txtTC.Text.Trim() == "" && txtMail.Text.Trim() == "")
     {
         mesajTitle = "Eksik bilgi girişi...";
         mesajText  = "Lütfen gerekli bilgileri eksiksiz girin...";
         txtUser.Focus();
         hata = true;
     }
     if (!hata)
     {
         try
         {
             otobusEntities ent          = new otobusEntities();
             var            musteriBilgi = (from s in ent.musteri
                                            where s.kadi == txtUser.Text || s.tckn == txtTC.Text || s.eposta == txtMail.Text
                                            select new { s.pass, s.eposta, s.kadi }).First();
             if (musteriBilgi.eposta != null)
             {
                 MailMessage mail       = new MailMessage();
                 SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");
                 mail.From = new MailAddress("*****@*****.**");
                 mail.To.Add(musteriBilgi.eposta);
                 mail.Subject           = "Şifre İstek";
                 mail.Body              = "Kullanıcı Adı:" + musteriBilgi.kadi + "<br />" + "Şifre:" + musteriBilgi.pass + "<br />" + "DİS Turizm iyi yolculuklar diler";
                 mail.IsBodyHtml        = true;
                 SmtpServer.Port        = 587;
                 SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "sonysony1907");
                 SmtpServer.EnableSsl   = true;
                 SmtpServer.Send(mail);
                 Response.Redirect("/login/Login.aspx");
             }
             else
             {
                 hata       = true;
                 mesajTitle = "Bilgilerinizde eposta adresiniz eksik!!!";
                 mesajText  = "Eposta bilginiz bulunmadığı için şifreniz müşteri hizmetlerinde veya DİS Turizm acentalarından alabilirsiniz...";
                 txtUser.Focus();
             }
         }
         catch (Exception)
         {
             hata       = true;
             mesajTitle = "Girilen bilgilerle uyuşan bir hesap bulunamadı";
             mesajText  = "";
             txtUser.Focus();
         }
     }
     divMesaj.Visible = hata;
 }
コード例 #2
0
        protected void btnGirisYap_Click(object sender, EventArgs e)
        {
            hata = false;
            if (txtUser.Text.Trim() == "")
            {
                mesajTitle = "Eksik bilgi girişi...";
                mesajText  = "Lütfen gerekli bilgileri eksiksiz girin...";
                txtUser.Focus();
                hata = true;
            }
            else if (txtPass.Text.Trim() == "")
            {
                mesajTitle = "Eksik bilgi girişi...";
                mesajText  = "Lütfen gerekli bilgileri eksiksiz girin...";
                txtPass.Focus();
                hata = true;
            }
            if (!hata)
            {
                otobusEntities ent = new otobusEntities();
                try
                {
                    var mus = (from m in ent.musteri
                               where m.kadi == txtUser.Text.Trim() && m.pass == txtPass.Text.Trim() && m.durum == true
                               select new { m.musteriID, m.cinsiyet }).First();
                    if (mus.cinsiyet != null && mus.cinsiyet != "")
                    {
                        Session["cinsiyet"]  = Convert.ToString(mus.cinsiyet);
                        Session["musteriID"] = Convert.ToString(mus.musteriID);
                        Response.Redirect("/BiletIslemleri.aspx");
                    }
                    else
                    {
                        mesajTitle = "Hatalı  Giriş";
                        mesajText  = "Lütfen bilgileriniz kontrol edip tekrar deneyiniz.";
                        hata       = true;
                    }
                }
                catch (Exception)
                {
                    mesajTitle = "Hatalı  Giriş";
                    mesajText  = "Lütfen bilgileriniz kontrol edip tekrar deneyiniz.";
                    txtUser.Focus();
                    hata = true;
                }
                //SqlConnection conn = new SqlConnection(genel.connStr);
                //SqlCommand comm = new SqlCommand("select * from musteri where kadi=@u and pass=@p", conn);
                //SqlDataReader dr;
                //comm.Parameters.AddWithValue("@u", txtUser.Text);
                //comm.Parameters.AddWithValue("@p", txtPass.Text);
                //if (conn.State == ConnectionState.Closed) conn.Open();
                //try
                //{
                //    dr = comm.ExecuteReader();
                //    if (dr.Read())
                //    {
                //        Session["cinsiyet"] = Convert.ToString(dr["cinsiyet"]);
                //        Session["musteriID"] = Convert.ToString(dr["musteriID"]);
                //        Response.Redirect("/Bilet.aspx");
                //    }
                //    else
                //    {
                //        mesajTitle = "Hatalı Giriş...";
                //        mesajText = "Lütfen Kontrol Edip Tekrar Deneyiniz...";
                //        hata = true;
                //        txtUser.Focus();
                //    }
                //    dr.Close();
                //}
                //catch (Exception)
                //{
                //    mesajTitle = "Opss... Bir Hata oluştu.";
                //    mesajText = "Daha zeki olmalısınız ve inputlarımızla oynamamalısınız... :)";
                //    hata = true;
                //}
                //finally { conn.Close(); }
            }

            divMesaj.Visible = hata;
        }