Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (MyWebAuthentication.IsUserLogOn() == false)
        {
            SetMessageState(State.Danger, "דף זה זמין רק למשתמשים רשומים!!");
            pnlOrderPanel.Visible = false;
            Title = "Error";
            return;
        }

        if (string.IsNullOrEmpty(Request.QueryString.Get("showID")) == true)
        {
            Response.Redirect("HomePage#shows");
        }

        // check if there is 'showID' string in QueryString
        // and then try parse (because sould be only intger)
        bool isIntger = int.TryParse(Request.QueryString.Get("showID"), out _showID);

        ShowsLogic shows = new ShowsLogic();

        if (isIntger == false || shows.IsShowExists(_showID) == false)
        {
            SetMessageState(State.Warning, "הופעה לא נמצאה!");
            pnlOrderPanel.Visible = false;
            Title = "Error";
            return;
        }

        Show show = shows.GetShow(_showID);

        Title = show.ShowTitle;

        lblShowTitle.Text     = show.ShowTitle;
        lblShowDate.Text      = show.ShowDate.ToLongDateString();
        lblShowDiscount.Text  = show.ShowDiscount.ToString();
        lblShowAddress.Text   = show.ShowAddress;
        lblShowComments.Text  = show.Comments;
        lblShowCardPrice.Text = show.ShowCardPrice.ToString();

        decimal price              = Convert.ToInt32(show.ShowCardPrice);
        decimal discount           = Convert.ToInt32(show.ShowDiscount);
        decimal priceAfterDiscount = price * (1 - discount / 100);

        lblCardPriceAfterDiscount.Text = Convert.ToString(priceAfterDiscount);

        imgShowImageUrl.ImageUrl = show.ShowImageUrl;

        string userName = users.GetUser(MyWebAuthentication.UserID).UserName;

        if (orders.IsUserOrderShow(userName, _showID))
        {
            lblHasOrdered.Attributes.Add("title", "כבר הזמנת כרטיסים להופעה הזאת!");
            lblHasOrdered.Visible = true;
        }
    }