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:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
| Imports System.Data.OleDb
Partial Class overzichtpnnr
Inherits System.Web.UI.Page
Protected Sub Btnzoek_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnzoek.Click
Dim strverzuim As String = System.Configuration.ConfigurationManager.ConnectionStrings("DBverzuimCS").ConnectionString
Dim conn As New OleDbConnection(strverzuim)
Dim cm As New OleDbCommand
cm.CommandText = "SELECT tblverzuim.Id, tblverzuim.datumvan, tblverzuim.datumtot, tblverzuim.datumziekteattest, [IGPNNR] & ' ' & RTrim([IGVRNM]) & ' ' & RTrim([IGNAAM]) AS Naam, tblverzuim.controle, tblverzuim.datumcontrole, tblverzuim.controleannulatie, tblverzuim.opmerkingen, tblverzuim.datumingave, tblverzuim.resultaatcontrole" _
& " FROM tblPersoneelAS400 INNER JOIN tblverzuim ON tblPersoneelAS400.IGPNNR = tblverzuim.pnnr" _
& " WHERE tblPersoneelAS400.IGPNNR=? AND tblverzuim.wissen=False" _
& " GROUP BY tblverzuim.Id, tblverzuim.datumvan, tblverzuim.datumtot, tblverzuim.datumziekteattest, [IGPNNR] & ' ' & RTrim([IGVRNM]) & ' ' & RTrim([IGNAAM]), tblverzuim.controle, tblverzuim.datumcontrole, tblverzuim.controleannulatie, tblverzuim.opmerkingen, tblverzuim.datumingave, tblverzuim.resultaatcontrole" _
& " ORDER BY tblverzuim.datumvan DESC , tblverzuim.datumtot DESC;"
Dim p2 As New OleDbParameter
p2.ParameterName = "pnnr"
p2.OleDbType = OleDbType.Double
p2.Value = Me.txtpnnrzoek.Text
cm.Connection = conn
cm.Connection.Open()
cm.Parameters.Add(p2)
Me.dgOverzicht.DataSource = cm.ExecuteReader()
Me.dgOverzicht.DataBind()
Me.lblok.Visible = False
Me.btnexcel.Visible = True
cm.Connection.Close()
cm.Parameters.Clear()
End Sub
''Kleur de rijen die vandaag gemaakt zijn groen & rijen die vandaag verlopen zijn rood. Hier word geselecteerd op Kolom "datumingave" uit de Tabel "tblVerzuim" van dbVerzuim
Protected Sub dgOverzicht_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles dgOverzicht.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim groen As String = DataBinder.Eval(e.Row.DataItem, "datumingave")
Dim rood As String = DataBinder.Eval(e.Row.DataItem, "datumtot")
If groen = Today Then
e.Row.ForeColor = Drawing.Color.Green
End If
If rood = Today Then
e.Row.ForeColor = Drawing.Color.Red
End If
End If
End Sub
Public Sub dgOverzicht_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgOverzicht.SelectedIndexChanged
Dim strverzuim As String = System.Configuration.ConfigurationManager.ConnectionStrings("DBverzuimCS").ConnectionString
Dim conn As New OleDbConnection(strverzuim)
Dim cm As New OleDbCommand
cm.CommandText = "SELECT tblverzuim.datumvan, tblverzuim.datumtot, tblverzuim.datumziekteattest, tblverzuim.pnnr, tblverzuim.wissen, tblverzuim.opmerkingen, tblverzuim.Id, tblverzuim.controle, tblverzuim.datumcontrole, tblverzuim.controleannulatie, tblverzuim.useringave, tblverzuim.datumingave, tblverzuim.userannulatiecontrole, tblverzuim.datumannulatiecontrole, tblverzuim.userwissen, tblverzuim.datumwissen, tblverzuim.usergewijzigd, tblverzuim.datumgewijzigd, tblverzuim.resultaatcontrole" _
& " FROM tblverzuim" _
& " WHERE tblverzuim.Id=?;"
Dim p1 As New OleDbParameter
p1.ParameterName = "ID"
p1.OleDbType = OleDbType.Double
p1.Value = CType(Me.dgOverzicht.SelectedRow.FindControl("lblid"), Label).Text
cm.Connection = conn
cm.Connection.Open()
cm.Parameters.Add(p1)
Me.DetailsView1.DataSource = cm.ExecuteReader
Me.DetailsView1.DataBind()
cm.Connection.Close()
cm.Parameters.Clear()
''hier vult de dropdownlist van Resultaat Controle zich mee op
Dim ctrl As Control
ctrl = DetailsView1.FindControl("drpResultaatControle")
If Not ctrl Is Nothing Then
Dim mylistbox As DropDownList = DirectCast(ctrl, DropDownList)
If Not mylistbox Is Nothing Then
' prepare the SQl query
Dim sqlCmd As String = "SELECT tblkeuzelijst.IdKeuze, tblKeuzelijst.keuzemogelijkheden FROM tblKeuzelijst"
VulListbox(mylistbox, sqlCmd)
End If
End If
End Sub
Private Sub VulListbox(ByVal lstObj As DropDownList, ByVal sqlCmd As String)
Dim p1 As New OleDbParameter
Dim strverzuim As String = System.Configuration.ConfigurationManager.ConnectionStrings("DBverzuimCS").ConnectionString
Dim conn As New OleDbConnection(strverzuim)
Dim cm As New OleDbCommand
cm.CommandText = sqlCmd
cm.Connection = conn
cm.Connection.Open()
lstObj.DataSource = cm.ExecuteReader()
lstObj.DataValueField = "IdKeuze"
lstObj.DataTextField = "keuzemogelijkheden"
lstObj.DataBind()
'sluit af
cm.Connection.Close()
cm.Parameters.Clear()
End Sub
Protected Sub btnOpslaan_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strverzuim As String = System.Configuration.ConfigurationManager.ConnectionStrings("DBverzuimCS").ConnectionString
Dim conn As New OleDbConnection(strverzuim)
Dim cm As New OleDbCommand
cm.CommandText = "UPDATE tblverzuim SET tblverzuim.datumvan = ?, tblverzuim.datumtot = ?, tblverzuim.datumziekteattest =?, tblverzuim.opmerkingen = ?, tblverzuim.usergewijzigd = ?, tblverzuim.datumgewijzigd = ?, tblverzuim.controle=?, tblverzuim.datumcontrole=?, tblverzuim.resultaatcontrole=?" _
& " WHERE (((tblverzuim.Id)=?));"
Dim p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 As New OleDbParameter
p1.ParameterName = "ID"
p2.ParameterName = "datumvan"
p3.ParameterName = "datumtot"
p4.ParameterName = "datumattest"
p5.ParameterName = "opmerkingen"
p6.ParameterName = "usergewijzigd"
p7.ParameterName = "datumgewijzigd"
p8.ParameterName = "controlejanee"
p9.ParameterName = "datumcontrole"
p10.ParameterName = "resultaatcontrole"
p1.OleDbType = OleDbType.Double
p2.OleDbType = OleDbType.Date
p3.OleDbType = OleDbType.Date
p4.OleDbType = OleDbType.Date
p5.OleDbType = OleDbType.Char
p6.OleDbType = OleDbType.Char
p7.OleDbType = OleDbType.Date
p8.OleDbType = OleDbType.Boolean
p9.OleDbType = OleDbType.Date
p10.OleDbType = OleDbType.Char
p1.Value = CType(Me.DetailsView1.FindControl("lblid"), Label).Text
p2.Value = CType(Me.DetailsView1.FindControl("txtdatumvan"), TextBox).Text
p3.Value = CType(Me.DetailsView1.FindControl("txtdatumtot"), TextBox).Text
p4.Value = CType(Me.DetailsView1.FindControl("txtdatumziekteattest"), TextBox).Text
p5.Value = CType(Me.DetailsView1.FindControl("txtopmerkingen"), TextBox).Text
p6.Value = User.Identity.Name
p7.Value = System.DateTime.Now
p8.Value = CType(Me.DetailsView1.FindControl("slkcontrole"), CheckBox).Checked
p9.Value = CType(Me.DetailsView1.FindControl("txtcontrole"), TextBox).Text
p10.Value = CType(Me.DetailsView1.FindControl("drpResultaatControle"), DropDownList).SelectedValue
cm.Connection = conn
cm.Connection.Open()
cm.Parameters.Add(p2)
cm.Parameters.Add(p3)
cm.Parameters.Add(p4)
cm.Parameters.Add(p5)
cm.Parameters.Add(p6)
cm.Parameters.Add(p7)
cm.Parameters.Add(p8)
cm.Parameters.Add(p9)
cm.Parameters.Add(p10)
cm.Parameters.Add(p1)
cm.ExecuteNonQuery()
cm.Connection.Close()
cm.Parameters.Clear()
Me.lblok.Visible = True
Me.DetailsView1.DataSource = Nothing
Me.DetailsView1.DataBind()
Me.dgOverzicht.DataSource = Nothing
Me.dgOverzicht.DataBind()
End Sub
Protected Sub btnWissen_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strverzuim As String = System.Configuration.ConfigurationManager.ConnectionStrings("DBverzuimCS").ConnectionString
Dim conn As New OleDbConnection(strverzuim)
Dim cm As New OleDbCommand
cm.CommandText = "UPDATE tblverzuim SET tblverzuim.wissen = -1, tblverzuim.userwissen =?, tblverzuim.datumwissen = ?" _
& " WHERE (((tblverzuim.Id)=?));"
Dim p1, p2, p3 As New OleDbParameter
p1.ParameterName = "ID"
p2.ParameterName = "userwissen"
p3.ParameterName = "datumwissen"
p2.OleDbType = OleDbType.Char
p3.OleDbType = OleDbType.Date
p1.OleDbType = OleDbType.Double
p1.Value = CType(Me.DetailsView1.FindControl("lblid"), Label).Text
p2.Value = User.Identity.Name
p3.Value = System.DateTime.Now
cm.Connection = conn
cm.Connection.Open()
cm.Parameters.Add(p2)
cm.Parameters.Add(p3)
cm.Parameters.Add(p1)
cm.ExecuteNonQuery()
cm.Connection.Close()
cm.Parameters.Clear()
Me.lblok.Visible = True
Me.DetailsView1.DataSource = Nothing
Me.DetailsView1.DataBind()
Me.dgOverzicht.DataSource = Nothing
Me.dgOverzicht.DataBind()
End Sub
Protected Sub btnannulatiecontrole_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strverzuim As String = System.Configuration.ConfigurationManager.ConnectionStrings("DBverzuimCS").ConnectionString
Dim conn As New OleDbConnection(strverzuim)
Dim cm As New OleDbCommand
cm.CommandText = "UPDATE tblverzuim SET tblverzuim.controleannulatie = -1, tblverzuim.userannulatiecontrole =?, tblverzuim.datumannulatiecontrole = ?" _
& " WHERE (((tblverzuim.Id)=?));"
Dim p1, p2, p3 As New OleDbParameter
p1.ParameterName = "ID"
p2.ParameterName = "userwissen"
p3.ParameterName = "datumwissen"
p2.OleDbType = OleDbType.Char
p3.OleDbType = OleDbType.Date
p1.OleDbType = OleDbType.Double
p1.Value = CType(Me.DetailsView1.FindControl("lblid"), Label).Text
p2.Value = User.Identity.Name
p3.Value = System.DateTime.Now
cm.Connection = conn
cm.Connection.Open()
cm.Parameters.Add(p2)
cm.Parameters.Add(p3)
cm.Parameters.Add(p1)
cm.ExecuteNonQuery()
cm.Connection.Close()
cm.Parameters.Clear()
Me.lblok.Visible = True
Me.DetailsView1.DataSource = Nothing
Me.DetailsView1.DataBind()
Me.dgOverzicht.DataSource = Nothing
Me.dgOverzicht.DataBind()
End Sub
Protected Sub btnexcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnexcel.Click
Dim sb As New System.Text.StringBuilder
Dim rij As Integer
'Dim kolom As Integer
Dim filename As String
filename = "verzuim.txt"
sb.Append("pnnr / Naam" & Chr(9) & "Ziekte van" & Chr(9) & "Ziekte tot" & Chr(9) & "datum ziekteattest" & Chr(9) & "controle" & Chr(9) & "datum controle" & Chr(9) & "annulatie controle" & Chr(9) & "opmerkingen" & vbCrLf)
For rij = 0 To Me.dgOverzicht.Rows.Count - 1
Me.dgOverzicht.SelectedIndex = rij
'gegevens uit gridview meenemen
sb.Append(CType(Me.dgOverzicht.SelectedRow.FindControl("lblpnnr"), Label).Text & Chr(9))
sb.Append(CType(Me.dgOverzicht.SelectedRow.FindControl("lbldatumvan"), Label).Text & Chr(9))
sb.Append(CType(Me.dgOverzicht.SelectedRow.FindControl("lbldatumtot"), Label).Text & Chr(9))
sb.Append(CType(Me.dgOverzicht.SelectedRow.FindControl("lbldatumziekteattest"), Label).Text & Chr(9))
sb.Append(CType(Me.dgOverzicht.SelectedRow.FindControl("slkcontrole"), CheckBox).Checked & Chr(9))
sb.Append(CType(Me.dgOverzicht.SelectedRow.FindControl("lbldatumcontrole"), Label).Text & Chr(9))
sb.Append(CType(Me.dgOverzicht.SelectedRow.FindControl("slkcontroleannulatie"), CheckBox).Checked & Chr(9))
sb.Append(CType(Me.dgOverzicht.SelectedRow.FindControl("txtopmerkingen"), TextBox).Text & vbCrLf)
Next
Response.ContentType = "Application/x-msexcel"
Response.AddHeader("content-disposition", "attachement; filename=""" & filename & """")
Response.Write(sb.ToString)
Response.End()
End Sub
End Class
|