Advertisement
Guest User

Transaksi Pinjam Barang

a guest
May 5th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 10.13 KB | None | 0 0
  1. Imports System
  2. Imports System.Text
  3. Imports System.Drawing
  4. Imports System.Windows.Forms
  5. Imports System.ComponentModel
  6. Imports System.Collections.Generic
  7. Imports ComponentFactory.Krypton.Ribbon
  8. Imports ComponentFactory.Krypton.Toolkit
  9. Public Class frm_inventaris
  10.     Dim proses As New ClsKoneksi
  11.     Dim perintah As String
  12.     Dim baris, carialat, carikode, brst As DataTable
  13.     Sub bersih()
  14.         txtkd.Text = ""
  15.         txtnm.Text = ""
  16.         txtpnjm.Text = ""
  17.         txtkdalat.Text = ""
  18.         txtjml.Text = ""
  19.         txttrs.Text = ""
  20.         txtkdk.Text = ""
  21.         txtnmk.Text = ""
  22.         txtjbtn.Text = ""
  23.         txtnotelp.Text = ""
  24.         txtjml.Text = ""
  25.         dgdetail.Rows.Clear()
  26.         dt2.Value = DateAdd(DateInterval.Day, 1, dt1.Value.Date)
  27.         txtkd.Text = Format(Now, "dd-MM-yyyy") + "-"
  28.     End Sub
  29.     Private Sub KryptonPanel_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles KryptonPanel.Paint
  30.  
  31.     End Sub
  32.  
  33.     Private Sub frm_inventaris_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  34.         bersih()
  35.     End Sub
  36.  
  37.     Private Sub frm_inventaris_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  38.         bersih()
  39.     End Sub
  40.  
  41.     Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
  42.         Form1.tb.Text = "b"
  43.         Form1.Button1.Enabled = False
  44.         Form1.Button2.Enabled = False
  45.         Form1.Button3.Enabled = False
  46.         Form1.Button4.Enabled = False
  47.         Form1.Button5.Enabled = False
  48.         Form1.Button6.Enabled = False
  49.         Form1.lcari.Visible = False
  50.         Form1.txtcari.Visible = False
  51.         Form1.ShowDialog()
  52.         txtjml.Focus()
  53.     End Sub
  54.     Sub cari()
  55.         If txtkdalat.Text = "" Then
  56.         Else
  57.             baris = proses.ExecuteQuery("Select label_alat as 'Label Alat' From MLabelAlat where kd_alat='" + txtkdalat.Text + "' and st='True' order by label_alat asc")
  58.             dglabel.DataSource = baris
  59.             dglabel.Columns(0).Width = 250
  60.             txttrs.Text = baris.Rows.Count
  61.             lb.Text = "0"
  62.         End If
  63.     End Sub
  64.  
  65.     Private Sub txtkdalat_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtkdalat.TextChanged
  66.         cari()
  67.     End Sub
  68.  
  69.     Private Sub dglabel_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dglabel.CellDoubleClick
  70.         Try
  71.             Dim a As String()
  72.             Dim b As String
  73.             b = dglabel.Rows(e.RowIndex).Cells(0).Value.ToString
  74.             a = {b}
  75.             dgdetail.Rows.Add(a)
  76.             dglabel.Rows.RemoveAt(e.RowIndex)
  77.         Catch ex As Exception
  78.  
  79.         End Try
  80.     End Sub
  81.  
  82.     Private Sub dt2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dt2.ValueChanged
  83.         Dim a As String
  84.         a = DateDiff(DateInterval.Day, dt1.Value.Date, dt2.Value.Date)
  85.         If Val(a.ToString) < 0 Then
  86.             dt2.Value = dt1.Value.Date.ToString
  87.         Else
  88.         End If
  89.     End Sub
  90.  
  91.     Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
  92.         frm_karyawan.tb.Text = "c"
  93.         frm_karyawan.ShowDialog()
  94.     End Sub
  95.     Sub ubah_bit()
  96.         Dim c As Int16 = 0
  97.         Dim a As String
  98.         Do Until c = dgdetail.Rows.Count
  99.             a = dgdetail.Rows(c).Cells(0).Value.ToString
  100.             perintah = "Update MLabelAlat set st='False' where label_alat='" + a.ToString + "'"
  101.             proses.ExecuteNonQuery(perintah)
  102.             c = c + 1
  103.         Loop
  104.         KryptonMessageBox.Show("Transaksi berhasil", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Information)
  105.     End Sub
  106.     Sub simpan_inventori()
  107.         perintah = "Insert Into TRSInventaris values('" + txtkd.Text + "','" + txtkdk.Text + "','" + txtpetugas.Text + "','" + dt1.Text + "','" + dt2.Text + "')"
  108.         proses.ExecuteNonQuery(perintah)
  109.     End Sub
  110.     Sub simpan_detail()
  111.         Dim c As Int16 = 0
  112.         Dim a As String
  113.         Do Until c = dgdetail.Rows.Count
  114.             a = dgdetail.Rows(c).Cells(0).Value.ToString
  115.             perintah = "Insert Into TRSDetailInventaris values('" + txtkd.Text + "','" + a + "','True')"
  116.             proses.ExecuteNonQuery(perintah)
  117.             c = c + 1
  118.         Loop
  119.     End Sub
  120.  
  121.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  122.         If txtkd.Text = "" Or txtkdalat.Text = "" Or txtkdk.Text = "" Then
  123.             KryptonMessageBox.Show("Data belum lengkap")
  124.         Else
  125.             Try
  126.                 simpan_detail()
  127.                 simpan_inventori()
  128.                 ubah_bit()
  129.                 lap_inventaris.Button2.Text = txtbeli.Text
  130.                 lap_inventaris.Button1.Text = txtkd.Text
  131.                 lap_inventaris.Show()
  132.                 bersih()
  133.             Catch ex As Exception
  134.                 MsgBox("Kode Telah Terpakai")
  135.             End Try
  136.         End If
  137.     End Sub
  138.  
  139.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  140.         bersih()
  141.     End Sub
  142.  
  143.     Private Sub KryptonButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton2.Click
  144.         If dglabel.RowCount <= 0 Then
  145.         Else
  146.             Try
  147.                 Dim a As Int16
  148.                 dgdetail.Rows.Add({dglabel.Rows(lb.Text).Cells(0).Value.ToString})
  149.                 dglabel.Rows.RemoveAt(lb.Text)
  150.             Catch ex As Exception
  151.  
  152.             End Try
  153.         End If
  154.     End Sub
  155.  
  156.     Private Sub KryptonButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton1.Click
  157.         Dim jml, a As Int16
  158.         Dim isi As String()
  159.         jml = 0
  160.         a = dglabel.RowCount
  161.         Do Until jml = a
  162.             isi = {dglabel.Rows(0).Cells(0).Value.ToString}
  163.             dgdetail.Rows.Add(isi)
  164.             dglabel.Rows.RemoveAt(0)
  165.             jml = jml + 1
  166.         Loop
  167.     End Sub
  168.  
  169.     Private Sub KryptonButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton4.Click
  170.         Dim a As String = KryptonMessageBox.Show("Apakah anda ingin menghapus semua data pinjam ?", "Perhatian", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
  171.         If a = MsgBoxResult.Yes Then
  172.             dgdetail.Rows.Clear()
  173.             txtbeli.Text = "Barang pinjam 0"
  174.         End If
  175.     End Sub
  176.  
  177.     Private Sub KryptonButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton3.Click
  178.         If Val(lb2.Text) < 0 Then
  179.         Else
  180.             Try
  181.                 Dim a As String
  182.                 a = KryptonMessageBox.Show("Apakah ingin menghapus data ini?", "Perhatian", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
  183.                 If a = MsgBoxResult.Yes Then
  184.                     dgdetail.Rows.RemoveAt(lb2.Text)
  185.                     If Val(dgdetail.RowCount) = lb2.Text Then
  186.                         lb2.Text = Val(lb2.Text) - 1
  187.                     End If
  188.                 End If
  189.             Catch ex As Exception
  190.  
  191.             End Try
  192.         End If
  193.     End Sub
  194.  
  195.     Private Sub dgdetail_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgdetail.CellDoubleClick
  196.         Dim a As String
  197.         a = KryptonMessageBox.Show("Apakah ingin menghapus data ini?", "Perhatian", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
  198.         If a = MsgBoxResult.Yes Then
  199.             dgdetail.Rows.RemoveAt(e.RowIndex)
  200.         End If
  201.     End Sub
  202.  
  203.     Private Sub dgdetail_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)
  204.         lb2.Text = e.RowIndex
  205.     End Sub
  206.  
  207.     Private Sub dglabel_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dglabel.CellClick, dgdetail.CellClick
  208.         lb.Text = e.RowIndex
  209.     End Sub
  210.     Sub total()
  211.         txtbeli.Text = "Barang pinjam sebanyak " + dgdetail.RowCount.ToString + " Item"
  212.     End Sub
  213.     Private Sub dgdetail_RowsRemoved(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewRowsRemovedEventArgs) Handles dgdetail.RowsRemoved
  214.         total()
  215.     End Sub
  216.     Sub tambah()
  217.         If txtjml.Text = "" Or txtpnjm.Text = "" Then
  218.         Else
  219.             Dim jm As Int16 = dglabel.RowCount
  220.             If Val(txtpnjm.Text) > jm.ToString Then
  221.                 txtpnjm.ForeColor = Color.White
  222.                 txtpnjm.BackColor = Color.Red
  223.             Else
  224.                 txtpnjm.ForeColor = Color.Black
  225.                 txtpnjm.BackColor = Color.White
  226.                 Dim a, b As Int16
  227.                 a = Val(txtpnjm.Text)
  228.                 b = 0
  229.                 Do Until b = a
  230.                     dgdetail.Rows.Add({dglabel.Rows(0).Cells(0).Value.ToString})
  231.                     dglabel.Rows.RemoveAt(0)
  232.                     b = b + 1
  233.                 Loop
  234.             End If
  235.         End If
  236.     End Sub
  237.     Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
  238.         tambah()
  239.     End Sub
  240.  
  241.     Private Sub dgdetail_RowsAdded(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewRowsAddedEventArgs) Handles dgdetail.RowsAdded
  242.         total()
  243.     End Sub
  244.  
  245.     Private Sub txtkdk_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtkdk.TextChanged
  246.  
  247.     End Sub
  248.  
  249.     Private Sub txtpnjm_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtpnjm.TextChanged
  250.         If txtpnjm.Text = "" Then
  251.         Else
  252.             If IsNumeric(txtpnjm.Text) Then
  253.             Else
  254.                 KryptonMessageBox.Show("Inputan hanya berupa angka", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Information)
  255.                 txtpnjm.Text = ""
  256.                 txtpnjm.Focus()
  257.             End If
  258.         End If
  259.     End Sub
  260. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement