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

📄 partsingleform.frm

📁 即时通讯
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      Top             =   2160
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "材料"
      Height          =   255
      Index           =   2
      Left            =   240
      TabIndex        =   14
      Top             =   3120
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "代    号:"
      Height          =   255
      Index           =   1
      Left            =   3240
      TabIndex        =   13
      Top             =   240
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "零件ID"
      Height          =   255
      Index           =   0
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Visible         =   0   'False
      Width           =   975
   End
End
Attribute VB_Name = "partsingleform"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'**************************************
'*    模 块 名 称 :零件资料管理用户操作界面
'*    功 能 描 述 :零件资料管理用户操作界面
'*    程序员姓名  : 石春晓
'*    最后修改人  : 石春晓
'*    最后修改时间:2005/09/05
'**************************************
Option Explicit
Public m_operatorType As Integer       ' 操作类型 0 - 新增 1 - 修改 2 - 查看
Public m_partId  As String        ' 修改时其它窗体传递过来的参数
Private m_partDAO As partDAO ' 数据库操作类
Private m_recordset As ADODB.Recordset ' 数据操作数据集对象
Public f As String




Private Sub c_cancel_Click()
    Unload Me
End Sub

Private Sub c_new_Click()
    Call Check
    If m_operatorType = 0 Then
        If f = "0" Then
           Exit Sub
        Else
           Call Newpart
           clear
        End If
    ElseIf m_operatorType = 1 Then
        Call Modifypart
        clear
        m_operatorType = 0
    End If

End Sub

Private Sub c_save_Click()
    Call Check
    If m_operatorType = 0 Then
        If f = "0" Then
           Exit Sub
        Else
           Call Newpart
        End If
    ElseIf m_operatorType = 1 Then
        If f = "0" Then
           Exit Sub
        Else
           Call Modifypart
        End If
    End If

    Unload Me
End Sub

Private Sub Command2_Click()
    Dim filename1 As String            ' 用户选择的文件的路径及文件名字符串
    
    CommonDialog1.FileName = ""
    CommonDialog1.ShowOpen                      '显示打开文件对话框
    Text1(10).text = CommonDialog1.FileName          '获取所选择的文件名

End Sub

Private Sub Command6_Click()
            Call Drbmhelp(1, Trim(notedate.text))                                   ' 根据设置选择显示编码和名称,并进行存储
    If Len(XT_calendar.Xtfhcs) <> 0 Then
            notedate.text = XT_calendar.Xtfhcs                              ' 将日历窗体里取得的值传给建档日期的文本框
    End If
End Sub

Private Sub Form_Load()

    
    Set m_partDAO = New partDAO
    Set m_recordset = New ADODB.Recordset
    

'    Me.Height = 4245
'    Me.Width = 6255
    Combo1.AddItem "自制"
    Combo1.AddItem "协作"
    Combo1.AddItem "外购"
    Combo1.ListIndex = 0
    If m_operatorType = 0 Then
        Me.caption = "零件资料_新增"
        
        clear
    ElseIf m_operatorType = 1 Then
        Me.caption = "零件资料_修改"
        FindByIdRefresh
    Else
        Me.caption = "零件资料_查看"
        FindByIdRefresh
        
        c_new.Enabled = False
        c_save.Enabled = False
    End If
End Sub
'**************************************
'*    功 能 描 述 :新增零件数据处理函数
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub Newpart()
    '
    Dim ret As Boolean
    
    Call Check
    
    ret = m_partDAO.Newpart(m_recordset, Trim(Text1(1).text), _
                   Trim(Text1(2).text), Trim(T_weight(3).text), Trim(Text1(4).text), _
                   Trim(Combo1.text), Trim(Text1(6).text), Trim(T_yield(7).text), _
                   Trim(Text1(8).text), Trim(Text1(9).text), Trim(Text1(10).text), CDate(Trim(notedate.text)), _
                   Trim(Text1(11).text))
End Sub
'**************************************
'*    功 能 描 述 :修改零件处理函数
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub Modifypart()
    '
    Dim ret As Boolean
    
    Call Check
    
    ret = m_partDAO.Modifypart(m_recordset, Trim(Text1(1).text), _
                   Trim(Text1(2).text), Trim(T_weight(3).text), _
                   Trim(Text1(4).text), Trim(Combo1.text), Trim(Text1(6).text), Trim(T_yield(7).text), _
                   Trim(Text1(8).text), Trim(Text1(9).text), Trim(Text1(10).text), CDate(Trim(notedate.text)), _
                   Trim(Text1(11).text), m_partId)
