public static List <Pack> load(string type) { List <Hashtable> res = DBConnect.getInstance().Select("SELECT * FROM " + type); List <Pack> packs = new List <Pack>(); foreach (Hashtable entry in res) { packs.Add(new Pack((string)entry["title"], (string)entry["description"], int.Parse((string)entry["id_" + type]), Convert.ToBoolean((string)entry["is_free"]), type)); } return(packs); }
public bool Save() { //save to database Hashtable vars = new Hashtable(); vars.Add("title", name); vars.Add("description", description); vars.Add("is_free", (isfree ? "1" : "0")); if (this.Id != 0) { return(DBConnect.getInstance().Update(this.type, vars, "id_" + type + " = " + this.id)); } else { return(DBConnect.getInstance().Insert(this.type, vars)); } }
public bool Save() { //save to database Hashtable vars = new Hashtable(); vars.Add("question", question); vars.Add("answer_a", reponseA); vars.Add("answer_b", reponseB); vars.Add("answer_c", reponseC); vars.Add("answer_d", reponseD); vars.Add("good_answer", goodAnswer); vars.Add("id_pack_question", idInnerPack); if (id != 0) { return(DBConnect.getInstance().Update("question", vars, "id_question" + " = " + id)); } return(DBConnect.getInstance().Insert("question", vars)); }
public bool Save() { //save to database Hashtable vars = new Hashtable(); vars.Add("label", label); vars.Add("duration", duration); vars.Add("for_sex", forSex); vars.Add("id_pack_gage", idInnerPack); if (level != 0) { vars.Add("level", level); } if (id != 0) { return(DBConnect.getInstance().Update("gage", vars, "id_gage" + " = " + id)); } return(DBConnect.getInstance().Insert("gage", vars)); }
public static List <Gage> load(int idPack) { List <Hashtable> res = DBConnect.getInstance().Select("SELECT label, for_sex, duration, level, id_gage, id_pack_gage FROM gage WHERE id_pack_gage = " + idPack); List <Gage> gages = new List <Gage>(); foreach (Hashtable entry in res) { gages.Add(new Gage( (string)entry["label"], int.Parse((string)entry["duration"]), int.Parse((string)entry["for_sex"]), int.Parse((string)entry["level"]), int.Parse((string)entry["id_pack_gage"]), int.Parse((string)entry["id_gage"]) ) ); } return(gages); }
public static List <Question> load(int idPack) { List <Hashtable> res = DBConnect.getInstance().Select("SELECT question, answer_a, answer_b, answer_c, answer_d, good_answer, id_question, id_pack_question FROM question WHERE id_pack_question = " + idPack); List <Question> questions = new List <Question>(); foreach (Hashtable entry in res) { questions.Add(new Question( (string)entry["question"], (string)entry["answer_a"], (string)entry["answer_b"], (string)entry["answer_c"], (string)entry["answer_d"], int.Parse((string)entry["good_answer"]), int.Parse((string)entry["id_question"]), int.Parse((string)entry["id_pack_question"]) ) ); } return(questions); }