コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (Entities db = new Entities())
            {
                LendingManager lenMan = new LendingManager(db);
                if (Int32.TryParse(Request.QueryString["lendid"], out lendId))
                {
                    bool wasProlonged = lenMan.WasProlonged(lendId);
                    if (!wasProlonged)
                    {
                        string date = (lenMan.prolongUserLending(lendId, User.Identity.GetUserId())).ToLongDateString();
                        SuccessMessage = String.Format("Vaše výpůjčka byla prodloužena do {0}.", date);
                    }
                    else
                    {
                        SuccessMessage = "Vaši výpůjčku nelze prodloužit, protože byla již jednou prodloužena.";
                    }

                }
                else
                {
                    SuccessMessage = "Chyba.";
                }
                Label1.Text = SuccessMessage;
            }
        }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (Entities db = new Entities())
     {
         LendingManager lenMan = new LendingManager(db);
         List<LendingInfo> lendings = lenMan.GetLendings();
         if (lendings.Count == 0)
         {
             Button1.Visible = false;
         }
         GridView1.DataSource = lendings;
         GridView1.DataBind();
     }
 }
コード例 #3
0
        protected void Return_Click(object sender, EventArgs e)
        {
            using (Entities db = new Entities())
            {
                LendingManager lenMan = new LendingManager(db);
                List<LendingInfo> lendings = (List<LendingInfo>)GridView1.DataSource;

                lenMan.ReturnBook(lendings[GridView1.SelectedIndex].LendId);
                lendings = lenMan.GetLendings();
                if (lendings.Count == 0)
                {
                    Button1.Visible = false;
                }
                GridView1.DataSource = lendings;
                GridView1.DataBind();
            }
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (User.Identity.IsAuthenticated && Int32.TryParse(Request.QueryString["id"], out bookId))
            {
                Button1.Visible = true;
                if (!ReservationManager.IsAvailable(bookId))
                {
                    Button1.Enabled = false;
                    using(Entities db=new Entities())
                    {LendingManager man = new LendingManager(db);
                    if (man.IsLend(bookId))
                    {
                        DateTime date = man.GetExpDate(bookId);

                        Label1.Text = date.ToLongDateString();
                        LendAlert.Visible = true;
                        int i = DateTime.Now.CompareTo(date);
                        if (i == 1)
                        {
                            NotReturnedAlert.Visible = true;
                        }
                    }
                    else
                    {

                        ReservedAlert.Visible = true;
                    }
                    }
                }
                else if (User.IsInRole("NotConfirmed"))
                {
                    Button1.Enabled = false;
                }

            }
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)
            {
                Response.Redirect("~/Account/Login.aspx");
            }

            if (!IsPostBack)
            {
                // Render success message
                var message = Request.QueryString["m"];
                if (message != null)
                {
                    // Strip the query string from action
                    Form.Action = ResolveUrl("~/Account/ManageAccount.aspx");

                    SuccessMessage =
                        message == "ChangePwdSuccess" ? "Vaše heslo bylo změněno."

                        : String.Empty;
                    //successMessage.Visible = !String.IsNullOrEmpty(SuccessMessage);
                    successDiv.Visible = !String.IsNullOrEmpty(SuccessMessage);
                }
                EntityDataSource1.WhereParameters.Clear();
                EntityDataSource1.WhereParameters.Add("UserId", System.Data.DbType.String, User.Identity.GetUserId());
            }
            // Loads user reservation table
            using (Entities db = new Entities())
            {
                ReservationManager resMan = new ReservationManager(db);
                if (Int32.TryParse(Request.QueryString["resid"], out _resId))
                {
                    resMan.DeleteUserReservation(_resId, User.Identity.GetUserId());
                }
                List<UserResInfo> reservations = resMan.GetUserReservations(User.Identity.GetUserId());
                ResView.DataSource = reservations;
                ResView.DataBind();
                //Louads user lendings table
                LendingManager lenMan = new LendingManager(db);
                List<UserLendInfo> lendings = lenMan.GetUserLendings(User.Identity.GetUserId());
                LendView.DataSource = lendings;
                LendView.DataBind();
            }
        }