コード例 #1
0
ファイル: AuthorSave.aspx.cs プロジェクト: eeh383/ehaksal
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Author a = new Author();
                a.Name        = txtName.Text;
                a.Surname     = txtSurname.Text;
                a.CreatedDate = DateTime.Now;
                a.Description = txtDescription.Text;


                using (var db = new BookEntities())
                {
                    if (Request.QueryString["Id"] != null)
                    {
                        a.Id = Convert.ToInt32(Request.QueryString["Id"]);
                        db.Entry(a).State = EntityState.Modified;
                    }
                    else
                    {
                        db.Entry(a).State = EntityState.Added;
                    }

                    db.SaveChanges();
                }

                Response.Redirect("AuthorDetail.aspx");
            }catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
ファイル: Dashboard.cs プロジェクト: AltayMahmudi/BACKEND-C-
        //BOOK SAVE UPDATE START
        private void InsertNewBook_Click(object sender, EventArgs e)
        {
            book.BookName            = textBoxBookName.Text.Trim();
            book.BookAuthor          = textBoxAuthor.Text.Trim();
            book.BookPublicationName = textBoxPublication.Text.Trim();
            book.BookReleaseDate     = dateTimePickerBook.Value;
            book.BookQuantity        = textBoxQuantity.Text.Trim();
            book.BookPrice           = textBoxPrice.Text.Trim();
            using (BookEntities db = new BookEntities())
            {
                ////Checks wether if fields empty or not
                if (textBoxBookName.Text == "" || textBoxAuthor.Text == "" || textBoxPublication.Text == "" || textBoxQuantity.Text == "" || textBoxPrice.Text == "")
                {
                    MessageBox.Show("Please fill in all the fields");
                }
                else
                {
                    if (book.BookID == 0)
                    {
                        db.Bookİnfoes.Add(book);                         //Insert
                    }
                    else
                    {
                        db.Entry(book).State = EntityState.Modified;
                    }
                    db.SaveChanges();                     //update
                    MessageBox.Show("Submit Successfull");
                }
            }

            ClearBook();
            FillBookDataGridView();
        }
コード例 #3
0
 //============================DataGridview=Fill=Start=================================
 //Fills DataGridView for Book with Corresponding Values from Database
 void FillBookDataGridView()
 {
     using (BookEntities db = new BookEntities())
     {
         DGVBooks.DataSource = db.Bookİnfoes.ToList <BookInfo>();
     }
 }
コード例 #4
0
 //Fills DataGridView for Person with Corresponding Values from Database
 void FillPersonDataGridView()
 {
     using (BookEntities db = new BookEntities())
     {
         DGVPerson.DataSource = db.People.ToList <Person>();
     }
 }
コード例 #5
0
ファイル: PublisherSave.aspx.cs プロジェクト: eeh383/ehaksal
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Publisher p = new Publisher();
                p.Name = txtName.Text;
                p.Address = txtAddress.Text;
                p.CreatedDate = DateTime.Now;
                p.PhoneNumber = txtPhoneNumber.Text;


                using (var db = new BookEntities())
                {

                    if (Request.QueryString["Id"] != null)
                    {
                        p.Id = Convert.ToInt32(Request.QueryString["Id"]);
                        db.Entry(p).State = EntityState.Modified;
                    }
                    else db.Entry(p).State = EntityState.Added;

                    db.SaveChanges();
                }

                Response.Redirect("PublisherDetail.aspx");

            }
            catch (Exception)
            {

                throw;
            }
        }
コード例 #6
0
        private void InsertNewBook_Click(object sender, EventArgs e)
        {
            book.BookName            = textBoxBookName.Text.Trim();
            book.BookAuthor          = textBoxAuthor.Text.Trim();
            book.BookPublicationName = textBoxPublication.Text.Trim();
            book.BookPurchaseDate    = dateTimePickerBook.Value;
            book.BookQuantity        = textBoxQuantity.Text.Trim();
            book.BookPrice           = textBoxPrice.Text.Trim();
            using (BookEntities db = new BookEntities())

            {
                if (book.BookID == 0)
                {
                    db.Bookİnfos.Add(book); //Insert
                }
                else
                {
                    db.Entry(book).State = EntityState.Modified;
                }
                db.SaveChanges();                 //update
            }

            Clear();
            PopulateDataGridView();
            MessageBox.Show("Submit Successfull");
        }
