public List <Ve> Ticket() { Connect(); List <Ve> list = new List <Ve>(); try { string sql1 = "SELECT * FROM Ve"; SqlCommand cmd = new SqlCommand(sql1, cn); cmd.CommandType = CommandType.Text; SqlDataReader dr = cmd.ExecuteReader(); string MaVe, MaHK, MaCB, HangVe, LoaiVe, GioBay, NgayBay, GioBan, NgayBan, NoiBan, Gia; while (dr.Read()) { MaVe = dr.GetString(0); MaHK = dr.GetString(1); MaCB = dr.GetString(2); HangVe = dr.GetString(3); LoaiVe = dr.GetString(4); GioBay = dr.GetString(5); NgayBay = dr.GetString(6); GioBan = dr.GetString(7); NgayBan = dr.GetString(8); NoiBan = dr.GetString(9); Gia = dr.GetString(10); Ve v = new Ve(MaVe, MaHK, MaCB, HangVe, LoaiVe, GioBay, NgayBay, GioBan, NgayBan, NoiBan, Gia); list.Add(v); } dr.Close(); } catch (SqlException ex) { MessageBox.Show(ex.Message); } finally { Disconnect(); } return(list); }
public List <Ve> GetEmployee() { Connect(); List <Ve> list = new List <Ve>(); try { string sql = "SELECT * FROM Ve"; SqlCommand cmd = new SqlCommand(sql, cn); SqlDataReader dr = cmd.ExecuteReader(); string MaVe, MaHK, MaCB, LoaiVe, Ngaygiobay, Ngaygioban, NoiBan, GiaVe, Diemdi, Diemden, Lephi; while (dr.Read()) { MaVe = dr.GetString(0); MaHK = dr.GetString(1); MaCB = dr.GetString(2); LoaiVe = dr.GetString(3); Ngaygiobay = dr.GetString(4); Ngaygioban = dr.GetString(5); NoiBan = dr.GetString(6); GiaVe = dr.GetString(7); Diemdi = dr.GetString(8); Diemden = dr.GetString(9); Lephi = dr.GetString(10); Ve v = new Ve(MaVe, MaHK, MaCB, LoaiVe, Ngaygiobay, Ngaygioban, NoiBan, GiaVe, Diemdi, Diemden, Lephi); list.Add(v); } dr.Close(); } catch (SqlException ex) { MessageBox.Show(ex.Message); } finally { Disconnect(); } return(list); }