コード例 #1
0
 private void staff_login_form_Load(object sender, EventArgs e)
 {
     staff_info_class staff_info = new staff_info_class();
     list_of_staff_info = staff_info.get_all_objects();
 }
コード例 #2
0
        public List<staff_info_class> get_all_objects()
        {
            connection_get_all_staff_info = new SqlConnection(@"Server= (local)\SQLEXPRESS; Initial Catalog=BoomDB; Integrated Security=True;");
            List<staff_info_class> result_list_of_staff_info = new List<staff_info_class>();
            staff_info_class result_staff_info;
            connection_get_all_staff_info.Open();
            SqlCommand command_get_all_staff_info = new SqlCommand("SELECT * FROM personal_info_t", connection_get_all_staff_info);
            SqlDataReader reader = command_get_all_staff_info.ExecuteReader();

            while (reader.Read())
            {
                result_staff_info = new staff_info_class();
                result_staff_info.person_id = reader["person_id"].ToString();
                result_staff_info.name = reader["name"].ToString();
                result_staff_info.password = reader["staff_password"].ToString();
                result_staff_info.position = reader["position"].ToString();
                result_staff_info.phone = reader["phone"].ToString();
                result_staff_info.additional_phone = reader["additional_phone"].ToString();
                result_staff_info.birthday = DateTime.Parse(reader["birthday"].ToString());
                result_staff_info.home_address = reader["home_address"].ToString(); ;
                result_staff_info.salary_per_day = double.Parse(reader["salary_per_day"].ToString());

                result_list_of_staff_info.Add(result_staff_info);
            }
            return result_list_of_staff_info;
        }