private void button1_Click(object sender, EventArgs e) { PupilGroup pupilGroup = (PupilGroup)comboBox1.SelectedItem; int selectedIndex = comboBox1.SelectedIndex; switch (mode) { case 1: DBWork.deleteUsersFromPupilGroup(pupilGroup.Id); comboBox1.SelectedIndex = 0; comboBox1.Items.RemoveAt(selectedIndex); System.Windows.Forms.MessageBox.Show("Данные удалены"); break; case 2: String passwords = DBWork.getUserPasswords(pupilGroup.Id); if (saveFileDialog.ShowDialog() == DialogResult.Cancel) { return; } String filename = saveFileDialog.FileName; System.IO.File.WriteAllText(filename, passwords); break; } }
private void loadPupilGroups() { pupilGroups = DBWork.getAllPupilGroups(); PupilGroup defaultGroup = new PupilGroup(0, "Все классы", -1); this.comboBox1.Items.Add(defaultGroup); foreach (PupilGroup group in pupilGroups) { this.comboBox1.Items.Add(group); } }
public TeacherForm(User user) { InitializeComponent(); currentUser = user; group = DBWork.getPupilGroup(currentUser.ClassId); this.Text += " " + currentUser.ToString() + " " + group.ToString(); results = new Dictionary <User, List <Answer> >(); totalTests = 0; totalK = 0; N = 0; questions = DBWork.getAllQuestions(); statuses = DBWork.getAllStatuses(); countResults(); fillTable(); saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Text Files(*.txt)|*.txt"; }
public static PupilGroup getPupilGroup(int classId) { PupilGroup pupilGroup = null; String query = "SELECT * FROM classes WHERE idclasses = " + classId; MySqlCommand command = new MySqlCommand(query); command.Connection = connection; MySqlDataReader data = command.ExecuteReader(); if (data.HasRows) { data.Read(); pupilGroup = new PupilGroup(data.GetInt32(0), data.GetString(1), data.GetInt32(2)); } data.Close(); return(pupilGroup); }
public QuestionForm(User user) { InitializeComponent(); currentUser = user; group = DBWork.getPupilGroup(currentUser.ClassId); this.Text += " " + currentUser.ToString() + " " + group.ToString(); questions = DBWork.getAllQuestions(); answers = new List <Answer>(); currentQuestionIndex = 0; loadClassmates(); TextQuestion.Text = questions.ElementAt(currentQuestionIndex).ToString(); comboBox1.SelectedIndex = 0; comboBox2.SelectedIndex = 0; comboBox3.SelectedIndex = 0; comboBox4.SelectedIndex = 0; comboBox5.SelectedIndex = 0; }