protected AircraftImportMatchRow MatchRowFromGridviewRow(GridViewRow grow)
    {
        HiddenField h  = (HiddenField)grow.FindControl("hdnMatchRowID");
        int         id = Convert.ToInt32(h.Value);

        return(CandidatesForImport.FirstOrDefault <AircraftImportMatchRow>(mr => mr.ID == id));
    }
    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();
        }
    }
Example #3
0
    protected AircraftImportMatchRow MatchRowFromGridviewRow(GridViewRow grow)
    {
        HiddenField h = (HiddenField)grow.FindControl("hdnMatchRowID");
        int         id;

        try
        {
            id = Convert.ToInt32(h.Value);
        } catch (FormatException ex)
        {
            throw new FormatException(String.Format(CultureInfo.CurrentCulture, "invalid number in hdnMatchRowID: '{0}'", h.Value == null ? "(null)" : h.Value), ex);
        }
        return(CandidatesForImport.FirstOrDefault <AircraftImportMatchRow>(mr => mr.ID == id));
    }