End Sub
'**************************************
'*    功 能 描 述 :检验数据的合法性
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub Check()
    f = "1"
    If Trim(Text1(1).text) = "" Then
        MainForm.g_msgText = "零件名称不能为空!"
        HMsgBox MainForm.g_msgText, 0, 1
        Text1(1).SetFocus
        f = "0"
        Exit Sub
        
    End If
    If Trim(Combo1.text) = "" Then
        MainForm.g_msgText = "状态不能为空!"
        HMsgBox MainForm.g_msgText, 0, 1
        Text1(1).SetFocus
        f = "0"
        Exit Sub
        
    End If
    If Not IsNumeric(Trim(T_weight(3).text)) Then
        MainForm.g_msgText = "净重量值的格式有误!"
        HMsgBox MainForm.g_msgText, 0, 1
        T_weight(3).SetFocus
        f = "0"
        Exit Sub
    End If
    If CDbl(Trim(T_weight(3).text)) < 0 Then
        MainForm.g_msgText = "净重量不能小于!"
        HMsgBox MainForm.g_msgText, 0, 1
        T_weight(3).SetFocus
        f = "0"
        Exit Sub
    End If
    If Trim(Text1(2).text) = "" Then
        MainForm.g_msgText = "代号不能为空!"
        HMsgBox MainForm.g_msgText, 0, 1
        Text1(2).SetFocus
        f = "0"
        Exit Sub
    End If
m_partDAO.FindAll m_recordset
While Not m_recordset.EOF
    If Text1(2).text <> Text1(2).Tag Then
        If Text1(2).text = Trim(m_recordset.Fields("代号")) Then
            MainForm.g_msgText = "代号已存在,请重新输入!"
            HMsgBox MainForm.g_msgText, 0, 1
            Text1(2).SetFocus
            f = "0"
            m_recordset.Close
            Exit Sub
        End If
    End If
    m_recordset.MoveNext
Wend
m_recordset.Close
End Sub
'**************************************
'*    功 能 描 述 :根据零件ID找到零件资料并显示在界面上
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub FindByIdRefresh()
    Dim ret As Boolean
    
    ret = m_partDAO.FindById(m_recordset, m_partId)
    
    If ret Then
      With m_recordset
            Text1(0).text = Trim(.Fields("零件ID"))
            Text1(1).text = Trim(.Fields("零件名称"))
            Text1(2).text = Trim(.Fields("代号"))
            Text1(2).Tag = Trim(.Fields("代号"))
            T_weight(3).text = Trim(.Fields("重量"))
            Text1(4).text = Trim(.Fields("材料"))
            Combo1.text = Trim(.Fields("状态"))
            Text1(6).text = Trim(.Fields("备注"))
            T_yield(7).text = Trim(.Fields("入库合格率"))
            Text1(8).text = Trim(.Fields("使用"))
            Text1(9).text = Trim(.Fields("标准"))
            Text1(10).text = Trim(.Fields("受控文件地址"))
            notedate.text = Trim(.Fields("受控日期"))
            Text1(11).text = Trim(.Fields("bomid"))
            m_recordset.Close
      End With
    Else
        MainForm.g_msgText = "零件ID不正确,请重新操作!"
        HMsgBox MainForm.g_msgText, 0, 1
        Unload Me
    End If
End Sub
'**************************************
'*    功 能 描 述 :清除界面上文本框里的所有内容
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub clear()
            Text1(0).text = ""
            Text1(1).text = ""
            Text1(2).text = ""
            T_weight(3).text = "0"
            Text1(4).text = ""
            Text1(6).text = ""
            T_yield(7).text = "0"
            Text1(8).text = "0"
            Text1(9).text = ""
            Text1(10).text = ""
            notedate.text = Date
            Text1(11).text = ""

End Sub
'**************************************
'*    功 能 描 述 :窗体卸载函数
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub Form_Unload(Cancel As Integer)
'    If Not m_exitFromButton Then
'        If m_operatorType = 2 Then
'            Cancel = -1
'        End If
'    End If
End Sub

'Private Sub T_weight_KeyPress(Index As Integer, KeyAscii As Integer)
'
'    InputFieldLimit T_weight(3), 4, KeyAscii
'
'End Sub


Private Sub T_yield_KeyPress(Index As Integer, KeyAscii As Integer)
    InputFieldLimit T_yield(7), 6, KeyAscii
End Sub

Public Sub Drbmhelp(bzlx As Integer, Scdwnr As String)                          '调入编码参照窗体
    
    '函数参数:帮助类型(0-通用型 1-日期型 2-特殊型),帮助编码,首次定位内容
    On Error GoTo ErrHandle
    XT_calendar.Xtfhcs = ""
    Select Case bzlx
        Case 1
            XT_calendar.xtcdcs = Date
            XT_calendar.show 1      '显示日历窗体
           
    End Select
    
ErrHandle:

End Sub

⌨️ 快捷键说明

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