Пример #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     obj = (Student)comboBox1.SelectedItem;
     textBox6.Text = obj.stu_name;
     textBox7.Text = obj.stu_id;
     textBox8.Text = obj.stu_department;
     textBox9.Text = obj.stu_semester;
     textBox10.Text = obj.stu_section;
 }
Пример #2
0
 private void button3_Click(object sender, EventArgs e)
 {
     obj = (Student)comboBox1.SelectedItem;
     obj.stu_name = textBox6.Text;
     obj.stu_id = textBox7.Text;
     obj.stu_department = textBox8.Text;
     obj.stu_semester = textBox9.Text;
     obj.stu_section = textBox10.Text;
 }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            obj = new Student();
            obj.stu_name = textBox1.Text;
            obj.stu_id = textBox2.Text;
            obj.stu_department = textBox3.Text;
            obj.stu_semester = textBox4.Text;
            obj.stu_section = textBox5.Text;

            comboBox1.Items.Add(obj);
        }
        public static List<Student> getStudent ()
        {
            List<Student> studentList = new List<Student>();
            string sqlString = "SELECT * FROM STUDENT";
            SqlCommand sqlCommand = new SqlCommand(sqlString, sqlConnection);

            try
            {
                sqlConnection.Open();
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                while (sqlDataReader.Read())
                {
                    Student student = new Student();
                    student.studentId = (int)sqlDataReader["Id"];
                    student.studentName = sqlDataReader["Name"].ToString();
                    student.studentDepartment = sqlDataReader["Department"].ToString();
                    student.studentCgpa = (double)sqlDataReader["CGPA"];
                    student.studentGender = (Boolean)sqlDataReader["Gender"];

                    studentList.Add(student);
                }
                sqlDataReader.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                sqlConnection.Close();
            }
            return studentList;
        }