private bool CreateBooks() { using (MyLibraryEntities db = new MyLibraryEntities()) { Book book = new Book(); if (GoChek.IsEmpityOrMaxChar(textBoxBooksName.Text) && GoChek.IsStringValue(textBoxBooksName.Text)) { book.BKName = GoChek.ClearValue; } if (GoChek.IsEmpityOrMaxChar(textBoxBooksPrice.Text) && GoChek.isPrice(textBoxBooksPrice.Text)) { book.Price = Convert.ToDecimal(GoChek.ClearValue); } else { return(false); } book.CatagoryId = (db.Catagories.Where(x => x.CTName == comboBoxBooksCategory.SelectedItem.ToString()).FirstOrDefault().Id); book.BKCount = 10; db.Books.Add(book); AuthorsBook authorsBook = new AuthorsBook(); authorsBook.AuthorId = db.Authors.Where(x => x.AUTName == comboBoxBooksAuthors.SelectedItem.ToString()).FirstOrDefault().Id; authorsBook.BookId = book.Id; db.AuthorsBooks.Add(authorsBook); return(GoChek.isSave(db.SaveChanges())); } }
private void FillComboAuthor() { using (MyLibraryEntities db = new MyLibraryEntities()) { this.comboBoxBooksAuthors.DataSource = db.Authors.Select(b => b.AUTName).ToList(); } }
public ActionResult Index(KitaplarModel model) { //modelden gelen page e gore deger atadık eger bos ise 1 degerini atadık int pageIndex = model.Page ?? 1; db = new MyLibraryEntities(); model.Kitaplar = (from kitap in db.Mylibrary.Where(x => (String.IsNullOrEmpty(model.KitapAdi) || x.KitapAdi.Contains(model.KitapAdi)) && (String.IsNullOrEmpty(model.Yazar) || x.Yazar.Contains(model.Yazar))).OrderBy(x => x.ID) select new KitaplarListe { KitapAdi = kitap.KitapAdi, Yazar = kitap.Yazar, Yayinevi = kitap.Yayinevi, SayfaNo = kitap.SayfaNo, AldigimTarih = kitap.AldigimTarih, Turu = kitap.Turu, ID = kitap.ID, Okundu = kitap.Okundu }).OrderByDescending(x => x.ID).ToPagedList(pageIndex, 5); //istek ajx üzerinden gelirse yanı sayfanın yenilenmesine gerek yoksa yani ilk kez acılmamışsa if (Request.IsAjaxRequest()) { return(PartialView("_Kitaplar", model)); } //sayfa ilk kez acılıyorsa yani istek ajax degilse else { return(View(model)); } //return View(GetKitaplar()); }
public static int TotalBookCount() { using (MyLibraryEntities db = new MyLibraryEntities()) { return(db.Book.Count()); } }
public static List <Author> ListAuthors() { using (MyLibraryEntities db = new MyLibraryEntities()) { return(db.Author.ToList()); } }
private void FillComboCatagory() { using (MyLibraryEntities db = new MyLibraryEntities()) { this.comboBoxBooksCategory.DataSource = db.Catagories.Select(b => b.CTName).ToList(); } }
private bool UpdateAuthor() { using (MyLibraryEntities db = new MyLibraryEntities()) { Author author = db.Authors.Where(x => x.Id == SelectedRowId).FirstOrDefault(); if (GoChek.IsEmpityOrMaxChar(textBoxAuthorsName.Text) && GoChek.IsStringValue(textBoxAuthorsName.Text)) { author.AUTName = GoChek.ClearValue; } else { return(false); } if (GoChek.IsEmpityOrMaxChar(textBoxAuthorsSurname.Text) && GoChek.IsStringValue(textBoxAuthorsSurname.Text)) { author.Surname = GoChek.ClearValue; } else { return(false); } return(GoChek.isSave(db.SaveChanges())); } }
public static List <Person> ListPersons() { using (MyLibraryEntities db = new MyLibraryEntities()) { return(db.Person.ToList()); } }
private bool CreateAuthors() { using (MyLibraryEntities db = new MyLibraryEntities()) { Author tableAuthor = new Author(); if (GoChek.IsEmpityOrMaxChar(textBoxAuthorsName.Text) && GoChek.IsStringValue(textBoxAuthorsName.Text)) { tableAuthor.AUTName = GoChek.ClearValue; } else { return(false); } if (GoChek.IsEmpityOrMaxChar(textBoxAuthorsSurname.Text) && GoChek.IsStringValue(textBoxAuthorsSurname.Text)) { tableAuthor.Surname = GoChek.ClearValue; } else { return(false); } db.Authors.Add(tableAuthor); return(GoChek.isSave(db.SaveChanges())); } }
public static int TotalPersonCount() { using (MyLibraryEntities db = new MyLibraryEntities()) { return(db.Person.Count()); } }
public static bool AddBookToMyLibrary(int bookID, int personID) { try { using (MyLibraryEntities db = new MyLibraryEntities()) { Book book = db.Book.Where(b => b.BookID == bookID).FirstOrDefault(); //seçilen kitabın kaydı var mı? Person person = db.Person.Where(p => p.PersonID == personID).FirstOrDefault(); // giris yapan kisi var mı? if (book is Book && person is Person) { person.Books.Add(book); db.SaveChanges(); return(true); } return(false); } } catch (Exception e) { throw new Exception(e.Message); } }
public static int TotalGenreCount() { using (MyLibraryEntities db = new MyLibraryEntities()) { return(db.Genre.Count()); } }
public static int TotalAuthorCount() { using (MyLibraryEntities db = new MyLibraryEntities()) { return(db.Author.Count()); } }
public static List <Genre> ListGenres() { using (MyLibraryEntities db = new MyLibraryEntities()) { return(db.Genre.ToList()); } }
public static void AddAuthor(Author author) { using (MyLibraryEntities db = new MyLibraryEntities()) { db.Author.Add(author); db.SaveChanges(); } }
public static void DeleteGenre(Genre genre) { using (MyLibraryEntities db = new MyLibraryEntities()) { db.Genre.Remove(genre); db.SaveChanges(); } }
public static void AddGenre(Genre genre) { using (MyLibraryEntities db = new MyLibraryEntities()) { db.Genre.Add(genre); db.SaveChanges(); } }
public static void DeleteAuthor(int authorID) { using (MyLibraryEntities db = new MyLibraryEntities()) { Author author = db.Author.Where(a => a.AuthorID == authorID).FirstOrDefault(); db.Author.Remove(author); db.SaveChanges(); } }
private void GridCategories_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { ChangeBtnToUpdate(); SelectedRowId = Convert.ToInt32(GridCategories.Rows[e.RowIndex].Cells[0].Value); using (MyLibraryEntities db = new MyLibraryEntities()) { this.textBoxCategoriesName.Text = db.Catagories.Where(x => x.Id == SelectedRowId).FirstOrDefault().CTName; } }
public static void DeleteBook(int bookID) { using (MyLibraryEntities db = new MyLibraryEntities()) { Book book = db.Book.Where(s => s.BookID == bookID).FirstOrDefault(); db.Book.Remove(book); db.SaveChanges(); } }
private void GridAuthors_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { ChangeBtnToUpdate(); SelectedRowId = Convert.ToInt32(GridAuthors.Rows[e.RowIndex].Cells[0].Value); using (MyLibraryEntities db = new MyLibraryEntities()) { Author authors = db.Authors.Where(x => x.Id == SelectedRowId).FirstOrDefault(); this.textBoxAuthorsName.Text = authors.AUTName; this.textBoxAuthorsSurname.Text = authors.Surname; } }
private void ClientBtn_Click(object sender, EventArgs e) { using (var db = new MyLibraryEntities()) { string clientSearch = txtClientSearch.Text.ToLower(); List <Models.Client> client = db.Clients.Where(c => c.Name.ToLower().Contains(clientSearch)).ToList(); dataGridView1.Rows.Clear(); foreach (var item in client) { dataGridView1.Rows.Add(item.Id, item.Name, item.Surname, item.Email, item.Phone, item.Status); } } }
private void GridBooks_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { ChangeBtnToUpdate(); SelectedRowId = Convert.ToInt32(GridBooks.Rows[e.RowIndex].Cells[0].Value); using (MyLibraryEntities db = new MyLibraryEntities()) { Book book = db.Books.Where(x => x.Id == SelectedRowId).FirstOrDefault(); this.textBoxBooksName.Text = book.BKName; this.textBoxBooksPrice.Text = book.Price.ToString(); this.comboBoxBooksAuthors.SelectedItem = db.Authors.Where(x => x.AUTName == GridBooks.Rows[e.RowIndex].Cells[2].Value.ToString()); this.comboBoxBooksCategory.SelectedItem = db.Catagories.Where(x => x.CTName == GridBooks.Rows[e.RowIndex].Cells[4].Value.ToString()); } }
private void BookBtn_Click(object sender, EventArgs e) { using (var db = new MyLibraryEntities()) { string bookSearch = txtBookSearch.Text.ToLower(); List <Models.Book> books = db.Books.Where(c => c.Name.ToLower().Contains(bookSearch)).ToList(); dataGridView2.Rows.Clear(); foreach (var item in books) { dataGridView2.Rows.Add(item.Name, item.AuthorsBooks, item.Price); } } }
private void GridClients_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { ChangeBtnToUpdate(); SelectedRowId = Convert.ToInt32(GridClients.Rows[e.RowIndex].Cells[0].Value); using (MyLibraryEntities db = new MyLibraryEntities()) { Client client = db.Clients.Where(x => x.Id == SelectedRowId).FirstOrDefault(); this.textBoxClientsName.Text = client.CLName; this.textBoxClientsSurname.Text = client.Surname; this.textBoxClientsPhone.Text = client.Phone; this.textBoxClientsEmail.Text = client.Email; } }
public static Person Login(string email, string password) { using (MyLibraryEntities db = new MyLibraryEntities()) { Person person = db.Person.Where(p => p.Email.Equals(email)).Where(p => p.Password.Equals(password)).FirstOrDefault(); if (person != null) { return(person); } return(person); } }
private void FillCategoriesGrid() { GridCategories.Rows.Clear(); using (MyLibraryEntities db = new MyLibraryEntities()) { List <Catagory> catagories = db.Catagories.ToList(); foreach (var item in catagories) { GridCategories.Rows.Add(item.Id, item.CTName); } } }
private void FillClientsGrid() { GridClients.Rows.Clear(); using (MyLibraryEntities db = new MyLibraryEntities()) { List <Client> clients = db.Clients.ToList(); foreach (var item in clients) { GridClients.Rows.Add(item.Id, item.CLName, item.Surname, item.Phone, item.Email, item.Status); } } }
private void FillAuthorsGrid() { GridAuthors.Rows.Clear(); using (MyLibraryEntities db = new MyLibraryEntities()) { List <Author> authors = db.Authors.ToList(); foreach (var item in authors) { GridAuthors.Rows.Add(item.Id, item.AUTName, item.Surname); } } }
public string Sil(int id) { try { db = new MyLibraryEntities(); var kitap = db.Mylibrary.FirstOrDefault(x => x.ID == id); db.Mylibrary.Remove(kitap); db.SaveChanges(); //sectigin satıları try catch icine almak icin ks tuslarına bas try sec return("1"); } catch { return("-1"); } }