void load_test(int id, view_table table) {//загрузить тест SQLiteConnection DB = new SQLiteConnection(port_db_helper.dbName); DB.Open(); string id_test = id.ToString(); SQLiteCommand CMD = DB.CreateCommand(); CMD.CommandText = "select * from questions where id_test = " + id_test; SQLiteDataReader reader = CMD.ExecuteReader(); if (reader == null) { return; } while (reader.Read()) { table.add_cortege( new question_plus_typeQuest( (string)reader["question"], Int32.Parse(reader["id_type"].ToString()), Int32.Parse(reader["id"].ToString()) ) ); } DB.Close(); }
void load_test(int id, view_table table) {//загрузить тест SQLiteConnection DB = new SQLiteConnection(port_db_helper.dbName); DB.Open(); string id_test = id.ToString(); SQLiteCommand CMD = DB.CreateCommand(); // CMD.CommandText = "select * from rules, questions where id_test = " + id_test; CMD.CommandText = "SELECT * FROM rules, questions WHERE questions.id = rules.id_questions + '0' AND questions.id_test = " + id_test; SQLiteDataReader reader = CMD.ExecuteReader(); if (reader == null) { return; } while (reader.Read()) { table.add_cortege( new question_plus_typeQuest(reader) ); } DB.Close(); }
private void btn_add_rule_Click(object sender, EventArgs e) { question_plus_typeQuest new_row = new question_plus_typeQuest(); new_row.added = true; table_1.add_cortege(new_row); table_1.redraw_on_form(); }
private void btn_add_question_Click(object sender, EventArgs e) {//КНОПКА добавить вопрос question_plus_typeQuest new_row = new question_plus_typeQuest("Новый вопрос", 1); new_row.added = true; table_1.add_cortege(new_row); table_1.redraw_on_form(); }
void upadate() { /* * ------------------ * Делаем расчет как у социолога * ------------------ * nedofix(Кликаем) сначала по социологу!!! */ table_sociolog = new view_table(0, 0, 0, this); Sociolog1 tmp = new Sociolog1(); tmp.ID_TEST = ID_TEST; tmp.load_test(tmp.ID_TEST, table_sociolog); /* * ------------------ * Нарисовали таблицу * ------------------ */ SQLiteConnection DB = new SQLiteConnection(port_db_helper.dbName); SQLiteCommand CMD = DB.CreateCommand(); CMD = DB.CreateCommand(); CMD.CommandText = "SELECT * FROM conf_rules"; DB.Open(); SQLiteDataReader reader = CMD.ExecuteReader(); //РАСЧЕТ ВЫВОДОВ int i = 1; while (reader.Read()) { pod_zacuchenie p = new pod_zacuchenie(reader, i); rezultat.Add(p); table_1.add_cortege(p); if (i == 3) { i = 1; rezultat = new List <pod_zacuchenie>(); continue; } i++; } DB.Close(); table_1.redraw_on_form(); }
void load_rules(int id_test, view_table table) {//загрузить rules SQLiteConnection DB = new SQLiteConnection(port_db_helper.dbName); DB.Open(); SQLiteCommand CMD = DB.CreateCommand(); CMD.CommandText = "SELECT * FROM conf_rules WHERE id_test = " + id_test; SQLiteDataReader reader = CMD.ExecuteReader(); if (reader == null) { return; } while (reader.Read()) { table.add_cortege(new question_plus_typeQuest(reader)); } DB.Close(); }
public void load_test(int id, view_table table) {//загрузить тест SQLiteConnection DB = new SQLiteConnection(port_db_helper.dbName); DB.Open(); string id_test = id.ToString(); SQLiteCommand CMD = DB.CreateCommand(); CMD.CommandText = "SELECT * FROM rules, questions WHERE questions.id = rules.id_questions AND questions.id_test = " + id_test; SQLiteDataReader reader = CMD.ExecuteReader(); if (reader == null) { return; } while (reader.Read()) { double percent = -1; double avg = -1; Int32 question_id = Int32.Parse(reader["id_questions"].ToString()); Int32 all_cnt = port_db_helper.get_count_answed_on_question(question_id); Int32 type_quest = Int32.Parse(reader["id_type"].ToString()); if (type_quest == 1) //если это + - то считаем % { Int32 cnt_yes = port_db_helper.get_count_answed_yes(question_id); percent = ((float)cnt_yes * 100.0) / (float)all_cnt; } else //если это 2..5 то считаем среднее { avg = port_db_helper.get_avg_answed_2_to_5(question_id); } table.add_cortege(new question_plus_typeQuest(reader, (int)percent, avg)); } DB.Close(); }