Пример #1
0
 //REQUEST TO BORROW A BOOK FROM BORROW BOOK TABLE =>PL
 private void btnRequestBook_Click(object sender, EventArgs e)
 {
     if (BookId > 0)
     {
         if (BookCopy == 0)
         {
             MessageBox.Show("Book is empty...");
         }
         else
         {
             BookCopy = BookCopy - 1;
             BookBL        bookBL        = new BookBL();
             UserRequestBL userRequestBL = new UserRequestBL();
             bool          isDone1       = bookBL.UpdateBookBL(BookId, BookName, BookAuthor, BookISBN, BookPrice, BookCopy);
             bool          isDone2       = userRequestBL.AddRequestBL(BookId, BookName, userId);
             if (isDone1 == true && isDone2 == true)
             {
                 MessageBox.Show("Requested successfully..");
             }
             else
             {
                 MessageBox.Show("Try again..");
             }
         }
     }
     else
     {
         MessageBox.Show("Select a book to request...");
     }
 }
Пример #2
0
        public void InitializeRequests()
        {
            try
            {
                UserRequestBL userRequestBL = new UserRequestBL();
                DataSet       ds            = userRequestBL.GetAllRequestBL();

                ObservableCollection <RequestedBook> lst = new ObservableCollection <RequestedBook>();

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    lst.Add(new RequestedBook
                    {
                        BookName      = Convert.ToString(dr["BookName"]),
                        BookId        = Convert.ToInt32(dr["BookId"]),
                        UserId        = Convert.ToInt32(dr["UserId"]),
                        UserName      = Convert.ToString(dr["UserName"]),
                        DateRequested = Convert.ToString(Convert.ToDateTime(dr["DateRequested"]).ToShortDateString()),
                    });
                }
                dgRequests.ItemsSource = lst;
            }
            catch (Exception)
            {
                MessageBox.Show("Some unknown exception is occured!!!, Try again..");
            }
        }
Пример #3
0
 //REJECT THE REQUESTED BOOK =>PL
 private void BtnReject_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         RequestedBook request = dgRequests.SelectedItem as RequestedBook;
         if (request != null)
         {
             BookBL        bookBL      = new BookBL();
             bool          isDone1     = bookBL.IncBookCopyBL(request.BookId);
             UserRequestBL userRequest = new UserRequestBL();
             bool          isDone2     = userRequest.DeleteRequestBL(request.BookId, request.UserId);
             if (isDone1 == true && isDone2 == true)
             {
                 MessageBox.Show("Rejected request successfully...");
                 InitializeRequests();
             }
             else
             {
                 MessageBox.Show("Try again latter...");
             }
         }
         else
         {
             MessageBox.Show("Select book properly...");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Some unknown exception is occured!!!, Try again..");
     }
 }
        //REFRESH THE REQUESTED BOOK GRID VIEW =>PL
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            UserRequestBL userRequestBL = new UserRequestBL();
            DataSet       ds            = userRequestBL.GetAllRequestBL();

            dgvRequestDetails.DataSource = ds.Tables[0];
        }
        //REFRESH REQUESTED BOOK GRID VIEW
        private void btnReqRefresh_Click(object sender, EventArgs e)
        {
            UserId = UserForm.UserId;
            UserRequestBL userRequestBL = new UserRequestBL();
            DataSet       ds1           = userRequestBL.GetAllRequestUserBL(UserId);

            dgvUserRequest.DataSource = ds1.Tables[0];
        }
        public AdminBookRequest()
        {
            InitializeComponent();
            UserRequestBL userRequestBL = new UserRequestBL();
            DataSet       ds            = userRequestBL.GetAllRequestBL();

            dgvRequestDetails.DataSource = ds.Tables[0];
        }
        public UserTransaction()
        {
            InitializeComponent();
            UserId = UserForm.UserId;
            UserRequestBL userRequestBL = new UserRequestBL();
            DataSet       ds1           = userRequestBL.GetAllRequestUserBL(UserId);

            dgvUserRequest.DataSource = ds1.Tables[0];
            UserRecieveBL userRecieveBL = new UserRecieveBL();
            DataSet       ds2           = userRecieveBL.GetAllRecieveUserBL(UserId);

            dgvUserRecieve.DataSource = ds2.Tables[0];
        }
 //REQUEST TO BORROW A BOOK FROM BORROW BOOK TABLE =>PL
 private void BtnRequest_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Book book = dgBorrow.SelectedItem as Book;
         if (book != null)
         {
             if (book.BookCopies == 0)
             {
                 MessageBox.Show("Book is empty...");
             }
             else
             {
                 int           BookCopy      = book.BookCopies - 1;
                 BookBL        bookBL        = new BookBL();
                 UserRequestBL userRequestBL = new UserRequestBL();
                 string        isDone1       = bookBL.UpdateBookBL(book.BookId, book.BookName, book.BookAuthor, book.BookISBN, book.BookPrice, BookCopy);
                 bool          isDone2       = userRequestBL.AddRequestBL(book.BookId, book.BookName, userId);
                 if (isDone1 == "true" && isDone2 == true)
                 {
                     MessageBox.Show("Requested successfully..");
                     InitializeUserBorrow();
                 }
                 else
                 {
                     MessageBox.Show("Try again..");
                 }
             }
         }
         else
         {
             MessageBox.Show("Select a book to request...");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Some unknown exception is occured!!!, Try again..");
     }
 }
 //REJECT THE REQUESTED BOOK =>PL
 private void btnReject_Click(object sender, EventArgs e)
 {
     if (BookId > 0)
     {
         BookBL        bookBL      = new BookBL();
         bool          isDone1     = bookBL.IncBookCopyBL(BookId);
         UserRequestBL userRequest = new UserRequestBL();
         bool          isDone2     = userRequest.DeleteRequestBL(BookId, UserId);
         if (isDone1 == true && isDone2 == true)
         {
             MessageBox.Show("Deleted request successfully...");
         }
         else
         {
             MessageBox.Show("Try again latter...");
         }
     }
     else
     {
         MessageBox.Show("Select book properly...");
     }
 }
 //ACCEPT THE REQUESTED BOOK =>PL
 private void btnAccept_Click(object sender, EventArgs e)
 {
     if (BookId > 0)
     {
         UserRecieveBL userRecieveBL = new UserRecieveBL();
         bool          isDone1       = userRecieveBL.AddRecieveBL(BookId, BookName, UserId, UserName);
         UserRequestBL userRequest   = new UserRequestBL();
         bool          isDone2       = userRequest.DeleteRequestBL(BookId, UserId);
         if (isDone1 == true && isDone2 == true)
         {
             MessageBox.Show("Accepted request successfully...");
         }
         else
         {
             MessageBox.Show("Try again latter...");
         }
     }
     else
     {
         MessageBox.Show("Select book properly...");
     }
 }
Пример #11
0
        public void InitializeUserTransaction()
        {
            try
            {
                userId = UserLogin.userId;
                UserRequestBL userRequestBL = new UserRequestBL();
                DataSet       ds1           = userRequestBL.GetAllRequestUserBL(userId);
                ObservableCollection <RequestedBook> lstRequest = new ObservableCollection <RequestedBook>();
                foreach (DataRow dr in ds1.Tables[0].Rows)
                {
                    lstRequest.Add(new RequestedBook
                    {
                        BookName      = Convert.ToString(dr["BookName"]),
                        BookId        = Convert.ToInt32(dr["BookId"]),
                        DateRequested = Convert.ToString(Convert.ToDateTime(dr["DateRequested"]).ToShortDateString()),
                    });;
                }
                dgRequest.ItemsSource = lstRequest;

                UserRecieveBL userRecieveBL = new UserRecieveBL();
                DataSet       ds2           = userRecieveBL.GetAllRecieveUserBL(userId);
                ObservableCollection <AcceptedBook> lstReceived = new ObservableCollection <AcceptedBook>();
                foreach (DataRow dr2 in ds2.Tables[0].Rows)
                {
                    lstReceived.Add(new AcceptedBook
                    {
                        BookName     = Convert.ToString(dr2["BookName"]),
                        BookId       = Convert.ToInt32(dr2["BookId"]),
                        DateRecieved = Convert.ToString(Convert.ToDateTime(dr2["DateRecieved"]).ToShortDateString()),
                    });;
                }
                dgReturn.ItemsSource = lstReceived;
            }
            catch (Exception)
            {
                MessageBox.Show("Some unknown exception is occured!!!, Try again..");
            }
        }