- 主题
- 0
- 积分
- 0
- 贝壳
- 0 个
- 来自
- 云南曲靖
- 注册时间
- 2006-11-19
- 最后登录
- 2006-11-19
|
[公告]技术区5.1比赛作品发表专帖
月盘点
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private 仓库编号 As String
Private 经办人编号 As String
Private m_data(5, 4) As String
Private m_otherdata(5) As String
Option Explicit
Private Sub printdata(i, j)
Dim X, Y As Long
X = col(j).left / 15 + 5
Y = row(i).Top / 15
TextOut Me.hdc, X, Y, m_data(i, j), Len(m_data(i, j))
End Sub
Private Sub printotherdata(i)
Dim X, Y As Long
If i = 0 Then
X = (other1.left + other1.width) / 15 + 5
Y = other1.Top / 15
ElseIf i = 1 Then
X = (other2.left + other2.width) / 15 + 5
Y = other2.Top / 15
ElseIf i = 2 Then
X = (other3.left + other3.width) / 15 + 5
Y = other3.Top / 15
ElseIf i = 3 Then
X = (other4.left + other4.width) / 15 + 5
Y = other4.Top / 15
ElseIf i = 4 Then
X = (other5.left + other5.width) / 15 + 5
Y = other5.Top / 15
Else
X = (other6.left + other6.width) / 15 + 5
Y = other6.Top / 15
End If
TextOut Me.hdc, X, Y, m_otherdata(i), Len(m_otherdata(i))
End Sub
Private Sub printalldata()
Dim i, j As Integer
For i = 0 To 5
For j = 0 To 4
printdata i, j
Next j
Next i
For i = 0 To 5
printotherdata i
Next i
End Sub
Private Function GetMinDate()
Dim t As Date
t = Date
t = DateAdd("m", -1, t)
GetMinDate = Str(t)
End Function
Private Sub ChangeBackColor()
Dim bkcolor As Long
bkcolor = Me.BackColor
编号.BackColor = bkcolor
日期.BackColor = bkcolor
经办人.BackColor = bkcolor
仓库名称.BackColor = bkcolor
进行月盘点.BackColor = bkcolor
更改背景.BackColor = bkcolor
打印月盘点单.BackColor = bkcolor
保存月盘点.BackColor = bkcolor
End Sub
Private Sub lockcontrol()
编号.Locked = True
仓库名称.Locked = True
经办人.Locked = True
End Sub
Private Sub Form_Paint()
printalldata
End Sub
Private Sub Form_Resize()
ChangeBackColor
';新增盘点单
If 编号.Text = "" Then
日期.Text = Date
打印月盘点单.Visible = False
更改背景.Visible = False
';初始化编号
fMainForm.m_checkado.RecordSource = "select 编号 from 盘点单"
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
fMainForm.m_checkado.Recordset.MoveLast
编号.Text = fMainForm.m_checkado.Recordset.Fields("编号").Value + 1
Else
编号.Text = 1
End If
Else ';打印盘点单
';初始化数据
fMainForm.m_checkado.RecordSource = "select 仓库.仓库名称,职员信息.姓名 as 经办人,盘点单.盘点数据,盘点单.盘点时间 from 仓库,职员信息,盘点单 where 仓库.编号=盘点单.仓库编号 and 职员信息.编号=盘点单.经办人编号 and 盘点单.编号=" + 编号.Text + " and 盘点时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
仓库名称.Text = fMainForm.m_checkado.Recordset.Fields("仓库名称").Value
经办人.Text = fMainForm.m_checkado.Recordset.Fields("经办人").Value
日期.Text = fMainForm.m_checkado.Recordset.Fields("盘点时间").Value
Dim data As String
data = fMainForm.m_checkado.Recordset.Fields("盘点数据").Value
Dim i, j, n As Long
i = 1: n = 1
j = InStr(i, data, ";")
While (j <> 0)
If n <= 30 Then
m_data(n / 5, (n - 1) Mod 5) = Mid(data, i, j - i)
Else
m_otherdata(n - 31) = Mid(data, i, j - i)
End If
On Error Resume Next
n = n + 1
i = j + 1
j = InStr(i, data, ";")
Wend
End If
进行月盘点.Visible = False
lockcontrol
End If
End Sub
Private Sub 保存月盘点_Click()
On Error Resume Next
fMainForm.m_checkado.RecordSource = "select * from 盘点单"
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
fMainForm.m_checkado.Recordset.MoveLast
End If
fMainForm.m_checkado.Recordset.AddNew
fMainForm.m_checkado.Recordset.Fields("编号").Value = 编号.Text
fMainForm.m_checkado.Recordset.Fields("仓库编号").Value = 仓库编号
fMainForm.m_checkado.Recordset.Fields("盘点时间").Value = 日期.Text
fMainForm.m_checkado.Recordset.Fields("经办人编号").Value = 经办人编号
Dim data As String
Dim i, j As Integer
data = ""
For j = 0 To 5
For i = 0 To 4
data = data + m_data(j, i) + ";"
Next i
Next j
For i = 0 To 5
data = data + m_otherdata(i) + ";"
Next i
fMainForm.m_checkado.Recordset.Fields("盘点数据").Value = data
fMainForm.m_checkado.Recordset.update
fMainForm.m_checkado.Refresh
MsgBox "月盘点单保存成功!"
';写入系统日志
fMainForm.WriteLog ("新增月盘点")
保存月盘点.Visible = False
更改背景.Visible = True
打印月盘点单.Visible = True
End Sub
Private Sub 仓库名称_Click()
If 仓库名称.Locked Then Exit Sub
On Error Resume Next
Dim sel As New 数据选择
sel.Adodc1.ConnectionString = DataConnectString
sel.Adodc1.RecordSource = "select 编号,仓库名称 from 仓库"
sel.title = "请选择盘点仓库"
sel.Show vbModal
If sel.result1 <> "" Then 仓库编号 = sel.result1
If sel.result2 <> "" Then 仓库名称.Text = sel.result2
Unload sel
End Sub
Private Sub 仓库名称_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
Private Sub 打印月盘点单_Click()
Me.Height = Me.Height - 700
PrintForm
Me.Height = Me.Height + 700
';写入系统日志
fMainForm.WriteLog ("打印月盘点")
End Sub
Private Sub 更改背景_Click()
On Error Resume Next
With CommonDialog1
.DialogTitle = "页面设置"
.CancelError = True
.ShowColor
End With
Me.BackColor = CommonDialog1.Color
ChangeBackColor
End Sub
Private Sub 进行月盘点_Click()
If 仓库名称.Text = "" Then MsgBox "请填写仓库名称", vbQuestion: Exit Sub
If 经办人.Text = "" Then MsgBox "请填写经办人", vbQuestion: Exit Sub
On Error Resume Next
fMainForm.m_checkado.RecordSource = "select * from 盘点单 where 仓库编号=" + 仓库编号 + " and 盘点时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
MsgBox "该仓库本月已盘点!"
Exit Sub
End If
';进行数据处理
';入库单
fMainForm.m_checkado.RecordSource = "select count(*) as 已处理定单数,sum(入库数量) as 入库总量,sum(入库单价*入库数量) as 总金额 from 入库单 where 定单状况=';已处理'; and 仓库编号=" + 仓库编号 + " and 入库时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(0, 0) = fMainForm.m_checkado.Recordset.Fields("已处理定单数").Value
m_data(0, 2) = fMainForm.m_checkado.Recordset.Fields("入库总量").Value
m_data(0, 4) = fMainForm.m_checkado.Recordset.Fields("总金额").Value
End If
fMainForm.m_checkado.RecordSource = "select count(*) as 定单总数,sum(其它金额) as 其它总金额 from 入库单 where 仓库编号=" + 仓库编号 + " and 入库时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(0, 1) = fMainForm.m_checkado.Recordset.Fields("定单总数").Value
m_data(0, 1) = Str(CLng(Val(m_data(0, 1)) - Val(m_data(0, 0))))
m_data(0, 3) = fMainForm.m_checkado.Recordset.Fields("其它总金额").Value
End If
';出库单
fMainForm.m_checkado.RecordSource = "select count(*) as 已处理定单数,sum(出库数量) as 出库总量,sum(出库单价*出库数量) as 总金额 from 出库单 where 定单状况=';已处理'; and 仓库编号=" + 仓库编号 + " and 出库时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(1, 0) = fMainForm.m_checkado.Recordset.Fields("已处理定单数").Value
m_data(1, 2) = fMainForm.m_checkado.Recordset.Fields("出库总量").Value
m_data(1, 4) = fMainForm.m_checkado.Recordset.Fields("总金额").Value
End If
fMainForm.m_checkado.RecordSource = "select count(*) as 定单总数,sum(其它金额) as 其它总金额 from 出库单 where 仓库编号=" + 仓库编号 + " and 出库时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(1, 1) = fMainForm.m_checkado.Recordset.Fields("定单总数").Value
m_data(1, 1) = Str(CLng(Val(m_data(1, 1)) - Val(m_data(1, 0))))
m_data(1, 3) = fMainForm.m_checkado.Recordset.Fields("其它总金额").Value
End If
';借入单
fMainForm.m_checkado.RecordSource = "select count(*) as 已处理定单数,sum(借入数量) as 借入总量 from 借入单 where 定单状况=';已处理'; and 仓库编号=" + 仓库编号 + " and 借入时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(2, 0) = fMainForm.m_checkado.Recordset.Fields("已处理定单数").Value
m_data(2, 2) = fMainForm.m_checkado.Recordset.Fields("借入总量").Value
m_data(2, 4) = ""
End If
fMainForm.m_checkado.RecordSource = "select count(*) as 定单总数,sum(其它金额) as 其它总金额 from 借入单 where 仓库编号=" + 仓库编号 + " and 借入时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(2, 1) = fMainForm.m_checkado.Recordset.Fields("定单总数").Value
m_data(2, 1) = Str(CLng(Val(m_data(2, 1)) - Val(m_data(2, 0))))
m_data(2, 3) = fMainForm.m_checkado.Recordset.Fields("其它总金额").Value
End If
';借出单
fMainForm.m_checkado.RecordSource = "select count(*) as 已处理定单数,sum(借出数量) as 借出总量 from 借出单 where 定单状况=';已处理'; and 仓库编号=" + 仓库编号 + " and 借出时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(3, 0) = fMainForm.m_checkado.Recordset.Fields("已处理定单数").Value
m_data(3, 2) = fMainForm.m_checkado.Recordset.Fields("借出总量").Value
m_data(3, 4) = ""
End If
fMainForm.m_checkado.RecordSource = "select count(*) as 定单总数,sum(其它金额) as 其它总金额 from 借出单 where 仓库编号=" + 仓库编号 + " and 借出时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(3, 1) = fMainForm.m_checkado.Recordset.Fields("定单总数").Value
m_data(3, 1) = Str(CLng(Val(m_data(3, 1)) - Val(m_data(3, 0))))
m_data(3, 3) = fMainForm.m_checkado.Recordset.Fields("其它总金额").Value
End If
';调拔单 原仓库
fMainForm.m_checkado.RecordSource = "select count(*) as 已处理定单数,sum(调拔数量) as 调拔总量 from 调拔单 where 原仓库编号=" + 仓库编号 + " and 调拔时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(4, 0) = fMainForm.m_checkado.Recordset.Fields("已处理定单数").Value
m_data(4, 2) = fMainForm.m_checkado.Recordset.Fields("调拔总量").Value
m_data(4, 4) = ""
End If
fMainForm.m_checkado.RecordSource = "select sum(其它金额) as 其它总金额 from 调拔单 where 原仓库编号=" + 仓库编号 + " and 调拔时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(4, 1) = ""
m_data(4, 3) = fMainForm.m_checkado.Recordset.Fields("其它总金额").Value
End If
';调拔单 目标仓库
fMainForm.m_checkado.RecordSource = "select count(*) as 已处理定单数,sum(调拔数量) as 调拔总量 from 调拔单 where 目标仓库编号=" + 仓库编号 + " and 调拔时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(4, 0) = LTrim$(Str(CLng(Val(m_data(4, 0)) + Val(fMainForm.m_checkado.Recordset.Fields("已处理定单数").Value))))
m_data(4, 2) = Str(CLng(Val(m_data(4, 2)) - Val(fMainForm.m_checkado.Recordset.Fields("调拔总量").Value)))
m_data(4, 4) = ""
End If
fMainForm.m_checkado.RecordSource = "select sum(其它金额) as 其它总金额 from 调拔单 where 目标仓库编号=" + 仓库编号 + " and 调拔时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(4, 1) = ""
m_data(4, 3) = Str(CLng(Val(m_data(4, 3)) + Val(fMainForm.m_checkado.Recordset.Fields("其它总金额").Value)))
End If
';报损单
fMainForm.m_checkado.RecordSource = "select count(*) as 已处理定单数,sum(报损数量) as 报损总量,sum(报损单价*报损数量) as 总金额 from 报损单 where 仓库编号=" + 仓库编号 + " and 报损时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(5, 0) = fMainForm.m_checkado.Recordset.Fields("已处理定单数").Value
m_data(5, 2) = fMainForm.m_checkado.Recordset.Fields("报损总量").Value
m_data(5, 4) = fMainForm.m_checkado.Recordset.Fields("总金额").Value
End If
fMainForm.m_checkado.RecordSource = "select sum(其它金额) as 其它总金额 from 报损单 where 仓库编号=" + 仓库编号 + " and 报损时间>" + GetMinDate
fMainForm.m_checkado.Refresh
If fMainForm.m_checkado.Recordset.RecordCount > 0 Then
On Error Resume Next
m_data(5, 1) = ""
m_data(5, 3) = fMainForm.m_checkado.Recordset.Fields("其它总金额").Value
End If
';其它总计
';流入,流出总量
On Error Resume Next
m_otherdata(0) = Str(CLng(Val(m_data(0, 2)) + Val(m_data(2, 2))))
m_otherdata(3) = Str(CLng(Val(m_data(1, 2)) + Val(m_data(3, 2))))
';调拔数量为正
On Error Resume Next
If m_data(4, 2) > 0 Then
m_otherdata(0) = Str(CLng(Val(m_otherdata(0)) + Val(m_data(4, 2))))
Else
m_otherdata(3) = Str(CLng(Val(m_otherdata(3)) + Val(m_data(4, 2))))
End If
';流入,流出金额
On Error Resume Next
m_otherdata(1) = Str(Val(m_data(0, 3)) + Val(m_data(1, 3)) + Val(m_data(2, 3)) + Val(m_data(3, 3)) + Val(m_data(4, 3)) + Val(m_data(0, 4)) + Val(m_data(5, 4)))
m_otherdata(4) = m_data(1, 4)
';平均单价
On Error Resume Next
m_otherdata(2) = Str(CLng((Val(m_otherdata(1)) / Val(m_otherdata(0))) * 100) / 100)
m_otherdata(5) = Str(CLng((Val(m_otherdata(4)) / Val(m_otherdata(3))) * 100) / 100)
';数据处理完毕
printalldata
进行月盘点.Visible = False
保存月盘点.Visible = True
仓库名称.Locked = True
经办人.Locked = True
End Sub
Private Sub 经办人_Click()
If 经办人.Locked Then Exit Sub
On Error Resume Next
Dim sel As New 数据选择
sel.Adodc1.ConnectionString = DataConnectString
sel.Adodc1.RecordSource = "select 编号,姓名 from 职员信息"
sel.title = "请选择经办人"
sel.Show vbModal
If sel.result1 <> "" Then 经办人编号 = sel.result1
If sel.result2 <> "" Then 经办人.Text = sel.result2
Unload sel
End Sub
Private Sub 经办人_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
|
|