internal void DeleteNonClassDate(NonClassDate nonClassDate) { String query = " DELETE from non_class_date where id = " + nonClassDate.Id + ";"; try { SQLiteCommand command = new SQLiteCommand(query, conn); command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
internal void AddNonClassDate(NonClassDate nonClassDate) { String query = " INSERT INTO non_class_date (non_class_date, class_id) VALUES (" + " " + (nonClassDate.NonClassDateTime != null ? "'" + ((DateTime)nonClassDate.NonClassDateTime).ToString("yyyy-MM-dd HH:mm:ss") + "'" : "null") + ", " + nonClassDate.ClassId + "); "; try { SQLiteCommand command = new SQLiteCommand(query, conn); command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
internal void AddNonClassDate() { if (null == NonClassDateListString) return; if (!NonClassDateList.Any(item => item.NonClassDateTime.Equals(SelectedNonClassDateForAdd))) { NonClassDate newDate = new NonClassDate(); newDate.ClassId = CurrentSelectedClass.Id; newDate.NonClassDateTime = SelectedNonClassDateForAdd; _addNonClassDateList.Add(newDate); NonClassDateList.Add(newDate); NotifyPropertyChanged("NonClassDateList"); } }
internal List<NonClassDate> FindNonClassDateListByClassId(int cid) { String query = " SELECT * FROM non_class_date WHERE class_id = " + cid + " order by non_class_date;"; List<NonClassDate> ncList = new List<NonClassDate>(); try { SQLiteCommand command = new SQLiteCommand(query, conn); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { NonClassDate ndate = new NonClassDate(); ndate.Id = System.DBNull.Value != reader["id"] ? Convert.ToInt32(reader["id"]) : 0; ndate.NonClassDateTime = System.DBNull.Value != reader["non_class_date"] ? (DateTime?)reader["non_class_date"] : (DateTime?)null; ndate.ClassId = System.DBNull.Value != reader["class_id"] ? Convert.ToInt32(reader["class_id"]) : 0; ncList.Add(ndate); } } catch (Exception ex) { Console.Write(ex.Message); } return ncList; }