コード例 #7
0
ファイル: Dashboard.cs プロジェクト: AltayMahmudi/BACKEND-C-
        //=============================CLİCK-END==============================

        //========================SAVE-UPDATE-BUTTON-START===========================
        private void SaveOrderS_Click_1(object sender, EventArgs e)
        {
            //Make Fields Empty
            order.PersonOrderName = LabelpersonNameS.Text.Trim();
            order.BookOrderName   = LabelBookNames.Text.Trim();
            order.IssueDate       = DateTimePickerIssueDate.Value;
            order.Deadline        = DateTimePickerDeadline.Value;
            //Make Fields Empty
            using (BookEntities db = new BookEntities())
            {
                //Checks wether if fields empty or not
                if (LabelpersonNameS.Text == "Name" ||
                    LabelBookNames.Text == "Name")
                {
                    MessageBox.Show("Please fill fields from List");
                }
                //Checks wether if fields empty or not
                else
                //if fieldboxes are not empty it allows operation
                {
                    if (order.OrderID == 0)
                    {
                        db.OrderBooks.Add(order);                         //Insert Operation
                    }
                    else
                    {
                        db.Entry(order).State = EntityState.Modified;
                    }
                    db.SaveChanges();                     //update Operation
                    MessageBox.Show("Submit Successfull");
                }
            }
            FillOrderListDGV();
            ClearOrderList();
        }
コード例 #8
0
        static void Main(string[] args)
        {
            using (var db = new BookEntities())
            {
                var newBook = new Book()
                {
                    Id   = Guid.NewGuid(),
                    Name = $"Test - {DateTime.Now.Ticks}",
                };
                db.Books.Add(newBook);



                Guid id = Guid.Parse("9F754B7A-C8E7-4EFF-9134-FF8B0FB8E2F3");

                var book = db.Books.Where(x => x.Id == id).FirstOrDefault();
                book.Name = "Nazir's book";


                db.SaveChanges();

                Console.WriteLine("Dnone");
                Console.ReadKey();
            }
        }
コード例 #9
0
ファイル: Dashboard.cs プロジェクト: AltayMahmudi/BACKEND-C-
 //Fills DataGridView for Person with Corresponding Values from Database
 void FillPersonDataGridView()
 {
     using (BookEntities db = new BookEntities())
     {
         DGVPerson.AutoGenerateColumns = false;
         DGVPerson.DataSource          = db.People.ToList <Person>();
     }
 }
コード例 #10
0
ファイル: Dashboard.cs プロジェクト: AltayMahmudi/BACKEND-C-
 //============================DataGridview=Fill=Start=================================
 //Fills DataGridView for Book with Corresponding Values from Database
 void FillBookDataGridView()
 {
     using (BookEntities db = new BookEntities())
     {
         DGVBooks.AutoGenerateColumns = false;
         DGVBooks.DataSource          = db.Bookİnfoes.ToList <BookInfo>();
     }
 }
コード例 #11
0
ファイル: Dashboard.cs プロジェクト: AltayMahmudi/BACKEND-C-
 void FillOrderListDGV()
 {
     using (BookEntities db = new BookEntities())
     {
         DGVOrderList.DataSource = db.OrderBooks.ToList <OrderBook>();
         DGVReport.DataSource    = db.OrderBooks.ToList <OrderBook>();
     }
 }
コード例 #12
0
        void PopulateDataGridView()
        {
            using (BookEntities db = new BookEntities())

            {
                DGVBooks.DataSource = db.Bookİnfos.ToList <BookInfo>();
            }
        }
コード例 #13
0
        public ActionResult StackWenXue()
        {
            BookEntities bookEntities = new BookEntities();
            var          list         = from BookDetails in bookEntities.BookDetails select BookDetails;

            ViewData.Model = list;
            return(View("Stack - WenXue"));
        }
