protected MakeModel MakeFromForm() { CategoryClass.CatClassID ccId = (CategoryClass.CatClassID)Enum.Parse(typeof(CategoryClass.CatClassID), cmbCatClass.SelectedValue, true); Boolean fSea = CategoryClass.IsSeaClass(ccId); if (ckComplex.Checked) { if (fSea) { ckRetract.Checked = true; } ckCowlFlaps.Checked = true; ckConstantProp.Checked = true; } // if we were going to be really anal here, there would be no "complex" field in the database; // it would be entirely derived. but we're not being really anal. // Complex is FAR 61.31. if ((fSea || ckRetract.Checked) && ckConstantProp.Checked && ckCowlFlaps.Checked) { ckComplex.Checked = true; } MakeModel mk = (MakeID == -1) ? new MakeModel() : new MakeModel(MakeID); mk.Model = txtModel.Text.Trim(); mk.ModelName = txtName.Text.Trim(); mk.TypeName = txtType.Text.Trim(); mk.CategoryClassID = ccId; mk.FamilyName = CategoryClass.HasICAO(ccId) ? txtFamilyName.Text.Trim().ToUpper(CultureInfo.InvariantCulture).Replace("-", string.Empty).Replace(" ", string.Empty) : string.Empty; mk.ManufacturerID = Convert.ToInt32(cmbManufacturer.SelectedValue, CultureInfo.InvariantCulture); mk.IsComplex = ckComplex.Checked; mk.PerformanceType = HighPerfType; mk.IsTailWheel = ckTailwheel.Checked; mk.IsConstantProp = ckConstantProp.Checked; mk.HasFlaps = ckCowlFlaps.Checked; mk.IsRetract = ckRetract.Checked; mk.AvionicsTechnology = AvionicsTechnology; mk.EngineType = (MakeModel.TurbineLevel)rblTurbineType.SelectedIndex; mk.ArmyMDS = txtArmyMDS.Text; mk.AllowedTypes = (AllowedAircraftTypes)rblAircraftAllowedTypes.SelectedIndex; mk.IsMotorGlider = (ckTMG.Checked && (ccId == CategoryClass.CatClassID.Glider)); mk.IsMultiEngineHelicopter = (ckMultiHeli.Checked && (ccId == CategoryClass.CatClassID.Helicopter)); mk.IsCertifiedSinglePilot = ckSinglePilot.Checked && mk.EngineType.IsTurbine() && !String.IsNullOrEmpty(mk.TypeName); // Sanity check - no complex for a jet if (mk.EngineType == MakeModel.TurbineLevel.Jet) { mk.IsComplex = mk.IsConstantProp = false; } // these don't get persisted, but help with dupe detection. mk.CategoryClassDisplay = cmbCatClass.SelectedItem.Text; mk.ManufacturerDisplay = cmbManufacturer.SelectedItem.Text; UpdateRowsForCatClass(mk.CategoryClassID); return(mk); }
protected void UpdateRowsForCatClass(CategoryClass.CatClassID idCatClass) { bool fIsGlider = idCatClass == CategoryClass.CatClassID.Glider; divTMG.Visible = fIsGlider; divTailwheel.Visible = CategoryClass.IsAirplane(idCatClass) && !CategoryClass.IsSeaClass(idCatClass); divMultiHeli.Visible = (idCatClass == CategoryClass.CatClassID.Helicopter); bool hasEngine = CategoryClass.HasEngine(idCatClass); rowEngineType.Visible = hasEngine; pnlHighPerfBlock.Visible = ckConstantProp.Enabled = ckComplex.Enabled = hasEngine; divComplex.Style["display"] = hasEngine || fIsGlider ? "inline-block" : "none"; if (!hasEngine) { ckComplex.Checked = ckConstantProp.Checked = ckCowlFlaps.Checked = ckRetract.Checked = false; rblTurbineType.SelectedIndex = 0; } bool fIsLegacyEligible = (idCatClass == CategoryClass.CatClassID.AMEL || idCatClass == CategoryClass.CatClassID.AMES || idCatClass == CategoryClass.CatClassID.Helicopter); pnlLegacyHighPerf.Style["display"] = fIsLegacyEligible ? "inline" : "none"; if (ckLegacyHighPerf.Checked && !fIsLegacyEligible) { HighPerfType = MakeModel.HighPerfType.NotHighPerf; } rowFamily.Visible = CategoryClass.HasICAO(idCatClass); }