Ejemplo n.º 1
0
    protected void RefreshTemplateList()
    {
        List <EndorsementType> lst = new List <EndorsementType>(EndorsementType.LoadTemplates(mfbSearchTemplates.SearchText));

        if (lst.Count == 0) // if nothing found, use the custom template
        {
            lst.Add(EndorsementType.GetEndorsementByID(1));
        }

        cmbTemplates.DataSource     = lst;
        cmbTemplates.DataValueField = "id";
        cmbTemplates.DataTextField  = "FullTitle";
        cmbTemplates.DataBind();

        int currentEndorsementID = mfbEditEndorsement1.EndorsementID;

        if (lst.Find(et => et.ID == currentEndorsementID) == null)  // restricted list doesn't have active template - select the first one.
        {
            cmbTemplates.SelectedIndex = 0;
            UpdateTemplate();
        }
        else if (currentEndorsementID.ToString(CultureInfo.InvariantCulture) != cmbTemplates.SelectedValue)
        {
            UpdateTemplate();
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Master.Title  = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.TitleTraining, Branding.CurrentBrand.AppName);
        Master.SelectedTab = tabID.tabTraining;

        if (!IsPostBack)
        {
            Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
            mfbEditEndorsement1.StudentType = Endorsement.StudentTypes.External;
            mfbEditEndorsement1.TargetUser  = pf;
            cmbTemplates.DataSource         = EndorsementType.LoadTemplates();
            cmbTemplates.DataValueField     = "id";
            cmbTemplates.DataTextField      = "FullTitle";
            cmbTemplates.DataBind();
            hdnLastTemplate.Value = cmbTemplates.SelectedValue;

            lblDisclaimerResponse.Text  = Branding.ReBrand(Resources.SignOff.SignDisclaimerAgreement1);
            lblDisclaimerResponse2.Text = Branding.ReBrand(Resources.SignOff.SignDisclaimerAgreement2);

            CFIStudentMap sm = new CFIStudentMap(Page.User.Identity.Name);
            if (sm.Instructors.Count() == 0)
            {
                mfbEditEndorsement1.Mode = EndorsementMode.StudentPullAdHoc;
                mvAddEndorsement.SetActiveView(vwAcceptTerms);
            }
            else
            {
                cmbInstructors.DataSource = sm.Instructors;
                cmbInstructors.DataBind();
                mvAddEndorsement.SetActiveView(vwPickInstructor);
            }

            mfbEditEndorsement1.StudentType = Endorsement.StudentTypes.Member;
            mfbEditEndorsement1.TargetUser  = pf;
        }

        // need to reconstitute the form from the template every time to ensure postback works.
        mfbEditEndorsement1.EndorsementID = Convert.ToInt32(hdnLastTemplate.Value, CultureInfo.InvariantCulture);
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Master.SelectedTab = tabID.tabTraining;
        this.Title = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.TitleProfile, Branding.CurrentBrand.AppName);

        pnlError.Visible = false;

        if (!IsPostBack)
        {
            try
            {
                if (Request.PathInfo.Length > 0)
                {
                    m_szTargetUser = Request.PathInfo.Substring(1);
                }

                bool fMemberEndorsement = util.GetIntParam(Request, "extern", 0) == 0;

                if (m_szTargetUser.Length == 0 && fMemberEndorsement)
                {
                    pnlEndorsement.Visible = false; // hide the new endorsement panel - just show all endorsements given
                }
                else
                {
                    mfbEditEndorsement1.StudentType = fMemberEndorsement ? Endorsement.StudentTypes.Member : Endorsement.StudentTypes.External;

                    if (fMemberEndorsement)
                    {
                        if (!new CFIStudentMap(Page.User.Identity.Name).IsInstructorOf(m_szTargetUser))
                        {
                            throw new MyFlightbookValidationException(Resources.Profile.errNotAuthorizedToEndorse);
                        }

                        Profile pfTarget     = MyFlightbook.Profile.GetUser(m_szTargetUser);
                        string  szTargetUser = pfTarget.UserFullName;

                        lblPageHeader.Text                = String.Format(CultureInfo.CurrentCulture, Resources.Profile.EndorsementsHeader, szTargetUser);
                        lblNewEndorsementHeader.Text      = String.Format(CultureInfo.CurrentCulture, Resources.Profile.EndorsementsNewEndorsementHeader, szTargetUser);
                        lblExistingEndorsementHeader.Text = String.Format(CultureInfo.CurrentCulture, Resources.Profile.EndorsementsExistingEndorsementHeader, szTargetUser);
                        mfbEditEndorsement1.TargetUser    = pfTarget;
                        mfbEditEndorsement1.Mode          = EndorsementMode.InstructorPushAuthenticated;
                    }
                    else
                    {
                        mfbEditEndorsement1.Mode = EndorsementMode.InstructorOfflineStudent;
                    }

                    Profile pf = MyFlightbook.Profile.GetUser(User.Identity.Name);

                    if (pf.Certificate.Length == 0)
                    {
                        throw new MyFlightbookValidationException(Resources.Profile.errNoCFICertificate);
                    }

                    mfbEditEndorsement1.SourceUser = pf;

                    cmbTemplates.DataSource     = EndorsementType.LoadTemplates();
                    cmbTemplates.DataValueField = "id";
                    cmbTemplates.DataTextField  = "FullTitle";
                    cmbTemplates.DataBind();
                    hdnLastTemplate.Value = cmbTemplates.SelectedValue;

                    ViewState[keyTargetUser] = m_szTargetUser;
                }
            }
            catch (MyFlightbookValidationException ex)
            {
                lblError.Text                   = ex.Message;
                pnlError.Visible                = true;
                pnlEndorsement.Visible          = false;
                pnlExistingEndorsements.Visible = false;
            }
        }
        else
        {
            m_szTargetUser = (string)ViewState[keyTargetUser];
        }

        // need to reconstitute the form from the template every time to ensure postback works.
        if (!pnlError.Visible && pnlEndorsement.Visible)
        {
            mfbEditEndorsement1.EndorsementID = Convert.ToInt32(hdnLastTemplate.Value, CultureInfo.InvariantCulture);
        }

        mfbEndorsementList1.Instructor = Page.User.Identity.Name;
        mfbEndorsementList1.Student    = m_szTargetUser;
        mfbEndorsementList1.RefreshEndorsements();
    }