Пример #1
0
 public bool insertSCORE(DTO_Score score)
 {
     try {
         SqlCommand command = new SqlCommand("INSERT INTO Score ( student_id, course_id, student_score ,description)" +
                                             "VALUES ( @student_id, @course_id, @student_score, @description)", this.getConnection);
         command.Parameters.Add("@student_id", SqlDbType.Int).Value      = score.idStudent;
         command.Parameters.Add("@course_id", SqlDbType.Int).Value       = score.idCourse;
         command.Parameters.Add("@student_score", SqlDbType.Float).Value = score.Score;
         command.Parameters.Add("@description", SqlDbType.VarChar).Value = score.desciption;
         this.openConnection();
         if (command.ExecuteNonQuery() == 1)
         {
             this.closeConnection();
             return(true);
         }
         else
         {
             this.closeConnection();
             return(false);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            string    label  = this.datagridSelected.CurrentRow.Cells[0].Value.ToString();
            int       id_cou = int.Parse(this.BUScourse.getCOURSELabel(label, int.Parse(this.comboSem.Value.ToString())).Rows[0][0].ToString());
            int       id_stu = int.Parse(this.txtStudentId.Text);
            DTO_Score score  = new DTO_Score(id_stu, id_cou, 0, "nothing");

            if (this.BUSscore.insertSCORE(score))
            {
                MessageBox.Show("success");
                if (this.BUScourse.getCOURSELabelStudent(id_stu, int.Parse(this.comboSem.Value.ToString())) != null)
                {
                    this.datagridSelected.DataSource = this.BUScourse.getCOURSELabelStudent(id_stu, int.Parse(this.comboSem.Value.ToString()));
                }
            }
            else
            {
                MessageBox.Show("unsuccess");
            }
        }
Пример #3
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (this.txtID.Text == "" || this.txtScore.Text == "" || this.txtDescription.Text == "" || this.comboCourse.SelectedItem == "")
     {
         MessageBox.Show("Field Emty", "Edit Score", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         int    student_id    = int.Parse(txtID.Text);
         int    course_id     = int.Parse(this.comboCourse.SelectedValue.ToString());
         string descrip       = txtDescription.Text;
         int    scoreStudenbt = int.Parse(this.txtScore.Text);
         try
         {
             int       id    = Convert.ToInt32(txtID.Text);
             DTO_Score score = new DTO_Score(student_id, course_id, scoreStudenbt, descrip);
             if (scoreStudenbt < 0 || scoreStudenbt > 10)
             {
                 MessageBox.Show("Score error", "Edit Score", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 if (BUSScore.updateCOURSE(score) == true)
                 {
                     MessageBox.Show("score informationg Updated", "Edit Score", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     MessageBox.Show("Edit Error", "Edit Score", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Edit Score", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
 }
Пример #4
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         int    idStudent  = int.Parse(txtID.Text);
         int    idCourse   = int.Parse(comboCourse.SelectedValue.ToString());
         float  score      = float.Parse(txtScore.Text);
         string desciption = txtDescription.Text;
         if (score >= 0 && score <= 10)
         {
             if (BUSScore.getSCOREAStudent(idStudent, idCourse).Rows.Count == 0)
             {
                 DTO_Score Score = new DTO_Score(idStudent, idCourse, score, desciption);
                 if (BUSScore.insertSCORE(Score))
                 {
                     MessageBox.Show("Student score inserted");
                 }
                 else
                 {
                     MessageBox.Show("Student score is not inserted");
                 }
             }
             else
             {
                 MessageBox.Show("Student score is exited" + BUSScore.getSCOREAStudent(idStudent, idCourse).Rows.Count);
             }
         }
         else
         {
             MessageBox.Show("Score is not correct");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #5
0
 public bool updateCOURSE(DTO_Score score)
 {
     try { SqlCommand command = new SqlCommand("UPDATE Score SET student_score =@student_score ,description = @description WHERE  student_id = @student_id and course_id = @course_id", this.getConnection);
           command.Parameters.Add("@student_id", SqlDbType.Int).Value      = score.idStudent;
           command.Parameters.Add("@course_id", SqlDbType.Int).Value       = score.idCourse;
           command.Parameters.Add("@student_score", SqlDbType.Float).Value = score.Score;
           command.Parameters.Add("@description", SqlDbType.VarChar).Value = score.desciption;
           this.openConnection();
           if (command.ExecuteNonQuery() == 1)
           {
               this.closeConnection();
               return(true);
           }
           else
           {
               this.closeConnection();
               return(false);
           } }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Пример #6
0
 public bool updateCOURSE(DTO_Score score)
 {
     return(scoreDAL.updateCOURSE(score));
 }
Пример #7
0
 public bool insertSCORE(DTO_Score score)
 {
     return(scoreDAL.insertSCORE(score));
 }