⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄

📁 VB开发的ERP系统
💻
📖 第 1 页 / 共 3 页
字号:

End Sub

Private Sub Form_Unload(Cancel As Integer)                                  '窗体卸载

    '卸载条件窗体
    SFC_OutputQuery.UnloadCheck.Value = 1
    Unload SFC_OutputQuery
    
    '卸载打印页面设置窗体
    Unload Dyymctbl
    Security_Log "MRP_ProductReportList", Xtczybm, 2, False  '用户退出时写上机日志
End Sub

Private Sub CxbbGrid_BeforeMoveColumn(ByVal Col As Long, Position As Long)           '网格列发生移动时自动交换网格索引信息
    Call FnBln_RefreshArray(Col, Position, GridStr(), GridInf())
End Sub

Private Sub GsToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)                '网格格式调整(Fixed)
  
    Select Case Button.Key
        Case "bcgs"                                          '保存表格格式
            Call Bcwggs(CxbbGrid, GridCode, GridStr())
        Case "hfmrgs"                                        '恢复默认格式
            Call Hfmrgs(CxbbGrid, GridCode, GridStr())
        Case "szxsxm"                                        '设置显示项目
            Call Szxsxm(CxbbGrid, GridCode)
    End Select

End Sub

Private Sub SzToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
    
    Select Case Button.Key
        Case "ymsz"                                          '页面设置
            Dyymctbl.Show 1
        Case "yl"                                            '预 览
            Call bbyl(True)
        Case "dy"                                            '打 印
            Call bbyl(False)
        Case "cx"                                            '查 询
            SFC_OutputQuery.Show 1
            
        Case "Bill"                                          '单 据
            If Not Security_Log("MRP_ProductDataReport_Edit", Xtczybm, 1) Then
                Exit Sub
            End If
            Call CxbbGrid_DblClick
        Case "xz"                                            '新 增
            If Not Security_Log("MRP_ProductDataReport_Edit", Xtczybm, 1) Then
                Exit Sub
            End If
            Xtcdcs = "1"
            Call Sub_AddBill
        Case "sc"                                            '删 除
            If Not Security_Log("MRP_ProductDataReport_Edit", Xtczybm, 1) Then
                Exit Sub
            End If
            Call Sub_DeleteBill
        Case "bz"                                            '帮 助
            Call F1bz
        Case "fh"                                            '退 出
           Unload Me

    End Select

End Sub

Private Sub Timer1_Timer()                                 '在窗体激活后调入查询程序
    
    Timer1.Enabled = False
    Xt_Wait.Show
    Xt_Wait.Refresh
   
    '加快显示速度
    CxbbGrid.Redraw = False
 
    '生成查询结果
    Call Sub_Query(0)
   
    CxbbGrid.Redraw = True
    
    Xt_Wait.Hide

End Sub

