Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Ri

Imports MySql.Data.MySqlClient Public Class frmpasien Private Sub loadpasien() Try strsql = "select * from pasien " connDB() cmd = New MySqlCommand(strsql, conn) dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) dgw.Rows.Clear() Do While dr.Read = True dgw.Rows.Add(dr(0), dr(1), dr(2), dr(3), dr(4), dr(5), dr(6), dr(7), dr(8)) Loop Catch ex As Exception MsgBox(ex.Message) Finally cmd.Dispose() conn.Close() End Try End Sub Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click Try If cbokdpasien.Text = "" Or txtnmpasien.Text = "" Or txttempat.Text = "" Or Format(dtptgllahir.Value, "yyyy-mm-dd") = "" Or IIf(rbpria.Checked, "Pria", "Wanita") = "" Or cboagama.Text = "" Or txtalamat.Text = "" Or txttelp.Text = "" Or cbogoldarah.Text = "" Then MsgBox("Data tidak bisa disimpan", MsgBoxStyle.Exclamation) Exit Sub End If If MsgBox("Apakah data ini akan disimpan", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Konfirmasi") = MsgBoxResult.No Then Exit Sub strsql = "Select kdpasien from pasien where kdpasien = '" & cbokdpasien.Text & "'" connDB() cmd = New MySqlCommand(strsql, conn) dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) If dr.Read = False Then strsql = "Insert pasien values ( '" & cbokdpasien.Text & "', '" & txtnmpasien.Text & "', '" & txttempat.Text & "','" & Format(dtptgllahir.Value, "yyyy-mm-dd") & "','" & IIf(rbpria.Checked, "Pria", "Wanita") & "','" & cboagama.Text & "','" & txtalamat.Text & "','" & txttelp.Text & "','" & cbogoldarah.Text & "')" Else strsql = "Update pasien set nmpasien= '" & txtnmpasien.Text & "', tptlahir='" & txttempat.Text & "',tgllahir='" & Format(dtptgllahir.Value, "yyyy-mm-dd") & "',jenkel='" & IIf(rbpria.Checked, "Pria", "Wanita") & "',agama='" & cboagama.Text & "',alamat='" & txtalamat.Text & "',telp='" & txttelp.Text & "',goldarah='" & cbogoldarah.Text & "'where kdpasien='" & cbokdpasien.Text & "'" End If connDB() cmd = New MySqlCommand(strsql, conn) Dim i As Integer i = cmd.ExecuteNonQuery() Call loadpasien() MsgBox("Program Studi Added Successfully", MsgBoxStyle.Information, " Add Program Studi") conn.Close() cmd.Dispose() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub frmpasien_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Call loadpasien() cbokdpasien.Items.Add("001") cbokdpasien.Items.Add("002") cbokdpasien.Items.Add("003") cbokdpasien.Items.Add("004") cbokdpasien.Items.Add("005") cbokdpasien.Items.Add("006") cbokdpasien.Items.Add("008") cbokdpasien.Items.Add("009") cbokdpasien.Items.Add("010") cbogoldarah.Items.Add("A") cbogoldarah.Items.Add("AB") cbogoldarah.Items.Add("B") cbogoldarah.Items.Add("O") cboagama.Items.Add("Islam") cboagama.Items.Add("Kristen Protestan") cboagama.Items.Add("Kristen Khatolik") cboagama.Items.Add("Hindu") cboagama.Items.Add("Budha") cboagama.Items.Add("Konghucu") End Sub Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click Try If MsgBox("Apakah data ini akan dihapus", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Konfirmasi") = MsgBoxResult.No Then Exit Sub strsql = "delete from pasien where kdpasien = '" & cbokdpasien.Text & "'" connDB() cmd = New MySqlCommand(strsql, conn) dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) connDB() cmd = New MySqlCommand(strsql, conn) dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) MsgBox("pasien delete Successfully", MsgBoxStyle.Information, "pasien") Call loadpasien() Catch ex As Exception MsgBox(ex.Message) Finally cmd.Dispose() conn.Close() End Try End Sub Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click cbokdpasien.Text = "" txtnmpasien.Text = "" txttempat.Text = "" dtptgllahir.Text = "" txtalamat.Text = "" txttelp.Text = "" cboagama.Text = "" cbogoldarah.Text = "" End Sub Private Sub dgw_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgw.Click cbokdpasien.Text = dgw.CurrentRow.Cells(0).Value txtnmpasien.Text = dgw.CurrentRow.Cells(1).Value txttempat.Text = dgw.CurrentRow.Cells(2).Value cboagama.Text = dgw.CurrentRow.Cells(5).Value txtalamat.Text = dgw.CurrentRow.Cells(6).Value txttelp.Text = dgw.CurrentRow.Cells(7).Value cbogoldarah.Text = dgw.CurrentRow.Cells(8).Value End Sub Private Sub btntutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntutup.Clic End Sub End Class