コード例 #1
0
 private void AddAssessment_Click(object sender, EventArgs e)
 {
     try
     {
         int assessmentId = (int)AssessmentCombo.SelectedValue;
         int critId = (int)CriteraComboBox.SelectedValue;
         int semesterId = (int)SemesterComboBox.SelectedValue;
         string facultyName = txtFaculty.Text;
         int score = Int32.Parse(ScoreDomainUpDown.Text);
         bool isSuccess = db.InsertStudentAssessment(s.UniversityId, assessmentId, critId, score, semesterId, facultyName);
         if(!isSuccess)
         {
             MessageBox.Show("An error occurred while inserting the assessment.", "Error");
             return;
         }
         else
         {
             AssessmentTree.Nodes.Clear();
             Emphasis emph = s.Emphasis;
             s = db.GetStudentInfoByStudentId(s.UniversityId);
             s.Emphasis = emph;
             populateAssessmentTree();
         }
     }
     catch(FormatException ex)
     {
         MessageBox.Show("Invalid integer for score. Please input an integer.", "Error");
         return;
     }
 }
コード例 #2
0
        public static Student ShowAndReturnObject()
        {
            var dlg = new FrmAddStudent();

            // loop in case we need to validate later
            while (true)
            {
                DialogResult ans = dlg.ShowDialog();

                if ( ans == DialogResult.OK )
                {
                    if ( dlg.txtFirstName.Text.Length <= 0 )
                    {
                        MessageBox.Show( "You must enter a first name.", "Error" );
                        continue;
                    }

                    if (dlg.txtLastName.Text.Length <= 0)
                    {
                        MessageBox.Show("You must enter a last name.", "Error");
                        continue;
                    }

                    if (dlg.txtMiddleName.Text.Length <= 0)
                    {
                        MessageBox.Show("You must enter a middle name.", "Error");
                        continue;
                    }

                    if (dlg.cmbStatus.Text.Length <= 0 || dlg.cmbStatus.SelectedIndex + 1 <= 0)
                    {
                        MessageBox.Show("You must enter a status.", "Error");
                        continue;
                    }

                    if (dlg.cmbEmphasis.Text.Length <= 0 || dlg.cmbEmphasis.SelectedIndex + 1 <= 0)
                    {
                        MessageBox.Show("You must enter an emphasis.", "Error");
                        continue;
                    }

                    Student stud = new Student
                    {
                        FirstName = dlg.txtFirstName.Text,
                        LastName = dlg.txtLastName.Text,
                        MiddleName = dlg.txtMiddleName.Text,
                        Status = (Status) (dlg.cmbStatus.SelectedIndex + 1),
                        Emphasis = new Emphasis
                        {
                            Id = dlg.cmbEmphasis.SelectedIndex + 1,
                        },
                    };

                    return stud;
                }

                return null;
            }
        }
コード例 #3
0
 public ViewStudent(Student stud)
 {
     InitializeComponent();
     s = stud;
     populateAssessmentTree();
     txtFirstName.Text = s.FirstName;
     txtMiddleName.Text = s.MiddleName;
     txtLastName.Text = s.LastName;
     txtStatus.Text = s.Status.ToString();
     txtEmphasis.Text = s.Emphasis.Name;
     populateAssessmentComboBox();
     populateSemesterCombo();
 }
コード例 #4
0
        public static Student ShowAndReturnObject(Student s)
        {
            var dlg = new EditStudent();
            dlg.txtFirstName.Text = s.FirstName;
            dlg.txtMiddleName.Text = s.MiddleName;
            dlg.txtLastName.Text = s.LastName;
            dlg.cmbEmphasis.SelectedIndex = s.Emphasis.Id - 1;
            if (s.Status == 0)
            {
                dlg.cmbStatus.Text = "Unknown";
            }
            else
            {
                dlg.cmbStatus.SelectedIndex = (int)s.Status;
            }

            while (true)
            {
                DialogResult ans = dlg.ShowDialog();

                if (ans == DialogResult.OK)
                {
                    if (dlg.txtFirstName.Text.Length <= 0)
                    {
                        MessageBox.Show("You must enter a first name.", "Error");
                        continue;
                    }

                    if (dlg.txtLastName.Text.Length <= 0)
                    {
                        MessageBox.Show("You must enter a last name.", "Error");
                        continue;
                    }

                    if (dlg.txtMiddleName.Text.Length <= 0)
                    {
                        MessageBox.Show("You must enter a middle name.", "Error");
                        continue;
                    }

                    if (dlg.cmbStatus.Text.Length <= 0 || dlg.cmbStatus.SelectedIndex + 1 <= 0)
                    {
                        MessageBox.Show("You must enter a status.", "Error");
                        continue;
                    }

                    if (dlg.cmbEmphasis.Text.Length <= 0 || dlg.cmbEmphasis.SelectedIndex + 1 <= 0)
                    {
                        MessageBox.Show("You must enter an emphasis.", "Error");
                        continue;
                    }

                    Student stud = new Student
                    {
                        UniversityId = s.UniversityId,
                        FirstName = dlg.txtFirstName.Text,
                        LastName = dlg.txtLastName.Text,
                        MiddleName = dlg.txtMiddleName.Text,
                        Status = (Status)(dlg.cmbStatus.SelectedIndex),
                        Emphasis = new Emphasis
                        {
                            Id = dlg.cmbEmphasis.SelectedIndex + 1,
                        },
                    };
                    return stud;
                }
                return null;
            }
        }
コード例 #5
0
        public bool UpdateStudent(Student s)
        {
            try
            {
                return ExecuteQuery("EditStudent",
                                    new
                                        {
                                            //fN VARCHAR(50), IN lN VARCHAR(50), IN mN VARCHAR(50), IN sT INT, IN eId
                                            sId = s.UniversityId,
                                            fN = s.FirstName,
                                            lN = s.LastName,
                                            mN = s.MiddleName,
                                            sT = (int)s.Status,
                                            eId = s.Emphasis.Id
                                        });
            }
            catch (SqlException e)
            {

                throw e;
            }
        }
コード例 #6
0
 public bool InsertStudent(Student s)
 {
     try
     {
         return ExecuteQuery("AddStudent", new { firstName = s.FirstName, lastName = s.LastName, middleName = s.MiddleName, status = (int)s.Status, emphasisId = s.Emphasis.Id });
     }
     catch(SqlException e)
     {
         throw e;
     }
 }