public static bool DeleteMD_SuDungPhong(MD_SuDungPhong mdsdp)
        {
            var cm = CreateCommand();

            cm.CommandText = @"Exec update_row_MD_SuDungPhong @ID";
            cm.Parameters.Add(new SqlParameter("@ID", mdsdp.ID));
            int rs = cm.ExecuteNonQuery();

            cn.Close();
            return(rs > 0);
        }
Esempio n. 2
0
        public static MD_SuDungPhong Read(SqlDataReader reader)
        {
            var bc = new MD_SuDungPhong()
            {
                ID          = reader.GetString(iID),
                MaPhong     = reader.GetString(iMaPhong),
                NgayBatDau  = reader.GetDateTime(iNgayBatDau),
                NgayKetThuc = reader.GetDateTime(iNgayKetThuc),
                MatDo       = reader.GetInt32(iMatDo)
            };

            return(bc);
        }
        public static bool ThemMD_SuDungPhong(MD_SuDungPhong mdsdp)
        {
            var cm = CreateCommand();

            cm.CommandText = @"Exec add_row_MD_SuDungPhong @ID, @MaPhong, @NgayBatDau, @NgayKetThuc, @MatDo";
            cm.Parameters.Add(new SqlParameter("@ID", mdsdp.ID));
            cm.Parameters.Add(new SqlParameter("@MaPhong", mdsdp.MaPhong));
            cm.Parameters.Add(new SqlParameter("@NgayBatDau", mdsdp.NgayBatDau));
            cm.Parameters.Add(new SqlParameter("@NgayKetThuc", mdsdp.NgayKetThuc));
            cm.Parameters.Add(new SqlParameter("@MatDo", mdsdp.MatDo));
            int rs = cm.ExecuteNonQuery();

            cn.Close();
            return(rs > 0);
        }
        public static bool UpdateMD_SuDungPhong(MD_SuDungPhong mdsdp)
        {
            var cm = CreateCommand();

            cm.CommandText = @"Exec update_row_MD_SuDungPhong @ID, @MP, @NBD, @NKT, @MD";
            cm.Parameters.Add(new SqlParameter("@ID", mdsdp.ID));
            cm.Parameters.Add(new SqlParameter("@MP", mdsdp.MaPhong));
            cm.Parameters.Add(new SqlParameter("@NBD", mdsdp.NgayBatDau));
            cm.Parameters.Add(new SqlParameter("@NKT", mdsdp.NgayKetThuc));
            cm.Parameters.Add(new SqlParameter("@MD", mdsdp.MatDo));
            int rs = cm.ExecuteNonQuery();

            cn.Close();
            return(rs > 0);
        }
        public static List <MD_SuDungPhong> DSMD_SuDungPhong()
        {
            var lmdsdp = new List <MD_SuDungPhong>();
            var cm     = CreateCommand();

            cm.CommandText = @"SELECT * FROM MD_SUDUNGPHONG";
            var reader = cm.ExecuteReader();

            while (reader.Read())
            {
                lmdsdp.Add(MD_SuDungPhong.Read(reader));
            }
            cn.Close();
            return(lmdsdp);
        }