Example #1
0
 protected void SelectMake1_ModelChanged(object sender, MakeSelectedEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException(nameof(e));
     }
     m_ac.ModelID    = e.SelectedModel;
     AvionicsUpgrade = MakeModel.AvionicsTechnologyType.None;  // reset this since model changed.
     AdjustForAircraftType();
 }
Example #2
0
    protected void  UpdateInstanceType(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(txtTail.Text) && !rbRealAnonymous.Checked && m_ac.IsNew)
        {
            SetUpCountryCode();
        }

        m_ac.InstanceType = SelectedInstanceType;
        pnlTrainingDeviceTypes.Visible = m_ac.InstanceType != AircraftInstanceTypes.RealAircraft;
        UpdateMask();
        AvionicsUpgrade = MakeModel.AvionicsTechnologyType.None;  // reset this since model changed.

        AdjustForAircraftType();
    }
Example #3
0
    protected void InitFormForMake()
    {
        if (MakeID == MakeModel.UnknownModel)
        {
            btnAddMake.Text = Resources.LocalizedText.EditMakeAddMake;
            Model           = new MakeModel();
        }
        else
        {
            btnAddMake.Text = Resources.LocalizedText.EditMakeUpdateMake;
            Model           = MakeModel.GetModel(MakeID);
        }

        txtModel.Text      = Model.Model;
        txtName.Text       = Model.ModelName;
        txtType.Text       = Model.TypeName;
        txtFamilyName.Text = Model.FamilyName;
        if (Model.CategoryClassID > 0)
        {
            cmbCatClass.SelectedValue = Model.CategoryClassID.ToString();
        }
        if (Model.ManufacturerID > 0)
        {
            cmbManufacturer.SelectedValue = Model.ManufacturerID.ToString(CultureInfo.InvariantCulture);
        }
        ckComplex.Checked                     = Model.IsComplex;
        HighPerfType                          = Model.PerformanceType;
        ckTailwheel.Checked                   = Model.IsTailWheel;
        ckConstantProp.Checked                = Model.IsConstantProp;
        ckCowlFlaps.Checked                   = Model.HasFlaps;
        ckRetract.Checked                     = Model.IsRetract;
        AvionicsTechnology                    = Model.AvionicsTechnology;
        rblTurbineType.SelectedIndex          = (int)Model.EngineType;
        rblAircraftAllowedTypes.SelectedIndex = (int)Model.AllowedTypes;
        ckTMG.Checked                         = ((Model.CategoryClassID == CategoryClass.CatClassID.Glider) && Model.IsMotorGlider);
        ckMultiHeli.Checked                   = ((Model.CategoryClassID == CategoryClass.CatClassID.Helicopter) && Model.IsMultiEngineHelicopter);
        ckSinglePilot.Checked                 = Model.IsCertifiedSinglePilot;
        pnlSinglePilotOps.Style["display"]    = Model.EngineType.IsTurbine() ? "block" : "none";
        UpdateRowsForCatClass(Model.CategoryClassID);

        rowArmyCurrency.Visible = MyFlightbook.Profile.GetUser(Page.User.Identity.Name).UsesArmyCurrency;
        txtArmyMDS.Text         = Model.ArmyMDS;
    }
        /// <summary>
        /// Shows/hides functionality based on instance type, new/existing, sim, or anonymous.  Does NOT bind any data
        /// </summary>
        protected void AdjustForAircraftType()
        {
            MakeModel mm = MakeModel.GetModel(m_ac.ModelID);

            bool fRealAircraft   = IsRealAircraft;
            CountryCodePrefix cc = CountryCodePrefix.BestMatchCountryCode(m_ac.TailNumber);

            bool fIsNew             = m_ac.IsNew;
            bool fHasModelSpecified = (m_ac.ModelID > 0);

            bool fIsAnonymous = rbRealAnonymous.Checked;

            rbRealRegistered.Enabled = rbRealAnonymous.Enabled = true;
            switch (mm.AllowedTypes)
            {
            case AllowedAircraftTypes.Any:
                break;

            case AllowedAircraftTypes.SimOrAnonymous:
                if (fRealAircraft)
                {
                    fIsAnonymous         = true;
                    m_ac.TailNumber      = CountryCodePrefix.AnonymousCountry.Prefix;  // so that the selected instance will do anonymous correctly
                    SelectedInstanceType = AircraftInstanceTypes.RealAircraft;
                }
                rbRealRegistered.Enabled = false;
                break;

            case AllowedAircraftTypes.SimulatorOnly:
                cc = CountryCodePrefix.SimCountry;
                if (fRealAircraft)
                {
                    // migrate to an ATD.
                    m_ac.InstanceType = SelectedInstanceType = AircraftInstanceTypes.CertifiedATD;
                    fRealAircraft     = false;
                }
                rbRealRegistered.Enabled = rbRealAnonymous.Enabled = false;
                break;
            }

            mvTailnumber.SetActiveView(fRealAircraft ? vwRealAircraft : vwSimTail);

            // Show glass option if this is not, by model, a glass cockpit AND if it's not anonymous
            bool fRealRegistered = fRealAircraft && !fIsAnonymous;

            // All avionics upgrade options are limited to real, registered aircraft.  Beyond that:
            // - Can upgrade to glass if the model is not already glass or TAA (i.e., = steam)
            // - Can upgrade to TAA if the model is not already TAA-only AND this is an airplane (TAA is airplane only).
            // - So we will hide the overall avionics upgrade panel if no upgrade is possible.
            bool fAvionicsGlassvisible = fRealRegistered && mm.AvionicsTechnology == MakeModel.AvionicsTechnologyType.None;
            bool fTAAVisible           = fRealRegistered && mm.AvionicsTechnology != MakeModel.AvionicsTechnologyType.TAA;

            rbAvionicsGlass.Visible = fAvionicsGlassvisible;
            pnlTAA.Visible          = fTAAVisible;
            pnlGlassCockpit.Visible = fAvionicsGlassvisible || fTAAVisible;

            // Sanity check
            if ((rbAvionicsGlass.Checked && !rbAvionicsGlass.Visible) || (rbAvionicsTAA.Checked && !rbAvionicsTAA.Visible))
            {
                AvionicsUpgrade = MakeModel.AvionicsTechnologyType.None;
            }

            rowCountry.Visible     = fRealAircraft && !fIsAnonymous;
            rowMaintenance.Visible = rowCountry.Visible && !fIsNew;

            pnlTrainingDeviceTypes.Visible = fIsNew && !fRealAircraft;

            AdjustForRealOrAnonymous(fRealAircraft, fIsAnonymous, fHasModelSpecified, cc);
        }
        protected void InitFormForAircraft()
        {
            bool fIsNew = m_ac.IsNew;

            mvInstanceType.SetActiveView(fIsNew ? vwInstanceNew : vwInstanceExisting);

            // disable editing of sims and anonymous aircraft.
            bool fIsLocked = (!AdminMode && m_ac.IsLocked);
            bool fCanEdit  = IsRealAircraft && !IsAnonymous && !fIsLocked;

            rbAvionicsNone.Enabled = rbAvionicsGlass.Enabled = rbAvionicsTAA.Enabled = fCanEdit;

            lblStep1.Visible = lblStep2.Visible = lblStep3.Visible = lblStep4.Visible = fIsNew;

            pnlLockedExplanation.Visible = m_ac.IsLocked;
            ckLocked.Visible             = AdminMode && IsRealAircraft;
            ckLocked.Checked             = m_ac.IsLocked;

            SelectedInstanceType = m_ac.InstanceType;

            SetUpCountryCode();

            lblReadTail.Visible = !(txtTail.Visible = cmbCountryCode.Enabled = fIsNew);    // Issue #724/80.  Now that we have aircraft mapping, shouldn't need to support editing?

            List <LinkedString> lstAttrib = new List <LinkedString>();

            if (!fIsNew)
            {
                lstAttrib.Add(new LinkedString(rbTrainingDevice.Checked ? rblTrainingDevices.SelectedItem.Text : (rbRealRegistered.Checked ? lblRealRegistered.Text : lblAnonymous.Text)));
                lstAttrib.AddRange(StatsForUser(m_ac));

                // Issue #860 - if the aircraft is "popular", get extra confirmation.  I'll define "popular" here (arbitrarily) as > 10 users OR > 100 flights
                if (Stats.Users > 10 || Stats.Flights > 10)
                {
                    SelectMake1.ConfirmationText = String.Format(CultureInfo.CurrentCulture, "{0} {1}", String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.EditAircraftUserStats, Stats.Users, Stats.Flights), Resources.Aircraft.EditPopularAircraftPrompt);
                }
            }
            SelectMake1.AircraftAttributes = lstAttrib;
            SelectMake1.SelectedModelID    = m_ac.ModelID;

            AvionicsUpgrade = m_ac.AvionicsTechnologyUpgrade;

            mfbIl.Key = txtTail.Text = lblReadTail.Text = m_ac.TailNumber;

            SetUpNotes();

            SetUpMaintenance();

            SetUpAlternativeVersions();

            SetUpSchedules(m_ac, rptSchedules, rowClubSchedules, (string sz) => { mfbEditAppt1.DefaultTitle = sz; });

            bool fIsKnown = AdminMode || (!fIsNew && new UserAircraft(Page.User.Identity.Name)[m_ac.AircraftID] != null);

            btnAddAircraft.Text = fIsKnown ? Resources.LocalizedText.EditAircraftUpdateAircraft : Resources.LocalizedText.EditAircraftAddAircraft;

            // Set the edit mode, based on chart above, which breaks down as:
            // Editing automatically enabled IF new aircraft OR real, registered, unlocked, single user.
            // Editing offered (with confirmation) if real, registered, (unlocked or admin), multiple-user
            // Otherwise, no editing
            SelectMake1.EditMode = fIsNew || (fCanEdit && IsOnlyUserOfAircraft)
                ? SelectMake.MakeEditMode.Edit
                : fCanEdit && !fIsLocked ? SelectMake.MakeEditMode.EditWithConfirm : SelectMake.MakeEditMode.Locked;

            mfbDateOfGlassUpgrade.Date  = m_ac.GlassUpgradeDate ?? DateTime.MinValue;
            pnlGlassUpgradeDate.Visible = !rbAvionicsNone.Checked;

            AdjustForAircraftType();

            AddPicturesForAircraft();

            // So that we can detect a tailnumber change (which should force a change of country code) vs. a country-code change
            // (which should force a change of tail number), preserve the last value for each.
            // We have to do this since we rebuild the country code dropdown on each postback (to save viewstate size), which makes it
            // hard to detect true changes of one vs. the other.
            hdnLastCountry.Value = cmbCountryCode.SelectedValue;
            hdnLastTail.Value    = txtTail.Text;

            pnlReuseWarning.Visible = fIsNew;
            if (!fIsNew)
            {
                lblTailnumber.Text = m_ac.IsAnonymous ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.LocalizedJoinWithSpace, m_ac.TailNumber, m_ac.DisplayTailnumber) : m_ac.TailNumber;
            }
        }