internal void Delete_Fertilize_Job(Fertilize_Job job) { if (Fertilize_Schedule.Contains(job)) { Fertilize_Schedule.Remove(job); OnFertilize_Schedule_Changed(new EventArgs()); } }
internal Fertilize_Job[] Get_All_Fertilize_Jobs() { Fertilize_Job[] all_Jobs = new Fertilize_Job[Fertilize_Schedule.Count]; for (int jobIndex = 0; jobIndex < Fertilize_Schedule.Count; jobIndex++) { all_Jobs[jobIndex] = (Fertilize_Job)Fertilize_Schedule[jobIndex]; } return(all_Jobs); }
internal static Fertilize_Job[] GetParameter(int Pump_Index) { string pump_Index = Pump_Index.ToString(); ResultSet result = settingsDatabase.ExecuteQuery("SELECT Starttime,Quantity FROM Fertilize_Jobs WHERE Pump_Index='" + pump_Index + "'"); Fertilize_Job[] jobs = new Fertilize_Job[result.RowCount]; for (int row = 0; row < result.RowCount; row++) { string startTime = (string)((ArrayList)result.Data[row])[0]; string hour = startTime.Substring(0, startTime.IndexOf(":")); string minute = startTime.Substring(startTime.IndexOf(":") + 1, startTime.Length - startTime.IndexOf(":") - 1); string quantity = (string)((ArrayList)result.Data[row])[1]; DateTime time = new DateTime(0).AddHours(int.Parse(hour)).AddMinutes(int.Parse(minute)); jobs[row] = new Fertilize_Job(time, int.Parse(quantity)); } return(jobs); }
internal Fertilize_Job Get_Nearest_Fertilize_Job() { Fertilize_Job nearest_Job = null; DateTime actualTime = new DateTime(0).AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute); foreach (Fertilize_Job job in Fertilize_Schedule) { if (nearest_Job == null) { nearest_Job = job; } else { if (job.StartTime > actualTime && nearest_Job.StartTime > actualTime) { if (job.StartTime < nearest_Job.StartTime) { nearest_Job = job; } } else if (job.StartTime > actualTime && nearest_Job.StartTime < actualTime) { nearest_Job = job; } else if (job.StartTime < actualTime && nearest_Job.StartTime < actualTime) { if (job.StartTime < nearest_Job.StartTime) { nearest_Job = job; } } } } return(nearest_Job); }
internal void Modify_Fertilize_Job(Fertilize_Job job) { Delete_Fertilize_Job(job); Add_Fertilize_Job(job); }
internal void Add_Fertilize_Job(Fertilize_Job job) { Fertilize_Schedule.Add(job); OnFertilize_Schedule_Changed(new EventArgs()); }