Private Sub Sub_Query(Int_QueryType As Integer)                                     '生成查询结果(Define)
    
    '过程参数:Int_QueryType 0-"点确定按钮"查询  1-"刷新"查询

    Dim Rec_Query As New ADODB.Recordset        '查询结果动态集
    Dim Coljsq As Long                          '网格列计数器
    Dim jsqte As Long                        '临时动态计数器
    Dim iYear As Integer, iMonth As Integer
    '以下为自定义部分[
 
    If Int_QueryType = 0 Then   '0-"点确定按钮"查询
        With SFC_OutputQuery
         
            '生成查询条件
            Str_QueryCondi = " where BillCode=0 "
            For jsqte = 1 To 8
                Select Case jsqte
                    Case 1  '起始日期
                        If Trim(.LrText(0).Text) <> "" Then
                            
                            Str_QueryCondi = Str_QueryCondi & "  And  a.ProDate>='" & Format(Trim(.LrText(0)), "yyyy-mm-dd") & "' "
                        End If
                    Case 2  '截止日期
                        If Trim(.LrText(1).Text) <> "" Then
                            Str_QueryCondi = Str_QueryCondi & " And  a.ProDate<='" & Format(Trim(.LrText(1)), "yyyy-mm-dd") & "' "
                        End If
                    Case 3  '生产部门
                        If Trim(.LrText(2).Text) <> "" Then
                            Str_QueryCondi = Str_QueryCondi & " And a.DeptCode = '" & Trim(.LrText(2).Tag) & "'"
                        End If
                    Case 4
                        If Trim(.LrText(3).Text) <> "" Then
                            Str_QueryCondi = Str_QueryCondi & " And a.MNumber = '" & Trim(.LrText(3).Text) & "'"
                        End If
                    
                End Select
            Next jsqte
        End With
    Else
        '1-"刷新"查询
        If Str_QueryCondi = "" Then
            Str_QueryCondi = " where 1=1 "
        End If
    End If
    
    Sqlstr = "Select * From MRP_V_ProductDayOutput a " & Str_QueryCondi & ""
    Sqlstr = Sqlstr + "  Order by  ProDate  , ProDailyMainID  , ProDailySubID "
    Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
    With Rec_Query
        CxbbGrid.Rows = CxbbGrid.FixedRows
        jsqte = CxbbGrid.FixedRows
        Do While Not .EOF
            CxbbGrid.AddItem ""
            '[>>自定义填充内容
            CxbbGrid.TextMatrix(jsqte, 0) = .Fields("ProDailyMainID")                                                           'ID(主要用来查询定位用)
            CxbbGrid.TextMatrix(jsqte, Sydz("001", GridStr(), Szzls)) = Format(Trim(Rec_Query!ProDate), "yyyy-mm-dd")           '生产日期
            CxbbGrid.TextMatrix(jsqte, Sydz("002", GridStr(), Szzls)) = Trim(Rec_Query!DeptName & "")                           '部门名称
            CxbbGrid.TextMatrix(jsqte, Sydz("003", GridStr(), Szzls)) = Trim(Rec_Query!MNumber & "")                            '物料编码
            CxbbGrid.TextMatrix(jsqte, Sydz("004", GridStr(), Szzls)) = Trim(Rec_Query!Mname & "")                              '物料名称
            CxbbGrid.TextMatrix(jsqte, Sydz("005", GridStr(), Szzls)) = Trim(Rec_Query!Model & "")                              '规格型号
            CxbbGrid.TextMatrix(jsqte, Sydz("006", GridStr(), Szzls)) = Trim(Rec_Query!PrimaryUnitName & "")                    '单位
            CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = Trim(Rec_Query!DayNumber & "")                          '日产量
            CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)) = Trim(Rec_Query!Maker & "")                              '制单人
            CxbbGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)) = Format(Trim(Rec_Query!MakeDate & ""), "yyyy-mm-dd")     '制单日期
            CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = Trim(Rec_Query!Remark & "")                             '备注
             
             '<<]
            '设置数据行高度(Fixed)
            CxbbGrid.RowHeight(jsqte) = Sjhgd
     
            '动态集指针加1,同时将计数器加1(Fixed)
            .MoveNext
            jsqte = jsqte + 1
        Loop
    End With

    ']以上为用户自定义部分

End Sub

Private Sub CxbbGrid_DblClick()                                              '用户双击网格调入相应单据
    
    Dim RecTemp As New ADODB.Recordset               '临时使用动态集

    '非数据行退出
    If CxbbGrid.Row < CxbbGrid.FixedRows Or Val(CxbbGrid.TextMatrix(CxbbGrid.Row, 0)) = 0 Then
        Exit Sub
    End If
    
    Sqlstr = "Select ProDailyMainID From MRP_ProductDailyMain Where   ProDailyMainID='" & Val(CxbbGrid.TextMatrix(CxbbGrid.Row, 0)) & "' "
    Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
    With RecTemp
        If .EOF Then
            Tsxx = "没有找到当前日报,可能已被其他用户删除!"
            Call Xtxxts(Tsxx, 0, 4)
            Exit Sub
        Else
            '调入单据处理窗体
            With SFC_OutputNote
                
                '填充查询单据标识
                XT_BillID = CxbbGrid.TextMatrix(CxbbGrid.Row, 0)
                Xtcdcsfz = Str_QueryCondi
                
                '设置单据处理为列表查询(修改)状态
                Xtcdcs = "2"
                .Show 1
            End With
            If Xtfhcs = "1" Then
                Tsxx = "日报发生变化,是否刷新日报列表?"
                yhAnswer = Xtxxts(Tsxx, 2, 2)
                If yhAnswer = 1 Then
                    Xt_Wait.Show
                    Xt_Wait.Refresh
   
                    '加快显示速度
                    CxbbGrid.Redraw = False
 
                    '生成查询结果
                    Call Sub_Query(1)
   
                    CxbbGrid.Redraw = True
                    Xt_Wait.Hide
                End If
            End If
        End If
    End With

