Esempio n. 1
0
 private void btnDecline_Click(object sender, EventArgs e)
 {
     try
     {
         int             selectedrowindex = dgvView.SelectedCells[0].RowIndex;
         DataGridViewRow selectedRow      = dgvView.Rows[selectedrowindex];
         //MessageBox.Show(selectedRow.Cells[0].Value.ToString());
         if (selectedRow.Cells[0].Value != null && selectedRow.Cells[0].Value.ToString() != string.Empty)
         {
             string         value  = selectedRow.Cells[0].Value.ToString();
             BUS.RequestBUS reqBUS = new BUS.RequestBUS();
             if (reqBUS.UpdateRequest(value, 3))
             {
                 LoadData();
                 MessageBox.Show("Decline successful!!!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("Decline fail!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 2
0
 private void LoadData()
 {
     BUS.RequestBUS bus = new BUS.RequestBUS();
     bsItem.DataSource        = bus.SelectRequestByRequestStatus(0);
     dgvView.DataSource       = bsItem;
     bnItemList.BindingSource = bsItem;
 }
        public bool AcceptRequest(string reqID)
        {
            BUS.RequestBUS reqBUS = new BUS.RequestBUS();
            //reqBUS.UpdateRequest(reqID, 2);
            DAO.RequestDAO     reqDAO = new DAO.RequestDAO();
            DTO.RequestDTO     reqDTO = reqDAO.SearchRequestByRequestID(reqID);
            DAO._MultiTableDAO mulDAO = new DAO._MultiTableDAO();
            DataTable          dt     = mulDAO.FindBookIDAndInventoryIDByBookTitleID(reqDTO.BookTitleID, "0").Tables[0];

            if (dt != null)
            {
                string bookID, inventoryID;
                try
                {
                    bookID      = dt.Rows[0]["BookID"].ToString();
                    inventoryID = dt.Rows[0]["InventoryID"].ToString();
                } catch (Exception ex)
                {
                    return(false);
                }
                Console.WriteLine(bookID);
                Console.WriteLine(inventoryID);
                if (bookID != null && inventoryID != null)
                {
                    try
                    {
                        bool result = true;
                        result &= reqBUS.UpdateRequest(reqID, 2);
                        Console.WriteLine(result);
                        InventoryBUS invBUS = new InventoryBUS();
                        result &= invBUS.UpdateInventory(inventoryID, 1);

                        Console.WriteLine(result);
                        LoanBUS loBUS = new LoanBUS();
                        if (result)
                        {
                            result &= loBUS.AddNewLoan(reqID, bookID);
                            Console.WriteLine(result);
                            if (result == true)
                            {
                                stt = "Inventory: " + inventoryID;
                            }
                            return(result);
                        }
                        else
                        {
                            reqBUS.UpdateRequest(reqID, 0);
                            invBUS.UpdateInventory(inventoryID, 0);
                        }
                    } catch (Exception ex)
                    {
                        Console.WriteLine("Exception: " + ex.Message);
                        reqBUS.UpdateRequest(reqID, 0);
                        InventoryBUS invBUS = new InventoryBUS();
                        invBUS.UpdateInventory(inventoryID, 0);
                    }
                }
            }
            return(false);
        }
        private void btnAddRequest_Click(object sender, EventArgs e)
        {
            int             selectedrowindex = dgvSearch.SelectedCells[0].RowIndex;
            DataGridViewRow selectedRow      = dgvSearch.Rows[selectedrowindex];

            if (selectedRow.Cells[0].Value != null && selectedRow.Cells[0].Value.ToString() != string.Empty)
            {
                string         value  = selectedRow.Cells[0].Value.ToString();
                BUS.RequestBUS bus    = new BUS.RequestBUS();
                bool           result = bus.AddNewRequest(UserID, value);
                if (result == true)
                {
                    MessageBox.Show("Borrow successful!!!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Borrow fail!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }