public List<Student> GetAllStudentDetails()
        {
            try
            {
                using (SqlCommand cmd = new SqlCommand("SelectAllStdents", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlDataReader rd = cmd.ExecuteReader();

                    while (rd.Read())
                    {
                        student = new Student();
                        student.StudentId = int.Parse(rd["StudentId"].ToString());
                        student.Name = rd["Name"].ToString();
                        student.DateOfBirth = DateTime.Parse(rd["DOB"].ToString());
                        student.Average = double.Parse(rd["GradePointAvg"].ToString());
                        student.IsActive = bool.Parse(rd["Active"].ToString());
                        StudentList.Add(student);
                    }
                    CacheStudentList = StudentList;
                    return StudentList;
                }
            }
            catch (CustomizeSqlException ex)
            {
                throw new ConfigurationSettingException(ex.Message);
            }
            finally
            {
                con.Close();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add new Entry to Grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            ValidateInputTextField objValidateInputTextField = new ValidateInputTextField();
            if (objValidateInputTextField.IsValidInput(txtbxName.Text) && objValidateInputTextField.IsValidInput(txtbxAverage.Text))
            {
                Student objStudent = new Student();
                objStudent.Name = txtbxName.Text;
                objStudent.DateOfBirth = DateTime.Parse(dtPicDOB.Text);
                objStudent.Average = double.Parse(txtbxAverage.Text);
                objStudent.IsActive = chkbxIsActive.Checked;

                objStdentBLL.AddNewStudent(objStudent);
                this.dataGridView1.DataSource = objStdentBLL.UpdateGridView();
                ClearDataEntryPanel();
            }
            else
                MessageBox.Show(Constants.FILL_ALL_FIELDS);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Add New Entry to List in Repository
 /// </summary>
 /// <param name="student"></param>
 public void AddNewStudentDetails(Student student)
 {
     objStudentDetailsRepository.AddNewStudent(student);
 }
 public void AddNewStudent(Student student)
 {
     int lastStuId = CacheStudentList.OrderBy(a => a.StudentId).Select(s => s.StudentId).LastOrDefault();
     student.StudentId = lastStuId + 1;
     CacheStudentList.Add(student);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Add New Student to List in the Repository
 /// </summary>
 /// <param name="student"></param>
 public void AddNewStudent(Student student)
 {
     StudentDAL objdal = new StudentDAL();
     objdal.AddNewStudentDetails(student);
 }