public bool removeStudent(StudentInfo student)
        {
            /*
             * - Remove student infor in Database Table first
             * - Remove student grade in Grade table
             * - Remove student info in student info table
             */
            cmd.CommandText = string.Format(@"DELETE FROM DatabaseTable WHERE DatabaseTable.StudentID = {0}",
                student.m_studentID);
            try
            {
                connection.Open();
                cmd.ExecuteNonQuery();
                connection.Close();
            }
            catch (Exception exception)
            {
                connection.Close();
                MessageBox.Show(@"Message: " + exception.ToString(), @"Error", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return false;
                throw;
            }
            cmd.CommandText = string.Format(@"DELETE FROM GradeTable WHERE GradeTable.StudentID = {0}",
                student.m_studentID);
            try
            {
                connection.Open();
                cmd.ExecuteNonQuery();
                connection.Close();

            }
            catch (Exception exception)
            {
                connection.Close();
                MessageBox.Show(@"Message: " + exception.ToString(), @"Error", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return false;
                throw;
            }
            cmd.CommandText = string.Format(@"DELETE FROM Student WHERE Student.StudentID = {0}", student.m_studentID);
            try
            {
                connection.Open();
                cmd.ExecuteNonQuery();
                connection.Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show(@"Message: " + exception.ToString(), @"Error", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                connection.Close();
                return false;
                throw;
            }
            return true;
        }
Example #2
0
 public DetailForm(StudentInfo studentInfo, int term)
 {
     InitializeComponent();
     m_studentInfo = new StudentInfo(studentInfo);
     m_Term = term;
     num_Term.ReadOnly = true;
     cb_StudentName.Enabled = false;
     cb_ABRSMgrade.Enabled = false;
     cb_Effort.Enabled = false;
     cb_Listening.Enabled = false;
     cb_MusicalLiteracy.Enabled = false;
     cb_Musicianship.Enabled = false;
     cb_Performing.Enabled = false;
     cb_Technique.Enabled = false;
     tb_TargetComment.ReadOnly = true;
     tb_Instrument.ReadOnly = true;
     tb_SchoolName.ReadOnly = true;
     tb_TeacherName.ReadOnly = true;
 }
 /*
  * - Add student info to student table
  * - Add studentID and ABRSMID to database table
  */
 public bool addStudent(StudentInfo student)
 {
     cmd.CommandText =
         string.Format(
             @"INSERT INTO Student (StudentID, Name, DoB, Address, ABRSMID, TeacherName, Instrument, EnsemblesPartition) VALUES ({0}, '{1}', '{2}', '{3}', {4}, '{5}', '{6}', '{7}')",
             student.m_studentID, student.m_studentName,
             Convert.ToDateTime(student.m_DoB).ToString("MM-dd-yyyy"),
             student.m_Adrress,
             student.m_ABRSMGradeID, student.m_TeacherName, student.m_Instrument, student.m_EnsemblesPartition);
     try
     {
         connection.Open();
         cmd.ExecuteNonQuery();
         connection.Close();
     }
     catch (Exception exception)
     {
         MessageBox.Show(@"Message: " + exception.ToString(), @"Error", MessageBoxButtons.OK,
             MessageBoxIcon.Error);
         connection.Close();
         return false;
     }
     return true;
 }
Example #4
0
        public ChartView(StudentInfo studentInfo)
        {
            m_studentInfo = new StudentInfo(studentInfo);
            InitializeComponent();
            chartControl1.Series[0].DataFilters.ClearAndAddRange(new DevExpress.XtraCharts.DataFilter[] {
            new DevExpress.XtraCharts.DataFilter("StudentID", "System.Int32", DevExpress.XtraCharts.DataFilterCondition.Equal, m_studentInfo.m_studentID)});
            // This line of code is generated by Data Source Configuration Wizard
            //databaseTableTableAdapter.Fill(musicalManagementDataSet.DatabaseTable);

            connection.ConnectionString = ConnectionStringToDatabase.getConnectionString();
            cmd.Connection = connection;
            connection.Close();
            // Read [DatabaseTable] table and add year to cb_Year
            try
            {
                cmd.CommandText = string.Format(@"select Term, SummaryGrade from DatabaseTable where StudentID = {0}", m_studentInfo.m_studentID);
                connection.Open();
                reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    int year = 0;
                    int term = 0;
                    while (reader.Read())
                    {
                        year = Convert.ToInt32(reader[0]) / 10;
                        listYear.Add(year);
                        term = Convert.ToInt32(reader[0]) % 10;
                        switch (term)
                        {
                            case 1:
                                summaryGrade[0] = Convert.ToInt32(reader[1]);
                                break;
                            case 2:
                                summaryGrade[1] = Convert.ToInt32(reader[1]);
                                break;
                            case 3:
                                summaryGrade[2] = Convert.ToInt32(reader[1]);
                                break;
                            case 4:
                                summaryGrade[3] = Convert.ToInt32(reader[1]);
                                break;
                            case 5:
                                summaryGrade[4] = Convert.ToInt32(reader[1]);
                                break;
                            case 6:
                                summaryGrade[5] = Convert.ToInt32(reader[1]);
                                break;

                        }

                    }
                }
                connection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(@"Message3: " + ex.Message.ToString(), @"Error");
                connection.Close();
            }
            //list.Distinct().ToArray();
            this.cb_Year.Properties.Items.AddRange(listYear.Distinct().ToArray());
        }
 private void detailButton_Click(object sender, EventArgs e)
 {
     this.Hide();
     var intTerm = 0;
     var button = sender as Button;
     if (button != null)
     {
         intTerm = Convert.ToInt32(button.Tag.ToString());
     }
     StudentInfo studentInfo = null;
     if (lb_studentNameBaseOnABRSM.SelectedItem != null)
     {
         /*Read student info from database*/
         _cmd.CommandText = string.Format(@"SELECT * FROM Student WHERE StudentID = {0}",
             ((ComboBoxItem)lb_studentNameBaseOnABRSM.SelectedItem).MValue);
         try
         {
             _connection.Open();
             _reader = _cmd.ExecuteReader();
             if (_reader.HasRows)
             {
                 while (_reader.Read())
                 {
                     studentInfo = new StudentInfo(_reader[0], _reader[1].ToString(), _reader[4],
                         DateTime.Parse(_reader[2].ToString()), _reader[3].ToString(), _reader[5].ToString(),
                         _reader[6].ToString(), _reader[7].ToString());
                 }
             }
             _connection.Close();
         }
         catch (Exception ex)
         {
             _connection.Close();
             MessageBox.Show(@"Message2: " + ex.Message.ToString(), @"Error");
             throw;
         }
     }
     DetailForm detailForm = null;
     detailForm = intTerm != 0 ? new DetailForm(studentInfo, intTerm) : new DetailForm();
     detailForm.Show();
     detailForm.FormClosing += detailForm_FormClosing;
     //MessageBox.Show(@"Detail button click: " + sender.ToString(), @"Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 private void bt_AddScore_Click(object sender, EventArgs e)
 {
     //Debug.Assert(lb_studentNameBaseOnABRSM.SelectedItem != null, "lb_studentNameBaseOnABRSM.SelectedItem != null");
     StudentInfo studentInfo = null;
     if (lb_studentNameBaseOnABRSM.SelectedItem != null)
     {
         /*Read student info from database*/
         _cmd.CommandText = string.Format(@"SELECT * FROM Student WHERE StudentID = {0}",
             ((ComboBoxItem) lb_studentNameBaseOnABRSM.SelectedItem).MValue);
         try
         {
             _connection.Open();
             _reader = _cmd.ExecuteReader();
             if (_reader.HasRows)
             {
                 while (_reader.Read())
                 {
                     studentInfo = new StudentInfo(_reader[0], _reader[1].ToString(), _reader[4],
                         DateTime.Parse(_reader[2].ToString()), _reader[3].ToString(), _reader[5].ToString(),
                         _reader[6].ToString(), _reader[7].ToString());
                 }
             }
             _connection.Close();
         }
         catch (Exception ex)
         {
             _connection.Close();
             MessageBox.Show(@"Message2: " + ex.Message.ToString(), @"Error");
             throw;
         }
         if (studentInfo != null)
         {
             var addScoreForm = new AddScore(studentInfo);
             addScoreForm.Show();
             this.Hide();
             addScoreForm.FormClosing += addScoreForm_FormClosing;
         }
         else
         {
             MessageBox.Show(@"Invalid student: ", @"Error");
         }
     }
     else
         MessageBox.Show(
             string.Format("There no student on ABRSM: {0}. You need to add student first.",
                 ((ComboBoxItem) cb_ABRSMGrade.SelectedItem).ToString()), @"Error", MessageBoxButtons.OK,
             MessageBoxIcon.Error);
 }
Example #7
0
 public StudentInfo(StudentInfo studentInfo)
 {
     m_studentID = studentInfo.m_studentID;
     m_studentName = studentInfo.m_studentName;
     m_ABRSMGradeID = studentInfo.m_ABRSMGradeID;
     m_DoB = studentInfo.m_DoB;
     m_Adrress = studentInfo.m_Adrress;
     m_TeacherName = studentInfo.m_TeacherName;
     m_Instrument = studentInfo.m_Instrument;
     m_EnsemblesPartition = studentInfo.m_EnsemblesPartition;
 }
Example #8
0
 public AddScore(StudentInfo studentInfo)
 {
     m_studentInfo = new StudentInfo(studentInfo);
     InitializeComponent();
 }