Exemplo n.º 1
0
 void FormLoad()
 {
     try
     {
         cmbxStandard.DataSource    = schoolMan.AllStandarts();
         cmbxStandard.ValueMember   = "Id";
         cmbxStandard.DisplayMember = "Name";
         cmbxStandard.Refresh();
         cmbxStandard.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
     try
     {
         cmbxTeacher.DataSource    = schoolMan.AllTeachers();
         cmbxTeacher.ValueMember   = "Id";
         cmbxTeacher.DisplayMember = "Name";
         cmbxTeacher.Refresh();
         cmbxTeacher.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
     try
     {
         if (_id != -1)
         {
             _student       = schoolMan.GetStudentById(_id);
             txtName.Text   = _student.Name;
             txtHeight.Text = _student.Height.ToStr();
             txtWeight.Text = _student.Weight.ToStr();
             if (_student.DateOfBirth.HasValue)
             {
                 dtpBirth.Value = _student.DateOfBirth.Value;
             }
             cmbxStandard.SelectedValue = _student.StandardId;
             cmbxTeacher.SelectedValue  = _student.TeacherId;
             if (_student.Photo != null)
             {
                 Image im = Bitmap.FromStream(new System.IO.MemoryStream(_student.Photo, false));
                 pcbxPhoto.Image = im;
             }
         }
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
         _student = new Student();
     }
     finally
     {
         isFormLoaded = true;
     }
 }