1,217
社区成员




Private Sub cmdOut_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlCells As Excel.Range
Dim i As Integer
Dim OraDyn As OraDynaset
Dim OraDyn1 As OraDynaset
Dim strSql As String
Dim strSql1 As String
Dim intR As Integer
Dim intC As Integer
Dim err As String
Dim err1 As String
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(mstrDataFile)
Set xlSheet = xlBook.ActiveSheet
Set xlCells = xlSheet.Cells
intR = xlSheet.Cells.SpecialCells(xlCellTypeLastCell).Row - 4
intC = 4
ReDim myText(1 To intR, 1 To intC)
For i = 1 To intR
myText(i, 1) = CStr(xlCells(i + 4, 2).Value)
myText(i, 2) = CStr(xlCells(i + 4, 3).Value)
myText(i, 3) = CStr(xlCells(i + 4, 5).Value)
myText(i, 4) = CStr(xlCells(i + 4, 6).Value)
strSql = "SELECT "
strSql = strSql & " HACHUTEN, "
strSql = strSql & " TEKIZAISU "
strSql = strSql & " FROM "
strSql = strSql & " TMJ0BA "
strSql = strSql & " WHERE "
strSql = strSql & " SOUKOCD = '" & xlCells(i + 4, 2).Value & "' "
strSql = strSql & " AND HINCD ='" & xlCells(i + 4, 3).Value & "' "
Set OraDyn = OraDB.CreateDynaset(strSql, ORADYN_READONLY)
If myText(i, 1) > 5 Then
err = "倉庫CD:1,2,3,4,5以外不可。"
End If
If IsNumericCheck(xlCells(i + 4, 3)) = True Then
err1 = "商品CD:半角英数。"
End If
If OraDyn.EOF = True Then
xlCells(i + 4, 7) = err & err1 & "在庫残高。"
Else
strSql1 = " UPDATE TMJ0BA SET "
strSql1 = strSql1 & " ZASOSHIKI = ' * ' ,"
strSql1 = strSql1 & " HACHUTEN = '" & xlCells(i + 4, 5).Value & "' ,"
strSql1 = strSql1 & " TEKIZAISU = '" & xlCells(i + 4, 6).Value & "' ,"
strSql1 = strSql1 & " LOTNO = ' * ' "
strSql1 = strSql1 & " WHERE "
strSql1 = strSql1 & " SOUKOCD = '" & xlCells(i + 4, 2).Value & "' "
strSql1 = strSql1 & " AND HINCD ='" & xlCells(i + 4, 3).Value & "' "
OraDB.ExecuteSQL (strSql1)
End If
Next i
Set xlCells = Nothing
Set xlSheet = Nothing
xlBook.Save
xlBook.Close
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub