Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.34 KB | None | 0 0
  1. Imports System.Data.OleDb
  2.  
  3.  
  4.  
  5. Public Class MasterSiswa
  6.  
  7.  
  8.  
  9. Sub NomorOtomatis()
  10.  
  11. CMD = New OleDbCommand("select id_siswa from tblsiswa order by id_siswa desc", Conn)
  12.  
  13. DR = CMD.ExecuteReader
  14.  
  15. DR.Read()
  16.  
  17. If Not DR.HasRows Then
  18.  
  19. txtIDSiswa.Text = "00001"
  20.  
  21. Else
  22.  
  23. txtIDSiswa.Text = Format(Microsoft.VisualBasic.Right(DR.Item("id_siswa"), 5) + 1, "00000")
  24.  
  25. End If
  26.  
  27.  
  28.  
  29. End Sub
  30.  
  31.  
  32.  
  33. Sub Kosongkan()
  34.  
  35. txtIDSiswa.Enabled = False
  36.  
  37. Call NomorOtomatis()
  38.  
  39. txtNIS.Clear()
  40.  
  41. txtNISN.Clear()
  42.  
  43. txtNama.Clear()
  44.  
  45. TextBox6.Clear()
  46.  
  47. cmbPendidikan.Text = ""
  48.  
  49. cmbTahunAjaran.Text = ""
  50.  
  51. cmbJurusan.Text = ""
  52.  
  53. cmbKelas.Text = ""
  54.  
  55. cmbSemester.Text = ""
  56.  
  57. Call Tampilangkatan()
  58.  
  59. Call TampilJurusan()
  60.  
  61. Call Tampilkelas()
  62.  
  63. Call TampilGrid()
  64.  
  65. txtNIS.Focus()
  66.  
  67. End Sub
  68.  
  69.  
  70.  
  71. Sub DataBaru()
  72.  
  73. txtNIS.Clear()
  74.  
  75. txtNISN.Clear()
  76.  
  77. txtNama.Clear()
  78.  
  79. TextBox6.Clear()
  80.  
  81. cmbPendidikan.Text = ""
  82.  
  83. cmbTahunAjaran.Text = ""
  84.  
  85. cmbJurusan.Text = ""
  86.  
  87. cmbKelas.Text = ""
  88.  
  89. cmbSemester.Text = ""
  90.  
  91. Call Tampilangkatan()
  92.  
  93. Call TampilJurusan()
  94.  
  95. Call Tampilkelas()
  96.  
  97. Call TampilGrid()
  98.  
  99. txtNIS.Focus()
  100.  
  101. End Sub
  102.  
  103.  
  104.  
  105. Sub Ketemu()
  106.  
  107. On Error Resume Next
  108.  
  109. txtIDSiswa.Enabled = False
  110.  
  111. txtNIS.Text = DR.Item("NIS")
  112.  
  113. txtNISN.Text = DR.Item("NISN")
  114.  
  115. txtNama.Text = DR.Item("nama_siswa")
  116.  
  117. cmbPendidikan.Text = DR.Item("id_biaya") ': SendKeys.Send("{tab}")
  118.  
  119. cmbTahunAjaran.Text = DR.Item("Tahun_ajaran")
  120.  
  121. cmbJurusan.Text = DR.Item("Jurusan")
  122.  
  123. cmbKelas.Text = DR.Item("kelas")
  124.  
  125. cmbSemester.Text = DR.Item("semester")
  126.  
  127. txtNIS.Focus()
  128.  
  129. End Sub
  130.  
  131.  
  132.  
  133. Sub TampilGrid()
  134.  
  135. DA = New OleDbDataAdapter("select * from tblsiswa", Conn)
  136.  
  137. DS = New DataSet
  138.  
  139. DA.Fill(DS)
  140.  
  141. DGV.DataSource = DS.Tables(0)
  142.  
  143. DGV.ReadOnly = True
  144.  
  145. End Sub
  146.  
  147.  
  148.  
  149. Sub TampilPendidikan()
  150.  
  151. CMD = New OleDbCommand("select * from tblLEVELPENDIDIKAN", Conn)
  152.  
  153. DR = CMD.ExecuteReader
  154.  
  155. cmbPendidikan.Items.Clear()
  156.  
  157. Do While DR.Read
  158.  
  159. cmbPendidikan.Items.Add(DR.Item(0) & Space(2) & DR(1))
  160.  
  161. Loop
  162.  
  163. End Sub
  164.  
  165.  
  166.  
  167. Sub Tampilangkatan()
  168.  
  169. CMD = New OleDbCommand("select DISTINCT TAHUN_AJARAN from tblSISWA", Conn)
  170.  
  171. DR = CMD.ExecuteReader
  172.  
  173. cmbTahunAjaran.Items.Clear()
  174.  
  175. Do While DR.Read
  176.  
  177. cmbTahunAjaran.Items.Add(DR.Item(0))
  178.  
  179. Loop
  180.  
  181. End Sub
  182.  
  183.  
  184.  
  185. Sub TampilJurusan()
  186.  
  187. CMD = New OleDbCommand("select DISTINCT JURUSAN from tblSISWA", Conn)
  188.  
  189. DR = CMD.ExecuteReader
  190.  
  191. cmbJurusan.Items.Clear()
  192.  
  193. Do While DR.Read
  194.  
  195. cmbJurusan.Items.Add(DR.Item(0))
  196.  
  197. Loop
  198.  
  199. End Sub
  200.  
  201.  
  202.  
  203. Sub Tampilkelas()
  204.  
  205. CMD = New OleDbCommand("select DISTINCT KELAS from tblSISWA", Conn)
  206.  
  207. DR = CMD.ExecuteReader
  208.  
  209. cmbKelas.Items.Clear()
  210.  
  211. Do While DR.Read
  212.  
  213. cmbKelas.Items.Add(DR.Item(0))
  214.  
  215. Loop
  216.  
  217. End Sub
  218.  
  219.  
  220.  
  221. Sub Kondisiawal()
  222.  
  223. Call Kosongkan()
  224.  
  225. Call TampilPendidikan()
  226.  
  227. Call Tampilangkatan()
  228.  
  229. Call TampilGrid()
  230.  
  231. Call TampilJurusan()
  232.  
  233. Call Tampilkelas()
  234.  
  235. End Sub
  236.  
  237.  
  238.  
  239. Sub Carisiswa()
  240.  
  241. CMD = New OleDbCommand("select * from tblsiswa where id_siswa='" & txtIDSiswa.Text & "'", Conn)
  242.  
  243. DR = CMD.ExecuteReader
  244.  
  245. DR.Read()
  246.  
  247. End Sub
  248.  
  249.  
  250.  
  251. Private Sub MasterSiswa_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  252.  
  253. Call Koneksi()
  254.  
  255. Call Kondisiawal()
  256.  
  257. LtempoPertama.Text = DateValue("10/07/" & Year(Today) & "")
  258.  
  259. End Sub
  260.  
  261.  
  262.  
  263. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  264.  
  265. Call Kondisiawal()
  266.  
  267. Call TampilGrid()
  268.  
  269. Call Kosongkan()
  270.  
  271. End Sub
  272.  
  273.  
  274.  
  275. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  276.  
  277. Me.Close()
  278.  
  279. End Sub
  280.  
  281.  
  282.  
  283. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  284.  
  285.  
  286.  
  287. Call Carisiswa()
  288.  
  289. Try
  290.  
  291. If Not DR.HasRows Then
  292.  
  293. 'Call Koneksi()
  294.  
  295. Dim simpan As String = "insert into tblsiswa values ('" & txtIDSiswa.Text & "','" & txtNIS.Text & "','" & txtNISN.Text & "','" & txtNama.Text & "','" & Microsoft.VisualBasic.Left(cmbPendidikan.Text, 2) & "','" & Microsoft.VisualBasic.Left(cmbPendidikan.Text, 2) & "','" & cmbTahunAjaran.Text & "','" & cmbJurusan.Text & "','" & cmbKelas.Text & "','" & cmbSemester.Text & "','" & MasterMenu.panellembaga.Text & "')"
  296.  
  297. CMD = New OleDbCommand(simpan, Conn)
  298.  
  299. CMD.ExecuteNonQuery()
  300.  
  301. For i As Integer = 1 To 12
  302.  
  303. Dim TempO As Date = DateAdd(DateInterval.Month, i - 1, DateValue(LtempoPertama.Text))
  304.  
  305. Call Koneksi()
  306.  
  307. Dim hasil As String = txtIDSiswa.Text
  308.  
  309. Dim simpandetail2 As String = "insert into TBLSPP values ('" & txtIDSiswa.Text & i & "',0,'" & TempO & "','" & Format(TempO, "MMMM") + " " + Format(TempO, "yyyy") & "','" & txtIDSiswa.Text & "',0,'-','-')"
  310.  
  311. CMD = New OleDbCommand(simpandetail2, Conn)
  312.  
  313. CMD.ExecuteNonQuery()
  314.  
  315. Next
  316.  
  317.  
  318.  
  319. CMD = New OleDbCommand("select * from TBLSPP order by 2,4", Conn)
  320.  
  321. DR = CMD.ExecuteReader
  322.  
  323. DR.Read()
  324.  
  325. Call Kosongkan()
  326.  
  327. Call TampilGrid()
  328.  
  329. Else
  330.  
  331. 'Call Koneksi()
  332.  
  333. Dim edit As String = "update tblsiswa set nis='" & txtNIS.Text & "',nisn='" & txtNISN.Text & "',nama_siswa='" & txtNama.Text & "',id_biaya='" & Microsoft.VisualBasic.Left(cmbPendidikan.Text, 2) & "',ID_PENDIDIKAN='" & Microsoft.VisualBasic.Left(cmbPendidikan.Text, 2) & "',Tahun_Ajaran='" & cmbTahunAjaran.Text & "',Jurusan='" & cmbJurusan.Text & "',Kelas='" & cmbKelas.Text & "',semester='" & cmbSemester.Text & "',ID_LEMBAGA='" & MasterMenu.panellembaga.Text & "' where id_siswa='" & txtIDSiswa.Text & "'"
  334.  
  335. CMD = New OleDbCommand(edit, Conn)
  336.  
  337. CMD.ExecuteNonQuery()
  338.  
  339.  
  340.  
  341. Call Kosongkan()
  342.  
  343. Call TampilGrid()
  344.  
  345. End If
  346.  
  347. Catch ex As Exception
  348.  
  349. MsgBox(ex.Message)
  350.  
  351. End Try
  352.  
  353. End Sub
  354.  
  355.  
  356.  
  357. Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick
  358.  
  359. 'On Error Resume Next
  360.  
  361. txtIDSiswa.Enabled = False
  362.  
  363. txtIDSiswa.Text = DGV.Rows(e.RowIndex).Cells(0).Value
  364.  
  365.  
  366.  
  367. Call Carisiswa()
  368.  
  369. If DR.HasRows Then
  370.  
  371. Call Ketemu()
  372.  
  373. End If
  374.  
  375. End Sub
  376.  
  377.  
  378.  
  379. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  380.  
  381. 'If txtIDSiswa.Text = "" Then
  382.  
  383. ' MsgBox("ID siswa harus diisi")
  384.  
  385. ' txtIDSiswa.Focus()
  386.  
  387. ' Exit Sub
  388.  
  389. 'End If
  390.  
  391.  
  392.  
  393. 'Call Carisiswa()
  394.  
  395. 'If Not DR.HasRows Then
  396.  
  397. ' MsgBox("id siswa tidak terdaftar")
  398.  
  399. ' txtIDSiswa.Focus()
  400.  
  401. ' Exit Sub
  402.  
  403. 'End If
  404.  
  405.  
  406.  
  407. 'If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
  408.  
  409. ' 'Call Koneksi()
  410.  
  411. ' Dim hapus As String = "delete from tblsiswa where id_siswa='" & txtIDSiswa.Text & "'"
  412.  
  413. ' CMD = New OleDbCommand(hapus, Conn)
  414.  
  415. ' CMD.ExecuteNonQuery()
  416.  
  417. ' Call Kosongkan()
  418.  
  419. ' Call TampilGrid()
  420.  
  421. 'Else
  422.  
  423. ' Call Kosongkan()
  424.  
  425.  
  426.  
  427. 'End If
  428.  
  429. End Sub
  430.  
  431.  
  432.  
  433. Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtIDSiswa.KeyPress
  434.  
  435. txtIDSiswa.MaxLength = 5
  436.  
  437. If e.KeyChar = Chr(13) Then
  438.  
  439. CMD = New OleDbCommand("select * from tblsiswa where id_siswa='" & txtIDSiswa.Text & "'", Conn)
  440.  
  441. DR = CMD.ExecuteReader
  442.  
  443. DR.Read()
  444.  
  445. If Not DR.HasRows Then
  446.  
  447. Call DataBaru()
  448.  
  449. Else
  450.  
  451. Call Ketemu()
  452.  
  453. End If
  454.  
  455. End If
  456.  
  457. End Sub
  458.  
  459.  
  460.  
  461. Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNIS.KeyPress
  462.  
  463. 'TextBox1.MaxLength = 5
  464.  
  465. If e.KeyChar = Chr(13) Then
  466.  
  467. txtNISN.Focus()
  468.  
  469. End If
  470.  
  471. End Sub
  472.  
  473.  
  474.  
  475. Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNISN.KeyPress
  476.  
  477. 'TextBox1.MaxLength = 5
  478.  
  479. If e.KeyChar = Chr(13) Then
  480.  
  481. txtNama.Focus()
  482.  
  483. End If
  484.  
  485. End Sub
  486.  
  487.  
  488.  
  489. Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNama.KeyPress
  490.  
  491. 'TextBox1.MaxLength = 5
  492.  
  493. If e.KeyChar = Chr(13) Then
  494.  
  495. cmbPendidikan.Focus()
  496.  
  497. End If
  498.  
  499. End Sub
  500.  
  501.  
  502.  
  503. Private Sub combobox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
  504.  
  505. 'TextBox1.MaxLength = 5
  506.  
  507. If e.KeyChar = Chr(13) Then
  508.  
  509. cmbTahunAjaran.Focus()
  510.  
  511. End If
  512.  
  513. End Sub
  514.  
  515.  
  516.  
  517. Private Sub combobox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
  518.  
  519. 'TextBox1.MaxLength = 5
  520.  
  521. If e.KeyChar = Chr(13) Then
  522.  
  523. cmbJurusan.Focus()
  524.  
  525. End If
  526.  
  527. End Sub
  528.  
  529.  
  530.  
  531. Private Sub combobox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
  532.  
  533. 'TextBox1.MaxLength = 5
  534.  
  535. If e.KeyChar = Chr(13) Then
  536.  
  537. Button1.Focus()
  538.  
  539. End If
  540.  
  541. End Sub
  542.  
  543.  
  544.  
  545. Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged
  546.  
  547. 'Call Koneksi()
  548.  
  549. DA = New OleDbDataAdapter("select * from tblsiswa where id_siswa like '%" & TextBox6.Text & "%' or nama_siswa like '%" & TextBox6.Text & "%'", Conn)
  550.  
  551. DS = New DataSet
  552.  
  553. DA.Fill(DS)
  554.  
  555. DGV.DataSource = DS.Tables(0)
  556.  
  557. End Sub
  558.  
  559.  
  560.  
  561. Private Sub cmbPendidikan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPendidikan.SelectedIndexChanged
  562.  
  563. CMD = New OleDbCommand("select * from tblBIAYA where id_BIAYA='" & Microsoft.VisualBasic.Left(cmbPendidikan.Text, 2) & "'", Conn)
  564.  
  565. DR = CMD.ExecuteReader
  566.  
  567. DR.Read()
  568.  
  569. If DR.HasRows Then
  570.  
  571. LblTotalBiaya.Text = DR("TOTAL_BIAYA")
  572.  
  573. Else
  574.  
  575. MsgBox("ID BIAYA SALAH")
  576.  
  577. End If
  578.  
  579. End Sub
  580.  
  581. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement