public List <BanBEAN> themBan(List <BanBEAN> ds, string maBan, string tenBan, long soGhe, out Boolean kq) { kq = false; // lấy về tất cả các loại có mã là maLoai var q = from l in ds where l.MaBan.Equals(maBan) select l; if (q.Count() == 0) { // thêm csdl ban.themBan(maBan, tenBan, soGhe); // thêm bộ nhớ BanBEAN b = new BanBEAN(maBan, tenBan, soGhe); ds.Add(b); kq = true; } return(ds); }
public List <BanBEAN> timBan(string key) { string sql = "SELECT * FROM Ban WHERE TenBan LIKE @tenBan "; SqlCommand cmd = new SqlCommand(sql, DungChung.cn); SqlParameter ts = new SqlParameter("@tenBan", "%" + key + "%"); cmd.Parameters.Add(ts); SqlDataReader rs = cmd.ExecuteReader(); List <BanBEAN> ds = new List <BanBEAN>(); while (rs.Read()) { string maBan = rs["MaBan"].ToString(); string tenBan = rs["TenBan"].ToString(); string soGhe = rs["SoGhe"].ToString(); BanBEAN ban = new BanBEAN(maBan, tenBan, long.Parse(soGhe)); ds.Add(ban); } rs.Close(); return(ds); }
public List <BanBEAN> getListBan() { string sql = "SELECT * FROM Ban"; SqlCommand cmd = new SqlCommand(sql, DungChung.cn); SqlDataReader rs = cmd.ExecuteReader(); List <BanBEAN> ds = new List <BanBEAN>(); while (rs.Read()) { string maBan = rs["MaBan"].ToString(); string tenBan = rs["TenBan"].ToString(); string soGhe = rs["SoGhe"].ToString(); BanBEAN ban = new BanBEAN(maBan, tenBan, long.Parse(soGhe)); ds.Add(ban); //String[] st = new String[2]; //st[0] = rs[0].ToString(); //st[1] = rs[1].ToString(); } rs.Close(); return(ds); }