private void GetInfosForTick() { string sqlTimeToEndFlight = "select date_assigned, TIME_TO_SEC(DATE_ADD(date_assigned, INTERVAL 30 MINUTE))-TIME_TO_SEC(NOW()) FROM pilotassignments WHERE pilot=@UserID and NOW() <= DATE_ADD(date_assigned, INTERVAL 30 MINUTE) LIMIT 1"; MySqlConnection conn = new MySqlConnection(Login.ConnectionString); try { conn.Open(); MySqlCommand sqlCmd = new MySqlCommand(sqlTimeToEndFlight, conn); sqlCmd.Parameters.AddWithValue("@UserID", a.UserID); MySqlDataReader sqlCmdRes = sqlCmd.ExecuteReader(); if (sqlCmdRes.HasRows) { while (sqlCmdRes.Read()) { s = Convert.ToInt32(sqlCmdRes[1]); sBar = 1800 - Convert.ToInt32(sqlCmdRes[1]); } } FlightTimeEndTick.Start(); } catch (Exception crap) { throw new ApplicationException("Failed to load exam @UserInfoDash()", crap); } finally { conn.Close(); } }
public void AlertFlight() { if (FlightID != 0) { lblFlightAlert.Text = String.Format("Alert!! You have one flight with callsign {0}, from {1} to {2} with {3}", FlightCallsign, UserDeparture, UserArrival, UserAircraft); lblFlightAlert.Visible = true; GetInfosForTick(); label1.Visible = true; pBarFlightTimeEnd.Visible = true; GetInfosForTick(); } else { lblFlightAlert.Visible = false; label1.Visible = false; pBarFlightTimeEnd.Visible = false; FlightTimeEndTick.Stop(); } }
private void FlightTimeEndTick_Tick(object sender, EventArgs e) { GetInfosForTick(); s = s - 1; sBar = sBar + 1; if (s == 0) { FlightTimeEndTick.Stop(); //END of Time } string ss = Convert.ToString(s); int ssBar = (sBar * 100) / 1800; pBarFlightTimeEnd.Value = ssBar; }
public void AlertFlight() { a = new UserInfo(); if (CurrentLocation != a.Location) { flightAssignmentCtrl.assingmentCtrl.comboTypeRatings(); } if (Flightid != 0) { if (!f.OnFlight) { lblFlightAlert.Text = String.Format("Alert!! You have one flight with callsign {0}, from {1} to {2} with {3}", FlightCallsign, UserDeparture, UserArrival, UserAircraft); lblFlightAlert.ForeColor = Color.Red; lblFlightAlert.Visible = true; label1.Visible = true; pBarFlightTimeEnd.Visible = true; FlightTimeEndTick.Start(); } else { lblFlightAlert.Text = String.Format("On Flying!! -> {0}, from {1} to {2} with {3}", FlightCallsign, UserDeparture, UserArrival, UserAircraft); lblFlightAlert.ForeColor = Color.ForestGreen; lblFlightAlert.Visible = true; label1.Visible = false; pBarFlightTimeEnd.Visible = false; FlightTimeEndTick.Stop(); } } else { if (a.Location != a.Hub) { LastFlight lf = new LastFlight(); int RemainingDaysToFlightExpire = ((lf.DateOfFlightExpire - DateTime.UtcNow.Date).Days - 1); if (RemainingDaysToFlightExpire <= -1) { lblFlightAlert.Visible = false; LastFlight.ReturnToHub(a.MediaTotalFlights); } else if (RemainingDaysToFlightExpire == 0) { lblFlightAlert.Text = String.Format("Alert!! Today is last day to return your hub without penalizations", RemainingDaysToFlightExpire.ToString()); lblFlightAlert.ForeColor = Color.Red; lblFlightAlert.Visible = true; } else { lblFlightAlert.Text = String.Format("Alert!! You have {0} days to return your hub without penalizations", RemainingDaysToFlightExpire.ToString()); lblFlightAlert.ForeColor = Color.Orange; lblFlightAlert.Visible = true; } label1.Visible = false; pBarFlightTimeEnd.Visible = false; FlightTimeEndTick.Stop(); } else { lblFlightAlert.Visible = false; label1.Visible = false; pBarFlightTimeEnd.Visible = false; FlightTimeEndTick.Stop(); } } CurrentLocation = a.Location; }