protected void Page_Load(object sender, EventArgs e) { try { ShowMessage(false); // Obtiene el usuario activo. UserEntity = (UserEntity)Session[SessionConstants.User]; if (UserEntity != null) { LabelWelcome.Text = GetLocalResourceObject("LabelWelcomeResource1.Text").ToString() + " <b>" + UserEntity.UserName.ToUpper(CultureInfo.InvariantCulture) + "</b>"; if (!Page.IsPostBack && (UserEntity.Store != null)) { // Crea un nuevo manejador para las categorias. tree = new CategoriesTree(); // Añade el árbol de categorias a la sesión. this.Session.Add(SessionConstants.CategoriesTree, tree); // Carga los datos de la tienda. LoadStoreData(); } else { // Obtiene el árbol de categorias de la sesión. tree = (CategoriesTree)this.Session[SessionConstants.CategoriesTree]; } } else { // Si el usuario no esta logeado es direccionado a la página de log. Server.Transfer(PagesConstants.LogOnPage); } } catch (UtnEmallBusinessLogicException utnEmallError) { InformationImage.ImageUrl = GetLocalResourceObject("Error").ToString(); LabelMessage.Text = GetLocalResourceObject("MessageUtnEmallProblems").ToString(); ShowMessage(true); Debug.WriteLine(utnEmallError.Message); } }
protected void Page_Load(object sender, EventArgs e) { try { ShowMessage(false); // Obtiene la sesión de usuario activa. userEntity = (UserEntity)Session[SessionConstants.User]; if (userEntity != null) { LabelWelcome.Text = GetLocalResourceObject("LabelWelcomeResource1.Text").ToString() + " <b>" + userEntity.UserName.ToUpper(CultureInfo.InvariantCulture) + "</b>"; if (!Page.IsPostBack) { // Crea el arbol de categorias para administrar las categorias de la tienda. tree = new CategoriesTree(); // Añade el árbol de categorias a la sesión. Session.Add(SessionConstants.TreeService, tree); // Fuerza al objeto Context.Handler para que coincida con el tipo de página. sourcepage = (ListServices)Context.Handler; // Muestra el valor de la propiedad. if (sourcepage.IdService != null) { // Obtiene el ID del servicio. idService = Convert.ToInt32(sourcepage.IdService, CultureInfo.InvariantCulture); // Añade el ID del servicio al ViewState. ViewState.Add(IDService, idService); // Carga y muestra los datos del servicio. LoadService(idService); } else { // Crea un nuevo servicio. serviceEntity = new ServiceEntity(); // El servicio está asociado con la tienda. serviceEntity.IdStore = UserEntity.Store.Id; // Formatea los datos a ser mostrados. ShowServiceDate(true); // Carga las categorias de la tienda. LoadCategories(); } } else { // Obtiene el árbol de categorias de la sesión. tree = (CategoriesTree)Session[SessionConstants.TreeService]; if (ViewState[IDService] != null) { // Obtiene el ID del servicio del ViewState. idService = Convert.ToInt32(ViewState[IDService], CultureInfo.InvariantCulture); // Carga los datos del servicio y de la tienda. serviceEntity = GetServiceEntity(idService); } else { // Carga los datos de la tienda, crea un nuevo servicio y asigna el ID de la tienda al servicio. serviceEntity = new ServiceEntity(); serviceEntity.IdStore = UserEntity.Store.Id; } } } else { // Si el usuario no esta logeado redirecciona a la página de log. Server.Transfer(PagesConstants.LogOnPage); } } catch (InvalidCastException error) { Debug.WriteLine(error.Message); Server.Transfer(PagesConstants.Homepage); } }