sub pu1rk_write()
dim my** as new adodb.connection
dim myrs as new adodb.recordset
dim strcon as string
'ado資料庫連線串
strcon = "provider=sqloledb;server=172.16.2.2;uid=sa;pwd=tpcims;database=movex12" 'dl580-1
on error goto error:
my**.connectionstring = strcon
'設定超時時間,為0時表示,將一直等待到命令執行完畢
my**.***mandtimeout = 0
my**.open
myrs.activeconnection = my**
'開啟儲存過程,引數為i3單元格內容
mystr = "execute pu1rk_zhangzs '" + range("i6") + "'"
' mystr = "select top 1 * from mittra "
' msgbox (mystr)
myrs.open mystr '為 recordset 賦值
'如果沒有查出記錄
if myrs.eof then
msgbox "質檢站還沒判定/您還沒有入庫操作!", vbokonly, "錯誤"
range("i6").value = ""
exit sub
end if
'為工作表解除保護
'worksheets("精整入庫").unprotect password:="zhangzs"
'插入所查詢的資料
range("b6") = "庫別:" + trim(myrs!庫位)
range("f6") = trim(myrs!物料號)
range("c17") = trim(myrs!交易日期)
range("b9") = trim(myrs!爐號)
range("d9") = trim(myrs!鋼種)
range("f9") = trim(myrs!鑄坯外徑)
range("h9") = trim(myrs!定尺長度) + "m"
if trim(trim(myrs!備註)) = "," then
range("b15") = "備註: "
else
range("b15") = "備註: " + trim(myrs!備註)
end if
n = 2 '初始變數
m = 11
do while not myrs.eof
cells(11, n) = trim(myrs!倍尺數)
cells(m + 1, n) = "支數"
cells(m + 1, n + 1) = "重量(t)"
cells(m + 2, n) = trim(myrs!實際支數)
cells(m + 2, n + 1) = trim(myrs!重量)
myrs.movenext
n = n + 2
loop
'worksheets("精整入庫").protect password:="zhangzs", drawingobjects:=true, contents:=true, scenarios:=true
'總重量,總支數
range("j9") = range("b13") + range("d13") + range("f13") + range("h13") + range("j13") + range("l13")
range("l9") = range("c13") + range("e13") + range("g13") + range("i13") + range("k13") + range("m13")
'關閉連線
myrs.close
my**.close
exit sub
'出現錯誤執行以下**
error:
msgbox err.description, vbokonly, "error message"
end sub
sub pu1rk_clear()
'取消工作表保護
worksheets("精整入庫").unprotect password:="zhangzs"
'清除部分單元格內容
range("b6") = "庫別:"
range("f6") = ""
range("c17") = ""
range("b9") = ""
range("d9") = ""
range("f9") = ""
range("h9") = ""
range("c16") = ""
range("b11") = ""
range("d11") = ""
range("f11") = ""
range("h11") = ""
range("j11") = ""
range("l11") = ""
range("b15") = "備註:"
'清空總支數,總重量
range("j9") = ""
range("l9") = ""
for i = 2 to 13
for j = 12 to 13
cells(j, i) = ""
next j
next i
'為工作表加保護
'worksheets("精整入庫").protect password:="zhangzs", drawingobjects:=true, contents:=true, scenarios:=true
end sub
private sub worksheet_change(byval target as range)
if target.column = 9 and target.row = 6 then
call pu1rk_clear
if range("i6") <> "" then
call pu1rk_write
end if
end if
end sub
--:
加工入庫單
begin declare pagelowerbound int declare pageupperbound int declare sql varchar 500 declare sql2 varchar 1000 declare rowstoreturn int first set the r...
WIP 完工入庫單
模組 wip inv.mtl transaction lot numbers 物料事務處理批次號表 transaction id 與 mmt.transaction id 連線 inv.mtl system items b 物料表 inventory item id與mmt.inventory it...
產品入庫更新生產任務單工時
create trigger update ics gongshi 自定義觸發器的名稱 on dbo icstockbillentry 出入庫單據分錄表 此處為表名,觸發器的表名,意為在哪個表建立觸發 for insert,update,delete 觸發型別 insert update delet...