-- 作者:zhangqinyun
-- 发布时间:2012/6/20 11:29:00
-- [求助]EPR系统的仓库数据问题,一直找不到好的解决方法
狐狸爸爸,我去年学的狐表,想做一个系统,但是仓库问题一直找不到好的解决方法,下面是我的思路,你看看,有没有完美点的方案
此主题相关图片如下:qq截图20120620110459.jpg
这个是仓库主界面
此主题相关图片如下:qq截图20120620110518.jpg
这个是生产领料单界面
我的思路是:
通过计划单号,在物料需求表中找到相关信息,输入领出数量,然后通过输入行,添加到生产领料单,
输入几行后,按《确认》,执行
一,在出入库单表中加入这个领料单的信息
二,For Each 行 In 生产领料单
1。在出入库明细表中 Insert 领料数据
2。在仓库库存中减掉领料数量,在预计出库(已分配物料)中剪掉领料数量
3。在物料需求表中加上领料数量
具体的代码是
\'检测不为空表 If DataTables("仓库出入单").DataRows.Count = 0 Then Messagebox.Show("禁止保存空单!") Return End If If e.Form.Controls("员工ID").Text = "none" Then Messagebox.Show("请输入领料人!") Return End If e.Sender.Enabled = False \'记入父表仓库出入单 Dim label As WinForm.Label = e.Form.Controls("仓库ID") Dim ckid As String Dim cmd,cmd1 As New SQLCommand Dim count,Key As Integer Dim td As Date = Date.Today cmd.ConnectionName = _UserCompany cmd1.ConnectionName = _UserCompany cmd.commandText = "Select 编号 From {ID} Where 字母=\'Y\'" Do Key = cmd.ExecuteScalar() cmd1.commandText = "Update {ID} Set 编号=" & (Key + 1) & " Where 编号=" & Key & " And 字母=\'Y\'" If cmd1.ExecuteNonQuery() > 0 Then Exit Do End If Loop ckid = "Y" & Format(td,"yyMM") & Format(Key,"000") Dim ss,ry,bz As String ss = e.Form.Controls("所属").Text ry = e.Form.Controls("员工ID").Text bz = e.Form.Controls("备注").Value cmd.CommandText = "Insert into {仓库} (仓库ID,日期,事项,所属,人员,备注,录入人) Values (\'" & ckid & "\',#" & td & "#,\'生领\',\'" & ss & "\',\'" & ry & "\',\'" & bz & "\',\'" & _UserName & "\')" count = cmd.ExecuteNonQuery If count = 0 Then Return End If \'记入每一条数据 Dim i As Byte = 0 Dim dr As DataRow Dim wlid,pd,ph As String Dim js As Integer Dim sl,yll,kc,yj As Double Dim dt As DataTable Dim drs As List(Of DataRow) = DataTables("仓库出入单").Select("") For Each dr In drs I = I + 1 \'记入进出1表 wlid = dr("物料ID") js = dr("件数") sl = dr("数量") pd = dr("凭单") ph = dr("凭行") cmd.CommandText = "Insert into {仓库1} (仓库ID,行号,物料ID,件数,数量,凭单,凭行) Values (\'" & ckid & "\'," & I & ",\'" & wlid & "\'," & js & "," & sl & ",\'" & pd & "\'," & ph & ")" If cmd.ExecuteNonQuery = 0 Then Return End If \'记入生产BOM cmd.CommandText = "Select 已领量 From {生产BOM} Where 令号ID=\'" & pd & "\' And 行号=" & ph yll = cmd.ExecuteScalar cmd.CommandText = "Update {生产BOM} Set 已领量=" & yll - sl & " Where 令号ID=\'" & pd & "\' And 行号=" & ph If cmd.ExecuteNonQuery = 0 Then Return End If \'占用记录 cmd.commandText = "Update {物料} Set 修改中=\'" & _UserName & "\' Where 物料ID=\'" & wlid & "\'And 修改中 Is Null" If cmd.ExecuteNonQuery = 0 Then Return End If cmd.commandText = "Select 仓库库存,预计出库 From {物料} Where 物料ID=\'" & wlid & "\' And 修改中=\'" & _UserName & "\'" dt = cmd.ExecuteReader kc = dt.DataRows(0)("仓库库存") yj = dt.DataRows(0)("预计出库") cmd.commandText = "Update {物料} Set 仓库库存=" & kc + sl & ",预计出库=" & yj + sl & " Where 物料ID=\'" & wlid & "\' And 修改中=\'" & _UserName & "\'" If cmd.ExecuteNonQuery = 0 Then Return End If \'取消占用 cmd.commandText = "Update {物料} Set 修改中 = Null Where 物料ID=\'" & wlid & "\' And 修改中=\'" & _UserName & "\'" If cmd.ExecuteNonQuery = 0 Then Return End If Next Label.Text = ckid \'打印 Dim Book As New XLS.Book(ProjectPath & "Attachments\\生产领料单.xls") Dim fl As String = ProjectPath & "Reports\\出库单.xls" Dim Sheet As XLS.Sheet = Book.Sheets(0) Sheet(2,1).Value = "单号:" & ckid Sheet(3,1).Value = "出库日期:" & td Sheet(3,5).Value = "产线:" & ss Sheet(3,7).Value = "领料人:" & e.Form.Controls("人员").Value Book.Build() \'生成细节区 Sheet = Book.Sheets(0) Sheet(Sheet.Rows.Count-4, 0).Value = "备注:" & bz Sheet(Sheet.Rows.Count-3, 5).Value = "制单人:" & _UserName Book.Save(fl) \'保存工作簿 e.Sender.Enabled = True MessageBox.Show("出库成功,出库单号:" & ckid) e.Form.Close
但是现在的问题是,执行时间好长阿。。。。。。。。。。还容易中断,,,,晕死
我还有一个思路,修改上面的独占,把单行独占改成整个表独占,这样可能会快一点。。但是不是很好。。
狐狸爸爸,你有什么建议啊
|