资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:83k
源码类别:
企业管理
开发平台:
Visual Basic
- VERSION 5.00
- Begin VB.Form Cg_FrmPlanUnitType
- BackColor = &H8000000A&
- BorderStyle = 1 'Fixed Single
- Caption = "合并生成采购计划方式"
- ClientHeight = 2130
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 3570
- Icon = "采购系统_采购计划生成条件.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2130
- ScaleWidth = 3570
- StartUpPosition = 1 '所有者中心
- Begin VB.CommandButton Cmd_Cancel
- Caption = "取消(&C)"
- Height = 300
- Left = 2370
- TabIndex = 9
- Top = 1740
- Width = 1120
- End
- Begin VB.CommandButton Cmd_OK
- Caption = "确定(&O)"
- Height = 300
- Left = 1170
- TabIndex = 8
- Top = 1740
- Width = 1120
- End
- Begin VB.Frame Frame1
- Height = 1605
- Left = 90
- TabIndex = 0
- Top = 30
- Width = 3390
- Begin VB.OptionButton Opt_CreateType
- Caption = "物料编码"
- Height = 240
- Index = 6
- Left = 165
- TabIndex = 7
- Top = 1170
- Width = 2175
- End
- Begin VB.OptionButton Opt_CreateType
- Caption = "供应商"
- Height = 240
- Index = 5
- Left = 1860
- TabIndex = 6
- Top = 850
- Width = 1215
- End
- Begin VB.OptionButton Opt_CreateType
- Caption = "计划日期"
- Height = 240
- Index = 4
- Left = 165
- TabIndex = 5
- Top = 850
- Width = 2175
- End
- Begin VB.OptionButton Opt_CreateType
- Caption = "计划到货日期"
- Height = 240
- Index = 3
- Left = 1860
- TabIndex = 4
- Top = 530
- Width = 1425
- End
- Begin VB.OptionButton Opt_CreateType
- Caption = "库存物料分类"
- Height = 240
- Index = 2
- Left = 165
- TabIndex = 3
- Top = 530
- Width = 1425
- End
- Begin VB.OptionButton Opt_CreateType
- Caption = "采购物料分类"
- Height = 240
- Index = 1
- Left = 1860
- TabIndex = 2
- Top = 210
- Width = 1425
- End
- Begin VB.OptionButton Opt_CreateType
- Caption = "供应商+物料"
- Height = 240
- Index = 0
- Left = 165
- TabIndex = 1
- Top = 210
- Value = -1 'True
- Width = 1455
- End
- End
- End
- Attribute VB_Name = "Cg_FrmPlanUnitType"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '*********************************************************************************************************
- '* 模 块 名 称 :采购计划合并
- '* 功 能 描 述 :此功能模块主要完成采购计划的合并
- '* 程序员姓名 : 李海祥
- '* 最后修改人 : 李海祥
- '* 最后修改时间:2001/07/19
- '* 备 注:程序中所有依实际情况自定义部分均用[>> <<]括起
- '*
- '*
- '*********************************************************************************************************
- Dim iType As Integer '合并方式
- Dim GridStr() As String '网格列信息(字符型)
- Dim Szzls As Integer '数组总列数(网格列数-1)
- Private Sub Cmd_Cancel_Click()
- Unload Me
- Xtfhcs = "0"
- End Sub
- Private Sub Cmd_OK_Click()
- Dim str_SQLSelectT1 As String 'select & from 语句
- Dim str_SQLSelectT2 As String
- Dim str_SQLSelectT As String
- Dim str_SQLGroupT1 As String 'group 语句
- Dim str_SQLGroupT2 As String
- Dim str_sqlTemp As String
- Dim str_SQLTempDis1 As String
- Dim str_SQLTempDis2 As String
- Dim str_SQLPurBillDet As String '采购计划从表
- Dim str_SQLWhereT As String '临时where语句
- Dim str_SQLWhere As String '经过查询得到的WHERE语句
- Dim autojsq As Integer
- Dim Rs_Hbpc As New ADODB.Recordset '合并批次查询记录集
- Dim Hbpc As Long '合并的批次
- Dim str_SQLSelectTmp As String
- Dim str_SQLGroupTmp As String
- Dim str_SQLWhereTmp As String
- Dim str_Insert As String
- Dim str_Update As String
- Dim str_SQLWhereTmp1 As String
- Dim Rs_SQLWhereTmp As New ADODB.Recordset '查询child_id记录集
- Dim str_SQLAssi As String '查询计划辅表语句
- Dim rs_SQLAssi As New ADODB.Recordset '计划辅表记录集
- Dim j As Integer
- Dim i As Integer
- Dim rs_CreatePurBillPri As New ADODB.Recordset
- Dim rs_CreatePurBillDet As New ADODB.Recordset
- Dim rs_TempDis1 As New ADODB.Recordset
- Dim rs_TempDis2 As New ADODB.Recordset
- Set Rs_Hbpc = Cw_DataEnvi.DataConnect.Execute("select max(SplitUniteNum) as m_SplitUniteNum from Cg_PurPlanMain")
- Hbpc = Rs_Hbpc.Fields("m_SplitUniteNum") + 1
- Set Rs_Hbpc = Nothing
- str_SQLWhere = str_SQLAutoid
- Set rs_Temp = Cw_DataEnvi.DataConnect.Execute("select distinct KjYear,Period from Cg_V_PlanBill " & str_SQLWhere)
- If rs_Temp.RecordCount <> 1 Then
- Call Xtxxts("应为同一会计年度和会计月份,请重新选择采购计划!", 0, 4)
- Set rs_Temp = Nothing
- Exit Sub
- Else
- Set rs_Temp = Nothing
- End If
- Set rs_Temp = Cw_DataEnvi.DataConnect.Execute("select distinct ExigenceFlag from Cg_V_PlanBill " & str_SQLWhere)
- If rs_Temp.RecordCount <> 1 Then
- Call Xtxxts("普通计划和紧急计划不能合并,请重新选择采购计划!", 0, 4)
- Set rs_Temp = Nothing
- Exit Sub
- Else
- Set rs_Temp = Nothing
- End If
- For i = 0 To Me.Opt_CreateType.count - 1
- If Me.Opt_CreateType(i).Value = True Then
- Exit For
- End If
- Next i
- iType = i
- Unload Me
- Xt_Wait.Show
- Xt_Wait.Refresh
- str_SQLPurBillDet = "select * from Cg_PurPlanSub where 1=2"
- rs_CreatePurBillDet.Open str_SQLPurBillDet, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockPessimistic
- str_sqlTemp = "select * from Cg_PurPlanMain where 1=2"
- rs_CreatePurBillPri.Open str_sqlTemp, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockPessimistic
- Cw_DataEnvi.DataConnect.BeginTrans
- On Error GoTo Err_Ctrl
- Select Case iType
- Case 0 '供应商+物料编码
- str_SQLSelectT1 = "select ExigenceFlag,KjYear,Period,SupplierCode,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT1 = " Group by ExigenceFlag,KjYear,Period ,SupplierCode,MNumber "
- str_SQLSelectT2 = "select ExigenceFlag,ProcFactory,KjYear,Period,SupplierCode,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT2 = " Group by ExigenceFlag,KjYear,Period ,SupplierCode,MNumber,ProcFactory "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period ,SupplierCode,MNumber from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,SupplierCode,MNumber "
- '没有生产厂家的计划合并
- str_SQLTempDis1 = str_SQLSelectT1 & str_SQLWhere & " and ProcFactory='' " & str_SQLGroupT1
- Set rs_TempDis1 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis1)
- Do While Not rs_TempDis1.EOF()
- str_SQLWhereT = ""
- If IsNull(rs_TempDis1.Fields("SupplierCode")) Then
- str_SQLWhereT = str_SQLWhere & " and SupplierCode is null and MNumber='" & Trim(rs_TempDis1.Fields("MNumber") & "") & "'"
- Else
- str_SQLWhereT = str_SQLWhere & " and SupplierCode='" & Trim(rs_TempDis1.Fields("SupplierCode") & "") & "' and MNumber='" & Trim(rs_TempDis1.Fields("MNumber") & "") & "'"
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory='' "
- str_SQLSupplierCodeT = str_SQLSelectT1 & str_SQLWhereT & str_SQLGroupT1
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis1.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis1.Fields("Period")) '会计期间
- .Fields("SupplierCode") = rs_TempDis1.Fields("SupplierCode") '供应商
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用 '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis1.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = S2N(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = "" '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis1.MoveNext
- Loop
- '有生产厂家计划合并
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period ,SupplierCode,MNumber from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,SupplierCode,MNumber "
- str_SQLTempDis2 = str_SQLSelectT2 & str_SQLWhere & " and ProcFactory<>'' " & str_SQLGroupT2
- Set rs_TempDis2 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis2)
- Do While Not rs_TempDis2.EOF()
- str_SQLWhereT = ""
- If IsNull(rs_TempDis1.Fields("SupplierCode")) Then
- str_SQLWhereT = str_SQLWhere & " and SupplierCode is null and MNumber='" & Trim(rs_TempDis2.Fields("MNumber") & "") & "'"
- Else
- str_SQLWhereT = str_SQLWhere & " and SupplierCode='" & Trim(rs_TempDis2.Fields("SupplierCode") & "") & "' and MNumber='" & Trim(rs_TempDis2.Fields("MNumber") & "") & "'"
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory<>'' "
- str_SQLSupplierCodeT = str_SQLSelectT2 & str_SQLWhereT & str_SQLGroupT2
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis2.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis2.Fields("Period")) '会计期间
- .Fields("SupplierCode") = rs_TempDis2.Fields("SupplierCode") '供应商
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用 '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis2.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = S2N(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = Trim(rs_suppliercodet.Fields("ProcFactory")) '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis2.MoveNext
- Loop
- Case 1 '采购物料分类
- '没有生产厂家的计划合并
- str_SQLSelectT = "select distinct KjYear,Period,PurSortCode,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis1 = str_SQLSelectT & str_SQLWhere & " and ProcFactory='' "
- Set rs_TempDis1 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis1)
- Do While Not rs_TempDis1.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- str_SQLWhereT = str_SQLWhere & " and PurSortCode = '" & Trim(rs_TempDis1.Fields("PurSortCode") & "") & "'"
- Else
- str_SQLWhereT = " where PurSortCode = '" & Trim(rs_TempDis1.Fields("PurSortCode") & "") & "'"
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory='' "
- str_SQLSelectT = "select KjYear,Period,PurSortCode,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by KjYear,Period ,PurSortCode,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,PurSortCode,MNumber,sum(Quantity) from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,PurSortCode,MNumber "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis1.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis1.Fields("Period")) '会计期间
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis1.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = "" '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis1.MoveNext
- Loop
- '有生产厂家的计划合并
- str_SQLSelectT = "select distinct KjYear,Period,PurSortCode,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis2 = str_SQLSelectT & str_SQLWhere & " and ProcFactory<>'' "
- Set rs_TempDis2 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis2)
- Do While Not rs_TempDis2.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- str_SQLWhereT = str_SQLWhere & " and PurSortCode = '" & Trim(rs_TempDis2.Fields("PurSortCode") & "") & "'"
- Else
- str_SQLWhereT = " where PurSortCode = '" & Trim(rs_TempDis2.Fields("PurSortCode") & "") & "'"
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory<>'' "
- str_SQLSelectT = "select ProcFactory,KjYear,Period,PurSortCode,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by KjYear,Period ,PurSortCode,ProcFactory,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,PurSortCode,MNumber,sum(Quantity),ProcFactory from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,PurSortCode,MNumber,ProcFactory "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis2.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis2.Fields("Period")) '会计期间
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis2.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = Trim(rs_suppliercodet.Fields("ProcFactory")) '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis2.MoveNext
- Loop
- Case 2 '库存物料分类
- '没有生产厂家的计划合并
- str_SQLSelectT = "select distinct KjYear,Period,InvSortCode,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis1 = str_SQLSelectT & str_SQLWhere & " and ProcFactory='' "
- Set rs_TempDis1 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis1)
- Do While Not rs_TempDis1.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- str_SQLWhereT = str_SQLWhere & " and InvSortCode = '" & Trim(rs_TempDis1.Fields("InvSortCode") & "") & "'"
- Else
- str_SQLWhereT = " where InvSortCode = '" & Trim(rs_TempDis1.Fields("InvSortCode") & "") & "'"
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory='' "
- str_SQLSelectT = "select KjYear,Period,InvSortCode,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by KjYear,Period ,InvSortCode,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,InvSortCode,MNumber,sum(Quantity) from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,InvSortCode,MNumber "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis1.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis1.Fields("Period")) '会计期间
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis1.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = "" '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis1.MoveNext
- Loop
- '有生产厂家的计划合并
- str_SQLSelectT = "select distinct KjYear,Period,InvSortCode,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis2 = str_SQLSelectT & str_SQLWhere & " and ProcFactory<>'' "
- Set rs_TempDis2 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis2)
- Do While Not rs_TempDis2.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- str_SQLWhereT = str_SQLWhere & " and InvSortCode = '" & Trim(rs_TempDis2.Fields("InvSortCode") & "") & "'"
- Else
- str_SQLWhereT = " where InvSortCode = '" & Trim(rs_TempDis2.Fields("InvSortCode") & "") & "'"
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory<>'' "
- str_SQLSelectT = "select KjYear,Period,ProcFactory,InvSortCode,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by KjYear,Period ,ProcFactory,InvSortCode,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,InvSortCode,MNumber,sum(Quantity),ProcFactory from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,InvSortCode,MNumber,ProcFactory "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis2.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis2.Fields("Period")) '会计期间
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis2.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = Trim(rs_suppliercodet.Fields("ProcFactory")) '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis2.MoveNext
- Loop
- Case 3 '计划到货日期
- str_SQLSelectT = "select distinct KjYear,Period,PlanArriveDate,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis1 = str_SQLSelectT & str_SQLWhere & " and ProcFactory='' "
- Set rs_TempDis1 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis1)
- Do While Not rs_TempDis1.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- If IsNull(rs_TempDis1.Fields("PlanArriveDate")) Or Trim(rs_TempDis1.Fields("PlanArriveDate") & "") = "" Then
- str_SQLWhereT = str_SQLWhere & " and (PlanArriveDate is null or PlanArriveDate='') "
- Else
- str_SQLWhereT = str_SQLWhere & " and PlanArriveDate = '" & Trim(rs_TempDis1.Fields("PlanArriveDate") & "") & "'"
- End If
- Else
- If IsNull(rs_TempDis1.Fields("PlanArriveDate")) Or Trim(rs_TempDis1.Fields("PlanArriveDate") & "") = "" Then
- str_SQLWhereT = " where (PlanArriveDate is null or PlanArriveDate='') "
- Else
- str_SQLWhereT = " where PlanArriveDate ='" & Trim(rs_TempDis1.Fields("PlanArriveDate") & "") & "'"
- End If
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory=''"
- str_SQLSelectT = "select KjYear,Period,PlanArriveDate,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by KjYear,Period ,PlanArriveDate,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,PlanArriveDate,MNumber,sum(Quantity) from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,PlanArriveDate,MNumber "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis1.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis1.Fields("Period")) '会计期间
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis1.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = "" '生产厂家
- .Fields("PlanArriveDate") = rs_TempDis1.Fields("PlanArriveDate") '计划到货日期
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis1.MoveNext
- Loop
- '有生产厂家的计划合并
- str_SQLSelectT = "select distinct KjYear,Period,PlanArriveDate,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis2 = str_SQLSelectT & str_SQLWhere & " and ProcFactory<>'' "
- Set rs_TempDis2 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis2)
- Do While Not rs_TempDis2.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- If IsNull(rs_TempDis2.Fields("PlanArriveDate")) Or Trim(rs_TempDis2.Fields("PlanArriveDate") & "") = "" Then
- str_SQLWhereT = str_SQLWhere & " and (PlanArriveDate is null or PlanArriveDate='') "
- Else
- str_SQLWhereT = str_SQLWhere & " and PlanArriveDate = '" & Trim(rs_TempDis2.Fields("PlanArriveDate") & "") & "'"
- End If
- Else
- If IsNull(rs_TempDis2.Fields("PlanArriveDate")) Or Trim(rs_TempDis2.Fields("PlanArriveDate") & "") = "" Then
- str_SQLWhereT = " where (PlanArriveDate is null or PlanArriveDate='') "
- Else
- str_SQLWhereT = " where PlanArriveDate ='" & Trim(rs_TempDis2.Fields("PlanArriveDate") & "") & "'"
- End If
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory<>''"
- str_SQLSelectT = "select ProcFactory,KjYear,Period,PlanArriveDate,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by ProcFactory,KjYear,Period ,PlanArriveDate,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,PlanArriveDate,MNumber,sum(Quantity),ProcFactory from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,PlanArriveDate,MNumber,ProcFactory "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis2.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis2.Fields("Period")) '会计期间
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis2.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = Trim(rs_suppliercodet.Fields("ProcFactory")) '生产厂家
- .Fields("PlanArriveDate") = rs_TempDis2.Fields("PlanArriveDate") '计划到货日期
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis2.MoveNext
- Loop
- Case 4 '计划日期
- str_SQLSelectT = "select distinct KjYear,Period,PurPlanDate,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis1 = str_SQLSelectT & str_SQLWhere & " and ProcFactory='' "
- Set rs_TempDis1 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis1)
- Do While Not rs_TempDis1.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- If IsNull(rs_TempDis1.Fields("PurPlanDate")) Or Trim(rs_TempDis1.Fields("PurPlanDate") & "") = "" Then
- str_SQLWhereT = str_SQLWhere & " and (PurPlanDate is null or PurPlanDate='') "
- Else
- str_SQLWhereT = str_SQLWhere & " and PurPlanDate = '" & Trim(rs_TempDis1.Fields("PurPlanDate") & "") & "'"
- End If
- Else
- If IsNull(rs_TempDis1.Fields("PurPlanDate")) Or Trim(rs_TempDis1.Fields("PurPlanDate") & "") = "" Then
- str_SQLWhereT = " where (PurPlanDate is null or PurPlanDate='') "
- Else
- str_SQLWhereT = " where PurPlanDate ='" & Trim(rs_TempDis1.Fields("PurPlanDate") & "") & "'"
- End If
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory=''"
- str_SQLSelectT = "select KjYear,Period,PurPlanDate,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by KjYear,Period ,PurPlanDate,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,PlanArriveDate,MNumber,sum(Quantity) from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,PlanArriveDate,MNumber "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = rs_TempDis1.Fields("PurPlanDate") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis1.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis1.Fields("Period")) '会计期间
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis1.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = "" '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis1.MoveNext
- Loop
- '有生产厂家的计划合并
- str_SQLSelectT = "select distinct KjYear,Period,PurPlanDate,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis2 = str_SQLSelectT & str_SQLWhere & " and ProcFactory<>'' "
- Set rs_TempDis2 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis2)
- Do While Not rs_TempDis2.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- If IsNull(rs_TempDis2.Fields("PurPlanDate")) Or Trim(rs_TempDis2.Fields("PurPlanDate") & "") = "" Then
- str_SQLWhereT = str_SQLWhere & " and (PurPlanDate is null or PurPlanDate='') "
- Else
- str_SQLWhereT = str_SQLWhere & " and PurPlanDate = '" & Trim(rs_TempDis2.Fields("PurPlanDate") & "") & "'"
- End If
- Else
- If IsNull(rs_TempDis2.Fields("PurPlanDate")) Or Trim(rs_TempDis2.Fields("PurPlanDate") & "") = "" Then
- str_SQLWhereT = " where (PurPlanDate is null or PurPlanDate='') "
- Else
- str_SQLWhereT = " where PurPlanDate ='" & Trim(rs_TempDis2.Fields("PurPlanDate") & "") & "'"
- End If
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory<>''"
- str_SQLSelectT = "select ProcFactory,KjYear,Period,PurPlanDate,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by ProcFactory,KjYear,Period ,PurPlanDate,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,PurPlanDate,MNumber,sum(Quantity),ProcFactory from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,PurPlanDate,MNumber,ProcFactory "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = rs_TempDis2.Fields("PurPlanDate") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis2.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis2.Fields("Period")) '会计期间
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis2.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = Trim(rs_suppliercodet.Fields("ProcFactory")) '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis2.MoveNext
- Loop
- Case 5 '供应商
- str_SQLSelectT = "select distinct KjYear,Period,SupplierCode,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis1 = str_SQLSelectT & str_SQLWhere & " and ProcFactory='' "
- Set rs_TempDis1 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis1)
- Do While Not rs_TempDis1.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- If IsNull(rs_TempDis1.Fields("SupplierCode")) Or Trim(rs_TempDis1.Fields("SupplierCode") & "") = "" Then
- str_SQLWhereT = str_SQLWhere & " and (SupplierCode is null or SupplierCode='') "
- Else
- str_SQLWhereT = str_SQLWhere & " and SupplierCode = '" & Trim(rs_TempDis1.Fields("SupplierCode") & "") & "'"
- End If
- Else
- If IsNull(rs_TempDis1.Fields("SupplierCode")) Or Trim(rs_TempDis1.Fields("SupplierCode") & "") = "" Then
- str_SQLWhereT = " where (SupplierCode is null or SupplierCode='') "
- Else
- str_SQLWhereT = " where SupplierCode ='" & Trim(rs_TempDis1.Fields("SupplierCode") & "") & "'"
- End If
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory=''"
- str_SQLSelectT = "select KjYear,Period,SupplierCode,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by KjYear,Period ,SupplierCode,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,SupplierCode,MNumber,sum(Quantity) from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,SupplierCode,MNumber "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis1.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis1.Fields("Period")) '会计期间
- .Fields("SupplierCode") = rs_TempDis1.Fields("SupplierCode") '供应商
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis1.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = "" '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis1.MoveNext
- Loop
- '有生产厂家的计划合并
- str_SQLSelectT = "select distinct KjYear,Period,SupplierCode,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis2 = str_SQLSelectT & str_SQLWhere & " and ProcFactory<>'' "
- Set rs_TempDis2 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis2)
- Do While Not rs_TempDis2.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- If IsNull(rs_TempDis2.Fields("SupplierCode")) Or Trim(rs_TempDis2.Fields("SupplierCode") & "") = "" Then
- str_SQLWhereT = str_SQLWhere & " and (SupplierCode is null or SupplierCode='') "
- Else
- str_SQLWhereT = str_SQLWhere & " and SupplierCode = '" & Trim(rs_TempDis2.Fields("SupplierCode") & "") & "'"
- End If
- Else
- If IsNull(rs_TempDis2.Fields("SupplierCode")) Or Trim(rs_TempDis2.Fields("SupplierCode") & "") = "" Then
- str_SQLWhereT = " where (SupplierCode is null or SupplierCode='') "
- Else
- str_SQLWhereT = " where SupplierCode ='" & Trim(rs_TempDis2.Fields("SupplierCode") & "") & "'"
- End If
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory<>''"
- str_SQLSelectT = "select ProcFactory,KjYear,Period,SupplierCode,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by ProcFactory,KjYear,Period ,SupplierCode,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,SupplierCode,MNumber,sum(Quantity),ProcFactory from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,SupplierCode,MNumber,ProcFactory "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis2.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis2.Fields("Period")) '会计期间
- .Fields("SupplierCode") = rs_TempDis2.Fields("SupplierCode") '供应商
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis2.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = Trim(rs_suppliercodet.Fields("ProcFactory")) '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis2.MoveNext
- Loop
- Case 6 '物料编码
- str_SQLSelectT = "select distinct KjYear,Period,MNumber,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis1 = str_SQLSelectT & str_SQLWhere & " and ProcFactory='' "
- Set rs_TempDis1 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis1)
- Do While Not rs_TempDis1.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- str_SQLWhereT = str_SQLWhere & " and MNumber = '" & Trim(rs_TempDis1.Fields("MNumber") & "") & "'"
- Else
- str_SQLWhereT = " where MNumber ='" & Trim(rs_TempDis1.Fields("MNumber") & "") & "'"
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory=''"
- str_SQLSelectT = "select KjYear,Period,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by KjYear,Period ,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,MNumber,sum(Quantity) from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,MNumber "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis1.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis1.Fields("Period")) '会计期间
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis1.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = "" '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis1.MoveNext
- Loop
- '有生产厂家的计划合并
- str_SQLSelectT = "select distinct KjYear,Period,MNumber,ExigenceFlag from Cg_V_PlanBill "
- str_SQLTempDis2 = str_SQLSelectT & str_SQLWhere & " and ProcFactory<>'' "
- Set rs_TempDis2 = Cw_DataEnvi.DataConnect.Execute(str_SQLTempDis2)
- Do While Not rs_TempDis2.EOF()
- str_SQLWhereT = ""
- If str_SQLWhere <> "" Then
- str_SQLWhereT = str_SQLWhere & " and MNumber = '" & Trim(rs_TempDis2.Fields("MNumber") & "") & "'"
- Else
- str_SQLWhereT = " where MNumber ='" & Trim(rs_TempDis2.Fields("MNumber") & "") & "'"
- End If
- str_SQLWhereT = str_SQLWhereT & " and ProcFactory<>''"
- str_SQLSelectT = "select ProcFactory,KjYear,Period,MNumber,sum(Quantity) as SumQuantity from Cg_V_PlanBill "
- str_SQLGroupT = " Group by ProcFactory,KjYear,Period ,MNumber "
- str_SQLSelectTmp = "select PurPlanMainID,PurPlanSubID,KjYear,Period,MNumber,sum(Quantity),ProcFactory from Cg_V_PlanBill "
- str_SQLGroupTmp = " Group by KjYear,Period ,PurPlanMainID,PurPlanSubID,MNumber,ProcFactory "
- str_SQLSupplierCodeT = str_SQLSelectT & str_SQLWhereT & str_SQLGroupT
- Set rs_suppliercodet = Nothing
- Set rs_suppliercodet = Cw_DataEnvi.DataConnect.Execute(str_SQLSupplierCodeT)
- '写记录
- If Not rs_suppliercodet.EOF() Then
- With rs_CreatePurBillPri
- .AddNew
- .Fields("PurPlanMainID") = CreatBillID("1101") '单据ID
- .Fields("PurPlanNum") = CreatBillCode("1101", True) '单据号
- .Fields("PurPlanDate") = Format(Xtrq, "yyyy-mm-dd") '计划日期
- .Fields("KjYear") = Trim(rs_TempDis2.Fields("KjYear")) '会计年
- .Fields("Period") = Trim(rs_TempDis2.Fields("Period")) '会计期间
- .Fields("PurPlanType") = "合并生成" '计划类型
- .Fields("Maker") = Xtczy '制单人
- .Fields("PurPlanStyle") = "2" '不能被生产系统调用
- .Fields("SplitUniteNum") = Hbpc '拆合过程号
- .Fields("SplitUniteFlag") = 0 '拆合标志
- .Fields("ExigenceFlag") = rs_TempDis2.Fields("ExigenceFlag") '紧急标志
- .Fields("Checker") = Xtczy '审核人
- .Fields("FinishFlag") = 0 '完成标志
- .Fields("Transmitter") = "" '下达人置空
- .UpdateBatch
- End With
- With rs_CreatePurBillDet
- j = 1
- Do While Not rs_suppliercodet.EOF()
- .AddNew
- .Fields("PurPlanSubID") = j '子表ID
- .Fields("PurPlanMainID") = rs_CreatePurBillPri.Fields("PurPlanMainID") + 0 '单据ID
- .Fields("MNumber") = Trim(rs_suppliercodet.Fields("MNumber") & "") '物料编码
- .Fields("Quantity") = Trim(rs_suppliercodet.Fields("SumQuantity") & "") '数量
- .Fields("ProcFactory") = Trim(rs_suppliercodet.Fields("ProcFactory")) '生产厂家
- .Fields("Remark") = "" '备注
- .UpdateBatch
- '更新计划拆合跟踪表
- str_SQLWhereTmp = str_SQLSelectTmp & str_SQLWhereT & str_SQLGroupTmp
- Set Rs_SQLWhereTmp = Nothing
- Set Rs_SQLWhereTmp = Cw_DataEnvi.DataConnect.Execute(str_SQLWhereTmp)
- Do While Not Rs_SQLWhereTmp.EOF()
- str_Insert = "insert into Cg_SplitUnite(SplitUniteNum,NewPurPlanMainID,NewPurPlanSubID,PurPlanMainID,PurPlanSubID)" & "values( " & Hbpc & "," & rs_CreatePurBillPri.Fields("PurPlanMainID") & " ," & rs_CreatePurBillDet.Fields("PurPlanSubID") & "," & Rs_SQLWhereTmp.Fields("PurPlanMainID") & "," & Rs_SQLWhereTmp.Fields("PurPlanSubID") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_Insert)
- Rs_SQLWhereTmp.MoveNext
- Loop
- '更新结束
- rs_suppliercodet.MoveNext
- j = j + 1
- Loop
- End With
- End If
- rs_TempDis2.MoveNext
- Loop
- End Select
- '设置已经生成标志
- Set rs_CreatePurBillPri = Nothing
- Set rs_Temp = Nothing
- Set rs_Temp = Cw_DataEnvi.DataConnect.Execute("select distinct PurPlanMainID from Cg_V_PlanBill " & str_SQLWhere & " and Checker=''")
- If Not rs_Temp.EOF() Then
- Call Xtxxts("已经有选择的计划被其他人弃审,合并生成失败,返回为生成状态!", 0, 1)
- Cw_DataEnvi.DataConnect.RollbackTrans
- Xt_Wait.Hide
- Exit Sub
- End If
- Set rs_Temp = Nothing
- Set rs_Temp = Cw_DataEnvi.DataConnect.Execute("select distinct PurPlanMainID from Cg_V_PlanBill " & str_SQLWhere)
- Do While Not rs_Temp.EOF()
- Cw_DataEnvi.DataConnect.Execute ("update Cg_PurPlanMain set SplitUniteFlag= 1 where PurPlanMainID='" & rs_Temp.Fields("PurPlanMainID") & "'")
- rs_Temp.MoveNext
- Loop
- Cw_DataEnvi.DataConnect.CommitTrans
- Xt_Wait.Hide
- Call Xtxxts("合并生成完毕!", 0, 4)
- Unload Me
- Xtfhcs = "1"
- Exit Sub
- Err_Ctrl:
- Cw_DataEnvi.DataConnect.RollbackTrans
- Xt_Wait.Hide
- Xtfhcs = "0"
- Call Xtxxts("合并生成失败,返回为生成状态!", 0, 4)
- End Sub