Esempio n. 1
0
        public void Delete_Book()
        {
            LibraryDBDataContext db = new LibraryDBDataContext();

            tbl_Borrow temp = (from T in db.tbl_Borrows
                               where T.BookID == this.ID
                               select T
                               ).FirstOrDefault();

            if (temp != null)
            {
                MessageBox.Show("Someone has this Book!");
                return;
            }
            else
            {
                tbl_Book B = (from T in db.tbl_Books
                              where T.ID == this.ID
                              select T).FirstOrDefault();
                tbl_Edition e = (from E in db.tbl_Editions
                                 where E.BookID == this.ID
                                 select E).FirstOrDefault();

                if (e != null)
                {
                    db.tbl_Editions.DeleteOnSubmit(e);
                }
                db.tbl_Books.DeleteOnSubmit(B);
                db.SubmitChanges();
            }
        }
Esempio n. 2
0
        public void SaveChanges()
        {
            LibraryDBDataContext db = new LibraryDBDataContext();
            var editAdmin           = (from B in db.tbl_AdminDetails
                                       where B.UserID == this.ID
                                       select B).FirstOrDefault();
            var editUser = (from U in db.tbl_Users
                            where U.ID == this.ID
                            select U).FirstOrDefault();

            editUser.Username    = this.Username;
            editUser.Password    = this.Password;
            editUser.FName       = this.FName;
            editUser.SName       = this.SName;
            editUser.Birthdate   = this.Birthdate;
            editUser.Address     = this.Address;
            editUser.Email       = this.Email;
            editUser.PhoneNumber = this.PhoneNumber;
            editUser.NationalID  = this.NationalID;
            editUser.RoleName    = this.Rolename.ToString();
            editAdmin.Shift      = this.Shift;
            editAdmin.Salary     = this.Salary;
            editAdmin.HireDate   = this.HireDate;

            db.SubmitChanges();
        }
Esempio n. 3
0
        public void SaveChanges()
        {
            LibraryDBDataContext db = new LibraryDBDataContext();
            var editStudent         = (from B in db.tbl_Students
                                       where B.User_ID == this.ID
                                       select B).FirstOrDefault();
            var editUser = (from U in db.tbl_Users
                            where U.ID == this.ID
                            select U).FirstOrDefault();

            editUser.Username         = this.Username;
            editUser.Password         = this.Password;
            editUser.FName            = this.FName;
            editUser.SName            = this.SName;
            editUser.Birthdate        = this.Birthdate;
            editUser.Address          = this.Address;
            editUser.Email            = this.Email;
            editUser.PhoneNumber      = this.PhoneNumber;
            editUser.NationalID       = this.NationalID;
            editUser.RoleName         = this.Rolename.ToString();
            editStudent.University    = this.University;
            editStudent.University_ID = this.University_ID;
            editStudent.GPA           = this.GPA;

            db.SubmitChanges();
        }
Esempio n. 4
0
        public void saveChanges()
        {
            LibraryDBDataContext db = new LibraryDBDataContext();
            var editBook            = (from B in db.tbl_Books
                                       where B.ID == this.ID
                                       select B).FirstOrDefault();
            var oldEdition = (from E in db.tbl_Editions
                              where E.BookID == this.ID
                              select E).FirstOrDefault();
            tbl_Edition newEdition = new tbl_Edition();


            editBook.ISBN        = this.ISBN;
            editBook.Name        = this.Name;
            editBook.PublisherID = this.Publisher.ID;
            editBook.AuthorID    = this.Author.ID; //l stren dol 7atet feehom l touch bta3y
            editBook.Genre       = this.Genre;
            editBook.Copies      = this.Copies;

            if (oldEdition != null && this.Version != null)
            {
                newEdition.BookID  = oldEdition.BookID;
                newEdition.Pages   = this.Pages;
                newEdition.Version = this.Version;
                db.tbl_Editions.DeleteOnSubmit(oldEdition);
                db.tbl_Editions.InsertOnSubmit(newEdition);
            }

            db.SubmitChanges();
        }
        public void AddBookMySelf(BookSelf bookself)
        {
            //Console.WriteLine(""+user.UserId+""+user.UserName+""+user.Title);

            LibraryDBDataContext cntx = new LibraryDBDataContext(Library_Managment_System.Data.Properties.Settings.Default.librarydbConnectionString);

            cntx.BookSelfs.InsertOnSubmit(bookself);
            cntx.SubmitChanges();
        }
Esempio n. 6
0
        public void Add()
        {
            LibraryDBDataContext db = new LibraryDBDataContext();
            tbl_Publisher        a  = new tbl_Publisher();

            a.Name    = this.Name;
            a.Address = this.Address;
            db.tbl_Publishers.InsertOnSubmit(a);
            db.SubmitChanges();
        }
        public void ReturnBook(string bookname)
        {
            bookName = bookname;
            LibraryDBDataContext cntx = new LibraryDBDataContext(Library_Managment_System.Data.Properties.Settings.Default.librarydbConnectionString);
            var q = from a in cntx.BookSelfs
                    where a.BookName == bookName
                    select a;
            BookSelf bookself = q.First();

            cntx.BookSelfs.DeleteOnSubmit(bookself);
            cntx.SubmitChanges();
        }
        public void Add()
        {
            LibraryDBDataContext db = new LibraryDBDataContext();
            tbl_Author           a  = new tbl_Author();

            a.Name      = this.Name;
            a.Address   = this.Address;
            a.Birthdate = this.Birthdate;
            db.tbl_Authors.InsertOnSubmit(a);
            db.SubmitChanges();
            ID = a.ID;
        }