コード例 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BookEntities db      = new BookEntities();
            var          results = (from i in db.BookLists
                                    select i).ToList();

            booksList.DataSource = results;
            booksList.DataBind();
        }
コード例 #15
0
        // GET: Book
        public ActionResult Index()
        {
            List <Book> m;

            using (var r = new BookEntities())
            {
                m = r.Book.ToList();
            }
            return(View(m));
        }
コード例 #16
0
ファイル: Dashboard.cs プロジェクト: AltayMahmudi/BACKEND-C-
 void FillOrderPersonBookDGV()
 {
     using (BookEntities db = new BookEntities())
     {
         DGVFindOrderS.AutoGenerateColumns = false;
         DGVFindBook.AutoGenerateColumns   = false;
         DGVFindOrderS.DataSource          = db.People.ToList <Person>();
         DGVFindBook.DataSource            = db.Bookİnfoes.ToList <BookInfo>();
     }
 }
コード例 #17
0
        public IEnumerable <Book> GetBooks(BookQueryViewModel bookQueryViewModel)
        {
            using (var dbcontext = new BookEntities())
            {
                var books = dbcontext.Books
                            .Where(x => x.Name == bookQueryViewModel.Name)
                            .ToList();

                return(books);
            }
        }
コード例 #18
0
        public void Add(BookViewMoel model)
        {
            using (var dbcontext = new BookEntities())
            {
                var book = new Book {
                    ISBN = model.ISBN, Name = model.Name
                };
                dbcontext.Books.Add(book);

                dbcontext.SaveChanges();
            }
        }
コード例 #19
0
ファイル: PublisherSave.aspx.cs プロジェクト: eeh383/ehaksal
        private void GetPublisher()
        {
            int publisher = Convert.ToInt32(Request.QueryString["Id"]);
            using (var db = new BookEntities())
            {
                var mypublisher = (from p in db.Publisher where p.Id == publisher select p).FirstOrDefault();

                txtName.Text = mypublisher.Name;
                txtAddress.Text = mypublisher.Address;
                txtPhoneNumber.Text = mypublisher.PhoneNumber;

            }
        }
コード例 #20
0
        public ActionResult Delete_Get(int Id)
        {
            var bookmodel = new Book();

            TryUpdateModel(bookmodel);

            using (var r = new BookEntities())
            {
                bookmodel = r.Book.FirstOrDefault(x => x.Id == Id);
            }

            return(View(bookmodel));
        }
コード例 #21
0
ファイル: AuthorSave.aspx.cs プロジェクト: eeh383/ehaksal
        private void GetAuthor()
        {
            int author = Convert.ToInt32(Request.QueryString["Id"]);

            using (var db = new BookEntities())
            {
                var myauthor = (from a in db.Author where a.Id == author select a).FirstOrDefault();

                txtName.Text        = myauthor.Name;
                txtSurname.Text     = myauthor.Name;
                txtDescription.Text = myauthor.Description;
            }
        }
コード例 #22
0
 static void Main(string[] args)
 {
     using (var db = new BookEntities())
     {
         var book = new Book()
         {
             BookName = "Dangerous Murder",
             Theme    = "Horror",
             Price    = 399,
         };
         db.Book
     }
 }
コード例 #23
0
        private void GetPublisherList()
        {
            using (var db = new BookEntities())
            {
                var publisherList = from p in db.Publisher
                                    select new PublisherDetailList {
                    Id = p.Id, Name = p.Name
                };


                grv.DataSource = publisherList.ToList();
                grv.DataBind();
            }
        }
