コード例 #1
0
ファイル: StudentForm.cs プロジェクト: Timothyyy/ICS_MSHRC
 private void confirm_Click(object sender, EventArgs e)
 {
     if (Controls.OfType<ComboBox>().Count(c => c.Text == "") != 0 || Controls.OfType<TextBox>().Count(t => t.Text == "") != 0)
     {
         MessageBox.Show("Все поля должны быть заполнены!", "Ошибка");
         return;
     }
     var student = new DBProvider.Student(FullName.Text, Sex.Text, Address.Text, Phone.Text, Email.Text,
                                          Birth.Text, Education.Text, Medical.Text,
                                          Nationality.Text, Hobby.Text, Dormitory.Checked, Group.Text,
                                          Other.Text);
     if (this.Text == "Добавить")
         DBProvider.AddStudent(student);
     else
         DBProvider.UpdateStudent(student, Id);
     Table.DataSource = DBProvider.Students();
     this.Close();
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: Timothyyy/ICS_MSHRC
 private void tableView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0 && tableView.ColumnCount == 14)
     {
         var student = new DBProvider.Student(tableView.Rows[e.RowIndex].Cells);
         (new StudentForm("Редактировать", tableView, student, Convert.ToInt32(tableView.Rows[e.RowIndex].Cells[0].Value))).Show();
         return;
     }
     if (e.RowIndex >= 0 && tableView.ColumnCount == 11)
     {
         var instructor = new DBProvider.Instructor(tableView.Rows[e.RowIndex].Cells);
         (new InstructorForm("Редактировать", tableView, instructor, Convert.ToInt32(tableView.Rows[e.RowIndex].Cells[0].Value))).Show();
         return;
     }
     if (e.RowIndex >= 0 && tableView.ColumnCount == 5)
     {
         var group = new DBProvider.Group(tableView.Rows[e.RowIndex].Cells);
         (new GroupForm("Редактировать", tableView, group, Convert.ToInt32(tableView.Rows[e.RowIndex].Cells[0].Value))).Show();
         return;
     }
     if (e.RowIndex >= 0 && tableView.ColumnCount == 3)
     {
         var value = new[] { tableView.Rows[e.RowIndex].Cells[1].Value.ToString(), tableView.Rows[e.RowIndex].Cells[2].Value.ToString() };
         replay:
         if (SubjectBox("Редактировать", ref value) == DialogResult.OK)
         {
             if (value.Any(s => s == ""))
             {
                 MessageBox.Show("Все поля должны быть заполнены!");
                 goto replay;
             }
             DBProvider.UpdateSubject(value[0], Convert.ToInt32(value[1]) + 1, Convert.ToInt32(tableView.Rows[e.RowIndex].Cells[0].Value));
             tableView.DataSource = DBProvider.Subjects();
         }
     }
 }