-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputDenda.aspx.vb
More file actions
76 lines (63 loc) · 3.18 KB
/
InputDenda.aspx.vb
File metadata and controls
76 lines (63 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Imports System.Data.OleDb
Partial Class InputDenda
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AccessDataSource4.SelectCommand = "SELECT [KodeMK], [KodeMK] & "" - "" & [Judul] as Judul FROM [books] ORDER BY [KodeMK], [Judul]"
If IsPostBack = False Then
Calendar1.SelectedDate = DateTime.Now
End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim msg As String = ""
If ListMember.Text.Length = 0 Then
msg += "Member is required<br/>"
End If
If DropDownList1.Text.Length = 0 Then
msg += "Book is required<br/>"
End If
Dim value As Integer = 0
Integer.TryParse(TextBox2.Text, value)
If value = 0 Then
msg += "Nilai Denda must be numeric"
End If
If msg.Length > 0 Then
LabelError.Text = msg
Return
End If
LabelError.Text = String.Empty
Dim tgl As Date = Calendar1.SelectedDate
Dim connstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Database/library.mdb") & ";"
Dim conn As OleDbConnection = New OleDbConnection(connstr)
Try
Dim query = String.Format("INSERT INTO denda ( [TglDenda], [KodeMK], [username], [Jumlah], [Status]) values ( @TglDenda, @KodeMK, @username, @Jumlah, 'Belum Dibayar')")
Dim paramkodemk = New OleDbParameter("@KodeMK", Convert.ToInt32(DropDownList1.SelectedValue))
Dim paramTglDenda = New OleDbParameter("@TglDenda", tgl.ToString("yyyy-MM-dd hh:mm:ss"))
Dim paramusername = New OleDbParameter("@username", ListMember.Text)
Dim paramJumlah = New OleDbParameter("@Jumlah", value)
Dim cmd As OleDbCommand = New OleDbCommand(query, conn)
cmd.Parameters.Add(paramTglDenda)
cmd.Parameters.Add(paramkodemk)
cmd.Parameters.Add(paramusername)
cmd.Parameters.Add(paramJumlah)
conn.Open()
cmd.ExecuteNonQuery()
DropDownList1.SelectedIndex = 0
ListMember.SelectedIndex = 0
TextBox2.Text = String.Empty
Calendar1.SelectedDate = DateTime.Now
Response.Redirect("InputDenda.aspx")
Catch ex As Exception
LabelError.Text = "INPUT DENDA FAILED, Message: " & ex.Message
Finally
conn.Close()
End Try
End Sub
Protected Sub GridView1_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles GridView1.SelectedIndexChanging
Dim id = GridView1.Rows(e.NewSelectedIndex).Cells(1).Text
Response.Redirect(String.Format("BayarDenda.aspx?id={0}", id))
End Sub
Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
AccessDataSource4.SelectCommand = "SELECT [KodeMK], [KodeMK] & "" - "" & [Judul] as Judul FROM [books] ORDER BY [KodeMK], [Judul]"
End Sub
End Class