private static void AutoComplete(LogbookEntry le) { // Issue #939: autofill cross-country/night, when possible. AutoFillOptions afo = AutoFillOptions.DefaultOptionsForUser(le.User); if (afo != null && le.CrossCountry == 0.0M) { if (le.Nighttime == 0.0M) { using (FlightData fd = new FlightData()) fd.AutoFill(le, afo); } else // just do xc time based on part 121 xc { CannedQuery fq = new CannedQuery() { Distance = FlightQuery.FlightDistance.NonLocalOnly }; if (fq.IsAirportMatch(le)) { le.CrossCountry = le.TotalFlightTime; } } } }
protected void gvSavedQueries_RowCommand(object sender, CommandEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (!int.TryParse(e.CommandArgument.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int idRow)) { return; } CannedQuery cq = CannedQuery.QueriesForUser(Page.User.Identity.Name).ElementAt(idRow); if (e.CommandName.CompareOrdinal("_Delete") == 0) { cq.Delete(); UpdateSavedQueries(); } else if (e.CommandName.CompareOrdinal("_Load") == 0) { Restriction = cq; RefreshFormForQuery(); txtQueryName.Text = string.Empty; DoSearch(); } }
protected void UpdateQueryList() { Queries = CannedQuery.QueriesForUser(Page.User.Identity.Name); foreach (CannedQuery cq in Queries) { cq.Refresh(); } gvCanned.DataSource = Queries; gvCanned.DataBind(); }
protected void btnUpdateColors_Click(object sender, EventArgs e) { foreach (GridViewRow gvr in gvCanned.Rows) { CannedQuery cq = Queries.ElementAt(gvr.RowIndex); cq.ColorString = ((TextBox)gvr.FindControl("txtQSamp")).Text; if (String.IsNullOrWhiteSpace(cq.ColorString)) { cq.ColorString = null; // remove it entirely. } cq.Commit(false); } UpdateQueryList(); lblColorsUpdated.Visible = true; }
protected void gvCanned_RowCommand(object sender, GridViewCommandEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (sender == null) { throw new ArgumentNullException(nameof(sender)); } if (e.CommandName.CompareOrdinal("_RemoveColor") == 0) { CannedQuery cq = new List <CannedQuery>(CannedQuery.QueriesForUser(Page.User.Identity.Name)).FirstOrDefault(cq2 => cq2.QueryName.CompareCurrentCultureIgnoreCase(e.CommandArgument.ToString()) == 0); ((TextBox)((Control)e.CommandSource).NamingContainer.FindControl("txtQSamp")).Text = string.Empty; ((Label)((Control)e.CommandSource).NamingContainer.FindControl("lblQSamp")).BackColor = System.Drawing.Color.Empty; } }
protected void DoSearch() { GetFlightQuery(); // Save it, if it was given a name CannedQuery cq = m_fq as CannedQuery; if (cq != null && !String.IsNullOrEmpty(cq.QueryName)) { cq.Commit(); UpdateSavedQueries(); txtQueryName.Text = string.Empty; } if (QuerySubmitted != null) { QuerySubmitted(this, new FlightQueryEventArgs(m_fq)); } }
protected void gvCanned_RowDataBound(object sender, GridViewRowEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.Row.RowType == DataControlRowType.DataRow) { CannedQuery cq = (CannedQuery)e.Row.DataItem; if (!String.IsNullOrWhiteSpace(cq.ColorString)) { TextBox t = (TextBox)e.Row.FindControl("txtQsamp"); Label l = (Label)e.Row.FindControl("lblQSamp"); t.Text = cq.ColorString; l.BackColor = FlightColor.TryParseColor(cq.ColorString); } } }
protected void UpdateSavedQueries() { gvSavedQueries.DataSource = CannedQuery.QueriesForUser(Page.User.Identity.Name); gvSavedQueries.DataBind(); }
protected void gvCustomRatings_RowCommand(object sender, GridViewCommandEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (sender == null) { throw new ArgumentNullException(nameof(e)); } GridView gv = sender as GridView; List <CustomRatingProgress> lst = new List <CustomRatingProgress>(CustomRatingProgress.CustomRatingsForUser(Page.User.Identity.Name)); if (e.CommandName.CompareCurrentCultureIgnoreCase("_DeleteRating") == 0) { lst.RemoveAll(crp => crp.Title.CompareCurrentCulture((string)e.CommandArgument) == 0); gvCustomRatings.EditIndex = -1; CustomRatingProgress.CommitRatingsForUser(Page.User.Identity.Name, lst); RefreshCustomRatings(); UpdateMilestones(); } else if (e.CommandName.CompareCurrentCultureIgnoreCase("_DeleteMilestone") == 0) { CustomRatingProgress crp = lst[Convert.ToInt32(hdnCpeIndex.Value, CultureInfo.InvariantCulture)]; crp.RemoveMilestoneAt(Convert.ToInt32(e.CommandArgument, CultureInfo.InvariantCulture)); mpeEditMilestones.Show(); // keep the dialog open CustomRatingProgress.CommitRatingsForUser(Page.User.Identity.Name, lst); gv.DataSource = crp.ProgressItems; gv.DataBind(); UpdateMilestones(); } else if (e.CommandName.CompareCurrentCultureIgnoreCase("_EditMilestones") == 0) { int row = Convert.ToInt32(e.CommandArgument, CultureInfo.InvariantCulture); CustomRatingProgress crp = lst[row]; hdnCpeIndex.Value = row.ToString(CultureInfo.InvariantCulture); if (cmbFields.Items.Count == 0) { // initialize the editing drop-downs, if needed cmbFields.DataSource = HistogramableValues; cmbFields.DataBind(); cmbQueries.DataSource = CannedQuery.QueriesForUser(User.Identity.Name); cmbQueries.DataBind(); } lblEditMilestonesForProgress.Text = String.Format(CultureInfo.InvariantCulture, Resources.MilestoneProgress.CustomProgressMilestonesForCustomRating, HttpUtility.HtmlEncode(crp.Title)); gvCustomRatingItems.DataSource = crp.ProgressItems; gvCustomRatingItems.DataBind(); mpeEditMilestones.Show(); } else if (e.CommandName.CompareCurrentCultureIgnoreCase("Update") == 0) { // Find the existing item CustomRatingProgress crp = lst[gv.EditIndex]; if (crp != null) { string szNewTitle = ((TextBox)gv.Rows[0].Cells[1].Controls[0]).Text; if (String.IsNullOrWhiteSpace(szNewTitle)) { return; } crp.Title = szNewTitle; crp.GeneralDisclaimer = ((TextBox)gv.Rows[0].Cells[2].Controls[0]).Text; } CustomRatingProgress.CommitRatingsForUser(Page.User.Identity.Name, lst); gvCustomRatings.EditIndex = -1; RefreshCustomRatings(); UpdateMilestones(); } }