コード例 #1
0
ファイル: frmStudentLookup.cs プロジェクト: orette/southville
        private void addItems(string name)
        {
            if (name == null || name.Equals(""))
            {
                dataGridView1.DataSource = null;
                dataGridView1.AutoGenerateColumns = false;
                dataGridView1.DataSource = Cache.students;
            }
            else
            {
                dataGridView1.DataSource = null;
                dataGridView1.AutoGenerateColumns = false;
                Students tempStudents = new Students();
                foreach (Student stud in Cache.students)
                {
                    if (stud.Fullname.ToUpper().Contains(name.ToUpper()))
                        tempStudents.Add(stud);

                }
                dataGridView1.DataSource = tempStudents;
            }
        }
コード例 #2
0
ファイル: StudentData.cs プロジェクト: orette/southville
        public Students GetStudents()
        {
            Students students = new Students();

            try
            {
                using (SqlConnection conn = new SqlConnection(connString))
                using (SqlCommand comm = new SqlCommand("usp_GetActiveCustomers", conn))
                {
                    comm.CommandType = CommandType.StoredProcedure;
                    conn.Open();

                    using (SqlDataReader dr = comm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            Student stud = new Student(dr["Customer Number"].ToString(),
                                dr["Customer Name"].ToString(),
                                dr["Price Level"].ToString(),
                                dr["Customer Class"].ToString(),
                                dr["Currency ID"].ToString(),
                                dr["Grade Level"].ToString(),
                                dr["Status"].ToString());

                            students.Add(stud);
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
            return students;
        }