1 Imports System.Data.SqlClient
2 Imports System.IO
3
4 Public Class frmBusFeePayment_Staff
5     Dim st2 As String
6     Sub Calculate()
7         Dim num1, num2 As Double
8         num1 = CDbl(Val(txtBusFee.Text) + Val(txtFine.Text) + Val(txtPreviousDue.Text) - Val(txtDiscount.Text))
9         num1 = Math.Round(num1,
2)
10         txtGrandTotal.Text = num1
11         num2 = Val(txtGrandTotal.Text) - Val(txtTotalPaid.Text)
12         num2 = Math.Round(num2,
2)
13         txtBalance.Text = num2
14     End Sub
15     Sub Print()
16         Try
17             Cursor = Cursors.WaitCursor
18             Timer1.Enabled = True
19             Dim rpt As New rptBusFeeReceipt_Staff
'The report you created.
20             Dim myConnection As SqlConnection
21             Dim MyCommand As New SqlCommand()
22             Dim myDA As New SqlDataAdapter()
23             Dim myDS As New DataSet
'The DataSet you created.
24             myConnection = New SqlConnection(cs)
25             MyCommand.Connection = myConnection
26             MyCommand.CommandText =
"SELECT BusFeePayment_Staff.BFP_ID, BusFeePayment_Staff.PaymentID, BusFeePayment_Staff.BusHolderID, BusFeePayment_Staff.Session, BusFeePayment_Staff.Installment,BusFeePayment_Staff.TotalFee, BusFeePayment_Staff.DiscountPer, BusFeePayment_Staff.DiscountAmt, BusFeePayment_Staff.PreviousDue, BusFeePayment_Staff.Fine, BusFeePayment_Staff.GrandTotal, BusFeePayment_Staff.TotalPaid, BusFeePayment_Staff.ModeOfPayment, BusFeePayment_Staff.PaymentModeDetails, BusFeePayment_Staff.PaymentDate, BusFeePayment_Staff.PaymentDue,BusCardHolder_Staff.BCH_ID, BusCardHolder_Staff.StaffID, BusCardHolder_Staff.BusNo, BusCardHolder_Staff.Location, BusCardHolder_Staff.JoiningDate, BusCardHolder_Staff.Status, Staff.St_ID,Staff.StaffID AS Expr1, Staff.StaffName, Staff.DateOfJoining, Staff.Gender, Staff.FatherName, Staff.TemporaryAddress, Staff.PermanentAddress, Staff.Designation, Staff.Qualifications, Staff.DOB, Staff.PhoneNo,Staff.MobileNo, Staff.Photo, Staff.ClassType, Staff.SchoolID, Staff.AccountName, Staff.AccountNumber, Staff.Bank, Staff.Branch, Staff.IFSCcode, Staff.Salary, SchoolInfo.S_Id,SchoolInfo.SchoolName, SchoolInfo.Address, SchoolInfo.ContactNo, SchoolInfo.AltContactNo, SchoolInfo.FaxNo, SchoolInfo.Email , SchoolInfo.Website, SchoolInfo.Logo, SchoolInfo.RegistrationNo, SchoolInfo.EstablishedYear, SchoolInfo.SchoolType FROM BusFeePayment_Staff INNER JOIN BusCardHolder_Staff ON BusFeePayment_Staff.BusHolderID = BusCardHolder_Staff.BCH_ID INNER JOIN Staff ON BusCardHolder_Staff.StaffID = Staff.St_ID INNER JOIN SchoolInfo ON Staff.SchoolID = SchoolInfo.S_Id where BusFeePayment_Staff.PaymentID='" & txtFeePaymentID.Text & "'"
27             MyCommand.CommandType = CommandType.Text
28             myDA.SelectCommand = MyCommand
29             myDA.Fill(myDS,
"SchoolInfo")
30             myDA.Fill(myDS,
"Staff")
31             myDA.Fill(myDS,
"BusCardHolder_Staff")
32             myDA.Fill(myDS,
"BusFeePayment_Staff")
33             rpt.SetDataSource(myDS)
34             rpt.SetParameterValue(
"p1", txtStaffID.Text)
35             frmReport.CrystalReportViewer1.ReportSource = rpt
36             frmReport.ShowDialog()
37         Catch ex As Exception
38             MessageBox.Show(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
39         End Try
40     End Sub
41     Private Function GenerateID() As String
42         con = New SqlConnection(cs)
43         Dim
value As String = "0000"
44         Try
45             
' Fetch the latest ID from the database
46             con.Open()
47             cmd = New SqlCommand(
"SELECT TOP 1 (BFP_ID) FROM BusFeePayment_Staff ORDER BY BFP_ID DESC", con)
48             rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
49             If rdr.HasRows Then
50                 rdr.Read()
51                 
value = rdr.Item("BFP_ID")
52             End If
53             rdr.Close()
54             
' Increase the ID by 1
55             
value += 1
56             
' Because incrementing a string with an integer removes 0's
57             
' we need to replace them. If necessary.
58             If
value <= 9 Then 'Value is between 0 and 10
59                 
value = "000" & value
60             ElseIf
value <= 99 Then 'Value is between 9 and 100
61                 
value = "00" & value
62             ElseIf
value <= 999 Then 'Value is between 999 and 1000
63                 
value = "0" & value
64             End If
65         Catch ex As Exception
66             
' If an error occurs, check the connection state and close it if necessary.
67             If con.State = ConnectionState.Open Then
68                 con.Close()
69             End If
70             
value = "0000"
71         End Try
72         Return
value
73     End Function
74     Public Sub auto()
75         Try
76             txtBFPId.Text = GenerateID()
77             Dim a As String = txtStaffID.Text
78             txtFeePaymentID.Text =
"SBFP-" + GenerateID() + "-" + a
79         Catch ex As Exception
80             MessageBox.Show(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
81         End Try
82     End Sub
83
84     Sub Reset()
85         cmbInstallment.DropDownStyle = ComboBoxStyle.DropDownList
86         txtStaffID.Text =
""
87         txtBusFee.Text =
""
88         txtPaymentModeDetails.Text =
""
89         txtBalance.Text =
""
90         txtDiscount.Text =
"0.00"
91         txtDiscountPer.Text =
"0.00"
92         txtDesignation.Text =
""
93         txtFine.Text =
"0.00"
94         txtGrandTotal.Text =
""
95         txtPreviousDue.Text =
""
96         txtLocation.Text =
""
97         cmbSession.SelectedIndex = -
1
98         txtStaffName.Text =
""
99         txtContactNo.Text =
""
100         txtTotalPaid.Text =
""
101         cmbPaymentMode.SelectedIndex =
0
102         cmbInstallment.SelectedIndex = -
1
103         txtContactNo.Text =
""
104         dtpPaymentDate.Value = Now
105         btnSave.Enabled = True
106         cmbInstallment.Enabled = True
107         cmbSession.Enabled = True
108         btnUpdate.Enabled = False
109         btnDelete.Enabled = False
110         btnPrint.Enabled = False
111         Button2.Enabled = True
112         dtpPaymentDate.Enabled = True
113         cmbSession.DropDownStyle = ComboBoxStyle.DropDownList
114     End Sub
115
116     Sub Fill()
117         Try
118             con = New SqlConnection(cs)
119             con.Open()
120             cmd = con.CreateCommand()
121             cmd.CommandText =
"SELECT Discount from Discount_Staff where StaffID=@d1"
122             cmd.Parameters.AddWithValue(
"@d1", txtSt_ID.Text)
123             rdr = cmd.ExecuteReader()
124             If rdr.Read() Then
125                 txtDiscountPer.Text = rdr.GetValue(
0)
126                 Dim num As Double
127                 num = CDbl((Val(txtBusFee.Text) * Val(txtDiscountPer.Text)) /
100)
128                 num = Math.Round(num,
2)
129                 txtDiscount.Text = num
130             End If
131             If (rdr IsNot Nothing) Then
132                 rdr.Close()
133             End If
134             If con.State = ConnectionState.Open Then
135                 con.Close()
136             End If
137
138             Calculate()
139         Catch ex As Exception
140             MessageBox.Show(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
141         End Try
142     End Sub
143     Sub fillSession()
144         Try
145             con = New SqlConnection(cs)
146             con.Open()
147             adp = New SqlDataAdapter()
148             adp.SelectCommand = New SqlCommand(
"SELECT distinct (Session) FROM Session_Master", con)
149             ds = New DataSet(
"ds")
150             adp.Fill(ds)
151             dtable = ds.Tables(
0)
152             cmbSession.Items.Clear()
153             For Each drow As DataRow In dtable.Rows
154                 cmbSession.Items.Add(drow(
0).ToString())
155             Next
156         Catch ex As Exception
157             MessageBox.Show(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
158         End Try
159     End Sub
160     Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
161         frmActiveBusCardHolder_StaffRecord.lblSet.Text =
"Bus Fee Payment"
162         frmActiveBusCardHolder_StaffRecord.Reset()
163         frmActiveBusCardHolder_StaffRecord.ShowDialog()
164     End Sub
165
166     Private Sub btnGetFeeList_Click(sender As System.Object, e As System.EventArgs) Handles btnGetFeeList.Click
167         Try
168             If txtStaffID.Text =
"" Then
169                 MessageBox.Show(
"Please retrieve bus holder info", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
170                 txtStaffID.Focus()
171                 Return
172             End If
173             If cmbSession.Text =
"" Then
174                 MessageBox.Show(
"Please select session", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
175                 cmbSession.Focus()
176                 Return
177             End If
178             If cmbInstallment.Text =
"" Then
179                 MessageBox.Show(
"Please select installment", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
180                 cmbInstallment.Focus()
181                 Return
182             End If
183             con = New SqlConnection(cs)
184             con.Open()
185             cmd = con.CreateCommand()
186             cmd.CommandText =
"SELECT Charges from Installment_Bus where Installment=@d1 and Location=@d2"
187             cmd.Parameters.AddWithValue(
"@d1", cmbInstallment.Text)
188             cmd.Parameters.AddWithValue(
"@d2", txtLocation.Text)
189             rdr = cmd.ExecuteReader()
190             If rdr.Read() Then
191                 txtBusFee.Text = rdr.GetValue(
0)
192             End If
193             If (rdr IsNot Nothing) Then
194                 rdr.Close()
195             End If
196             If con.State = ConnectionState.Open Then
197                 con.Close()
198             End If
199             con = New SqlConnection(cs)
200             con.Open()
201             cmd = con.CreateCommand()
202             cmd.CommandText =
"SELECT Sum(PaymentDue-PreviousDue) from BusFeePayment_Staff where BusHolderID=@d1 group by BusHolderID"
203             cmd.Parameters.AddWithValue(
"@d1", txtBusHolderID.Text)
204             rdr = cmd.ExecuteReader()
205             If rdr.Read() Then
206                 txtPreviousDue.Text = rdr.GetValue(
0)
207             Else
208                 txtPreviousDue.Text =
0
209             End If
210             If (rdr IsNot Nothing) Then
211                 rdr.Close()
212             End If
213             If con.State = ConnectionState.Open Then
214                 con.Close()
215             End If
216             Fill()
217         Catch ex As Exception
218             MessageBox.Show(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
219         End Try
220     End Sub
221
222     Private Sub btnNew_Click(sender As System.Object, e As System.EventArgs) Handles btnNew.Click
223         Reset()
224         Reset()
225     End Sub
226
227     Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
228         If Len(Trim(txtStaffID.Text)) =
0 Then
229             MessageBox.Show(
"Please retrieve bus holder info", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
230             txtStaffID.Focus()
231             Exit Sub
232         End If
233         If Len(Trim(cmbSession.Text)) =
0 Then
234             MessageBox.Show(
"Please select session", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
235             cmbSession.Focus()
236             Exit Sub
237         End If
238         If Len(Trim(cmbInstallment.Text)) =
0 Then
239             MessageBox.Show(
"Please select installment", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
240             cmbInstallment.Focus()
241             Exit Sub
242         End If
243         If Len(Trim(txtFine.Text)) =
0 Then
244             MessageBox.Show(
"Please enter fine", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
245             txtFine.Focus()
246             Exit Sub
247         End If
248         If Len(Trim(cmbPaymentMode.Text)) =
0 Then
249             MessageBox.Show(
"Please select Payment Mode", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
250             cmbPaymentMode.Focus()
251             Exit Sub
252         End If
253         If Len(Trim(txtTotalPaid.Text)) =
0 Then
254             MessageBox.Show(
"Please enter total paid", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
255             txtTotalPaid.Focus()
256             Exit Sub
257         End If
258         If Val(txtTotalPaid.Text) <
0 Then
259             MessageBox.Show(
"Total paid must be greater than zero", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
260             txtTotalPaid.Focus()
261             Exit Sub
262         End If
263         If Val(txtBalance.Text) <
0 Then
264             MessageBox.Show(
"Balance is not possible less than zero", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Error)
265             Exit Sub
266         End If
267         Try
268             con = New SqlConnection(cs)
269             con.Open()
270             Dim ct As String =
"select Session,BusHolderID,Installment from BusFeePayment_Staff where Session=@d1 and BusHolderID=@d2 and Installment=@d3"
271             cmd = New SqlCommand(ct)
272             cmd.Connection = con
273             cmd.Parameters.AddWithValue(
"@d1", cmbSession.Text)
274             cmd.Parameters.AddWithValue(
"@d2", txtBusHolderID.Text)
275             cmd.Parameters.AddWithValue(
"@d3", cmbInstallment.Text)
276             rdr = cmd.ExecuteReader()
277             If rdr.Read Then
278                 MessageBox.Show(
"Already paid", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
279                 If Not rdr Is Nothing Then
280                     rdr.Close()
281                 End If
282                 Exit Sub
283             End If
284             auto()
285             con = New SqlConnection(cs)
286             con.Open()
287             Dim cb As String =
"insert into BusFeePayment_Staff(BFP_ID, PaymentID, BusHolderID, Session,installment,TotalFee, DiscountPer, DiscountAmt, PreviousDue, Fine, GrandTotal, TotalPaid, ModeOfPayment, PaymentModeDetails, PaymentDate, PaymentDue) VALUES (@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d8,@d9,@d10,@d11,@d12,@d13,@d14,@d15,@d16)"
288             cmd = New SqlCommand(cb)
289             cmd.Connection = con
290             cmd.Parameters.AddWithValue(
"@d1", txtBFPId.Text)
291             cmd.Parameters.AddWithValue(
"@d2", txtFeePaymentID.Text)
292             cmd.Parameters.AddWithValue(
"@d3", txtBusHolderID.Text)
293             cmd.Parameters.AddWithValue(
"@d4", cmbSession.Text)
294             cmd.Parameters.AddWithValue(
"@d5", cmbInstallment.Text)
295             cmd.Parameters.AddWithValue(
"@d6", txtBusFee.Text)
296             cmd.Parameters.AddWithValue(
"@d7", txtDiscountPer.Text)
297             cmd.Parameters.AddWithValue(
"@d8", txtDiscount.Text)
298             cmd.Parameters.AddWithValue(
"@d9", txtPreviousDue.Text)
299             cmd.Parameters.AddWithValue(
"@d10", txtFine.Text)
300             cmd.Parameters.AddWithValue(
"@d11", txtGrandTotal.Text)
301             cmd.Parameters.AddWithValue(
"@d12", txtTotalPaid.Text)
302             cmd.Parameters.AddWithValue(
"@d13", cmbPaymentMode.Text)
303             cmd.Parameters.AddWithValue(
"@d14", txtPaymentModeDetails.Text)
304             cmd.Parameters.AddWithValue(
"@d15", dtpPaymentDate.Value)
305             cmd.Parameters.AddWithValue(
"@d16", txtBalance.Text)
306             cmd.ExecuteNonQuery()
307             con.Close()
308             Dim st As String =
"added the new bus fee payment entry having payment id '" & txtFeePaymentID.Text & "'"
309             LogFunc(lblUser.Text, st)
310             MessageBox.Show(
"Successfully paid", "Fee", MessageBoxButtons.OK, MessageBoxIcon.Information)
311             btnSave.Enabled = False
312             LedgerSave(dtpPaymentDate.Value.Date, txtStaffName.Text, txtFeePaymentID.Text,
"Bus Fee Payment(Staff)", Val(txtGrandTotal.Text), 0, txtStaffID.Text)
313             If cmbPaymentMode.Text =
"By Cash" Then
314                 LedgerSave(dtpPaymentDate.Value.Date,
"Cash Account", txtFeePaymentID.Text, "Payment", 0, Val(txtTotalPaid.Text), txtStaffID.Text)
315             End If
316             If cmbPaymentMode.Text =
"By Cheque" Or cmbPaymentMode.Text = "By DD" Then
317                 LedgerSave(dtpPaymentDate.Value.Date,
"bank Account", txtFeePaymentID.Text, "Payment", 0, Val(txtTotalPaid.Text), txtStaffID.Text)
318             End If
319             If CheckForInternetConnection() = True Then
320                 con = New SqlConnection(cs)
321                 con.Open()
322                 Dim ctn As String =
"select RTRIM(APIURL) from SMSSetting where IsDefault='Yes' and IsEnabled='Yes'"
323                 cmd = New SqlCommand(ctn)
324                 cmd.Connection = con
325                 rdr = cmd.ExecuteReader()
326                 If rdr.Read() Then
327                     st2 = rdr.GetValue(
0)
328                     Dim st3 As String =
"Hello, " & txtStaffName.Text & " you have successfully paid " & cmbInstallment.Text & " installment of bus fee having Fee Payment ID '" & txtFeePaymentID.Text & "'"
329                     SMSFunc(txtContactNo.Text, st3, st2)
330                     If (rdr IsNot Nothing) Then
331                         rdr.Close()
332                     End If
333                 End If
334             End If
335             Print()
336         Catch ex As Exception
337             MessageBox.Show(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
338         End Try
339     End Sub
340
341     Private Sub btnDelete_Click(sender As System.Object, e As System.EventArgs) Handles btnDelete.Click
342         Try
343             If MessageBox.Show(
"Do you really want to delete the record?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.Yes Then
344                 delete_records()
345             End If
346         Catch ex As Exception
347             MessageBox.Show(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
348         End Try
349     End Sub
350     Private Sub delete_records()
351         Try
352             Dim RowsAffected As Integer =
0
353             con = New SqlConnection(cs)
354             con.Open()
355             Dim cq As String =
"delete from BusFeePayment_Staff where BFP_ID= " & txtBFPId.Text & ""
356             cmd = New SqlCommand(cq)
357             cmd.Connection = con
358             RowsAffected = cmd.ExecuteNonQuery()
359             If RowsAffected >
0 Then
360                 LedgerDelete(txtFeePaymentID.Text,
"Bus Fee Payment(Staff)")
361                 LedgerDelete(txtFeePaymentID.Text,
"Payment")
362                 Dim st As String =
"deleted the bus fee payment entry having payment id '" & txtFeePaymentID.Text & "'"
363                 LogFunc(lblUser.Text, st)
364                 MessageBox.Show(
"Successfully deleted", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information)
365                 Reset()
366                 Reset()
367             Else
368                 MessageBox.Show(
"No record found", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Information)
369                 Reset()
370                 Reset()
371             End If
372             con.Close()
373         Catch ex As Exception
374             MessageBox.Show(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
375         End Try
376     End Sub
377
378     Private Sub btnUpdate_Click(sender As System.Object, e As System.EventArgs) Handles btnUpdate.Click
379         If Len(Trim(txtStaffID.Text)) =
0 Then
380             MessageBox.Show(
"Please retrieve bus holder info", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
381             txtStaffID.Focus()
382             Exit Sub
383         End If
384
385         If Len(Trim(cmbInstallment.Text)) =
0 Then
386             MessageBox.Show(
"Please select installment", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
387             cmbInstallment.Focus()
388             Exit Sub
389         End If
390         If Len(Trim(txtFine.Text)) =
0 Then
391             MessageBox.Show(
"Please enter fine", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
392             txtFine.Focus()
393             Exit Sub
394         End If
395         If Len(Trim(cmbPaymentMode.Text)) =
0 Then
396             MessageBox.Show(
"Please select Payment Mode", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
397             cmbPaymentMode.Focus()
398             Exit Sub
399         End If
400         If Len(Trim(txtTotalPaid.Text)) =
0 Then
401             MessageBox.Show(
"Please enter total paid", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
402             txtTotalPaid.Focus()
403             Exit Sub
404         End If
405         If Val(txtTotalPaid.Text) <
0 Then
406             MessageBox.Show(
"Total paid must be greater than zero", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
407             txtTotalPaid.Focus()
408             Exit Sub
409         End If
410         If Val(txtBalance.Text) <
0 Then
411             MessageBox.Show(
"Balance is not possible less than zero", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Error)
412             Exit Sub
413         End If
414         Try
415             
'con = New SqlConnection(cs)
416             
'con.Open()
417             
'Dim ct As String = "select PaymentDate from BusFeePayment_Staff where AdmissionNo=@d1"
418             
'cmd = New SqlCommand(ct)
419             
'cmd.Connection = con
420             
'cmd.Parameters.AddWithValue("@d1", txtAdmissionNo.Text)
421             
'Dim da As New SqlDataAdapter(cmd)
422             
'Dim ds As DataSet = New DataSet()
423             
'da.Fill(ds)
424             
'If ds.Tables(0).Rows.Count > 0 Then
425             
'If dtpPaymentDate.Value.Date < ds.Tables(0).Rows(0)("PaymentDate") Then
426             
'MessageBox.Show("updating old record is not allowed when student has been already paid fee again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
427             
'End If
428             
'Exit Sub
429             
'End If
430             
'con.Close()
431             con = New SqlConnection(cs)
432             con.Open()
433             Dim cb As String =
"Update BusFeePayment_Staff set BFP_ID=@d1, PaymentID=@d2, BusHolderID=@d3, Session=@d4, Installment=@d5,TotalFee=@d6, DiscountPer=@d7, DiscountAmt=@d8, PreviousDue=@d9, Fine=@d10, GrandTotal=@d11, TotalPaid=@d12, ModeOfPayment=@d13, PaymentModeDetails=@d14,PaymentDue=@d15 where BFP_ID=@d1 "
434             cmd = New SqlCommand(cb)
435             cmd.Connection = con
436             cmd.Parameters.AddWithValue(
"@d1", Val(txtBFPId.Text))
437             cmd.Parameters.AddWithValue(
"@d2", txtFeePaymentID.Text)
438             cmd.Parameters.AddWithValue(
"@d3", txtBusHolderID.Text)
439             cmd.Parameters.AddWithValue(
"@d4", cmbSession.Text)
440             cmd.Parameters.AddWithValue(
"@d5", cmbInstallment.Text)
441             cmd.Parameters.AddWithValue(
"@d6", txtBusFee.Text)
442             cmd.Parameters.AddWithValue(
"@d7", txtDiscountPer.Text)
443             cmd.Parameters.AddWithValue(
"@d8", txtDiscount.Text)
444             cmd.Parameters.AddWithValue(
"@d9", txtPreviousDue.Text)
445             cmd.Parameters.AddWithValue(
"@d10", txtFine.Text)
446             cmd.Parameters.AddWithValue(
"@d11", txtGrandTotal.Text)
447             cmd.Parameters.AddWithValue(
"@d12", txtTotalPaid.Text)
448             cmd.Parameters.AddWithValue(
"@d13", cmbPaymentMode.Text)
449             cmd.Parameters.AddWithValue(
"@d14", txtPaymentModeDetails.Text)
450             cmd.Parameters.AddWithValue(
"@d15", txtBalance.Text)
451             cmd.ExecuteNonQuery()
452             con.Close()
453             LedgerUpdate(dtpPaymentDate.Value.Date, txtStaffName.Text, Val(txtGrandTotal.Text),
0, txtStaffID.Text, txtFeePaymentID.Text, "Bus Fee Payment(Staff)")
454             If cmbPaymentMode.Text =
"By Cash" Then
455                 LedgerUpdate(dtpPaymentDate.Value.Date,
"Cash Account", 0, Val(txtTotalPaid.Text), txtStaffID.Text, txtFeePaymentID.Text, "Payment")
456             End If
457             If cmbPaymentMode.Text =
"By Cheque" Or cmbPaymentMode.Text = "By DD" Then
458                 LedgerUpdate(dtpPaymentDate.Value.Date,
"bank Account", 0, Val(txtTotalPaid.Text), txtStaffID.Text, txtFeePaymentID.Text, "Payment")
459             End If
460             Dim st As String =
"updated the bus fee payment entry having payment id '" & txtFeePaymentID.Text & "'"
461             LogFunc(lblUser.Text, st)
462             MessageBox.Show(
"Successfully updated", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information)
463             btnUpdate.Enabled = False
464             con.Close()
465         Catch ex As Exception
466             MessageBox.Show(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
467         End Try
468     End Sub
469
470     Private Sub txtFine_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtFine.KeyPress
471         Dim keyChar = e.KeyChar
472
473         If Char.IsControl(keyChar) Then
474             
'Allow all control characters.
475         ElseIf Char.IsDigit(keyChar) OrElse keyChar =
"."c Then
476             Dim text = Me.txtFine.Text
477             Dim selectionStart = Me.txtFine.SelectionStart
478             Dim selectionLength = Me.txtFine.SelectionLength
479
480             text = text.Substring(
0, selectionStart) & keyChar & text.Substring(selectionStart + selectionLength)
481
482             If Integer.TryParse(text, New Integer) AndAlso text.Length >
16 Then
483                 
'Reject an integer that is longer than 16 digits.
484                 e.Handled = True
485             ElseIf Double.TryParse(text, New Double) AndAlso text.IndexOf(
"."c) < text.Length - 3 Then
486                 
'Reject a real number with two many decimal places.
487                 e.Handled = False
488             End If
489         Else
490             
'Reject all other characters.
491             e.Handled = True
492         End If
493     End Sub
494
495     Private Sub txtTotalPaid_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtTotalPaid.KeyPress
496         Dim keyChar = e.KeyChar
497
498         If Char.IsControl(keyChar) Then
499             
'Allow all control characters.
500         ElseIf Char.IsDigit(keyChar) OrElse keyChar =
"."c Then
501             Dim text = Me.txtTotalPaid.Text
502             Dim selectionStart = Me.txtTotalPaid.SelectionStart
503             Dim selectionLength = Me.txtTotalPaid.SelectionLength
504
505             text = text.Substring(
0, selectionStart) & keyChar & text.Substring(selectionStart + selectionLength)
506
507             If Integer.TryParse(text, New Integer) AndAlso text.Length >
16 Then
508                 
'Reject an integer that is longer than 16 digits.
509                 e.Handled = True
510             ElseIf Double.TryParse(text, New Double) AndAlso text.IndexOf(
"."c) < text.Length - 3 Then
511                 
'Reject a real number with two many decimal places.
512                 e.Handled = False
513             End If
514         Else
515             
'Reject all other characters.
516             e.Handled = True
517         End If
518     End Sub
519
520     Private Sub txtTotalPaid_Validating(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles txtTotalPaid.Validating
521         If Val(txtTotalPaid.Text) > Val(txtGrandTotal.Text) Then
522             MessageBox.Show(
"Total Pay can not be more than grand total", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
523             txtTotalPaid.Text =
""
524             txtTotalPaid.Focus()
525             Exit Sub
526         End If
527     End Sub
528
529     Private Sub txtFine_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtFine.TextChanged
530         Fill()
531     End Sub
532
533     Private Sub txtTotalPaid_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtTotalPaid.TextChanged
534         Fill()
535     End Sub
536
537     Private Sub btnClose_Click(sender As System.Object, e As System.EventArgs) Handles btnClose.Click
538         Me.Close()
539     End Sub
540
541     Private Sub btnGetData_Click(sender As System.Object, e As System.EventArgs) Handles btnGetData.Click
542         frmBusFeePayment_StaffRecord.lblSet.Text =
"Bus Fee Payment"
543         frmBusFeePayment_StaffRecord.lblUserType.Text = lblUserType.Text
544         frmBusFeePayment_StaffRecord.Reset()
545         frmBusFeePayment_StaffRecord.ShowDialog()
546     End Sub
547     Sub fillInstallment()
548         Try
549             con = New SqlConnection(cs)
550             con.Open()
551             Dim ct As String =
"SELECT distinct RTRIM(Installment) FROM Installment_Bus where Location=@d1"
552             cmd = New SqlCommand(ct)
553             cmd.Parameters.AddWithValue(
"@d1", txtLocation.Text)
554             cmd.Connection = con
555             rdr = cmd.ExecuteReader()
556             cmbInstallment.Items.Clear()
557             While rdr.Read
558                 cmbInstallment.Items.Add(rdr(
0))
559             End While
560             con.Close()
561         Catch ex As Exception
562             MessageBox.Show(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
563         End Try
564     End Sub
565     Private Sub frmBusFeePayment_Staff_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
566         fillInstallment()
567         fillSession()
568     End Sub
569
570     Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
571         Cursor = Cursors.Default
572         Timer1.Enabled = False
573     End Sub
574
575     Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
576         Print()
577     End Sub
578 End Class


Gõ tìm kiếm nhanh...