public PhongLuuTru getPhongLuuTru(int ID) { PhongLuuTru result = null; string query = "SELECT * FROM Su_PhongLuuTru WHERE ID = " + ID + ""; DataTable dt = getData(query); if (dt.Rows.Count > 0) { result = new PhongLuuTru(); result.ID = ID; result.Coquan = dt.Rows[0]["Coquan"].ToString(); result.MaPhong = dt.Rows[0]["MaPhong"].ToString(); result.TenPhong = dt.Rows[0]["TenPhong"].ToString(); result.LichSu = dt.Rows[0]["LichSu"].ToString(); result.ThoigianTaiLieu = dt.Rows[0]["ThoigianTaiLieu"].ToString(); result.TongSoTaiLieu = dt.Rows[0]["TongSoTaiLieu"].ToString(); result.TaiLieuChinhLy = dt.Rows[0]["TaiLieuChinhLy"].ToString(); result.TaiLieuChuaChinhLy = dt.Rows[0]["TaiLieuChuaChinhLy"].ToString(); result.CacNhomTaiLieu = dt.Rows[0]["CacNhomTaiLieu"].ToString(); result.NhomTaiLieuKhac = dt.Rows[0]["NhomTaiLieuKhac"].ToString(); result.ThoiGianNhap = dt.Rows[0]["ThoiGianNhap"].ToString(); result.NgonNgu = dt.Rows[0]["NgonNgu"].ToString(); result.CongCu = dt.Rows[0]["CongCu"].ToString(); result.BanSaoBaoHiem = dt.Rows[0]["BanSaoBaoHiem"].ToString(); result.GhiChu = dt.Rows[0]["GhiChu"].ToString(); } return(result); }
public bool addPhongLuuTru(PhongLuuTru newSec) { bool result = false; SqlConnection conn = new SqlConnection(connectionString); try { string query = @"INSERT INTO Su_PhongLuuTru ([Coquan] ,[MaPhong] ,[TenPhong] ,[LichSu] ,[ThoigianTaiLieu] ,[TongSoTaiLieu] ,[TaiLieuChinhLy] ,[TaiLieuChuaChinhLy] ,[CacNhomTaiLieu] ,[NhomTaiLieuKhac] ,[ThoiGianNhap] ,[NgonNgu] ,[CongCu] ,[BanSaoBaoHiem] ,[GhiChu]) VALUES('" + newSec.Coquan + "', N'" + newSec.MaPhong + "', N'" + newSec.TenPhong + "', N'" + newSec.LichSu + "', N'" + newSec.ThoigianTaiLieu + "', N'" + newSec.TongSoTaiLieu + "', N'" + newSec.TaiLieuChinhLy + "', N'" + newSec.TaiLieuChuaChinhLy + "', N'" + newSec.CacNhomTaiLieu + "', N'" + newSec.NhomTaiLieuKhac + "', N'" + newSec.ThoiGianNhap + "', N'" + newSec.NgonNgu + "', N'" + newSec.CongCu + "', N'" + newSec.BanSaoBaoHiem + "', N'" + newSec.GhiChu + "');"; conn.Open(); executeDataByQuery(query, conn, null); result = true; } catch (Exception e) { logUserManagement("addPhongLuuTru()", e.Message); } finally { conn.Close(); } return(result); }
public bool updatePhongLuuTru(PhongLuuTru Sec) { bool result = false; SqlConnection conn = new SqlConnection(connectionString); string query = "UPDATE Su_PhongLuuTru SET Coquan = '" + Sec.Coquan + "', MaPhong = N'" + Sec.MaPhong + "', TenPhong = N'" + Sec.TenPhong + "', LichSu = N'" + Sec.LichSu + "', TongSoTaiLieu = N'" + Sec.TongSoTaiLieu + "', TaiLieuChinhLy = N'" + Sec.TaiLieuChinhLy + "', TaiLieuChuaChinhLy = N'" + Sec.TaiLieuChuaChinhLy + "', CacNhomTaiLieu = N'" + Sec.CacNhomTaiLieu + "', NhomTaiLieuKhac = N'" + Sec.NhomTaiLieuKhac + "', ThoiGianNhap = N'" + Sec.ThoiGianNhap + "', ThoigianTaiLieu = N'" + Sec.ThoigianTaiLieu + "', NgonNgu = N'" + Sec.NgonNgu + "', CongCu = N'" + Sec.CongCu + "', BanSaoBaoHiem = N'" + Sec.BanSaoBaoHiem + "', GhiChu = N'" + Sec.GhiChu + "' WHERE ID = " + Sec.ID + ""; try { conn.Open(); executeDataByQuery(query, conn, null); result = true; } catch (Exception e) { logUserManagement("updatePhongLuuTru()", e.Message); } finally { conn.Close(); } return(result); }