private void selectGradeLevelComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            GradeManager aGradeManager = new GradeManager();
            Grade aGrade = new Grade();
            aGrade.BasicAmount = aGradeManager.Get((int)selectGradeLevelComboBox.SelectedValue).BasicAmount;
            aGrade.MedicalAllowance = aGradeManager.Get((int)selectGradeLevelComboBox.SelectedValue).MedicalAllowance;
            aGrade.HouseRent = aGradeManager.Get((int)selectGradeLevelComboBox.SelectedValue).HouseRent;
            totalSalaryTextBox.Text = aGrade.GetTotalSalary().ToString();

            gradeId = (int) selectGradeLevelComboBox.SelectedValue;
        }
        private void saveButton_Click(object sender, EventArgs e)
        {
            Grade aGrade = new Grade();
            aGrade.GradeLevel = gradeLevelTextBox.Text;
            aGrade.BasicAmount = Convert.ToDouble(basicAmountTextBox.Text);
            aGrade.MedicalAllowance = Convert.ToDouble(medicalAllowanceTextBox.Text);
            aGrade.HouseRent = Convert.ToDouble(houseRentTextBox.Text);

            GradeManager aGradeManager = new GradeManager();
            string msg = aGradeManager.Save(aGrade);
            MessageBox.Show(msg);
        }
        public Grade Get(int gradeId)
        {
            string query = "SELECT * FROM t_grade WHERE id = '" + gradeId + "'";
            SqlConnection sqlConnection = new SqlConnection(connectionString);
            sqlConnection.Open();
            SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

            if (sqlDataReader.HasRows)
            {
                sqlDataReader.Read();
                Grade aGrade = new Grade();
                aGrade.GradeLevel = sqlDataReader[1].ToString();
                aGrade.BasicAmount = Convert.ToDouble(sqlDataReader[2]);
                aGrade.MedicalAllowance = Convert.ToDouble(sqlDataReader[3]);
                aGrade.HouseRent = Convert.ToDouble(sqlDataReader[4]);
                sqlConnection.Close();
                return aGrade;
            }

            sqlConnection.Close();
            return null;
        }
        public List<Grade> GetAll()
        {
            string query = "SELECT * FROM t_grade";
            SqlConnection sqlConnection = new SqlConnection(connectionString);
            sqlConnection.Open();
            SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

            List<Grade> grades = new List<Grade>();
            while (sqlDataReader.Read())
            {
                Grade aGrade = new Grade();
                aGrade.Id = Convert.ToInt32(sqlDataReader[0]);
                aGrade.GradeLevel = sqlDataReader[1].ToString();
                aGrade.BasicAmount = Convert.ToDouble(sqlDataReader[2]);
                aGrade.MedicalAllowance = Convert.ToDouble(sqlDataReader[3]);
                aGrade.HouseRent = Convert.ToDouble(sqlDataReader[4]);
                grades.Add(aGrade);

            }

            sqlConnection.Close();
            return grades;
        }
 public string Save(Grade aGrade)
 {
     string query = "INSERT INTO t_grade VALUES ('" + aGrade.GradeLevel + "'," + aGrade.BasicAmount + "," + aGrade.MedicalAllowance + "," + aGrade.HouseRent + ")";
     SqlConnection sqlConnection = new SqlConnection(connectionString);
     sqlConnection.Open();
     SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
     sqlCommand.ExecuteNonQuery();
     sqlConnection.Close();
     return "Grade saved";
 }
 public string Save(Grade someGrade)
 {
     return aGradeGateway.Save(someGrade);
 }