protected void cmbMakeModel_SelectedIndexChanged(object sender, EventArgs e) { int modelID = SelectedModelID; UpdateAttributesForModel(modelID == MakeModel.UnknownModel ? null : MakeModel.GetModel(modelID)); ModelChanged?.Invoke(this, new MakeSelectedEventArgs(modelID)); }
protected void gvAircraftCandidates_RowCommand(object sender, CommandEventArgs e) { if (e == null) { throw new ArgumentException("null gridviewcommandeventargs for new aircraft to import", "e"); } int idRow = Convert.ToInt32(e.CommandArgument, CultureInfo.InvariantCulture); if (e.CommandName.CompareOrdinalIgnoreCase("AddNew") == 0) { UserAircraft ua = new UserAircraft(Page.User.Identity.Name); AircraftImportMatchRow mr = CandidatesForImport.FirstOrDefault <AircraftImportMatchRow>(mr2 => mr2.ID == idRow); mr.BestMatchAircraft.Commit(Page.User.Identity.Name); ModelMapping[mr.ModelGiven] = MakeModel.GetModel(mr.BestMatchAircraft.ModelID); // remember the mapping. // hack, but the commit above can result in the instance type being cleared out, so restore it. if (String.IsNullOrEmpty(mr.BestMatchAircraft.InstanceTypeDescription)) { mr.BestMatchAircraft.InstanceTypeDescription = AircraftInstance.GetInstanceTypes()[mr.BestMatchAircraft.InstanceTypeID - 1].DisplayName; } mr.State = AircraftImportMatchRow.MatchState.JustAdded; UpdateGrid(); } }
public static string AddNewAircraft(string szTail, int idModel, int instanceType, string szModelGiven, string szJsonMapping) { if (!HttpContext.Current.User.Identity.IsAuthenticated || String.IsNullOrEmpty(HttpContext.Current.User.Identity.Name)) { throw new MyFlightbookException("Unauthenticated call to add new aircraft"); } if (string.IsNullOrEmpty(szTail)) { throw new ArgumentException("Missing tail in AddNewAircraft"); } Dictionary <string, MakeModel> dModelMapping = String.IsNullOrEmpty(szJsonMapping) ? new Dictionary <string, MakeModel>() : JsonConvert.DeserializeObject <Dictionary <string, MakeModel> >(szJsonMapping); string szCurrentUser = HttpContext.Current.User.Identity.Name; Aircraft ac = new Aircraft() { TailNumber = szTail, ModelID = idModel, InstanceTypeID = instanceType }; // Issue #296: allow sims to come through without a sim prefix; we can fix it at AddNewAircraft time. AircraftInstance aic = Array.Find(AircraftInstance.GetInstanceTypes(), it => it.InstanceTypeInt == instanceType); string szSpecifiedTail = szTail; bool fIsNamedSim = !aic.IsRealAircraft && !szTail.ToUpper(CultureInfo.CurrentCulture).StartsWith(CountryCodePrefix.SimCountry.Prefix.ToUpper(CultureInfo.CurrentCulture), StringComparison.CurrentCultureIgnoreCase); if (fIsNamedSim) { ac.TailNumber = CountryCodePrefix.SimCountry.Prefix; } if (ac.FixTailAndValidate()) { ac.CommitForUser(szCurrentUser); UserAircraft ua = new UserAircraft(szCurrentUser); if (fIsNamedSim) { ac.PrivateNotes = String.Format(CultureInfo.InvariantCulture, "{0} #ALT{1}#", ac.PrivateNotes ?? string.Empty, szSpecifiedTail); } ua.FAddAircraftForUser(ac); ua.InvalidateCache(); if (!String.IsNullOrEmpty(szModelGiven)) { dModelMapping[szModelGiven] = MakeModel.GetModel(idModel); } } else { throw new MyFlightbookValidationException(ac.ErrorString); } return(JsonConvert.SerializeObject(dModelMapping)); }
public void AddPictures(Object sender, GridViewRowEventArgs e) { if (e != null && e.Row.RowType == DataControlRowType.DataRow) { Aircraft ac = (Aircraft)e.Row.DataItem; // Refresh the images if (!IsAdminMode) { ((Controls_mfbHoverImageList)e.Row.FindControl("mfbHoverThumb")).Refresh(); } // Show aircraft capabilities too. Controls_popmenu popup = (Controls_popmenu)e.Row.FindControl("popmenu1"); ((RadioButtonList)popup.FindControl("rblRole")).SelectedValue = ac.RoleForPilot.ToString(); ((CheckBox)popup.FindControl("ckShowInFavorites")).Checked = !ac.HideFromSelection; ((Label)popup.FindControl("lblOptionHeader")).Text = String.Format(CultureInfo.CurrentCulture, Resources.Aircraft.optionHeader, ac.DisplayTailnumber); if (!IsAdminMode) { List <LinkedString> lst = new List <LinkedString>(); if (ac.Stats != null) { lst.Add(ac.Stats.UserStatsDisplay); } MakeModel mm = MakeModel.GetModel(ac.ModelID); if (mm != null) { if (!String.IsNullOrEmpty(mm.FamilyName)) { lst.Add(new LinkedString(ModelQuery.ICAOPrefix + mm.FamilyName)); } foreach (string sz in mm.AttributeList(ac.AvionicsTechnologyUpgrade, ac.GlassUpgradeDate)) { lst.Add(new LinkedString(sz)); } } Repeater rpt = (Repeater)e.Row.FindControl("rptAttributes"); rpt.DataSource = lst; rpt.DataBind(); } if (IsAdminMode) { HyperLink lnkRegistration = (HyperLink)e.Row.FindControl("lnkRegistration"); string szURL = ac.LinkForTailnumberRegistry(); lnkRegistration.Visible = szURL.Length > 0; lnkRegistration.NavigateUrl = szURL; } } }
private FlightQuery AddModelToQuery(FlightQuery fq, int idModel) { List <MakeModel> lst = new List <MakeModel>(fq.MakeList); if (!lst.Exists(m => m.MakeModelID == idModel)) { lst.Add(MakeModel.GetModel(idModel)); } fq.MakeList = lst.ToArray(); return(fq); }
protected void lnkPopulateModel_Click(object sender, EventArgs e) { if (int.TryParse(hdnSelectedModel.Value, out int mmID)) { MakeModel mm = MakeModel.GetModel(mmID); cmbManufacturers.SelectedValue = mm.ManufacturerID.ToString(CultureInfo.InvariantCulture); LastSelectedManufacturer = mm.ManufacturerID; UpdateModelList(mm.ManufacturerID); cmbMakeModel.SelectedValue = mmID.ToString(CultureInfo.InvariantCulture); UpdateAttributesForModel(mm); ModelChanged?.Invoke(this, new MakeSelectedEventArgs(SelectedModelID)); hdnSelectedModel.Value = txtFilter.Text = string.Empty; } }
/// <summary> /// Updates the flight query with the specified models /// </summary> private void ModelsFromForm() { if (cklMakes.SelectedIndex >= 0) { m_fq.MakeList.Clear(); foreach (ListItem li in cklMakes.Items) { if (li.Selected) { m_fq.MakeList.Add(MakeModel.GetModel(Convert.ToInt32(li.Value, CultureInfo.InvariantCulture))); } } } m_fq.ModelName = txtModelNameText.Text; }
private void InitAircraftModelRestriction(string szReqTail, string szReqModel, string szReqICAO, string szcc) { if (!String.IsNullOrEmpty(szReqTail) || !String.IsNullOrEmpty(szReqModel) || !String.IsNullOrEmpty(szReqICAO)) { UserAircraft ua = new UserAircraft(Restriction.UserName); Collection <Aircraft> lstac = new Collection <Aircraft>(); HashSet <int> lstmm = new HashSet <int>(); foreach (Aircraft ac in ua.GetAircraftForUser()) { if (ac.DisplayTailnumber.CompareCurrentCultureIgnoreCase(szReqTail) == 0) { lstac.Add(ac); } MakeModel mm = MakeModel.GetModel(ac.ModelID); if (!lstmm.Contains(mm.MakeModelID) && ((!String.IsNullOrEmpty(szReqModel) && mm.Model.CompareCurrentCultureIgnoreCase(szReqModel) == 0) || (!String.IsNullOrEmpty(szReqICAO) && mm.FamilyName.CompareCurrentCultureIgnoreCase(szReqICAO) == 0))) { lstmm.Add(mm.MakeModelID); } } if (lstac.Count > 0) { Restriction.AirportList.Clear(); Restriction.AddAircraft(lstac); } if (lstmm.Count > 0) { Restriction.MakeList.Clear(); Restriction.AddModels(lstmm); } } if (!String.IsNullOrEmpty(szcc)) { foreach (CategoryClass cc in CategoryClass.CategoryClasses()) { if (cc.CatClass.CompareCurrentCultureIgnoreCase(szcc) == 0) { Restriction.AddCatClass(cc); } } } }
/// <summary> /// Updates the flight query with the specified models /// </summary> private void ModelsFromForm() { if (cklMakes.SelectedIndex >= 0) { List <MakeModel> lstMakes = new List <MakeModel>(); foreach (ListItem li in cklMakes.Items) { if (li.Selected) { lstMakes.Add(MakeModel.GetModel(Convert.ToInt32(li.Value, CultureInfo.InvariantCulture))); } } m_fq.MakeList = lstMakes.ToArray(); } m_fq.ModelName = txtModelNameText.Text; }
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; }
public void gvFlightLogs_RowDataBound(Object sender, GridViewRowEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.Row.RowType == DataControlRowType.DataRow) { if (!(e.Row.DataItem is LogbookEntryBase le)) { throw new InvalidCastException("DataItem is not a logbook entry!"); } // Property summary string szProperties = CustomFlightProperty.PropListDisplay(le.CustomProperties, false, "; "); if (szProperties.Length > 0) { PlaceHolder plcProperties = (PlaceHolder)e.Row.FindControl("plcProperties"); TableCell tc = (TableCell)plcProperties.Parent; tc.Text = szProperties; } // Splice in the custom property types. foreach (CustomFlightProperty cfp in le.CustomProperties) { e.Row.Cells[PropertyColumnMap[cfp.PropTypeID]].Text = cfp.ValueString; } // Add model attributes MakeModel m = MakeModel.GetModel(AircraftForUser[le.AircraftID].ModelID); ((Label)e.Row.FindControl("lblComplex")).Text = m.IsComplex.FormatBooleanInt(); ((Label)e.Row.FindControl("lblCSP")).Text = m.IsConstantProp.FormatBooleanInt(); ((Label)e.Row.FindControl("lblFlaps")).Text = m.HasFlaps.FormatBooleanInt(); ((Label)e.Row.FindControl("lblRetract")).Text = m.IsRetract.FormatBooleanInt(); ((Label)e.Row.FindControl("lblTailwheel")).Text = m.IsTailWheel.FormatBooleanInt(); ((Label)e.Row.FindControl("lblHP")).Text = m.IsHighPerf.FormatBooleanInt(); ((Label)e.Row.FindControl("lblTurbine")).Text = m.EngineType == MakeModel.TurbineLevel.Piston ? string.Empty : 1.FormatBooleanInt(); } }
/// <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); }
/// <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); Boolean fRealAircraft = IsRealAircraft; CountryCodePrefix cc = CountryCodePrefix.BestMatchCountryCode(m_ac.TailNumber); Boolean fIsNew = m_ac.IsNew; Boolean fHasModelSpecified = (m_ac.ModelID > 0); Boolean 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; if (fRealAircraft) { if (fIsAnonymous) { lblAnonTailDisplay.Text = m_ac.TailNumber = txtTail.Text = (fHasModelSpecified) ? Aircraft.AnonymousTailnumberForModel(m_ac.ModelID) : String.Empty; pnlAnonTail.Visible = (fHasModelSpecified); } else { if (cc.IsSim || cc.IsAnonymous) // reset tail if switching from sim or anonymous { m_ac.TailNumber = txtTail.Text = cmbCountryCode.SelectedItem.Value; } else { m_ac.TailNumber = txtTail.Text = CountryCodePrefix.SetCountryCodeForTail(new CountryCodePrefix(cmbCountryCode.SelectedItem.Text, cmbCountryCode.SelectedValue), txtTail.Text); } } mvRealAircraft.SetActiveView(fIsAnonymous ? vwAnonTail : vwRegularTail); valTailNumber.Enabled = fIsAnonymous; FixFAALink(); } else { // Sim if (fHasModelSpecified) { m_ac.TailNumber = Aircraft.SuggestSims(m_ac.ModelID, m_ac.InstanceType)[0].TailNumber; } vwSimTailDisplay.SetActiveView(fHasModelSpecified ? vwHasModel : vwNoModel); lblSimTail.Text = txtTail.Text = m_ac.TailNumber; } }
/// <summary> /// Checks flights for various potential issues /// </summary> /// <param name="rgle">An enumerable of flights. MUST BE IN ASCENDING CHRONOLOGICAL ORDER</param> /// <param name="options">A bitmask of LintOptions flags</param> /// <param name="szUser">The name of the user (necessary to get their aircraft, other preferences</param> /// <param name="dtMinDate">Ignore any issues with flights on or before this date</param> /// <returns></returns> public IEnumerable <FlightWithIssues> CheckFlights(IEnumerable <LogbookEntryBase> rgle, string szUser, UInt32 options, DateTime?dtMinDate = null) { if (rgle == null) { throw new ArgumentNullException(nameof(rgle)); } if (szUser == null) { throw new ArgumentNullException(nameof(szUser)); } if (options == 0) { return(Array.Empty <FlightWithIssues>()); } List <FlightWithIssues> lstFlights = new List <FlightWithIssues>(); userAircraft = new UserAircraft(szUser); seenCheckrides = new HashSet <int>(); StringBuilder sb = new StringBuilder(); foreach (LogbookEntryBase le in rgle) { sb.AppendFormat(CultureInfo.CurrentCulture, "{0} ", le.Route); } alMaster = new AirportList(sb.ToString()); // context for sequential flight issues previousFlight = null; dutyStart = dutyEnd = null; flightDutyStart = flightDutyEnd = null; foreach (LogbookEntryBase le in rgle) { currentIssues = new List <FlightIssue>(); // If the flight has any actual errors, add those first if (!String.IsNullOrEmpty(le.ErrorString)) { currentIssues.Add(new FlightIssue() { IssueDescription = le.ErrorString }); } // ignore deadhead flights if (le.CustomProperties.PropertyExistsWithID(CustomPropertyType.KnownProperties.IDPropDeadhead)) { continue; } currentAircraft = userAircraft.GetUserAircraftByID(le.AircraftID); if (currentAircraft == null) { currentIssues.Add(new FlightIssue(LintOptions.MiscIssues, Resources.FlightLint.warningSIMAircraftNotFound)); continue; } currentModel = MakeModel.GetModel(currentAircraft.ModelID); currentCatClassID = (le.CatClassOverride == 0 ? currentModel.CategoryClassID : (CategoryClass.CatClassID)le.CatClassOverride); if (alMaster != null) { alSubset = alMaster.CloneSubset(le.Route); } if ((options & (UInt32)LintOptions.SimIssues) != 0) { CheckSimIssues(le); } if ((options & (UInt32)LintOptions.IFRIssues) != 0) { CheckIFRIssues(le); } if ((options & (UInt32)LintOptions.AirportIssues) != 0) { CheckAirportIssues(le); } if ((options & (UInt32)LintOptions.XCIssues) != 0) { CheckXCIssues(le); } if ((options & (UInt32)LintOptions.PICSICDualMath) != 0) { CheckPICSICDualIssues(le); } if ((options & (UInt32)LintOptions.TimeIssues) != 0) { CheckTimeIssues(le); } if ((options & (UInt32)LintOptions.DateTimeIssues) != 0) { CheckDateTimeIssues(le); } if ((options & (UInt32)LintOptions.MiscIssues) != 0) { CheckMiscIssues(le); } if (currentIssues.Count > 0 && (dtMinDate == null || (dtMinDate.HasValue && le.Date.CompareTo(dtMinDate.Value) > 0))) { lstFlights.Add(new FlightWithIssues(le, currentIssues)); } previousFlight = le; } return(lstFlights); }
public void gvAircraft_OnRowDataBound(Object sender, GridViewRowEventArgs e) { if (e != null && e.Row.RowType == DataControlRowType.DataRow) { Aircraft ac = (Aircraft)e.Row.DataItem; // Refresh the images if (!IsAdminMode) { ((Controls_mfbHoverImageList)e.Row.FindControl("mfbHoverThumb")).Refresh(); } // Show aircraft capabilities too. Control popup = e.Row.FindControl("popmenu1"); RadioButton rbRoleNone = (RadioButton)popup.FindControl("rbRoleNone"); RadioButton rbRoleCFI = (RadioButton)popup.FindControl("rbRoleCFI"); RadioButton rbRoleSIC = (RadioButton)popup.FindControl("rbRoleSIC"); RadioButton rbRolePIC = (RadioButton)popup.FindControl("rbRolePIC"); switch (ac.RoleForPilot) { case Aircraft.PilotRole.None: rbRoleNone.Checked = true; break; case Aircraft.PilotRole.CFI: rbRoleCFI.Checked = true; break; case Aircraft.PilotRole.SIC: rbRoleSIC.Checked = true; break; case Aircraft.PilotRole.PIC: rbRolePIC.Checked = true; break; } CheckBox ckIsFavorite = (CheckBox)popup.FindControl("ckShowInFavorites"); ckIsFavorite.Checked = !ac.HideFromSelection; ckIsFavorite.Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:toggleFavorite({0},this.checked,'{1}');", ac.AircraftID, ResolveClientUrl("~/Member/Aircraft.aspx/SetActive")); CheckBox ckAddName = (CheckBox)popup.FindControl("ckAddNameAsPIC"); ckAddName.Checked = ac.CopyPICNameWithCrossfill; ckAddName.Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:document.getElementById(\"{0}\").click();", rbRolePIC.ClientID); // clicking the "Add Name" checkbox should effectively click the PIC checkbox. rbRoleNone.Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:setRole({0},\"{1}\",false,document.getElementById(\"{2}\"),\"{3}\");", ac.AircraftID, Aircraft.PilotRole.None.ToString(), ckAddName.ClientID, ResolveClientUrl("~/Member/Aircraft.aspx/SetRole")); rbRoleCFI.Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:setRole({0},\"{1}\",false,document.getElementById(\"{2}\"),\"{3}\");", ac.AircraftID, Aircraft.PilotRole.CFI.ToString(), ckAddName.ClientID, ResolveClientUrl("~/Member/Aircraft.aspx/SetRole")); rbRoleSIC.Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:setRole({0},\"{1}\",false,document.getElementById(\"{2}\"),\"{3}\");", ac.AircraftID, Aircraft.PilotRole.SIC.ToString(), ckAddName.ClientID, ResolveClientUrl("~/Member/Aircraft.aspx/SetRole")); rbRolePIC.Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:setRole({0},\"{1}\",document.getElementById(\"{2}\").checked, document.getElementById(\"{3}\"),\"{4}\");", ac.AircraftID, Aircraft.PilotRole.PIC.ToString(), ckAddName.ClientID, ckAddName.ClientID, ResolveClientUrl("~/Member/Aircraft.aspx/SetRole")); ((Label)popup.FindControl("lblOptionHeader")).Text = String.Format(CultureInfo.CurrentCulture, Resources.Aircraft.optionHeader, ac.DisplayTailnumber); if (!IsAdminMode) { List <LinkedString> lst = new List <LinkedString>(); if (ac.Stats != null) { lst.Add(ac.Stats.UserStatsDisplay); } MakeModel mm = MakeModel.GetModel(ac.ModelID); if (mm != null) { if (!String.IsNullOrEmpty(mm.FamilyName)) { lst.Add(new LinkedString(ModelQuery.ICAOPrefix + mm.FamilyName)); } foreach (string sz in mm.AttributeList(ac.AvionicsTechnologyUpgrade, ac.GlassUpgradeDate)) { lst.Add(new LinkedString(sz)); } } Repeater rpt = (Repeater)e.Row.FindControl("rptAttributes"); rpt.DataSource = lst; rpt.DataBind(); } Controls_mfbSelectTemplates selectTemplates = (Controls_mfbSelectTemplates)popup.FindControl("mfbSelectTemplates"); foreach (int i in ac.DefaultTemplates) { selectTemplates.AddTemplate(i); } selectTemplates.Refresh(); if (IsAdminMode) { HyperLink lnkRegistration = (HyperLink)e.Row.FindControl("lnkRegistration"); string szURL = ac.LinkForTailnumberRegistry(); lnkRegistration.Visible = szURL.Length > 0; lnkRegistration.NavigateUrl = szURL; } } }