Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // set title for page
            Page.Title = "Lending - BookShare";
            if (Session["currentUser"] == null)
            {
                Server.Transfer("ErrorPage.aspx");
            }
            else
            {
                User user = (User)Session["currentUser"];

                listQuery.Add("Available");
                listQuery.Add("Pending");
                listQuery.Add("Lending");
                listQuery.Add("Completed");

                filter = Request.QueryString["filter"] == null ? "Pending" : Request.QueryString["filter"];
                page   = Request.QueryString["page"] == null ? 1 : int.Parse(Request.QueryString["page"]);
                int id = Request.QueryString["id"] == null ? -1 : int.Parse(Request.QueryString["id"]);

                int point = Request.QueryString["point"] == null ? -1 : int.Parse(Request.QueryString["point"]);

                //Check if page is reload and there is some deletion action
                if (filter == "Delete")
                {
                    int tradingID = int.Parse(Request.QueryString["deleteID"]);
                    DeleteTrading(tradingID);
                    Response.Redirect("Lending.aspx?filter=Available");
                }
                else if (filter == "Approve")
                {
                    //Check if page is reload and there is some aprroval action
                    int tradingID = int.Parse(Request.QueryString["approveID"]);
                    ApproveTrading(tradingID);
                    Response.Redirect("Lending.aspx?filter=Pending");
                }
                else if (filter == "Complete")
                {
                    //Check if page is reload and there is some complete action
                    int tradingID = int.Parse(Request.QueryString["completeID"]);
                    CompleteTrading(tradingID);
                    Response.Redirect("Lending.aspx?filter=Completed");
                }

                FillData(filter, user.Id);

                if (id != -1)
                {
                    borrowerId        = borrowers[id].Id;
                    myModal.Visible   = true;
                    info.InnerHtml    = "Trading no: " + (id + 1) + "<br/>Borrower: " + borrowers[id].FullName + "<br/>";
                    trading.InnerText = tradings[id].Id + "";
                }

                if (point != -1)
                {
                    int        tradingID  = int.Parse(Request.QueryString["trading"]);
                    TradingDAO tradingDAO = new TradingDAO();
                    tradingDAO.UpdateBorrowerRatePoint(tradingID, point);
                    Response.Redirect("Lending.aspx?filter=Completed");
                }
            }
        }