> For the complete documentation index, see [llms.txt](https://kythuat.dtechvn.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kythuat.dtechvn.com/nghiep-vu/temp-note-phan-tich.md).

# TEMP NOTE PHÂN TÍCH

## Ý nghĩa chức năng <a href="#y-nghia-chuc-nang" id="y-nghia-chuc-nang"></a>

* temp dùng để lưu vết cấu trúc, nguyên tắc tạo báo cáo
* khi sửa đổi bổ sung thì nên chèn dòng và mô tả lý do tại sao

## Code tạo temp Phân tích

```sql
declare @nghiepvu int = 1034
select N'.I. Mô tả nội dung nghiệp vụ'+ char(13)
+ char(13) + N'.II. Chi tiết cấu hinh nghiệp vụ'+ char(13)
from nghiepvu where nghiepvu=@nghiepvu

union
select N'1. ID + Tên Nghiệp vụ:' 
+ char(13) + space(5) + convert(nvarchar(10),nghiepvu) +' - '+ vietnam
from nghiepvu where nghiepvu=@nghiepvu

union
select N'2. ẩn hiện chung:' 
+ char(13) + space(5)+ nghiepvu.FieldShow
from nghiepvu where nghiepvu=@nghiepvu

union
select N'3. ẩn hiện chi tiết:' 
+ char(13) + space(5) + nghiepvu.FieldDetail
from nghiepvu where nghiepvu=@nghiepvu

union
select N'4. ẩn hiện nút:' 
+ char(13) + space(5)+ case when AnHienNut<>'' then nghiepvu.AnHienNut else '-null' end
from nghiepvu where nghiepvu=@nghiepvu

union
select N'5. Đặt mặc định:' 
+ char(13) + space(5) + case when [SetDefault]<>'' then nghiepvu.[SetDefault] else '-null' end
from nghiepvu where nghiepvu=@nghiepvu

union
select N'6. Trường kiểm tra:' 
+ char(13) + space(5) + case when FieldKtra<>'' then nghiepvu.FieldKtra else '-null' end
from nghiepvu where nghiepvu=@nghiepvu

union
select N'7. Trường không được trống:' 
+ char(13) + space(5) + case when FieldNotEmpty<>'' then nghiepvu.FieldNotEmpty else '-null' end
from nghiepvu where nghiepvu=@nghiepvu

union
select N'8. Trường để lại sau khi lưu:' 
+ char(13) + space(5) + case when DeLai<>'' then nghiepvu.DeLai else '-null' end
from nghiepvu where nghiepvu=@nghiepvu

union
select N'9. Trường readonly:' 
+ char(13) + space(5)+ case when FReadOnly<>'' then nghiepvu.FReadOnly else '-null' end
from nghiepvu where nghiepvu=@nghiepvu
```

## Code so sánh ẩn hiện của form chung giữa 2 bản&#x20;

* Copy text ẩn hiện của bản số 1 và gán vào biến @fieldShowSosanh
* Chạy câu lệnh dưới để nhìn thấy sự khác biệt

```sql
-- Gán lại giá trị cho biến @fieldShowSosanh 
declare @fieldShowSosanh nvarchar(2000) = 'Ngay,0#ChungTu,1#PtVAT,5#SoHD,3#NgayHD,4#OngBa,6#'
declare @fieldShowHientai nvarchar(2000) =''
-- sửa lại giá trị nghiệp vụ
declare @nghiepvu int = 301
set @fieldShowHientai = (select fieldshow from nghiepvu where nghiepvu=@nghiepvu)

select T1.tencot as tencotHientai, T2.tencot as tencotSosanh from
(
select *
, substring(SplitItem,1, CHARINDEX(',', splititem)-1) as tencot
from [dbo].[SplitString](@fieldShowHientai, '#')
)T1 full outer join 
(
select *
, substring(SplitItem,1, CHARINDEX(',', splititem)-1) as tencot
from [dbo].[SplitString](@fieldShowSosanh, '#')
)T2
on T1.tencot =t2.tencot

```

## Code so sánh ẩn hiện của lưới chi tiết giữa 2 bản

* Copy text ẩn hiện của bản bản số 1 và gán vào biến @detailSosanh
* chạy câu lệnh dưới để nhìn thấy sự khác biệt ẩn hiện cột

```sql
-- gán lại giá trị cho biến @detailSosanh
declare @detailSosanh nvarchar(2000) = 'TkCo(388)TaiKhoan,ma,ma#soLuong(391)#donGia(392)#soInvoice(100)'
declare @detailHientai nvarchar(2000) =''
-- sửa lại giá trị biến nghiệp vụ
declare @nghiepvu int = 301

set @detailHientai = (select fielddetail from nghiepvu where nghiepvu=@nghiepvu)
select T1.tencot as tencotHientai, T2.tencot as tencotSosanh from
(
select *
, substring(SplitItem, 1, CHARINDEX('(', splititem)-1) as fieldName
, substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) )  as sourceName
, case when  substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) ) <>''
	then substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) ) 
	else substring(SplitItem, 1, CHARINDEX('(', splititem)-1)
	end as tencot
from [dbo].[SplitString](@detailHientai, '#')
)T1 full outer join 
(
select *
, substring(SplitItem, 1, CHARINDEX('(', splititem)-1) as fieldName
, substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) ) as sourceName
, case when  substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) ) <>''
	then substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) ) 
	else substring(SplitItem, 1, CHARINDEX('(', splititem)-1)
	end as tencot
from [dbo].[SplitString](@detailSosanh, '#')


)T2
on T1.tencot =t2.tencot

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://kythuat.dtechvn.com/nghiep-vu/temp-note-phan-tich.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
