Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.SelectedTab = tabID.actMyClubs;

        try
        {
            if (Request.PathInfo.Length > 0 && Request.PathInfo.StartsWith("/", StringComparison.OrdinalIgnoreCase))
            {
                if (!IsPostBack)
                {
                    CurrentClub = Club.ClubWithID(Convert.ToInt32(Request.PathInfo.Substring(1), CultureInfo.InvariantCulture));
                    if (CurrentClub == null)
                    {
                        throw new MyFlightbookException(Resources.Club.errNoSuchClub);
                    }

                    Master.Title       = CurrentClub.Name;
                    lblClubHeader.Text = CurrentClub.Name;

                    ClubMember cm = CurrentClub.GetMember(Page.User.Identity.Name);

                    if (!IsManager)
                    {
                        throw new MyFlightbookException(Resources.Club.errNotAuthorizedToManage);
                    }

                    gvMembers.DataSource = CurrentClub.Members;
                    gvMembers.DataBind();
                    vcEdit.ShowDelete = (cm.RoleInClub == ClubMember.ClubMemberRole.Owner);

                    cmbClubAircraft.DataSource = CurrentClub.MemberAircraft;
                    cmbClubAircraft.DataBind();
                    cmbClubMembers.DataSource = CurrentClub.Members;
                    cmbClubMembers.DataBind();

                    dateStart.Date      = (Request.Cookies[szCookieLastStart] != null && DateTime.TryParse(Request.Cookies[szCookieLastStart].Value, out DateTime dtStart)) ? dtStart : CurrentClub.CreationDate;
                    dateEnd.Date        = (Request.Cookies[szCookieLastEnd] != null && DateTime.TryParse(Request.Cookies[szCookieLastEnd].Value, out DateTime dtEnd)) ? dtEnd : DateTime.Now;
                    dateEnd.DefaultDate = DateTime.Now;
                    RefreshAircraft();

                    lblManageheader.Text        = String.Format(CultureInfo.CurrentCulture, Resources.Club.LabelManageThisClub, CurrentClub.Name);
                    lnkReturnToClub.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/ClubDetails.aspx/{0}", CurrentClub.ID);

                    vcEdit.ActiveClub = CurrentClub;    // do this at the end so that all of the above (like ShowDelete) are captured
                }
            }
            else
            {
                throw new MyFlightbookException(Resources.Club.errNoClubSpecified);
            }
        }
        catch (MyFlightbookException ex)
        {
            lblErr.Text             = ex.Message;
            lnkReturnToClub.Visible = tabManage.Visible = false;
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.SelectedTab = tabID.actMyClubs;

        if (Request.PathInfo.Length > 0 && Request.PathInfo.StartsWith("/", StringComparison.OrdinalIgnoreCase))
        {
            if (!IsPostBack)
            {
                try
                {
                    CurrentClub = Club.ClubWithID(Convert.ToInt32(Request.PathInfo.Substring(1), CultureInfo.InvariantCulture));
                    if (CurrentClub == null)
                    {
                        throw new MyFlightbookException(Resources.Club.errNoSuchClub);
                    }

                    Master.Title       = CurrentClub.Name;
                    lblClubHeader.Text = CurrentClub.Name;

                    ClubMember cm = CurrentClub.GetMember(Page.User.Identity.Name);

                    DateTime dtClub = ScheduledEvent.FromUTC(DateTime.UtcNow, CurrentClub.TimeZone);
                    lblCurTime.Text      = String.Format(CultureInfo.InvariantCulture, Resources.LocalizedText.LocalizedJoinWithSpace, dtClub.ToShortDateString(), dtClub.ToShortTimeString());
                    lblTZDisclaimer.Text = String.Format(CultureInfo.CurrentCulture, Resources.Club.TimeZoneDisclaimer, CurrentClub.TimeZone.StandardName);

                    bool fIsAdmin = util.GetIntParam(Request, "a", 0) != 0 && (MyFlightbook.Profile.GetUser(Page.User.Identity.Name)).CanManageData;
                    if (fIsAdmin && cm == null)
                    {
                        cm = new ClubMember(CurrentClub.ID, Page.User.Identity.Name, ClubMember.ClubMemberRole.Admin);
                    }
                    bool fIsManager = fIsAdmin || (cm != null && cm.IsManager);
                    lnkManageClub.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/ClubManage.aspx/{0}", CurrentClub.ID);
                    mvMain.SetActiveView(cm == null ? vwMainGuest : vwSchedules);
                    mvTop.SetActiveView(cm == null ? vwTopGuest : (fIsManager ? vwTopAdmin : vwTopMember));

                    if (cm == null)
                    {
                        accClub.SelectedIndex = 0;
                        acpMembers.Visible    = acpSchedules.Visible = false;
                    }

                    pnlLeaveGroup.Visible = (cm != null && !cm.IsManager);

                    switch (CurrentClub.Status)
                    {
                    case Club.ClubStatus.Promotional:
                        mvPromoStatus.SetActiveView(vwPromotional);
                        string szTemplate = (Page.User.Identity.Name.CompareOrdinal(Page.User.Identity.Name) == 0) ? Resources.Club.clubStatusTrialOwner : Resources.Club.clubStatusTrial;
                        lblPromo.Text = String.Format(CultureInfo.CurrentCulture, Branding.ReBrand(szTemplate), CurrentClub.ExpirationDate.Value.ToShortDateString());
                        break;

                    case Club.ClubStatus.Expired:
                    case Club.ClubStatus.Inactive:
                        mvPromoStatus.SetActiveView(vwInactive);
                        lblInactive.Text = Branding.ReBrand(CurrentClub.Status == Club.ClubStatus.Inactive ? Resources.Club.errClubInactive : Resources.Club.errClubPromoExpired);
                        break;

                    default:
                        mvPromoStatus.Visible = false;
                        break;
                    }

                    // Initialize from the cookie, if possible.
                    rbScheduleMode.SelectedValue = SchedulePreferences.DefaultScheduleMode.ToString();

                    if (CurrentClub.PrependsScheduleWithOwnerName)
                    {
                        mfbEditAppt1.DefaultTitle = MyFlightbook.Profile.GetUser(Page.User.Identity.Name).UserFullName;
                    }

                    RefreshAircraft();

                    if (cm != null)
                    {
                        gvMembers.DataSource = CurrentClub.Members;
                        gvMembers.DataBind();
                        // Hack - trim the last column if not showing mobiles.  This is fragile.
                        if (CurrentClub.HideMobileNumbers)
                        {
                            gvMembers.Columns[gvMembers.Columns.Count - 1].Visible = false;
                        }
                    }
                }
                catch (MyFlightbookException ex)
                {
                    lblErr.Text = ex.Message;
                }
            }

            // Do this every time - if it's a postback in an update panel, it's a non-issue, but if it's full-page, this keeps things from going away.
            RefreshSummary();
        }
    }