Esempio n. 9
0
        public new void Add()
        {
            LibraryDBDataContext db = new LibraryDBDataContext();

            base.Add();
            tbl_AdminDetail a = new tbl_AdminDetail();

            a.UserID   = base.ID;
            a.Salary   = this.Salary;
            a.HireDate = this.HireDate;
            a.Shift    = this.Shift;

            db.tbl_AdminDetails.InsertOnSubmit(a);
            db.SubmitChanges();
        }
Esempio n. 10
0
        public void add()
        {
            LibraryDBDataContext db = new LibraryDBDataContext();
            tbl_Book             b  = new tbl_Book();

            b.ISBN        = this.ISBN;
            b.Name        = this.Name;
            b.PublisherID = this.Publisher.ID;
            b.AuthorID    = this.Author.ID;
            b.Copies      = this.Copies;
            b.Genre       = this.Genre;

            db.tbl_Books.InsertOnSubmit(b);
            db.SubmitChanges();
        }
Esempio n. 11
0
        public new void Add()
        {
            base.Add();
            LibraryDBDataContext db = new LibraryDBDataContext();

            tbl_Student s = new tbl_Student();

            s.User_ID       = base.ID;
            s.University    = University;
            s.University_ID = University_ID;
            s.GPA           = GPA;

            db.tbl_Students.InsertOnSubmit(s);
            db.SubmitChanges();
        }
Esempio n. 12
0
        public virtual void Add()
        {
            LibraryDBDataContext db = new LibraryDBDataContext();
            tbl_User             u  = new tbl_User();

            u.Username    = this.Username;
            u.Password    = this.Password;
            u.FName       = this.FName;
            u.SName       = this.SName;
            u.Birthdate   = this.Birthdate;
            u.Address     = this.Address;
            u.Email       = this.Email;
            u.PhoneNumber = this.PhoneNumber;
            u.NationalID  = this.NationalID;
            u.RoleName    = this.Rolename.ToString();

            db.tbl_Users.InsertOnSubmit(u);
            db.SubmitChanges();
            this.ID = u.ID;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (ISBN_TB.Text == "")
            {
                MessageBox.Show("Please Enter ISBN");
                return;
            }
            Book b      = Book.LoadByISBN(int.Parse(ISBN_TB.Text));
            int  bookID = b.ID;

            if (b == null)
            {
                MessageBox.Show("Book doesn't exist");
            }
            else
            {
                LibraryDBDataContext db = new LibraryDBDataContext();
                tbl_Edition          ed = (
                    from Edition in db.tbl_Editions
                    where (Edition.BookID == bookID) && (Edition.Version == Edition_TB.Text)
                    select Edition
                    ).FirstOrDefault();
                if (ed != null)
                {
                    MessageBox.Show("Edition already exists");
                }
                else
                {
                    tbl_Edition Edition = new tbl_Edition();
                    Edition.BookID  = bookID;
                    Edition.Version = Edition_TB.Text;
                    Edition.Pages   = int.Parse(Pages_TB.Text);
                    db.tbl_Editions.InsertOnSubmit(Edition);
                    db.SubmitChanges();
                    this.Close();
                }
            }
        }
Esempio n. 14
0
        public void Borrow(int ISBN)
        {
            Book        b        = Book.LoadByISBN(ISBN);
            List <Book> Borrowed = LoadAllBorrowedBooks();

            foreach (Book temp in Borrowed)
            {
                if (temp.ID == b.ID)
                {
                    MessageBox.Show("You Have already borrowed it!");
                    return;
                }
            }

            if (b == null)
            {
                MessageBox.Show("Book doesn't exist");
                return;
            }
            else if (b.Copies == 0)
            {
                MessageBox.Show("Book is currently unavailable");
                return;
            }
            else
            {
                b.Copies--;
                b.saveChanges();
                MessageBox.Show("Done!");
                LibraryDBDataContext db  = new LibraryDBDataContext();
                tbl_Borrow           bor = new tbl_Borrow();
                bor.UserID = this.ID;
                bor.BookID = b.ID;
                bor.Date   = DateTime.Now;
                db.tbl_Borrows.InsertOnSubmit(bor);
                db.SubmitChanges();
            }
        }
Esempio n. 15
0
        public void Delete_Student()
        {
            List <Book> Borrowed = this.LoadAllBorrowedBooks();

            foreach (Book i in Borrowed)
            {
                this.Return(i.ISBN);
            }
            LibraryDBDataContext db = new LibraryDBDataContext();
            tbl_Student          S  = (from std in db.tbl_Students
                                       where std.User_ID == this.ID
                                       select std
                                       ).FirstOrDefault();

            tbl_User U = (from US in db.tbl_Users
                          where US.ID == this.ID
                          select US).FirstOrDefault();

            db.tbl_Students.DeleteOnSubmit(S);
            db.tbl_Users.DeleteOnSubmit(U);

            db.SubmitChanges();
        }
Esempio n. 16
0
        public void Return(int ISBN)
        {
            Book b = Book.LoadByISBN(ISBN);

            if (b == null)
            {
                MessageBox.Show("Book doesn't exist");
                return;
            }
            else
            {
                b.Copies++;
                b.saveChanges();
                LibraryDBDataContext db  = new LibraryDBDataContext();
                tbl_Borrow           bor = (from B in db.tbl_Borrows
                                            where B.BookID == b.ID && this.ID == B.UserID
                                            select B
                                            ).FirstOrDefault();

                db.tbl_Borrows.DeleteOnSubmit(bor);
                db.SubmitChanges();
            }
        }