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

📄 frmwangong.vb

📁 一个实际的商业项目
💻 VB
📖 第 1 页 / 共 2 页
字号:
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(48, 23)
        Me.Label12.TabIndex = 26
        Me.Label12.Text = "价格:"
        '
        'Label13
        '
        Me.Label13.Location = New System.Drawing.Point(288, 216)
        Me.Label13.Name = "Label13"
        Me.Label13.Size = New System.Drawing.Size(48, 23)
        Me.Label13.TabIndex = 27
        Me.Label13.Text = "价格:"
        '
        'Label14
        '
        Me.Label14.Location = New System.Drawing.Point(288, 248)
        Me.Label14.Name = "Label14"
        Me.Label14.Size = New System.Drawing.Size(48, 23)
        Me.Label14.TabIndex = 28
        Me.Label14.Text = "价格:"
        '
        'txtJg1
        '
        Me.txtJg1.Location = New System.Drawing.Point(360, 184)
        Me.txtJg1.Name = "txtJg1"
        Me.txtJg1.ReadOnly = True
        Me.txtJg1.TabIndex = 10
        Me.txtJg1.Text = ""
        '
        'txtJg2
        '
        Me.txtJg2.Location = New System.Drawing.Point(360, 216)
        Me.txtJg2.Name = "txtJg2"
        Me.txtJg2.ReadOnly = True
        Me.txtJg2.TabIndex = 11
        Me.txtJg2.Text = ""
        '
        'txtJg3
        '
        Me.txtJg3.Location = New System.Drawing.Point(360, 248)
        Me.txtJg3.Name = "txtJg3"
        Me.txtJg3.ReadOnly = True
        Me.txtJg3.TabIndex = 12
        Me.txtJg3.Text = ""
        '
        'Label15
        '
        Me.Label15.Location = New System.Drawing.Point(40, 280)
        Me.Label15.Name = "Label15"
        Me.Label15.Size = New System.Drawing.Size(48, 23)
        Me.Label15.TabIndex = 22
        Me.Label15.Text = "备注:"
        '
        'txtBz
        '
        Me.txtBz.Location = New System.Drawing.Point(120, 280)
        Me.txtBz.Name = "txtBz"
        Me.txtBz.TabIndex = 7
        Me.txtBz.Text = ""
        '
        'frmWanGong
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(504, 384)
        Me.Controls.Add(Me.txtBz)
        Me.Controls.Add(Me.Label15)
        Me.Controls.Add(Me.txtJg3)
        Me.Controls.Add(Me.txtJg2)
        Me.Controls.Add(Me.txtJg1)
        Me.Controls.Add(Me.Label14)
        Me.Controls.Add(Me.Label13)
        Me.Controls.Add(Me.Label12)
        Me.Controls.Add(Me.txtFei3)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.txtFei2)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.txtFei1)
        Me.Controls.Add(Me.Label11)
        Me.Controls.Add(Me.cbGh)
        Me.Controls.Add(Me.Label10)
        Me.Controls.Add(Me.txtXm)
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.btnSave)
        Me.Controls.Add(Me.btnNext)
        Me.Controls.Add(Me.Label8)
        Me.Controls.Add(Me.txtJe)
        Me.Controls.Add(Me.txtSl)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.cbGx)
        Me.Controls.Add(Me.txtJg)
        Me.Controls.Add(Me.txtPf)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.dp)
        Me.Controls.Add(Me.Label1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmWanGong"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        Me.Text = "计件完工单输入"
        Me.ResumeLayout(False)

    End Sub

#End Region


    Dim WithEvents cnData As New OleDbConnection
    Dim cmdSQL As New OleDbCommand
    Dim count As Integer = 0

    Private Sub Updata()
        Dim strDate As String
        strDate = dp.Value.Year.ToString
        If dp.Value.Month.ToString.Length = 1 Then
            strDate = strDate & "0" & dp.Value.Month.ToString
        Else
            strDate = strDate & dp.Value.Month.ToString
        End If
        If dp.Value.Day.ToString.Length = 1 Then
            strDate = strDate & "0" & dp.Value.Day.ToString
        Else
            strDate = strDate & dp.Value.Day.ToString
        End If

        cmdSQL.CommandText = "insert into Wg (Rq, Gh, Xm, Pf, Gx, Sl, Sl1, Sl2, Sl3, Bz) " & _
                             "values ('" & strDate & "', '" & cbGh.Text & "', '" & txtXm.Text & "', '" & txtPf.Text & "', '" & cbGx.Text & "', " & txtSl.Text & ", " & txtFei1.Text & ", " & txtFei2.Text & ", " & txtFei3.Text & ", '" & txtBz.Text & "')"

        
        Try
            cnData.Open()
            cmdSQL.ExecuteNonQuery()

        Catch ex As Exception
            'MessageBox.Show(ex.Message)
            MessageBox.Show("当前数据已输入!")
        Finally
            cnData.Close()
        End Try
    End Sub

    Private Sub Cls()
        'txtXm.Text = ""
        txtSl.Text = ""
        txtFei1.Text = "0"
        txtFei2.Text = "0"
        txtFei3.Text = "0"
        txtBz.Text = ""
        'txtJg.Text = "0"
        txtJe.Text = ""
        'cbGh.Items.Clear()
        'cbGx.Items.Clear()
        txtXm.Focus()

    End Sub

    Private Sub frmWanGong_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        txtFei1.Text = "0"
        txtFei2.Text = "0"
        txtFei3.Text = "0"

        'txtJg.Text = "0"
        cnData.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:database password=power;;Data Source= " & Application.StartupPath & "\gongzi.mdb;Persist Security Info=False"
        cmdSQL.Connection = cnData
    End Sub


    Private Sub cbGx_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbGx.SelectedIndexChanged
        Dim rd As OleDbDataReader
        cmdSQL.CommandText = "select Jg, Fei1, Fei2, Fei3 from Cpgx " & _
                            "where Pf = '" & txtPf.Text & "' and Gx = '" & cbGx.Text & "'"
        cnData.Open()
        rd = cmdSQL.ExecuteReader(CommandBehavior.CloseConnection)
        'txtJg.Text = cmdSQL.ExecuteScalar().ToString
        If rd.Read Then
            txtJg.Text = rd.GetDecimal(0).ToString
            txtJg1.Text = rd.GetDecimal(1).ToString
            txtJg2.Text = rd.GetDecimal(2).ToString
            txtJg3.Text = rd.GetDecimal(3).ToString
        End If

        rd.Close()



    End Sub


    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
        If cbGh.Text = "" Or txtXm.Text = "" Or txtPf.Text = "" Or cbGx.Text = "" Or txtSl.Text = "" Or txtFei1.Text = "" Or txtFei2.Text = "" Or txtFei3.Text = "" Then
            MessageBox.Show("请输入所有数据!并保证数据合法!")
            Exit Sub
        End If

        If Not (IsNumeric(txtSl.Text) And IsNumeric(txtFei1.Text) And IsNumeric(txtFei2.Text) And IsNumeric(txtFei3.Text)) Then
            MessageBox.Show("完工数和报废数必须是数字!")
            Exit Sub
        End If
        Updata()
        Cls()


    End Sub

    Private Sub txtXm_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtXm.LostFocus
        cbGh.Items.Clear()
        cbGh.Text = ""

        Dim rd As OleDbDataReader
        cmdSQL.CommandText = "select Gh from Ryzl " & _
                             "where Xm = '" & txtXm.Text & "'"
        cnData.Open()
        rd = cmdSQL.ExecuteReader(CommandBehavior.CloseConnection)
        Do While rd.Read
            cbGh.Items.Add(Trim(rd.GetString(0)))
        Loop
        rd.Close()

        If cbGh.Items.Count >= 1 Then
            cbGh.SelectedIndex = 0
        Else
            'MessageBox.Show("无此名字!")


        End If
    End Sub

    Private Sub txtPf_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPf.LostFocus
        cbGx.Items.Clear()
        Dim rd As OleDbDataReader
        cmdSQL.CommandText = "select Gx from Cpgx " & _
                             "where Pf = '" & txtPf.Text & "'"
        cnData.Open()
        rd = cmdSQL.ExecuteReader(CommandBehavior.CloseConnection)
        Do While rd.Read
            cbGx.Items.Add(Trim(rd.GetString(0)))
        Loop
        rd.Close()
        If cbGx.Items.Count = 0 Then
            'MessageBox.Show("无此品番!")
        Else
            cbGx.SelectedIndex = 0
        End If
    End Sub

    Private Sub txtJe_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtJe.GotFocus
        If IsNumeric(txtSl.Text) And IsNumeric(txtJg.Text) And IsNumeric(txtJg1.Text) And IsNumeric(txtJg2.Text) And IsNumeric(txtJg3.Text) And IsNumeric(txtFei1.Text) And IsNumeric(txtFei2.Text) And IsNumeric(txtFei3.Text) Then
            txtJe.Text = (CType(txtJg.Text, Single) * CType(txtSl.Text, Single) - CType(txtFei1.Text, Single) * CType(txtJg1.Text, Single) - CType(txtFei2.Text, Single) * CType(txtJg2.Text, Single) - CType(txtFei3.Text, Single) * CType(txtJg3.Text, Single)).ToString
        End If
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        If cbGh.Text = "" Or txtXm.Text = "" Or txtPf.Text = "" Or cbGx.Text = "" Or txtSl.Text = "" Or txtFei1.Text = "" Or txtFei2.Text = "" Or txtFei3.Text = "" Then
            MessageBox.Show("请输入所有数据!并保证数据合法!")
            Exit Sub
        End If

        If Not (IsNumeric(txtSl.Text) And IsNumeric(txtFei1.Text) And IsNumeric(txtFei2.Text) And IsNumeric(txtFei3.Text)) Then
            MessageBox.Show("完工数和报废数必须是数字!")
            Exit Sub
        End If
        Updata()
        Me.Close()
    End Sub

    Private Sub cbGh_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbGh.LostFocus

        txtXm.Text = ""
        Dim rd As OleDbDataReader
        cmdSQL.CommandText = "select Xm from Ryzl " & _
                            "where Gh = '" & cbGh.Text & "'"
        cnData.Open()
        rd = cmdSQL.ExecuteReader(CommandBehavior.CloseConnection)
        If rd.Read Then
            txtXm.Text = rd.GetString(0)
        End If
        rd.Close()
        
    End Sub
End Class

⌨️ 快捷键说明

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