public static List <TinhTrangBo> GetTinhTrangBo(TinhTrangBo tinhTrangBo) { List <TinhTrangBo> result = null; try { result = DataProvider.ExecuteReader((SqlDataReader row) => { return(new TinhTrangBo() { MaChamSoc = row.GetValueDefault <string>(0), MaPhanCong = row.GetValueDefault <string>(1), MaBo = row.GetValueDefault <string>(2), ChieuCao = row.GetValueDefault <float>(3), CanNang = row.GetValueDefault <float>(4) }); }, string.Format("select ttb.MaChamSoc,pc.MaPhanCong,cs.MaBo,ttb.ChieuCao,ttb.CanNang " + "from TinhTrangBo ttb,ChamSoc cs,PhanCong pc " + "where ttb.machamsoc = '{0}' and ttb.MaChamSoc=cs.MaChamSoc and cs.MaPhanCong = pc.MaPhanCong order by ThoiGianGhiNhan desc", tinhTrangBo.MaChamSoc)); } catch (Exception) { return(result); } return(result); }
//add tinh trang bo public static ChamSoc AddTinhTrangBo(TinhTrangBo tinhTrangBo) { ChamSoc result = null; try { result = DataProvider.ExecuteReaderOne((SqlDataReader row) => { return(new ChamSoc() { MaChamSoc = row.GetValueDefault <string>(0), NgayGhiNhan = row.GetValueDefault <DateTime>(1), TinhTrangCongViec = row.GetValueDefault <string>(2), LuongSua = row.GetValueDefault <float>(3), DaChoAn = row.GetValueDefault <bool>(4), DaDonVeSinh = row.GetValueDefault <bool>(5), DaVatSua = row.GetValueDefault <bool>(6), MaPhanCong = row.GetValueDefault <string>(7), MaBo = row.GetValueDefault <string>(8) }); }, string.Format("select top 1 * from chamsoc where maphancong = '{0}' and mabo = '{1}' and NgayGhiNhan='{2}'", tinhTrangBo.MaPhanCong, tinhTrangBo.MaBo, DateTime.Now)); } catch (Exception) { return(null); } try { DataProvider.ExecuteNonQuery(string.Format("insert into TinhTrangBo(MaChamSoc,ThoiGianGhiNhan,CanNang,ChieuCao) values ('{0}', '{1}', {2}, {3})", result.MaChamSoc, DateTime.Now, tinhTrangBo.CanNang, tinhTrangBo.ChieuCao)); } catch (Exception) { return(null); } PhanCong temp = null; try { temp = DataProvider.ExecuteReaderOne((SqlDataReader row) => { return(new PhanCong() { MaPhanCong = row.GetValueDefault <string>(0), MaChuong = row.GetValueDefault <string>(5) }); }, string.Format("select top 1 * from phancong where maphancong = '{0}'", result.MaPhanCong)); } catch (Exception) { return(null); } result.MaChuong = temp.MaChuong; return(result); }