End Sub

Private Sub Sub_AddBill()                                              '新增单据
   
    With SFC_OutputNote
   
        '设置单据处理为填制单据状态
        Xtcdcs = "1"
        .Show 1
    End With
       
    If Xtfhcs = "1" Then
        Tsxx = "日报列表发生变化,是否刷新日报列表?"
        yhAnswer = Xtxxts(Tsxx, 2, 2)
        If yhAnswer = 1 Then
            Xt_Wait.Show
            Xt_Wait.Refresh
   
            '加快显示速度
            CxbbGrid.Redraw = False
 
            '生成查询结果
            Call Sub_Query(1)
   
            CxbbGrid.Redraw = True
            Xt_Wait.Hide
        End If
    End If
   
End Sub

Private Sub Sub_DeleteBill()                                            '删除选中当前单据
    
    Dim YAnswer As Integer
    Dim Lng_BillID As Long           '单据标识
  
    '非数据行退出
    If CxbbGrid.Row < CxbbGrid.FixedRows Or Val(CxbbGrid.TextMatrix(CxbbGrid.Row, 0)) = 0 Then
        Exit Sub
    End If
  
    Tsxx = "请确认是否删除当前日报?"
    yhAnswer = Xtxxts(Tsxx, 2, 2)
  
    If yhAnswer = 1 Then
        '1.判断当前订单是否允许删除
  
        '2.删除单据所有内容
        Lng_BillID = Val(CxbbGrid.TextMatrix(CxbbGrid.Row, 0))
        On Error GoTo Swcwcl
        Cw_DataEnvi.DataConnect.BeginTrans
        Cw_DataEnvi.DataConnect.Execute ("Delete MRP_ProductDailySub Where ProDailyMainID=" & Lng_BillID)          '删除单据主表内容
        Cw_DataEnvi.DataConnect.Execute ("Delete MRP_ProductDailyMain Where ProDailyMainID=" & Lng_BillID)         '删除单据子表内容
        Cw_DataEnvi.DataConnect.CommitTrans
             
        '删除网格中单据数据
        jsqte = CxbbGrid.Rows - 1
        Do While jsqte >= CxbbGrid.FixedRows
            If Trim(CxbbGrid.TextMatrix(jsqte, Sydz(0, GridStr(), Szzls))) = Lng_BillID Then
                CxbbGrid.RemoveItem (CxbbGrid.Row)
                jsqte = jsqte - 1
            Else
                jsqte = jsqte - 1
            End If
        Loop
        Exit Sub
        
    Else
        Exit Sub
    End If
    Exit Sub
Swcwcl:
    Cw_DataEnvi.DataConnect.RollbackTrans
    Tsxx = "删除过程中出现未知错误,程序自动恢复删除前状态!"
    Call Xtxxts(Tsxx, 0, 1)
    Exit Sub
  
End Sub

 

Private Sub bbyl(bbylte As Boolean)                    '报表打印预览
    
    Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
    Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
    Bbxbtgs = 1                                          '报 表 小 标 题 行 数
    Bbbwhgs = 0                                          '报 表 表 尾 行 数
    ReDim Bbxbt(1 To Bbxbtgs)
    ReDim bbxbtzzxs(1 To Bbxbtgs)
    If Bbbwhgs <> 0 Then
        ReDim Bbbwh(1 To Bbbwhgs)
        ReDim Bbbwhzzxs(1 To Bbbwhgs)
    End If
    Bbzbt = ReportTitle
    Bbxbt(1) = ""
    bbxbtzzxs(1) = 0                                     '报表行组织形式(0-居左 1-居中 2-居右)
    Call Scyxsjb(CxbbGrid)                               '生成报表数据
    Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
    If Not bbylte Then
        Unload DY_Tybbyldy
    End If

End Sub

 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -