Beispiel #1
0
        public void SaveFunction()
        {
            GradingSP   gradingSP   = new GradingSP();
            GradingInfo gradingInfo = new GradingInfo();

            try
            {
                for (int i = 0; i < dgvGrading.RowCount - 1; i++)
                {
                    if (dgvGrading.Rows[i].Cells["dgvsubject"].Value.ToString() != string.Empty && dgvGrading.Rows[i].Cells["dgvsubject"].Value != null)
                    {
                        gradingInfo.SubjectId = Convert.ToInt32(dgvGrading.Rows[i].Cells["dgvsubject"].Value);
                    }

                    if (dgvGrading.Rows[i].Cells["dgvmarks"].Value.ToString() != string.Empty && dgvGrading.Rows[i].Cells["dgvmarks"].Value != null)
                    {
                        gradingInfo.Marks = Convert.ToInt32(dgvGrading.Rows[i].Cells["dgvmarks"].Value);
                    }

                    gradingInfo.TermId    = Convert.ToInt32(cmbTerm.SelectedValue);
                    gradingInfo.ClassId   = Convert.ToInt32(cmbClass.SelectedValue);
                    gradingInfo.StudentId = Convert.ToInt32(cmbStudent.SelectedValue);


                    gradingSP.GradingAdd(gradingInfo);
                }

                clearfielsd();
                Messages.SavedMessage();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        ///<summary>
        ///Function to get Student
        /// </summary>
        public void GradingAdd(GradingInfo gradingInfo)
        {
            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }

                MySqlCommand sqlcmd = new MySqlCommand("GradingAdd", sqlcon);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                MySqlParameter sqlparam = new MySqlParameter();
                sqlparam       = sqlcmd.Parameters.Add("?student_id", MySqlDbType.Int32);
                sqlparam.Value = gradingInfo.StudentId;
                sqlparam       = sqlcmd.Parameters.Add("?class_id", MySqlDbType.Int32);
                sqlparam.Value = gradingInfo.ClassId;
                sqlparam       = sqlcmd.Parameters.Add("?subject_id", MySqlDbType.Int32);
                sqlparam.Value = gradingInfo.SubjectId;
                sqlparam       = sqlcmd.Parameters.Add("?term_id", MySqlDbType.Int32);
                sqlparam.Value = gradingInfo.TermId;
                sqlparam       = sqlcmd.Parameters.Add("?marks", MySqlDbType.Decimal);
                sqlparam.Value = gradingInfo.Marks;
                sqlparam       = sqlcmd.Parameters.Add("?total", MySqlDbType.Decimal);
                sqlparam.Value = gradingInfo.Total;
                sqlcmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }
        }