protected void gvDeadlines_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } DeadlineCurrency dc = UserDeadlines[e.RowIndex]; DeadlineCurrency dcOriginal = new DeadlineCurrency(); util.CopyObject(dc, dcOriginal); Controls_mfbTypeInDate typeinNew = (Controls_mfbTypeInDate)gvDeadlines.Rows[e.RowIndex].FindControl("mfbUpdateDeadlineDate"); Controls_mfbDecimalEdit typeinNewHours = (Controls_mfbDecimalEdit)gvDeadlines.Rows[e.RowIndex].FindControl("decNewHours"); if (dc.AircraftHours > 0) { dc.AircraftHours = dc.NewHoursBasedOnHours(typeinNewHours.Value); } else { dc.Expiration = dc.NewDueDateBasedOnDate(typeinNew.Date); } if (dc.IsValid() && dc.FCommit()) { gvDeadlines.EditIndex = -1; ForceRefresh(); DeadlineUpdated?.Invoke(this, new DeadlineEventArgs(dcOriginal, dc)); } }
/// <summary> /// Initializes the specified starting flight with the values of the decimal edits in the row /// </summary> /// <param name="sf">The starting flight</param> /// <param name="iRow">The row</param> protected void FromRow(LogbookEntryCore sf, int iRow) { int iCol = 0; foreach (StartingFlightColumn sfc in Enum.GetValues(typeof(StartingFlightColumn))) { Controls_mfbDecimalEdit de = (Controls_mfbDecimalEdit)tblStartingFlights.Rows[iRow].FindControl(IDForCell(iRow, iCol)); SetValueForColumn(sfc, sf, de.Value); iCol++; } }
protected void gvDeadlines_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } DeadlineCurrency dc = UserDeadlines[e.RowIndex]; DeadlineCurrency dcOriginal = new DeadlineCurrency(); util.CopyObject(dc, dcOriginal); Controls_mfbTypeInDate typeinNew = (Controls_mfbTypeInDate)gvDeadlines.Rows[e.RowIndex].FindControl("mfbUpdateDeadlineDate"); Controls_mfbDecimalEdit typeinNewHours = (Controls_mfbDecimalEdit)gvDeadlines.Rows[e.RowIndex].FindControl("decNewHours"); if (dc.AircraftHours > 0) { dc.AircraftHours = dc.NewHoursBasedOnHours(typeinNewHours.Value); } else { dc.Expiration = dc.NewDueDateBasedOnDate(typeinNew.Date); } if (dc.IsValid() && dc.FCommit()) { gvDeadlines.EditIndex = -1; ForceRefresh(); if (dc.AircraftID > 0) { string szDiff = dc.DifferenceDescription(dcOriginal); if (!String.IsNullOrEmpty(szDiff)) { MaintenanceLog ml = new MaintenanceLog() { AircraftID = dc.AircraftID, ChangeDate = DateTime.Now, User = UserName, Description = szDiff, Comment = string.Empty }; ml.FAddToLog(); } } if (DeadlineUpdated != null) { DeadlineUpdated(this, new DeadlineEventArgs(dcOriginal, dc)); } } }
protected void gvAircraft_RowDataBound(object sender, GridViewRowEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if ((e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit) { ClubAircraft ca = (ClubAircraft)e.Row.DataItem; Controls_mfbDecimalEdit decHighWater = (Controls_mfbDecimalEdit)e.Row.FindControl("decEditTime"); decHighWater.Value = ca.HighWater; Label lnkHobbs = (Label)e.Row.FindControl("lnkCopyHobbs"); Label lnkTach = (Label)e.Row.FindControl("lnkCopyTach"); e.Row.FindControl("pnlHighHobbs").Visible = ca.HighestRecordedHobbs > 0; e.Row.FindControl("pnlHighTach").Visible = ca.HighestRecordedTach > 0; lnkHobbs.Text = String.Format(CultureInfo.CurrentCulture, Resources.Club.ClubAircraftHighestHobbs, ca.HighestRecordedHobbs); lnkTach.Text = String.Format(CultureInfo.CurrentCulture, Resources.Club.ClubAircraftHighestTach, ca.HighestRecordedTach); ((Image)e.Row.FindControl("imgXFillHobbs")).Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:$find('{0}').set_text('{1}');", decHighWater.EditBoxWE.ClientID, ca.HighestRecordedHobbs.ToString(CultureInfo.CurrentCulture)); ((Image)e.Row.FindControl("imgXFillTach")).Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:$find('{0}').set_text('{1}');", decHighWater.EditBoxWE.ClientID, ca.HighestRecordedTach.ToString(CultureInfo.CurrentCulture)); } }
protected void gvDeadlines_RowDataBound(object sender, GridViewRowEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit) { Controls_mfbTypeInDate typeindate = (Controls_mfbTypeInDate)e.Row.FindControl("mfbUpdateDeadlineDate"); Controls_mfbDecimalEdit decEdit = (Controls_mfbDecimalEdit)e.Row.FindControl("decNewHours"); DeadlineCurrency dc = UserDeadlines[e.Row.RowIndex]; if (dc.UsesHours) { decEdit.Value = dc.AircraftHours; } else { typeindate.Date = typeindate.DefaultDate = dc.Expiration.LaterDate(DateTime.Now); } } } }
protected void UpdateFlightTable() { if (StartingFlights == null) { return; } tblStartingFlights.Rows.Clear(); if (StartingFlights.Count == 0) { lblNoAircraft.Visible = true; return; } TableRow trHeader = new TableRow(); tblStartingFlights.Rows.Add(trHeader); trHeader.Font.Bold = true; // table header // Description... TableCell tc = new TableCell(); trHeader.Cells.Add(tc); // ...Then the editable cells foreach (StartingFlightColumn sfc in Enum.GetValues(typeof(StartingFlightColumn))) { tc = new TableCell(); trHeader.Cells.Add(tc); tc.Text = ColumnTitleFromColumn(sfc); } bool fHHMM = MyFlightbook.Profile.GetUser(Page.User.Identity.Name).UsesHHMM; // Now the individual rows. int iRow = 0; foreach (StartingFlight sf in StartingFlights) { TableRow tr = new TableRow(); tblStartingFlights.Rows.Add(tr); tc = new TableCell(); tr.Cells.Add(tc); switch (CurrentMode) { case RepresentativeAircraft.RepresentativeTypeMode.ByModel: AddAircraftDescription(sf.RepresentativeAircraft.ExampleAircraft.ModelCommonName, sf.RepresentativeAircraft.ExampleAircraft.ModelDescription, tc); break; case RepresentativeAircraft.RepresentativeTypeMode.CatClassCapabilities: { string szDesc = sf.RepresentativeAircraft.Descriptor; AddAircraftDescription(sf.RepresentativeAircraft.Name + (szDesc.Length > 0 ? String.Format(CultureInfo.InvariantCulture, Resources.LocalizedText.LocalizedParentheticalWithSpace, szDesc) : string.Empty), String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.StartingFlightAircraftExample, sf.RepresentativeAircraft.ExampleAircraft.ModelCommonName), tc); } break; case RepresentativeAircraft.RepresentativeTypeMode.CatClassType: AddAircraftDescription(sf.RepresentativeAircraft.Name, String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.StartingFlightAircraftExample, sf.RepresentativeAircraft.ExampleAircraft.ModelDescription), tc); break; } int iCol = 0; foreach (StartingFlightColumn sfc in Enum.GetValues(typeof(StartingFlightColumn))) { tc = new TableCell(); tr.Cells.Add(tc); tc.ID = IDForCell(iRow, iCol) + sfc.ToString(); Controls_mfbDecimalEdit dc = (Controls_mfbDecimalEdit)LoadControl("~/Controls/mfbDecimalEdit.ascx"); dc.ID = IDForCell(iRow, iCol); tc.Controls.Add(dc); dc.EditingMode = fHHMM ? Controls_mfbDecimalEdit.EditMode.HHMMFormat : Controls_mfbDecimalEdit.EditMode.Decimal; iCol++; } ToRow(sf, iRow); iRow++; } }