コード例 #24
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string fileName = string.Empty;
                if (flUpload.HasFile)
                {
                    flUpload.SaveAs(Server.MapPath("~/BookCover/") + flUpload.FileName);
                    fileName = flUpload.FileName;
                }

                using (var db = new BookEntities())
                {
                    Book b = new Book();
                    b.Title         = txtTitle.Text;
                    b.Isbn          = txtIsbn.Text;
                    b.PublisId      = Convert.ToInt32(ddlPublisher.SelectedValue);
                    b.PublishedDate = clDate.SelectedDate;
                    b.NumberOfPages = Convert.ToInt32(txtNumberOfPages.Text);
                    b.Edition       = txtEdition.Text;
                    b.FormatId      = Convert.ToInt32(ddlFormat.SelectedValue);
                    b.Description   = txtDescription.Text;
                    b.ContentId     = Convert.ToInt32(ddlContent.SelectedValue);
                    b.AuthorId_     = Convert.ToInt32(ddlAuthor.SelectedValue);
                    if (!String.IsNullOrEmpty(fileName))
                    {
                        b.BookCoverPath = "~/BookCover/" + fileName;
                    }

                    if (Request.QueryString["Id"] != null)
                    {
                        b.Id = Convert.ToInt64(Request.QueryString["Id"]);
                        db.Entry(b).State = EntityState.Modified;
                    }
                    else
                    {
                        db.Entry(b).State = EntityState.Added;
                    }

                    db.SaveChanges();
                }

                Response.Redirect("BookDetail.aspx");
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #25
0
ファイル: AuthorDetail.aspx.cs プロジェクト: eeh383/ehaksal
        private void GetAuthorList()
        {
            using (var db = new BookEntities())
            {
                var authorList = from a in db.Author
                                 select new AuthorDetailList {
                    Id = a.Id, Name = a.Name + " " + a.Surname
                };



                grv.DataSource = authorList.ToList();
                grv.DataBind();
            }
        }
コード例 #26
0
        private void GetBookList()
        {
            using (var db = new BookEntities())
            {
                var bookList = from b in db.Book
                               join a in db.Author on b.AuthorId_ equals a.Id
                               select new BookDetailList {
                    Id = b.Id, AuthorName = a.Name + " " + a.Surname, Title = b.Title
                };


                grv.DataSource = bookList.ToList();
                grv.DataBind();
            }
        }
コード例 #27
0
        public ActionResult Create_Post()
        {
            var bookmodel = new Book();

            TryUpdateModel(bookmodel);

            using (var r = new BookEntities())
            {
                r.Book.Add(bookmodel);
                r.SaveChanges();
            }


            return(RedirectToAction("Index"));
        }
コード例 #28
0
        public ActionResult Edit_Post(int Id)
        {
            var bookmodel = new Book();

            TryUpdateModel(bookmodel);

            using (var r = new BookEntities())
            {
                var m = r.Book.Where(x => x.Id == Id).FirstOrDefault();
                TryUpdateModel(m);
                r.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
コード例 #29
0
ファイル: Dashboard.cs プロジェクト: AltayMahmudi/BACKEND-C-
        //==============================CLEAR=TEXTBOX=START==========================


        //=============================CLİCK-START============================

        //Double Clicking Fills Empty Textboxes therefore makes Updating possible
        //BOOK DOUBLE-CLICK  START
        private void DGVFindBook_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (DGVFindBook.CurrentRow.Index != -1)
            {
                book.BookID = Convert.ToInt32(DGVFindBook.CurrentRow.Cells["dataGridViewTextBoxColumn10"].Value);
                using (BookEntities db = new BookEntities())
                {
                    book = db.Bookİnfoes.Where(x => x.BookID == book.BookID).FirstOrDefault();
                    LabelBookNames.Text = book.BookName;
                }
                BTNSave.Text = ("Update");
                //Delete Button becomes available once you double click to Rows/Cells
                BTNBookDelete.Enabled = true;
            }
        }
コード例 #30
0
ファイル: Dashboard.cs プロジェクト: AltayMahmudi/BACKEND-C-
        //BOOK DOUBLE-CLICK  END



        private void DGVOrderList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (DGVOrderList.CurrentRow.Index != -1)
            {
                order.OrderID = Convert.ToInt32(DGVOrderList.CurrentRow.Cells["OrderID"].Value);
                using (BookEntities db = new BookEntities())
                {
                    order = db.OrderBooks.Where(x => x.OrderID == order.OrderID).FirstOrDefault();
                    LabelBookNames.Text   = order.BookOrderName;
                    LabelpersonNameS.Text = order.PersonOrderName;
                }
                SaveOrderS.Text = ("Update");
                //Delete Button becomes available once you double click to Rows/Cells
                DeleteOrderS.Enabled = true;
            }
        }