protected void Button1_Click(object sender, EventArgs e) { veritabani vt = new veritabani(); SqlConnection conn = new SqlConnection(); conn = vt.Connection(); String sorgu1 = "INSERT INTO musteri (hno, ad,soyad,sifre,hesap,email,adres,tel,musteri_tipi) VALUES (@hno, @ad, @soyad, @sifre,@hesap,@email,@adres,@tel,@musteri_tipi)"; String sorgu2 = "SELECT hno FROM musteri ORDER BY hno DESC"; SqlCommand cmd = new SqlCommand(sorgu1, conn); DataRow row = vt.GetDataRow(sorgu2); int yeni_hsno = Convert.ToInt32(row["hno"].ToString()) + 1; Random randoms = new Random(); int sifre = randoms.Next(1000, 10000); try { cmd.Parameters.AddWithValue("hno", yeni_hsno); cmd.Parameters.AddWithValue("ad", UserName.Text); cmd.Parameters.AddWithValue("soyad", soyad.Text); cmd.Parameters.AddWithValue("sifre", sifre); cmd.Parameters.AddWithValue("hesap", 1000000); cmd.Parameters.AddWithValue("email", email.Text); cmd.Parameters.AddWithValue("tel", tel.Text); cmd.Parameters.AddWithValue("adres", Adres.Text); cmd.Parameters.AddWithValue("musteri_tipi", bireyselkurumsal.SelectedIndex); cmd.ExecuteNonQuery(); //mail yollama string icerik = "BGABANK Ultimate Kullanıcı Bilgileriniz <br/><br/>" + "Ad Soyad:" + UserName.Text + " " + soyad.Text + "<br/>Müşteri numarası: " + yeni_hsno + "<br/>" + "Şifre: " + sifre; Mail mail = new Mail(); mail.hesapbilgi_gonder(icerik, email.Text); Label1.Text = yeni_hsno.ToString(); Metotlar metot = new Metotlar(); int sonuc1 = 0; sonuc1 = metot.hareket_olustur("1000000", "Hesap Açma", yeni_hsno.ToString(), "1000000"); } catch { Label1.Text = "Başvuru alınamadı.."; } finally { Response.Redirect("kayitalindi.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { Metotlar methods = new Metotlar(); veritabani vt = new veritabani(); #region The code-piece inserting the news to the database string sqlQuery; try { string rssUrl = "http://www.trthaber.com/sondakika.rss"; XmlDocument xmlVerisi = new XmlDocument(); for (int i = 0; i < 3; i++) { xmlVerisi.Load(rssUrl); } Newsitem News = new Newsitem(); for (int i = 0; i < 3; i++) { News.Title = xmlVerisi.SelectNodes("rss/channel/item/title")[i].InnerText; News.Description = xmlVerisi.SelectNodes("rss/channel/item/description")[i].InnerText; News.ImageURL = xmlVerisi.SelectNodes("rss/channel/item/imageUrl")[i].InnerText; News.Link = xmlVerisi.SelectNodes("rss/channel/item/link")[i].InnerText; News.Title = methods.TirnaklariKaldir(News.Title); News.Description = methods.TirnaklariKaldir(News.Description); News.Description = methods.BoslukKaldır(News.Description); if (i == 0 && News.Title != null && News.Link != null && News.Description != null && News.ImageURL != null) { vt.Connection(); sqlQuery = "select * from haberler"; int count = vt.Command(sqlQuery); if (count == -1) { vt.Connection(); vt.Command("DELETE FROM haberler"); for (int k = 0; k < 3; k++) { File.Delete(Server.MapPath("~/img/YeniHaber" + k.ToString() + ".jpg")); } } } WebClient webClient = new WebClient(); News.FotoYol = "/img/YeniHaber" + i.ToString() + ".jpg"; webClient.DownloadFile(News.ImageURL, Server.MapPath("~" + News.FotoYol)); sqlQuery = "INSERT INTO haberler (haber_baslik, haber_detay, haber_foto_link, haber_link, haber_foto_yol) VALUES('" + News.Title + "','" + News.Description + "','" + News.ImageURL + "','" + News.Link + "','" + News.FotoYol + "')"; vt.Connection(); vt.Command(sqlQuery); } } catch (Exception ex) { ex.Message.ToString(); } #endregion #region The code-piece showing the news on the page vt.Connection(); SqlDataReader dr = vt.GetDataReader("SELECT * FROM haberler"); int j = 0; while (dr.Read()) { if (j == 0) { NewsTitle1.Text = dr["haber_baslik"].ToString(); NewsDescription1.Text = dr["haber_detay"].ToString(); NewsImage1.ImageUrl = dr["haber_foto_yol"].ToString(); NewsLink1.NavigateUrl = dr["haber_link"].ToString(); } else if (j == 1) { NewsTitle2.Text = dr["haber_baslik"].ToString(); NewsDescription2.Text = dr["haber_detay"].ToString(); NewsImage2.ImageUrl = dr["haber_foto_yol"].ToString(); NewsLink2.NavigateUrl = dr["haber_link"].ToString(); } else { NewsTitle3.Text = dr["haber_baslik"].ToString(); NewsDescription3.Text = dr["haber_detay"].ToString(); NewsImage3.ImageUrl = dr["haber_foto_yol"].ToString(); NewsLink3.NavigateUrl = dr["haber_link"].ToString(); } j++; } dr.Close(); #endregion }