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

📄 transaction.vb

📁 图书管理系统最新的
💻 VB
📖 第 1 页 / 共 3 页
字号:
        Me.grb_fine.Controls.Add(Me.lbl_fine)
        Me.grb_fine.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.grb_fine.ForeColor = System.Drawing.Color.Navy
        Me.grb_fine.Location = New System.Drawing.Point(24, 368)
        Me.grb_fine.Name = "grb_fine"
        Me.grb_fine.Size = New System.Drawing.Size(288, 88)
        Me.grb_fine.TabIndex = 18
        Me.grb_fine.TabStop = False
        Me.grb_fine.Text = "Fine Details"
        '
        'Cmb_desc
        '
        Me.Cmb_desc.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.Cmb_desc.Items.AddRange(New Object() {"Late fine", "Book Damaged / Lost"})
        Me.Cmb_desc.Location = New System.Drawing.Point(112, 56)
        Me.Cmb_desc.Name = "Cmb_desc"
        Me.Cmb_desc.Size = New System.Drawing.Size(160, 21)
        Me.Cmb_desc.TabIndex = 7
        '
        'Lbl_disc
        '
        Me.Lbl_disc.AutoSize = True
        Me.Lbl_disc.Location = New System.Drawing.Point(16, 59)
        Me.Lbl_disc.Name = "Lbl_disc"
        Me.Lbl_disc.Size = New System.Drawing.Size(80, 17)
        Me.Lbl_disc.TabIndex = 2
        Me.Lbl_disc.Text = "Description  :"
        '
        'lbl_fine_disp
        '
        Me.lbl_fine_disp.BackColor = System.Drawing.Color.White
        Me.lbl_fine_disp.ForeColor = System.Drawing.Color.Red
        Me.lbl_fine_disp.Location = New System.Drawing.Point(112, 30)
        Me.lbl_fine_disp.Name = "lbl_fine_disp"
        Me.lbl_fine_disp.Size = New System.Drawing.Size(160, 16)
        Me.lbl_fine_disp.TabIndex = 1
        '
        'lbl_fine
        '
        Me.lbl_fine.AutoSize = True
        Me.lbl_fine.Location = New System.Drawing.Point(16, 32)
        Me.lbl_fine.Name = "lbl_fine"
        Me.lbl_fine.Size = New System.Drawing.Size(39, 17)
        Me.lbl_fine.TabIndex = 0
        Me.lbl_fine.Text = "Fine : "
        '
        'btn_issue
        '
        Me.btn_issue.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btn_issue.ForeColor = System.Drawing.Color.Black
        Me.btn_issue.Location = New System.Drawing.Point(72, 472)
        Me.btn_issue.Name = "btn_issue"
        Me.btn_issue.TabIndex = 9
        Me.btn_issue.Text = "&Issue"
        '
        'btn_return
        '
        Me.btn_return.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btn_return.ForeColor = System.Drawing.Color.Black
        Me.btn_return.Location = New System.Drawing.Point(160, 472)
        Me.btn_return.Name = "btn_return"
        Me.btn_return.TabIndex = 10
        Me.btn_return.Text = "&Return"
        '
        'txt_search
        '
        Me.txt_search.Location = New System.Drawing.Point(328, 472)
        Me.txt_search.Name = "txt_search"
        Me.txt_search.Size = New System.Drawing.Size(88, 22)
        Me.txt_search.TabIndex = 13
        Me.txt_search.Text = ""
        '
        'btn_search
        '
        Me.btn_search.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btn_search.Location = New System.Drawing.Point(424, 472)
        Me.btn_search.Name = "btn_search"
        Me.btn_search.Size = New System.Drawing.Size(56, 16)
        Me.btn_search.TabIndex = 14
        Me.btn_search.Text = "search"
        '
        'Label1
        '
        Me.Label1.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.ForeColor = System.Drawing.Color.Blue
        Me.Label1.Location = New System.Drawing.Point(328, 16)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(248, 17)
        Me.Label1.TabIndex = 10
        Me.Label1.Text = "Select the book to be issued or returned :"
        '
        'transaction
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
        Me.BackColor = System.Drawing.Color.Silver
        Me.ClientSize = New System.Drawing.Size(804, 525)
        Me.ControlBox = False
        Me.Controls.Add(Me.btn_search)
        Me.Controls.Add(Me.txt_search)
        Me.Controls.Add(Me.btn_return)
        Me.Controls.Add(Me.btn_issue)
        Me.Controls.Add(Me.grb_fine)
        Me.Controls.Add(Me.gb_rtn)
        Me.Controls.Add(Me.btn_close)
        Me.Controls.Add(Me.dg_books)
        Me.Controls.Add(Me.Label1)
        Me.Font = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "transaction"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Transaction"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        Me.gb_rtn.ResumeLayout(False)
        CType(Me.dg_books, System.ComponentModel.ISupportInitialize).EndInit()
        Me.grb_fine.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Dim cn As New SqlConnection("server=localhost;database=lms;uid=sa;password=;")
    Dim da As SqlDataAdapter
    Dim ds As DataSet
    Dim cmd As SqlCommand
    Dim dv As DataView
    Dim i, f_charge As Integer
    Dim d As Date
    Dim f As Integer

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

        Try

            cn.Open() 'opening connection
            rd_issue.Select()

            cmd = New SqlCommand
            With cmd
                .Connection = cn
                .CommandText = "select F_Charge from options"
            End With

            ' storing fine charge in a variable
            f_charge = CType(cmd.ExecuteScalar, Integer)


        Catch ex As SqlException
            MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Me.Close()

        Finally

            txt_sid.Select()
            cmd = Nothing

        End Try
    End Sub



    'method to fetch books info. and display it in the grid
    Sub issue_fillgrid()

        Try

            da = New SqlDataAdapter("select * from book_info where Book_Id not in (select Book_id from trans)", cn)
            ds = New DataSet
            da.Fill(ds, "book_info")
            dv = New DataView(ds.Tables(0))
            dv.Sort = "Book_id"

            dg_books.DataSource = dv


        Catch ex As SqlException
            MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)

        Catch err As System.Exception
            MessageBox.Show(err.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)

        Finally

            'dereferencing objects
            da = Nothing
            ds = Nothing
            dv = Nothing

        End Try

    End Sub

    Sub return_fillgrid()

        Try

            da = New SqlDataAdapter("select s1.S_Id,s1.Name,s1.Branch,b1.Book_Id,b1.Title,t1.Issue_date,t1.return_date from stud_info s1,Book_info b1,trans t1 where s1.S_Id=t1.S_Id and t1.Book_Id=b1.Book_Id", cn)
            ds = New DataSet
            da.Fill(ds, "stud_info")

            dv = New DataView(ds.Tables(0))
            dv.Sort = "S_id"

            dg_books.DataSource = dv


        Catch ex As SqlException
            MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)

        Catch err As System.Exception
            MessageBox.Show(err.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)

        Finally

            'dereferencing objects
            da = Nothing
            ds = Nothing
            dv = Nothing

        End Try

    End Sub



    Private Sub rd_issue_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rd_issue.CheckedChanged

        issue_fillgrid() 'filling book info in the grid
        grb_fine.Enabled = False
        Cmb_desc.SelectedIndex = -1
        btn_return.Enabled = False
        btn_issue.Enabled = True


        txt_issue.Text = Format(Date.Today, "dd-MM-yyyy")
        txt_ret.Text = Format(Date.Today.AddDays(7), "dd-MM-yyyy")


        dg_books.CaptionText = "Availbale Books"



    End Sub

    Private Sub btn_close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_close.Click
        Me.Close()
    End Sub



    Private Sub rd_return_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rd_return.CheckedChanged

        'enabling controls
        return_fillgrid() 'filling student data info in the grid
        grb_fine.Enabled = True
        btn_return.Enabled = True
        btn_issue.Enabled = False

        dg_books.CaptionText = "Issued Books Information."
        txt_ret.Text = Format(Date.Today, "dd-MM-yyyy")

        txt_issue.Clear()

        Cmb_desc.SelectedIndex = 0
        lbl_fine_disp.Text = ""

        clearfields()


    End Sub



    Private Sub btn_issue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_issue.Click

        Dim j As Short = 0

        Try

            j = check_if_issued()

            If j = 1 Then
                MessageBox.Show("Can not issue,A book is already been issued to this student.", "LMS", MessageBoxButtons.OK, MessageBoxIcon.Stop)
            Else

                If txt_sid.Text <> "" AndAlso txt_sname.Text <> "" AndAlso txt_branch.Text <> "" _
                AndAlso txt_bookid.Text <> "" AndAlso txt_booktitle.Text <> "" Then



                    'inserting record
                    cmd = New SqlCommand
                    cmd.Connection = cn
                    cmd.CommandText = "insert into trans values('" & txt_sid.Text & "','" & txt_bookid.Text & "','" & Date.Today.ToShortDateString & "','" & Date.Today.AddDays(7) & "')"
                    cmd.ExecuteNonQuery()
                    MessageBox.Show("Book issued successfully!!", "LMS", MessageBoxButtons.OK, MessageBoxIcon.Information)

                    issue_fillgrid()
                    clearfields()

                Else 'one or more fields are blank

                    MessageBox.Show("All fields are mandatory to fill." & vbNewLine & "Enter the student ID and select the book from the list of available books.", "LMS", MessageBoxButtons.OK, MessageBoxIcon.Warning)
                    txt_sid.Focus()

                End If

            End If


        Catch ex As SqlException
            MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
            txt_bookid.Focus()

        Catch err As System.Exception
            MessageBox.Show(err.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
            txt_bookid.Focus()

        Finally

            cmd = Nothing

        End Try




    End Sub

    Sub get_from_grid()

⌨️ 快捷键说明

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