Example #1
0
        private void button_Add_Click(object sender, EventArgs e)
        {
            Students students = new Students();
            People   student  = new People();

            student.name        = textBox_Name.Text;
            student.surname     = textBox_Surname.Text;
            student.patronumic  = textBox_Patronumic.Text;
            student.login       = textBox_Login.Text;
            student.birthday    = dateTimePicker_Birthday.Value;
            student.information = richTextBox_Information.Text;
            student.phonenumber = textBox_PhoneNumber.Text;
            try
            {
                grups.OpenConnection(connectionString);
                students.OpenConnection(connectionString);
                students.InsertStudent(student, grups.GetIdByName(comboBox_Grups.Text));
                students.CloseConnection();
                grups.CloseConnection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            MessageBox.Show("Студент был успешно добавлен!\nПароль для первого входа - 12345");
            this.Close();
        }