private void btnSil_Click(object sender, EventArgs e) { EBooks silinecekKitap = (EBooks)dataGridView1.SelectedRows[0].DataBoundItem; if (silinecekKitap != null) { DialogResult result = MessageBox.Show("Silmek istediğinize emin misiniz ?", "Uyarı", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { EBooks book = new EBooks(); book.ID = silinecekKitap.ID; if (BLLBooks.Delete(book)) { MessageBox.Show("Silme işleminiz başarıyla tamamlanmıştır."); dataGridView1.DataSource = BLLBooks.GetAll(); Clear(); txtKitapAdi.Focus(); } else { MessageBox.Show("Bir hata oluştu"); } } } else { MessageBox.Show("Lütfen silmek istediğiniz kitabı seçiniz!"); } }
public static EBooks GetIdOnly(int bookID) { SqlCommand cmd = new SqlCommand("spBooks_GetIdOnly", Baglanti.conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@BookID", bookID); Baglanti.conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); EBooks book = new EBooks(); book.Author = new EAuthors(); book.Shelf = new EShelf(); book.Category = new ECategories(); book.Publisher = new EPublisher(); while (dr.Read()) { book.ID = Convert.ToInt32(dr["ID"]); book.Name = dr["Name"].ToString(); book.Author.ID = Convert.ToInt32(dr["AuthorID"]); book.Author.FirstName = dr["FirstName"].ToString(); book.Author.LastName = dr["LastName"].ToString(); book.Author.FullName = book.Author.FirstName + " " + book.Author.LastName; book.DateOfPublish = Convert.ToDateTime(dr["DateOfPublish"]); book.ISBNNO = dr["ISBN No"].ToString(); book.Shelf.ID = Convert.ToInt32(dr["ShelfID"]); book.Shelf.ShelfNo = dr["ShelfNo"].ToString(); book.Publisher.ID = Convert.ToInt32(dr["PublisherID"]); book.Publisher.Name = dr["PublisherName"].ToString(); book.Category.Name = dr["CategoryName"].ToString(); } dr.Close(); Baglanti.conn.Close(); return(book); }
public Book Read(int id) { return(EBooks .AsEnumerable() .Select(Book) .FirstOrDefault()); }
public static List <EBooks> GetAll() { SqlCommand cmd = new SqlCommand("spBooks_GetAll", Baglanti.conn); cmd.CommandType = CommandType.StoredProcedure; Baglanti.conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); List <EBooks> rliste = new List <EBooks>(); while (dr.Read()) { EBooks b = new EBooks(); b.ID = Convert.ToInt32(dr["ID"]); b.Name = dr["Name"].ToString(); b.Author.ID = Convert.ToInt32(dr["AuthorID"]); b.Author.FirstName = dr["FirstName"].ToString(); b.Author.LastName = dr["LastName"].ToString(); b.Author.FullName = b.Author.FirstName + " " + b.Author.LastName; b.DateOfPublish = Convert.ToDateTime(dr["DateOfPublish"]); b.ISBNNO = dr["ISBN No"].ToString(); b.Shelf.ShelfNo = dr["ShelfNo"].ToString(); b.Shelf.ID = Convert.ToInt32(dr["ShelfID"]); b.Publisher.Name = dr["PublisherName"].ToString(); b.Publisher.ID = Convert.ToInt32(dr["PublisherID"]); b.Category.Name = dr["CategoryName"].ToString(); b.Category.ID = Convert.ToInt32(dr["CategoryID"]); b.IsReturned = Convert.ToBoolean(dr["IsReturned"]); rliste.Add(b); } dr.Close(); Baglanti.conn.Close(); return(rliste); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Request.QueryString["ID"] != null) { EBooks book = new EBooks(); book.ID = int.Parse(Request.QueryString["ID"]); bool sonuc = BLLBooks.Delete(book); if (sonuc) { Response.Write("<script>alert('Harika! Silindi!')</script>"); } else { Response.Write("<script>alert('Hay Aksi! Silinemedi!')</script>"); } } rptKitaplar.DataSource = BLLBooks.GetAll(); rptKitaplar.DataBind(); if (Request.QueryString["scs"] != null) { int scsID = Convert.ToInt32(Request.QueryString["scs"].ToString()); if (scsID == 1) { Response.Write("<script>alert('Harika! Güncellendi!');</script>"); } } }
private void btnKaydet_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtKitapAdi.Text) & !string.IsNullOrEmpty(txtISBNNo.Text) & cmbKitapYazari.SelectedIndex != -1 & cmbRafNo.SelectedIndex != -1 & cmbTur.SelectedIndex != -1 & cmbYayinEvi.SelectedIndex != -1) { DateTime dtpBasimTar = Convert.ToDateTime(dtpBasimTarihi.Text); if (dtpBasimTar <= DateTime.Now) { List <EBooks> bookList = BLLBooks.GetAll(); bookList = (from l in bookList where l.ISBNNO.Trim().ToLower().Equals(txtISBNNo.Text.Trim().ToLower()) select l).ToList(); if (bookList.Count == 0) { EBooks book = new EBooks(); book.Author = new EAuthors(); book.Shelf = new EShelf(); book.Name = txtKitapAdi.Text; book.Author.ID = Convert.ToInt32(cmbKitapYazari.SelectedValue); book.Shelf.ID = Convert.ToInt32(cmbRafNo.SelectedValue); book.ISBNNO = txtISBNNo.Text; book.DateOfPublish = dtpBasimTarihi.Value; EBookCategory bookCategory = new EBookCategory(); bookCategory.CategoryID = Convert.ToInt32(cmbTur.SelectedValue); bookCategory.BookID = BLLBooks.InsertNewBook(book); EBookPublisher bookPublisher = new EBookPublisher(); bookPublisher.PublisherID = Convert.ToInt32(cmbYayinEvi.SelectedValue); bookPublisher.BookID = bookCategory.BookID; if (BLLBookCategory.InsertNewBookCategory(bookCategory) & BLLBookPublisher.InsertNewBookPublisher(bookPublisher)) { MessageBox.Show("Kitap kayıt işleminiz başarıyla gerçekleşmiştir!"); dataGridView1.DataSource = BLLBooks.GetAll(); Clear(); txtKitapAdi.Focus(); } else { MessageBox.Show("Bir hata oluştu!"); } } else { MessageBox.Show("Girmiş olduğunuz ISBN Numaralı kitap zaten kayıtlı!"); } } else { MessageBox.Show("Basım Tarihi Bugünün Tarihinden Büyük Olamaz!"); } } else { MessageBox.Show("Eksik bilgi girdiniz. Lütfen kontrol ediniz!"); } }
public Book Read(int id) { return(EBooks .Where(b => b.Id == id) .AsEnumerable() .Select(Book) .FirstOrDefault()); }
public static void Delete(EBooks book) { SqlCommand cmd = new SqlCommand("spBooks_Delete", Baglanti.conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("bookID", book.ID); Baglanti.conn.Open(); cmd.ExecuteNonQuery(); Baglanti.conn.Close(); }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { seciliKitap = (EBooks)dataGridView1.SelectedRows[0].DataBoundItem; txtKitapAdi.Text = seciliKitap.Name; txtISBNNo.Text = seciliKitap.ISBNNO; cmbKitapYazari.SelectedValue = seciliKitap.Author.ID; cmbRafNo.Text = seciliKitap.Shelf.ShelfNo; dtpBasimTarihi.Value = seciliKitap.DateOfPublish; cmbTur.SelectedValue = seciliKitap.Category.ID; cmbYayinEvi.SelectedValue = seciliKitap.Publisher.ID; }
private void btnGuncelle_Click(object sender, EventArgs e) { if (seciliKitap != null) { if (!string.IsNullOrEmpty(txtKitapAdi.Text) & !string.IsNullOrEmpty(txtISBNNo.Text) & cmbKitapYazari.SelectedIndex != -1 & cmbRafNo.SelectedIndex != -1 & cmbTur.SelectedIndex != -1 & cmbYayinEvi.SelectedIndex != -1) { DateTime dtpBasimTar = Convert.ToDateTime(dtpBasimTarihi.Text); if (dtpBasimTar <= DateTime.Now) { EBooks book = new EBooks(); book.Author = new EAuthors(); book.Shelf = new EShelf(); book.Category = new ECategories(); book.Publisher = new EPublisher(); book.ID = Convert.ToInt32(seciliKitap.ID); book.Name = txtKitapAdi.Text; book.Author.ID = Convert.ToInt32(cmbKitapYazari.SelectedValue); book.Shelf.ID = Convert.ToInt32(cmbRafNo.SelectedValue); book.Category.ID = Convert.ToInt32(cmbTur.SelectedValue); book.Publisher.ID = Convert.ToInt32(cmbYayinEvi.SelectedValue); book.DateOfPublish = dtpBasimTarihi.Value; book.ISBNNO = txtISBNNo.Text; bool sonuc = BLLBooks.Update(book); if (sonuc) { MessageBox.Show("Güncelleme başarılı!"); dataGridView1.DataSource = BLLBooks.GetAll(); Clear(); txtKitapAdi.Focus(); } else { MessageBox.Show("Güncelleme başarısız oldu!"); } } else { MessageBox.Show("Basım Tarihi Bugünün Tarihinden Büyük Olamaz!"); } } else { MessageBox.Show("Eksik bilgi girdiniz. Lütfen kontrol ediniz!"); } } else { MessageBox.Show("Güncelleme işlemi yapmak istediğiniz kitabın üzerine çift tıklayarak seçiniz."); } }
EBook EBook(StoreContext context, Book book) { var eBook = EBooks.FirstOrDefault(b => b.Id == book.Id); if (eBook != null) { return(eBook); } eBook = new EBook { RegisteredAt = Clock.GetTime() }; context.Books.Add(eBook); return(eBook); }
protected override void OnNavigatedTo(NavigationEventArgs e) { BookEntry = e.Parameter as EBooks; BookEntry.InitializeViews( ViewGrid, AddGrid, ViewCommand, AddCommand, NameInput, AuthorInput, EditionInput, PressInput, BookTypeInput, BestBookInput, AddButton); }
protected void btnGuncelle_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtKitapAdi.Text) & !string.IsNullOrEmpty(txtISBNNo.Text) & !string.IsNullOrEmpty(dtpBasimTarihi.Text)) { DateTime dtpBasimTar = Convert.ToDateTime(dtpBasimTarihi.Text); if (dtpBasimTar <= DateTime.Now) { EBooks guncellenecek = new EBooks(); guncellenecek.Author = new EAuthors(); guncellenecek.Shelf = new EShelf(); guncellenecek.Category = new ECategories(); guncellenecek.Publisher = new EPublisher(); guncellenecek.ID = int.Parse(Request.QueryString["bookID"]); guncellenecek.Shelf.ID = Convert.ToInt32(cmbRafNo.SelectedValue); guncellenecek.Category.ID = Convert.ToInt32(cmbTur.SelectedValue); guncellenecek.Publisher.ID = Convert.ToInt32(cmbYayinEvi.SelectedValue); guncellenecek.Author.ID = Convert.ToInt32(cmbKitapYazari.SelectedValue); guncellenecek.Name = txtKitapAdi.Text; guncellenecek.ISBNNO = txtISBNNo.Text; guncellenecek.DateOfPublish = DateTime.Parse(dtpBasimTarihi.Text); bool sonuc = BLLBooks.Update(guncellenecek); if (sonuc) { Response.Write("<script>alert('Harika! Güncellendi!');</script>"); Response.Redirect("Kitaplar.aspx?scs=1"); } else { Response.Write("<script>alert('Hay Aksi! Hata Oluştu!')</script>"); } } else { Response.Write("<script>alert('Basım Tarihi Bugünün Tarihinden Büyük Olamaz!')</script>"); dtpBasimTarihi.Text = String.Empty; } } else { Response.Write("<script>alert('Eksik bilgi girdiniz. Lütfen kontrol ediniz!')</script>"); } }
public static void Update(EBooks ubook) { SqlCommand cmd = new SqlCommand("spBooks_Update", Baglanti.conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Name", ubook.Name); cmd.Parameters.AddWithValue("@AuthorID", ubook.Author.ID); cmd.Parameters.AddWithValue("@DateOfPublish", ubook.DateOfPublish); cmd.Parameters.AddWithValue("@ISBNNO", ubook.ISBNNO); cmd.Parameters.AddWithValue("@ShelfID", ubook.Shelf.ID); cmd.Parameters.AddWithValue("@bookID", ubook.ID); cmd.Parameters.AddWithValue("@CategoryID", ubook.Category.ID); cmd.Parameters.AddWithValue("@PublisherID", ubook.Publisher.ID); Baglanti.conn.Open(); cmd.ExecuteNonQuery(); Baglanti.conn.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { cmbKitapYazari.DataSource = BLLAuthors.GetAll(); cmbKitapYazari.DataTextField = "FullName"; cmbKitapYazari.DataValueField = "ID"; cmbKitapYazari.DataBind(); cmbTur.DataSource = BLLCategories.GetAll(); cmbTur.DataTextField = "Name"; cmbTur.DataValueField = "ID"; cmbTur.DataBind(); cmbRafNo.DataSource = BLLShelf.GetAll(); cmbRafNo.DataTextField = "ShelfNo"; cmbRafNo.DataValueField = "ID"; cmbRafNo.DataBind(); cmbYayinEvi.DataSource = BLLPublisher.GetAll(); cmbYayinEvi.DataTextField = "Name"; cmbYayinEvi.DataValueField = "ID"; cmbYayinEvi.DataBind(); int bookID = Convert.ToInt32(Request.QueryString["bookID"].ToString()); EBooks book = new EBooks(); book.Author = new EAuthors(); book.Shelf = new EShelf(); book.Category = new ECategories(); book.Publisher = new EPublisher(); book = BLLBooks.GetIdOnly(bookID); txtKitapAdi.Text = book.Name; txtISBNNo.Text = book.ISBNNO; cmbRafNo.SelectedValue = book.Shelf.ID.ToString(); cmbKitapYazari.SelectedValue = book.Author.ID.ToString(); cmbTur.SelectedValue = book.Category.ID.ToString(); cmbYayinEvi.SelectedValue = book.Publisher.ID.ToString(); dtpBasimTarihi.Text = book.DateOfPublish.ToString(); } }
public static int InsertNewBook(EBooks book) { SqlCommand cmd = new SqlCommand(SP_BOOKS_INSERT, Baglanti.conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Name", book.Name); cmd.Parameters.AddWithValue("@AuthorID", book.Author.ID); cmd.Parameters.AddWithValue("@DateOfPublish", book.DateOfPublish); cmd.Parameters.AddWithValue("@ISBNNO", book.ISBNNO); cmd.Parameters.AddWithValue("@ShelfID", book.Shelf.ID); Baglanti.conn.Open(); int insertedID = (int)cmd.ExecuteScalar(); Baglanti.conn.Close(); return(insertedID); }
public static List <EBooks> GetBookNames() { SqlCommand cmd = new SqlCommand("spBooks_GetOnlyBooks", Baglanti.conn); cmd.CommandType = CommandType.StoredProcedure; Baglanti.conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); List <EBooks> rliste = new List <EBooks>(); while (dr.Read()) { EBooks b = new EBooks(); b.ID = Convert.ToInt32(dr["ID"]); b.Name = dr["Name"].ToString(); b.IsReturned = Convert.ToBoolean(dr["IsReturned"]); rliste.Add(b); } dr.Close(); Baglanti.conn.Close(); return(rliste); }
public static bool Update(EBooks book) { DALBooks.Update(book); return(true); }
protected void btnKaydet_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtKitapAdi.Text) & !string.IsNullOrEmpty(dtpBasimTarihi.Text) & !string.IsNullOrEmpty(txtISBNNo.Text)) { DateTime dtpBasimTar = Convert.ToDateTime(dtpBasimTarihi.Text); if (dtpBasimTar <= DateTime.Now) { List <EBooks> bookList = BLLBooks.GetAll(); bookList = (from l in bookList where l.ISBNNO.Trim().ToLower().Equals(txtISBNNo.Text.Trim().ToLower()) select l).ToList(); if (bookList.Count == 0) { EBooks book = new EBooks(); book.Author = new EAuthors(); book.Shelf = new EShelf(); book.Name = txtKitapAdi.Text; book.Author.ID = Convert.ToInt32(cmbKitapYazari.SelectedValue); book.Shelf.ID = Convert.ToInt32(cmbRafNo.SelectedValue); book.ISBNNO = txtISBNNo.Text; string[] basimTarArr = dtpBasimTarihi.Text.Split(new string[] { "." }, StringSplitOptions.None); book.DateOfPublish = new DateTime(int.Parse(basimTarArr[2]), int.Parse(basimTarArr[1]), int.Parse(basimTarArr[0])); EBookCategory bookCategory = new EBookCategory(); bookCategory.CategoryID = Convert.ToInt32(cmbTur.SelectedValue); bookCategory.BookID = BLLBooks.InsertNewBook(book); EBookPublisher bookPublisher = new EBookPublisher(); bookPublisher.PublisherID = Convert.ToInt32(cmbYayinEvi.SelectedValue); bookPublisher.BookID = bookCategory.BookID; if (BLLBookCategory.InsertNewBookCategory(bookCategory) & BLLBookPublisher.InsertNewBookPublisher(bookPublisher)) { Response.Write("<script>alert('Kitap kayıt işleminiz başarıyla gerçekleşmiştir.')</script>"); } else { Response.Write("<script>alert('Hata Oluştu!')</script>"); } } else { Response.Write("<script>alert('Girmiş olduğunuz ISBN Numaralı kitap zaten kayıtlı!')</script>"); } txtKitapAdi.Text = String.Empty; txtISBNNo.Text = String.Empty; dtpBasimTarihi.Text = String.Empty; cmbKitapYazari.ClearSelection(); cmbRafNo.ClearSelection(); cmbTur.ClearSelection(); cmbYayinEvi.ClearSelection(); txtKitapAdi.Focus(); } else { Response.Write("<script>alert('Basım Tarihi Bugünün Tarihinden Büyük Olamaz!')</script>"); dtpBasimTarihi.Text = String.Empty; } } else { Response.Write("<script>alert('Eksik bilgi girdiniz. Lütfen kontrol ediniz!')</script>"); } }
public static int InsertNewBook(EBooks book) { int bookID = DALBooks.InsertNewBook(book); return(bookID); }
public static bool Delete(EBooks book) { DALBooks.Delete(book); return(true); }