001.
Imports
System
002.
Imports
System.Data
003.
Imports
System.Data.SqlClient
004.
Imports
System.IO
005.
Imports
System.Text
006.
Imports
System.Data.OleDb
007.
008.
Public
Class
uBranch
009.
Inherits
uBaseClass
010.
011.
Private
Sub
Internalloaddata()
012.
013.
Dim
dt
As
New
DataTable
014.
Dim
_strQuery
As
New
StringBuilder
015.
016.
_strQuery.Append(
" select COMP_ID as COMP_ID,COMP_CODE as COMP_CODE,COMP_NAME as COMP_NAME,COMP_ADDRESS1 AS COMP_ADDRESS1 ,COMP_ADDRESS2 as COMP_ADDRESS2,COMP_TEL as COMP_TEL,COMP_FAX as COMP_FAX,COMP_REGISTRATIONNO as COMP_REGISTRATIONNO,COMP_TAXNO as COMP_TAXNO,COMP_CREATEDATE as COMP_CREATEDATE,COMP_LASTUPDATE as COMP_LASTUPDATE,COMP_CREATEDBY as COMP_CREATEDBY,COMP_UPDATEDBY as COMP_UPDATEDBY,"
)
017.
_strQuery.Append(
" COMP_STATUS as COMP_STATUS from COMP"
)
018.
019.
020.
Console.WriteLine(
"COMP data start ..."
)
021.
dt = uProcessData.QueryData_Str(uConnect.conn, _strQuery.ToString)
022.
Console.WriteLine(
"COMP data Query Data ..."
)
023.
024.
If
Not
dt
Is
Nothing
Then
025.
If
dt.Rows.Count > 0
Then
026.
Console.WriteLine(
"COMP data have Data ..."
)
027.
SaveData(dt)
028.
Else
029.
Console.WriteLine(
"COMP data not have Data ..."
)
030.
End
If
031.
Else
032.
Console.WriteLine(
"COMP data not have Data ..."
)
033.
End
If
034.
035.
End
Sub
036.
037.
Sub
New
()
038.
039.
Internalloaddata()
040.
041.
End
Sub
042.
043.
044.
Private
Sub
SaveData(
ByVal
dt
As
DataTable)
045.
046.
For
i
As
Integer
= 0
To
dt.Rows.Count - 1
047.
If
InsertData(dt, i) =
False
Then
048.
Updatedata(dt, i)
049.
End
If
050.
Next
051.
052.
End
Sub
053.
054.
Private
Function
InsertData(
ByVal
dt
As
DataTable,
ByVal
Arow
As
Integer
)
As
Boolean
055.
056.
Dim
_strQuery
As
New
StringBuilder
057.
058.
Dim
COMP_ID
As
String
= dt.Rows(Arow)(
"COMP_ID"
).ToString
059.
Dim
COMP_CODE
As
String
= dt.Rows(Arow)(
"COMP_CODE"
).ToString
060.
Dim
COMP_NAME
As
String
= dt.Rows(Arow)(
"COMP_NAME"
).ToString
061.
Dim
COMP_ADDRESS1
As
String
= dt.Rows(Arow)(
"COMP_ADDRESS1"
).ToString
062.
Dim
COMP_ADDRESS2
As
String
= dt.Rows(Arow)(
"COMP_ADDRESS2"
).ToString
063.
Dim
COMP_TEL
As
String
= dt.Rows(Arow)(
"COMP_TEL"
).ToString
064.
Dim
COMP_FAX
As
String
= dt.Rows(Arow)(
"COMP_FAX"
).ToString
065.
Dim
COMP_REGISTRATIONNO
As
String
= dt.Rows(Arow)(
"COMP_REGISTRATIONNO"
).ToString
066.
Dim
COMP_TAXNO
As
String
= dt.Rows(Arow)(
"COMP_TAXNO"
).ToString
067.
Dim
COMP_CREATEDATE
As
String
= dt.Rows(Arow)(
"COMP_CREATEDATE"
).ToString
068.
Dim
COMP_LASTUPDATE
As
String
= dt.Rows(Arow)(
"COMP_LASTUPDATE"
).ToString
069.
Dim
COMP_CREATEDBY
As
String
= dt.Rows(Arow)(
"COMP_CREATEDBY"
).ToString
070.
Dim
COMP_UPDATEDBY
As
String
= dt.Rows(Arow)(
"COMP_UPDATEDBY"
).ToString
071.
Dim
COMP_STATUS
As
String
= dt.Rows(Arow)(
"COMP_STATUS"
).ToString
072.
073.
uConnectDestination.tr = uConnectDestination.conn.BeginTransaction
074.
075.
Try
076.
077.
_strQuery.Append(
" insert into COMP"
)
078.
_strQuery.Append(
" (COMP_ID,COMP_CODE,COMP_NAME,COMP_ADDRESS1,COMP_ADDRESS2,COMP_TEL,COMP_FAX,COMP_REGISTRATIONNO,"
)
079.
_strQuery.Append(
" COMP_TAXNO,COMP_CREATEDATE,COMP_LASTUPDATE,COMP_CREATEDBY,COMP_UPDATEDBY,COMP_STATUS)"
)
080.
_strQuery.Append(
" values "
)
081.
_strQuery.Append(
"("
)
082.
_strQuery.Append(
"'"
).Append(COMP_ID).Append(
"',"
)
083.
_strQuery.Append(
"'"
).Append(COMP_CODE).Append(
"',"
)
084.
_strQuery.Append(
"'"
).Append(COMP_NAME).Append(
"',"
)
085.
_strQuery.Append(
"'"
).Append(COMP_ADDRESS1).Append(
"',"
)
086.
_strQuery.Append(
"'"
).Append(COMP_ADDRESS2).Append(
"',"
)
087.
_strQuery.Append(
"'"
).Append(COMP_TEL).Append(
"',"
)
088.
_strQuery.Append(
"'"
).Append(COMP_FAX).Append(
"',"
)
089.
_strQuery.Append(
"'"
).Append(COMP_REGISTRATIONNO).Append(
"',"
)
090.
_strQuery.Append(
"'"
).Append(COMP_TAXNO).Append(
"',"
)
091.
_strQuery.Append(
"'"
).Append(COMP_CREATEDATE).Append(
"',"
)
092.
_strQuery.Append(
"'"
).Append(COMP_LASTUPDATE).Append(
"',"
)
093.
_strQuery.Append(
"'"
).Append(COMP_CREATEDBY).Append(
"',"
)
094.
_strQuery.Append(
"'"
).Append(COMP_STATUS).Append(
"'"
)
095.
_strQuery.Append(
")"
)
096.
097.
uProcessData.ModifyData_Str(uConnectDestination.conn, uConnectDestination.tr, _
098.
_strQuery.ToString)
099.
100.
uConnectDestination.tr.Commit()
101.
Console.WriteLine(
"Insert New COMP @Row"
& Arow + 1 &
"/"
& dt.Rows.Count)
102.
103.
Return
True
104.
105.
Catch
ex
As
Exception
106.
uConnectDestination.tr.Rollback()
107.
Return
False
108.
End
Try
109.
110.
End
Function
111.
112.
113.
Private
Function
Updatedata(
ByVal
dt
As
DataTable,
ByVal
Arow
As
Integer
)
As
Boolean
114.
115.
Dim
_strQuery
As
New
StringBuilder
116.
117.
Dim
COMP_ID
As
String
= dt.Rows(Arow)(
"COMP_ID"
).ToString
118.
Dim
COMP_CODE
As
String
= dt.Rows(Arow)(
"COMP_CODE"
).ToString
119.
Dim
COMP_NAME
As
String
= dt.Rows(Arow)(
"COMP_NAME"
).ToString
120.
Dim
COMP_ADDRESS1
As
String
= dt.Rows(Arow)(
"COMP_ADDRESS1"
).ToString
121.
Dim
COMP_ADDRESS2
As
String
= dt.Rows(Arow)(
"COMP_ADDRESS2"
).ToString
122.
Dim
COMP_TEL
As
String
= dt.Rows(Arow)(
"COMP_TEL"
).ToString
123.
Dim
COMP_FAX
As
String
= dt.Rows(Arow)(
"COMP_FAX"
).ToString
124.
Dim
COMP_REGISTRATIONNO
As
String
= dt.Rows(Arow)(
"COMP_REGISTRATIONNO"
).ToString
125.
Dim
COMP_TAXNO
As
String
= dt.Rows(Arow)(
"COMP_TAXNO"
).ToString
126.
Dim
COMP_CREATEDATE
As
String
= dt.Rows(Arow)(
"COMP_CREATEDATE"
).ToString
127.
Dim
COMP_LASTUPDATE
As
String
= dt.Rows(Arow)(
"COMP_LASTUPDATE"
).ToString
128.
Dim
COMP_CREATEDBY
As
String
= dt.Rows(Arow)(
"COMP_CREATEDBY"
).ToString
129.
Dim
COMP_UPDATEDBY
As
String
= dt.Rows(Arow)(
"COMP_UPDATEDBY"
).ToString
130.
Dim
COMP_STATUS
As
String
= dt.Rows(Arow)(
"COMP_STATUS"
).ToString
131.
132.
uConnectDestination.tr = uConnectDestination.conn.BeginTransaction
133.
134.
Try
135.
136.
_strQuery.Append(
" update COMP"
)
137.
_strQuery.Append(
" set "
)
138.
_strQuery.Append(
" COMP_ID = '"
).Append(COMP_ID).Append(
"',"
)
139.
_strQuery.Append(
" COMP_CODE = '"
).Append(COMP_CODE).Append(
"',"
)
140.
_strQuery.Append(
" COMP_NAME = '"
).Append(COMP_NAME).Append(
"',"
)
141.
_strQuery.Append(
" COMP_ADDRESS1 = '"
).Append(COMP_ADDRESS1).Append(
"',"
)
142.
_strQuery.Append(
" COMP_ADDRESS2 = '"
).Append(COMP_ADDRESS2).Append(
"',"
)
143.
_strQuery.Append(
" COMP_TEL = '"
).Append(COMP_TEL).Append(
"',"
)
144.
_strQuery.Append(
" COMP_FAX = '"
).Append(COMP_FAX).Append(
"',"
)
145.
_strQuery.Append(
" COMP_REGISTRATIONNO = '"
).Append(COMP_REGISTRATIONNO).Append(
"',"
)
146.
_strQuery.Append(
" COMP_TAXNO = '"
).Append(COMP_TAXNO).Append(
"',"
)
147.
_strQuery.Append(
" COMP_CREATEDATE = '"
).Append(COMP_CREATEDATE).Append(
"',"
)
148.
_strQuery.Append(
" COMP_LASTUPDATE = '"
).Append(COMP_LASTUPDATE).Append(
"',"
)
149.
_strQuery.Append(
" COMP_CREATEDBY = '"
).Append(COMP_CREATEDBY).Append(
"',"
)
150.
_strQuery.Append(
" COMP_UPDATEDBY = '"
).Append(COMP_UPDATEDBY).Append(
"',"
)
151.
_strQuery.Append(
" COMP_STATUS = '"
).Append(COMP_STATUS).Append(
"'"
)
152.
_strQuery.Append(
" where COMP_ID = '"
).Append(COMP_ID).Append(
"'"
)
153.
154.
155.
uProcessData.ModifyData_Str(uConnectDestination.conn, uConnectDestination.tr, _
156.
_strQuery.ToString)
157.
158.
159.
uConnectDestination.tr.Commit()
160.
Console.WriteLine(
"Update COMP @Row"
& Arow + 1 &
"/"
& dt.Rows.Count)
161.
Return
True
162.
163.
Catch
ex
As
Exception
164.
uConnectDestination.tr.Rollback()
165.
Return
False
166.
End
Try
167.
168.
169.
170.
End
Function
171.
172.
173.
End
Class