public static EKitap Select(int _ID) { EKitap item = null; try { SqlCommand com = new SqlCommand("Kitap_Select ", Baglanti.Con); com.CommandType = CommandType.StoredProcedure; if (com.Connection.State != ConnectionState.Open) { com.Connection.Open(); } com.Parameters.AddWithValue("Id", _ID); SqlDataReader rdr = com.ExecuteReader(); if (rdr.HasRows) { while (rdr.Read()) { item = new EKitap(); item.ID = Convert.ToInt32(rdr["ID"]); item.Adi = rdr["ADI"].ToString(); item.Kategoriİd = Convert.ToInt32(rdr["Kategoriİd"]); item.SayfaSayisi = Convert.ToInt16(rdr["Sayfasayisi"]); } } } catch { item = null; } return(item); }
private void btSil_Click(object sender, EventArgs e) { DialogResult durum = MessageBox.Show("Kaydı silmek istediğinizden eminmisiniz?", "Silme Onayı", MessageBoxButtons.YesNo); if (DialogResult.Yes == durum) { EKitap kitapItem = new EKitap(); kitapItem.ID = Convert.ToInt32(txtID.Text); kitapItem.Kategoriİd = Convert.ToInt32(cbKategori.SelectedValue); kitapItem.SayfaSayisi = Convert.ToInt16(txtSayfaS.Text); kitapItem.Adi = txtAdi.Text; kitapItem.Yazar = txtYazar.Text; if (BLLKitap.Delete(kitapItem.ID) == true) { kitapListele(); MessageBox.Show("Kitap basarıyla silindi!!"); txtAdi.ResetText(); txtYazar.ResetText(); txtSayfaS.ResetText(); txtID.ResetText(); } else { MessageBox.Show("Kitap silmede bir hata meydana geldi lütfen destek talep ediniz.Hata kodu : #98565"); } } }
public static bool Update(EKitap item) { bool sonuc = false; try { SqlCommand com = new SqlCommand("Kitap_Update ", Baglanti.Con); com.CommandType = CommandType.StoredProcedure; if (com.Connection.State != ConnectionState.Open) { com.Connection.Open(); } com.Parameters.AddWithValue("ID", item.ID); com.Parameters.AddWithValue("Adi", item.Adi); com.Parameters.AddWithValue("Kategoriİd", item.Kategoriİd); com.Parameters.AddWithValue("SayfaSayisi", item.SayfaSayisi); com.Parameters.AddWithValue("Yazar", item.Yazar); sonuc = com.ExecuteNonQuery() > 0; } catch (Exception ex) { sonuc = false; } return(sonuc); }
public static int Insert(EKitap item) { int etkilenen = 0; try { SqlCommand com = new SqlCommand("Kitap_Insert ", Baglanti.Con); com.CommandType = CommandType.StoredProcedure; if (com.Connection.State != ConnectionState.Open) { com.Connection.Open(); } com.Parameters.AddWithValue("Adi", item.Adi); com.Parameters.AddWithValue("Kategoriİd", item.Kategoriİd); com.Parameters.AddWithValue("SayfaSayisi", item.SayfaSayisi); com.Parameters.AddWithValue("YAZAR", item.Yazar); etkilenen = com.ExecuteNonQuery(); } catch (Exception ex) { etkilenen = -1; } return(etkilenen); }
public static bool Update(EKitap item) { if (item.Adi != null && item.Adi.Trim().Length > 0 && item.Yazar != null && item.Yazar.Trim().Length > 0 && item.ID > 0 && item.Kategoriİd > 0 && item.SayfaSayisi > 0) { return(FKitap.Update(item)); } return(false); }
public static int İnsert(EKitap item) { if (item.Adi != null && item.Adi.Trim().Length > 0 && item.Yazar != null && item.Yazar.Trim().Length > 0 && item.SayfaSayisi > 0) { return(FKitap.Insert(item)); } return(-1); }
public ActionResult KitapEkle(EKitap k, HttpPostedFileBase EKitapURL, List <int> SecilenKonular) { var klasor = "/Content/EkitapUpload/"; string kaydedilecekIsim = ""; try { #region dosyayiKaydet if (EKitapURL != null && EKitapURL.ContentLength > 0) { var kitapAdi = EKitapURL.FileName; kaydedilecekIsim = kitapAdi; if (System.IO.File.Exists(klasor + kitapAdi)) { System.IO.FileInfo bilgi = new System.IO.FileInfo(klasor + kitapAdi); var sadeceDosyaAdi = bilgi.Name.Replace(bilgi.Extension, ""); string[] bulunanlar = System.IO.Directory.GetFiles(klasor, sadeceDosyaAdi + ".*", System.IO.SearchOption.AllDirectories); var kacTane = bulunanlar.Length; kaydedilecekIsim = sadeceDosyaAdi + "-" + kacTane + "." + bilgi.Extension; } var path = Server.MapPath(klasor); EKitapURL.SaveAs(path + kaydedilecekIsim); } #endregion } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); } k.EKitapURL = kaydedilecekIsim; /* * if (SecilenKonular == null || SecilenKonular.Count == 0) * ModelState.AddModelError(string.Empty, "Bir konu seciniz."); * else * using (KonuRep kr = new KonuRep()) * k.Konular = kr.GetAll().Where(x => SecilenKonular.Any(a => a == x.KonuID)).ToList(); */ if (ModelState.IsValid) { new EkitapRep().Insert(k); ViewBag.EklendiMi = true; } return(View()); }
public static List <EKitap> SelectList() { List <EKitap> itemlist = null; try { SqlCommand com = new SqlCommand("Kitap_SelectList ", Baglanti.Con) { CommandType = CommandType.StoredProcedure }; if (com.Connection.State != ConnectionState.Open) { com.Connection.Open(); } SqlDataReader rdr = com.ExecuteReader(); if (rdr.HasRows) { itemlist = new List <EKitap>(); while (rdr.Read()) { EKitap item = new EKitap(); item = new EKitap(); item.ID = Convert.ToInt32(rdr["ID"]); item.Adi = rdr["ADI"].ToString(); item.Yazar = rdr["Yazar"].ToString(); item.Kategoriİd = Convert.ToInt32(rdr["Kategoriİd"]); item.SayfaSayisi = Convert.ToInt16(rdr["Sayfasayisi"]); itemlist.Add(item); } } rdr.Close(); } catch (Exception ex) { itemlist = null; } return(itemlist); }
private void btEkle_Click(object sender, EventArgs e) { EKitap kitapItem = new EKitap(); kitapItem.Kategoriİd = Convert.ToInt32(cbKategori.SelectedValue); kitapItem.SayfaSayisi = Convert.ToInt16(txtSayfaS.Text); kitapItem.Adi = txtAdi.Text; kitapItem.Yazar = txtYazar.Text; if (BLLKitap.İnsert(kitapItem) > 0) { kitapListele(); MessageBox.Show("Kitap ekleme işlemi başarılı!!"); txtAdi.ResetText(); txtYazar.ResetText(); txtSayfaS.ResetText(); txtID.ResetText(); } else { MessageBox.Show("Kitap eklerken bir hata meydana geldi lütfen destek talep ediniz.Hata kodu : #98565"); } }
private void btguncelle_Click(object sender, EventArgs e) { EKitap kitapItem = new EKitap(); kitapItem.ID = Convert.ToInt32(txtID.Text); kitapItem.Kategoriİd = Convert.ToInt32(cbKategori.SelectedValue); kitapItem.SayfaSayisi = Convert.ToInt16(txtSayfaS.Text); kitapItem.Adi = txtAdi.Text; kitapItem.Yazar = txtYazar.Text; if (BLLKitap.Update(kitapItem) == true) { kitapListele(); MessageBox.Show("Kitap bilgileri guncellestirildi!!"); txtAdi.ResetText(); txtYazar.ResetText(); txtSayfaS.ResetText(); txtID.ResetText(); } else { MessageBox.Show("Kitap guncellestirirken bir hata meydana geldi lütfen destek talep ediniz.Hata kodu : #98565"); } }
public ActionResult Duzenle(EKitap k, HttpPostedFileBase EKitapURL, List <int> SecilenKonular) { string kaydedilecekIsim = ""; var klasor = "/Content/EkitapUpload/"; try { #region dosyayiKaydet if (k.EKitapURL != null) { var kitapAdi = EKitapURL.FileName; kaydedilecekIsim = kitapAdi; if (System.IO.File.Exists(klasor + kitapAdi)) { System.IO.FileInfo bilgi = new System.IO.FileInfo(klasor + kitapAdi); var sadeceDosyaAdi = bilgi.Name.Replace(bilgi.Extension, ""); string[] bulunanlar = System.IO.Directory.GetFiles(klasor, sadeceDosyaAdi + ".*", System.IO.SearchOption.AllDirectories); var kacTane = bulunanlar.Length; kaydedilecekIsim = sadeceDosyaAdi + "-" + kacTane + "." + bilgi.Extension; } var path = Server.MapPath(klasor); EKitapURL.SaveAs(path + kaydedilecekIsim); } #endregion } catch (Exception ex) { LogHelper.Log(ex); ModelState.AddModelError(string.Empty, ex.Message); } if (SecilenKonular == null || SecilenKonular.Count == 0) { ModelState.AddModelError(string.Empty, "Bir konu seciniz."); } if (ModelState.IsValid) { EkitapRep er = new EkitapRep(); EKitap kitap = er.GetById(k.EKitapID); if (!string.IsNullOrEmpty(kaydedilecekIsim)) { try { if (System.IO.File.Exists(klasor + kitap.EKitapURL)) { System.IO.File.Delete(klasor + kitap.EKitapURL); } } catch (Exception ex) { LogHelper.Log(ex); } kitap.EKitapURL = kaydedilecekIsim; } kitap.Baslik = k.Baslik; kitap.Description = k.Description; kitap.EKitapIcerik = k.EKitapIcerik; kitap.Keywords = k.Keywords; kitap.KisaAciklama = k.KisaAciklama; KonuRep kr = new KonuRep(); kitap.Konular = kr.GetAll().Where(x => SecilenKonular.Any(a => a == x.KonuID)).ToList(); kitap.Title = k.Title; er.Update(kitap); return(RedirectToAction("Index")); } return(View()); }