protected void Page_Load(object sender, EventArgs e) { if (MyWebAuthentication.IsUserLogOn()) { Response.Redirect("Member?u=" + MyWebAuthentication.UserID); } }
protected void Page_Load(object sender, EventArgs e) { // disable caching for masterpage (so that OutputCache will not cache this pages) Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); // check if user is log on if (MyWebAuthentication.IsUserLogOn()) { UsersLogic users = new UsersLogic(); // if he is log on thats mean i can access to his userID: User user = users.GetUser(MyWebAuthentication.UserID); // set the userName inside the button btnUserOptions.Text = user.UserName; // hide the two links of signin and signup lnkSignIn.Visible = lnkSignUp.Visible = false; // if the user is Admin show link to AdminPage if (user.IsAdmin == true) { lnkLinkToAdmin.Visible = true; } } else// hide the button that sould hold the userName if the user is not login { btnUserOptions.Visible = false; } }
protected void btnUserLogOut_Click(object sender, EventArgs e) { // log out and go to HomePage if (MyWebAuthentication.IsUserLogOn()) { MyWebAuthentication.LogOut("HomePage"); } }
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; } }
const string _emailAddressToSend = "email"; // email to send the notification message (the website owner) protected void Page_Load(object sender, EventArgs e) { // check if the user is log on and if he is: // put his firstName and lastName and Email automatically in the TextBoxs if (MyWebAuthentication.IsUserLogOn()) { UsersLogic users = new UsersLogic(); User user = users.GetUser(MyWebAuthentication.UserID); txtFullName.Text = user.FirstName + " " + user.LastName; txtEmail.Text = user.Email; } }
protected void Page_Load(object sender, EventArgs e) { if (MyWebAuthentication.IsUserLogOn()) { UsersLogic users = new UsersLogic(); User user = users.GetUser(MyWebAuthentication.UserID); Title = user.UserName; string fullName = user.FirstName + " " + user.LastName; lblFullName.Text = fullName; } else { Response.Redirect("HomePage"); } }
protected void Page_Load(object sender, EventArgs e) { // checking if the user logged in if (MyWebAuthentication.IsUserLogOn()) { int userID = MyWebAuthentication.UserID; // checking if he is Admin, if he is not send him to HomePage if (users.IsAdmin(userID) == false) { Response.Redirect("HomePage", true); } } else // if not logged in send him to HomePage { Response.Redirect("HomePage", true); } // setting the 'min' attribute to <input type=date> so he can choose only the future days. string dateFormat = string.Format("{0}-{1:D2}-{2:D2}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); txtShowDate.Attributes.Add("min", dateFormat); }