Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int user_Id = Convert.ToInt32(dataGridViewDataDel.Rows[dataGridViewDataDel.CurrentCell.RowIndex].Cells[2].Value);

            user = db.Users.Find(user_Id);

            DeliveredBooks deliveredBooks = new DeliveredBooks();

            deliveredBooks.BookId       = Convert.ToInt32(labelBookId.Text);
            deliveredBooks.BookName     = labelBookName.Text;
            deliveredBooks.UserId       = Convert.ToInt32(user_Id);
            deliveredBooks.UserName     = user.Name;
            deliveredBooks.DeliveryDate = DateTime.Now;


            var sorgus = (from p in db.DeliveredBooks where p.BookId.ToString() == labelBookId.Text select p).First();//teslim silme

            db.DeliveredBooks.Remove(sorgus);
            db.SaveChanges();



            string al = "Alınabilir";

            int idx   = Convert.ToInt32(labelBookId.Text);
            var kayit = db.Books.Find(idx);

            kayit.Status = al;
            db.Books.AddOrUpdate(kayit);
            db.SaveChanges();
        }
Ejemplo n.º 2
0
        private void btnOnay_Click(object sender, EventArgs e)
        {
            var            book      = db.Books.Find(_bookId);
            DeliveredBooks delivered = new DeliveredBooks();

            {
                delivered.UserId       = _userID;
                delivered.UserName     = usname;
                delivered.BookId       = Convert.ToInt32(labelBookId.Text);
                delivered.DeliveryDate = DateTime.Now;
                delivered.BookName     = book.Name;
            }
            db.DeliveredBooks.Add(delivered);
            db.SaveChanges();


            var sorgu = (from p in db.EntrustedBooks where p.BookId.ToString() == labelBookId.Text select p).First();

            db.EntrustedBooks.Remove(sorgu);
            db.SaveChanges();
        }