private void set_TextBox_RemainingTime(Fertilize_Pump pump, TextBox textBox) { if (Time_Service.isTimeSet) { Fertilize_Job job = pump.Get_Nearest_Fertilize_Job(); DateTime actualTime = new DateTime(0).AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute); if (job != null) { if (actualTime < job.StartTime) { TimeSpan remainingTimeToStart = job.StartTime - actualTime; textBox.Text = remainingTimeToStart.Hours.ToString("D2") + ":" + remainingTimeToStart.Minutes.ToString("D2"); } else { DateTime remainingTimeToStart = job.StartTime + (new DateTime(0).AddHours(24) - actualTime); textBox.Text = remainingTimeToStart.Hour.ToString("D2") + ":" + remainingTimeToStart.Minute.ToString("D2"); } } else { textBox.Text = "--:--"; } } else { textBox.Text = "--:--"; } textBox.Invalidate(); }
void textbox_Quantity_ValueChangedEvent(object sender) { if (dataGrid_Schedule.SelectedIndex >= 0 && dropDown_PumpSelection.Value != null) { Fertilize_Job job = ((Fertilize_Job)dataGrid_Schedule.GetCellData(2, dataGrid_Schedule.SelectedIndex)); string quantity_ml_string; if (textbox_Quantity.Text.IndexOf(" ml") == (textbox_Quantity.Text.Length - 3) && textbox_Quantity.Text.IndexOf(" ml") > 0) { quantity_ml_string = textbox_Quantity.Text.Substring(0, textbox_Quantity.Text.Length - 3); } else { quantity_ml_string = textbox_Quantity.Text; } int quantity_ml = 0; try { quantity_ml = int.Parse(quantity_ml_string); } catch (Exception) { } job.Quantity_ml = quantity_ml; Fertilize_Manager.GetFertilizePumpByIndex((int)dropDown_PumpSelection.Value).Modify_Fertilize_Job(job); } }
void set_TextBox_NextFertilizeJob(Fertilize_Pump pump, TextBox textBox) { string nextStartTime = "--:--"; Fertilize_Job job = pump.Get_Nearest_Fertilize_Job(); if (job != null) { nextStartTime = job.StartTime.Hour.ToString("D2") + ":" + job.StartTime.Minute.ToString("D2"); } textBox.Text = nextStartTime; }
void textbox_StartTime_ValueChangedEvent(object sender) { if (dataGrid_Schedule.SelectedIndex >= 0 && dropDown_PumpSelection.Value != null) { Fertilize_Job job = ((Fertilize_Job)dataGrid_Schedule.GetCellData(2, dataGrid_Schedule.SelectedIndex)); DateTime startTime = new DateTime(0); if ((textbox_StartTime.Text.IndexOf(":") > 0) && ((textbox_StartTime.Text.Length - 1) > textbox_StartTime.Text.IndexOf(":"))) { string hour = textbox_StartTime.Text.Substring(0, textbox_StartTime.Text.IndexOf(":")); string minute = textbox_StartTime.Text.Substring(textbox_StartTime.Text.IndexOf(":") + 1, textbox_StartTime.Text.Length - textbox_StartTime.Text.IndexOf(":") - 1); startTime = startTime.AddHours(int.Parse(hour)).AddMinutes(int.Parse(minute)); } job.StartTime = startTime; Fertilize_Manager.GetFertilizePumpByIndex((int)dropDown_PumpSelection.Value).Modify_Fertilize_Job(job); } }