protected void gvReplaies_RowCommand(object sender, GridViewCommandEventArgs e) { LibraryDataContext lib = new LibraryDataContext(); if (e.CommandName == "confrim") { Response.Write("confirim"); int nid = Convert.ToInt32(gvReplaies.Rows[Convert.ToInt32(e.CommandArgument)].Cells[1].Text); Response.Write(nid.ToString()); Replay rep = (from rp in lib.Replays where rp.ID == nid select rp).SingleOrDefault(); rep.Enable = Convert.ToBoolean(rep.Enable) ? false : true; lib.SubmitChanges(); } else if (e.CommandName == "delete") { int nid = Convert.ToInt32(gvReplaies.Rows[Convert.ToInt32(e.CommandArgument)].Cells[1].Text); Response.Write(nid.ToString()); Replay rep = (from rp in lib.Replays where rp.ID == nid select rp).SingleOrDefault(); rep.Deleted = Convert.ToBoolean(rep.Deleted) ? false : true; lib.SubmitChanges(); } gvReplaies.DataBind(); Response.Write(" ca:" + e.CommandArgument.ToString()); }
public void addVisitCount(Int32 nArticleID) { Article oneArticle = (from aa in dcLb.Articles where aa.ID == nArticleID select aa).SingleOrDefault(); oneArticle.VisitCount++; dcLb.SubmitChanges(); }
public void AddEvents(int Id, int ClientId, System.DateTime Date, int BookId) { Events events = new Events(); events.Id = Id; events.ClientId = ClientId; events.Date = Date; events.BookId = BookId; context.Events.InsertOnSubmit(events); context.SubmitChanges(); }
public void AddClient(int Id, string Name, string Surname, int Age) { Clients client = new Clients(); client.Id = Id; client.Name = Name; client.Surname = Surname; client.Age = Age; context.Clients.InsertOnSubmit(client); context.SubmitChanges(); }
public void AddBook(int Id, string Title, string Author, int Pages, int Genre, System.DateTime Date) { Books book = new Books(); book.Id = Id; book.Title = Title; book.Author = Author; book.Pages = Pages; book.Date_of_publication = Date; book.Genre = Genre; context.Books.InsertOnSubmit(book); context.SubmitChanges(); }
public override void Save(Reader item) { Reader reader = GetItem(item.Id); if (reader == null) { context.Readers.InsertOnSubmit(item); } else { reader.FullName = item.FullName; reader.Address = item.Address; } context.SubmitChanges(); }
public override void Save(LibraryDepartment item) { LibraryDepartment department = GetItem(item.Id); if (department == null) { context.LibraryDepartments.InsertOnSubmit(item); } else { department.Name = item.Name; department.IsAbonement = item.IsAbonement; } context.SubmitChanges(); }
public override void Save(Librarian item) { Librarian librarian = GetItem(item.Id); if (librarian == null) { context.Librarians.InsertOnSubmit(item); } else { librarian.FullName = item.FullName; librarian.Department = item.Department; } context.SubmitChanges(); }
public override void Save(Book item) { Book book = GetItem(item.Id); if (book == null) { context.Books.InsertOnSubmit(item); } else { book.Author = item.Author; book.Title = item.Title; book.Year = item.Year; book.Department = item.Department; } context.SubmitChanges(); }
static public bool UpdateReaderLName(int id, string lName) { using (var context = new LibraryDataContext()) { Reader reader = context.Readers.SingleOrDefault(i => i.reader_id == id); reader.reader_l_name = lName; context.SubmitChanges(); return(true); } }
static public bool DeleteBook(string title) { using (var context = new LibraryDataContext()) { Book book = context.Books.FirstOrDefault(i => i.title == title); context.Books.DeleteOnSubmit(book); context.SubmitChanges(); return(true); } }
static public bool UpdateBookGenre(int _id, string genre) { using (var context = new LibraryDataContext()) { Book book = context.Books.SingleOrDefault(i => i.book_id == _id); book.genre = genre; context.SubmitChanges(); return(true); } }
static public bool UpdateBookYear(int _id, int year) { using (var context = new LibraryDataContext()) { Book book = context.Books.SingleOrDefault(i => i.book_id == _id); book.publishment_year = year; context.SubmitChanges(); return(true); } }
public bool UpdateEventType(int id) { using (var context = new LibraryDataContext()) { Event ev = context.Events.SingleOrDefault(e => e.event_id == id); ev.is_borrowing_event = !ev.is_borrowing_event; context.SubmitChanges(); return(true); } }
protected void btnChangePass_Click(object sender, EventArgs e) { //Eza eza = (Eza)Session["CurrentUser"]; LibraryDataContext dcLib = new LibraryDataContext(); SecurityTools st = new SecurityTools(); Eza objEza = dcLib.Ezas.Where(m => m.ID == Convert.ToInt32(ddlEza.SelectedValue)).SingleOrDefault(); objEza.Password = st.toMD5(txtNewPass.Text); dcLib.SubmitChanges(); }
public bool UpdateEventTime(int id, DateTime time) { using (var context = new LibraryDataContext()) { Event ev = context.Events.SingleOrDefault(e => e.event_id == id); ev.event_time = time; context.SubmitChanges(); return(true); } }
public void DeleteBookFromDatabase() { using (var db = new LibraryDataContext()) { Book book = db.Books.FirstOrDefault(b => b.title.Equals("Game of Thrones")); Assert.IsNotNull(book); db.Books.DeleteOnSubmit(book); db.SubmitChanges(); } }
static public bool DeleteReader(string fName, string lName) { using (var context = new LibraryDataContext()) { Reader reader = context.Readers.SingleOrDefault(i => i.reader_f_name.Equals(fName) && i.reader_l_name.Equals(lName)); context.Readers.DeleteOnSubmit(reader); context.SubmitChanges(); return(true); } }
protected void btnRemove_Click(object sender, EventArgs e) { if (lbUserPages.SelectedIndex > -1) { LibraryDataContext dc = new LibraryDataContext(); UserRole rol = dc.UserRoles.Where(r => r.PageID == Convert.ToInt32(lbUserPages.SelectedValue) && r.Eza.ID == Convert.ToInt32(ddlUser.SelectedValue)).Single(); dc.UserRoles.DeleteOnSubmit(rol); dc.SubmitChanges(); LoadRoles(); } }
protected void btnAddRole_Click(object sender, EventArgs e) { LibraryDataContext dcLib = new LibraryDataContext(); UserRole ur = new UserRole(); ur.Enable = true; ur.PageID = Convert.ToInt32(ddlWebPage.SelectedValue); ur.UserID = Convert.ToInt32(ddlUser.SelectedValue); dcLib.UserRoles.InsertOnSubmit(ur); dcLib.SubmitChanges(); gvRole.DataBind(); }
public override void Save(Order item) { Order order = GetItem(item.Id); if (order == null) { context.Orders.InsertOnSubmit(item); } else { order.Book = item.Book; order.Reader = item.Reader; order.Department = item.Department; order.TimeGetBook = item.TimeGetBook; order.LibrarianOpenOrder = item.LibrarianOpenOrder; order.TimeReturnBook = item.TimeReturnBook; order.LibrarianClosedOrder = item.LibrarianClosedOrder; order.Closed = item.Closed; } context.SubmitChanges(); }
static public void DeleteEventsForBook(int bookId) { using (var context = new LibraryDataContext()) { IEnumerable <Event> events = context.Events.Where(e => e.book == bookId); foreach (Event e in events) { context.Events.DeleteOnSubmit(e); context.SubmitChanges(); } } }
protected void btnAddAuthor_Click(object sender, EventArgs e) { LibraryDataContext dcLib = new LibraryDataContext(); Author auth = new Author(); auth.ArticleID = getArticleID(); auth.AuthorName = txtAuthor.Text.Trim(); dcLib.Authors.InsertOnSubmit(auth); dcLib.SubmitChanges(); txtAuthor.Text = ""; gvAuthor.DataBind(); }
protected void btnAddRole_Click(object sender, EventArgs e) { LibraryDataContext dcLib = new LibraryDataContext(); WebPage wp = new WebPage(); wp.PageFile = txtPageFileName.Text; wp.PageTitle = txtPageTitle.Text; dcLib.WebPages.InsertOnSubmit(wp); dcLib.SubmitChanges(); txtPageFileName.Text = txtPageTitle.Text = string.Empty; gvWebPages.DataBind(); }
protected void btnAddSubject_Click(object sender, EventArgs e) { LibraryDataContext dcLib = new LibraryDataContext(); Abstraction abs = new Abstraction(); abs.ArticleID = getArticleID(); abs.Language = usAbstractionLang.selectedLanguage.ID; abs.Abstract = txtAbstraction.Text; dcLib.Abstractions.InsertOnSubmit(abs); dcLib.SubmitChanges(); txtAbstraction.Text = ""; gvAbstraction.DataBind(); }
protected void btnAddTitle_Click(object sender, EventArgs e) { LibraryDataContext dcLib = new LibraryDataContext(); Title ttl = new Title(); ttl.ArticleID = getArticleID(); ttl.Language = ucLangForTitle.selectedLanguage.ID; ttl.Title1 = txtTitle.Text.Trim(); dcLib.Titles.InsertOnSubmit(ttl); dcLib.SubmitChanges(); txtTitle.Text = ""; gvTitles.DataBind(); }
static public bool DeleteEvent(int readerId, int bookId) { using (var context = new LibraryDataContext()) { Event ev = context.Events.FirstOrDefault(e => e.reader == readerId && e.book == bookId); if (ev != null) { context.Events.DeleteOnSubmit(ev); context.SubmitChanges(); return(true); } return(false); } }
static public bool UpdateBookAuthor(int _id, string author) //not sure if id will work with the view { using (var context = new LibraryDataContext()) { Book book = context.Books.SingleOrDefault(i => i.book_id == _id); //if (book != null) always not null? //{ book.author = author; context.SubmitChanges(); return(true); //} //return false; } }
static public bool UpdateBookQuantity(int _id, int q) { using (var context = new LibraryDataContext()) { if (q >= 0) { Book book = context.Books.SingleOrDefault(i => i.book_id == _id); book.quantity = q; context.SubmitChanges(); return(true); } return(false); } }
private void CreateNewArticle() { Article art = new Article(); art.DownCount = 0; art.VisitCount = 0; art.ReadCount = 0; art.AddTime = DateTime.Now; LibraryDataContext dcLib = new LibraryDataContext(); dcLib.Articles.InsertOnSubmit(art); dcLib.SubmitChanges(); hfArticleID.Value = art.ID.ToString(); }