public static void deleteClass(Class classElement) { executeSql("" + "DELETE FROM " + "`" + tableName + "` " + "WHERE " + "`" + field_classId + " = " + classElement.ClassId + " " + "LIMIT 1" ); }
public static int createStudent( string firstName, string lastName, DateTime birthday, char gender, string street, int zip, string city, Class classObject, bool active ) { executeSql("" + "INSERT INTO " + "`" + tableName + "` " + "(" + "`" + field_firstName + "`, " + "`" + field_lastName + "`, " + "`" + field_birthday + "`, " + "`" + field_gender + "`, " + "`" + field_street + "`, " + "`" + field_zip + "`, " + "`" + field_city + "`, " + "`" + field_classId + "`, " + "`" + field_active + "`" + ") VALUES (" + "'" + firstName + "', " + "'" + lastName + "', " + "'" + birthday.ToString("yyyy-MM-dd") + "', " + "'" + gender + "', " + "'" + street + "', " + zip + ", " + "'" + city + "', " + classObject.ClassId + ", " + active + ")" ); Dictionary<string, object> result = querySingleSql("SELECT MAX(`" + field_studentId + "`) AS `insertionId` FROM `" + tableName + "`"); int insertionId = Convert.ToInt32(result["insertionId"]); return insertionId; }
public Student( int studentId, string firstName, string lastName, DateTime birthday, char gender, string street, int zip, string city, Class classObject, bool active ) { this.studentId = studentId; this.firstName = firstName; this.lastName = lastName; this.birthday = birthday; this.gender = gender; this.street = street; this.zip = zip; this.city = city; this.classObject = classObject; this.active = active; }
public void storeNewStudent( string firstName, string lastName, DateTime birthday, char gender, string street, int zip, string city, Class selectedClass, bool isActive ) { StudentProvider.createStudent( firstName, lastName, birthday, gender, street, zip, city, selectedClass, isActive ); }
public static void updateClass(Class classElement) { executeSql("" + "UPDATE " + "`" + tableName + "` " + "SET " + "`" + field_prefix + "` = '" + classElement.Prefix + "', " + "`" + field_year + "` = " + classElement.Year + ", " + "`" + field_suffix + "` = '" + classElement.Suffix + "' " + "WHERE " + "`" + field_classId + "` = " + classElement.ClassId ); }
public static Class getClassById(int classId) { Dictionary<string, object> result = querySingleSql("" + "SELECT " + "`" + field_classId + "`, " + "`" + field_prefix + "`, " + "`" + field_year + "`, " + "`" + field_suffix + "` " + "FROM " + "`" + tableName + "` " + "WHERE " + "`" + field_classId + "` = " + classId ); if (result == null) { return null; } Class classElement = new Class( Convert.ToInt32(result[field_classId]), Convert.ToString(result[field_prefix]), Convert.ToInt32(result[field_year]), Convert.ToString(result[field_suffix]) ); return classElement; }
private bool checkSaveAllowed( string firstName, string lastName, DateTime birthday, char gender, string street, int zip, string city, Class selectedClass ) { if ( firstName == "" || lastName == "" || birthday.CompareTo(DateTime.Today) >= 0 || ( gender != 'f' && gender != 'm' ) || street == "" || zip == 0 || city == "" || selectedClass == null ) { return false; } return true; }