Coding For Gym Software
Coding For Gym Software
vb 1
Imports System.Data.SqlClient
Imports System.Drawing.Printing
Imports Excel = Microsoft.Office.Interop.Excel
''Sum of Column
'Dim total As Double = 0
'For i As Integer = 0 To MembershipsDataGridView.RowCount - 1
' total += MembershipsDataGridView.Rows(i).Cells(4).Value
'Next
'txtBlMsPoints.Text = total
'APPLICATION STARTUP
'TAB-1 CORE
Private Sub frmMainPage_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Members()
'TODO: This line of code loads data into the 'CoreDataSet.invsettings' table. You can move, or
remove it, as needed.
Me.InvsettingsTableAdapter.Fill(Me.CoreDataSet.invsettings)
Me.Inv_Settings_Readonly()
'TODO: This line of code loads data into the 'CoreDataSet.invoice' table. You can move, or
remove it, as needed.
Me.InvoiceTableAdapter.Fill(Me.CoreDataSet.invoice)
'TODO: This line of code loads data into the 'CoreDataSet.products' table. You can move, or
remove it, as needed.
Me.ProductsTableAdapter.Fill(Me.CoreDataSet.products)
'TODO: This line of code loads data into the 'CoreDataSet.tax' table. You can move, or remove it
, as needed.
Me.TaxTableAdapter.Fill(Me.CoreDataSet.tax)
'TODO: This line of code loads data into the 'ProgramsDataSet1.programs' table. You can move, or
remove it, as needed.
Me.ProgramsTableAdapter1.Fill(Me.ProgramsDataSet1.programs)
'TODO: This line of code loads data into the 'MpmsDataSet2.memberships' table. You can move, or
remove it, as needed.
' Me.MembershipsTableAdapter1.Fill(Me.MpmsDataSet2.memberships)
'TODO: This line of code loads data into the 'CoreDataSet1.assessments' table. You can move, or
remove it, as needed.
Me.AssessmentsTableAdapter1.Fill(Me.CoreDataSet1.assessments)
''TODO: This line of code loads data into the 'CoreDataSet.programs' table. You can move, or
remove it, as needed.
'Me.ProgramsTableAdapter.Fill(Me.CoreDataSet.programs)
''TODO: This line of code loads data into the 'CoreDataSet.assessments' table. You can move, or
remove it, as needed.
'Me.AssessmentsTableAdapter.Fill(Me.CoreDataSet.assessments)
'TODO: This line of code loads data into the 'CoreDataSet.memberships' table. You can move, or
remove it, as needed.
Me.MembershipsTableAdapter.Fill(Me.CoreDataSet.memberships)
Me.MembershipsBindingSource.AddNew()
'Total Membership
Dim rowcount As Integer
rowcount = MembershipsDataGridView2.BindingContext(MembershipsDataGridView2.DataSource,
MembershipsDataGridView2.DataMember).Count.ToString
txtTotalMembership.Text = rowcount
'Total Members
E:\My Files\VB Projects\Back Up\CORE FITNESS\Testings\core-05122015-test5\core\Form1.vb 2
Dim totalmem As Integer
totalmem = MembersDataGridView.BindingContext(MembersDataGridView.DataSource,
MembersDataGridView.DataMember).Count.ToString
txtTotalMembers.Text = totalmem
btnInvPrintPreview.Enabled = False
'Methods
Me.StPd_readonly()
Me.StPr_Readonly()
Me.StTax_Readonly()
'User Entry
txtUser.Text = "Admin"
End Sub
'TAB-2 MEMBERS
Private Sub tpMembers_Enter(sender As System.Object, e As System.EventArgs) Handles tpMembers.Enter
Me.member_readonly()
'If txtUser.Text = "Admin" Then
' btnUpdate.Enabled = False
' btnUpdatedSave.Enabled = False
'End If
End Sub
ElseIf cbMemSearchby.Text = "MsP <" Then 'Coding to Filter Less than specified Membership
Points
Try
Me.MembersBindingSource.Filter = "pincode <= '" & txtMemSearchCriteria.Text & "'"
Catch ex As Exception
MsgBox("Error in Search by Ms Point" & ex.Message)
End Try
ElseIf cbMemSearchby.Text = "MsP >" Then 'Coding to Filter More than specified Membership
Points
Try
Me.MembersBindingSource.Filter = "pincode >= '" & txtMemSearchCriteria.Text & "'"
Catch ex As Exception
MsgBox("Error in Search by Ms Point" & ex.Message)
End Try
End If
End Sub
Catch ex As Exception
MessageBox.Show("Error in saving Assessment : " & ex.Message)
End Try
Catch ex As Exception
MessageBox.Show("Error in adding New Member : " & ex.Message)
End Try 'Closing Members Insert Try
End If 'Closing count IF Statement
AssessmentsDataGridView.FirstDisplayedScrollingRowIndex = AssessmentsDataGridView.Rows.Count - 1
MembersDataGridView.FirstDisplayedScrollingRowIndex = MembersDataGridView.Rows.Count - 1 'To
scroll down position of Dategrid view
End Sub
height = Convert.ToDecimal(txtMemHeight.Text)
weight = Convert.ToDecimal(txtMemWeight.Text)
bmi = Format(weight / (height * height), "0.00")
txtMemBmi.Text = bmi
'TAB-3 MEMBERSHIPS
Private Sub tpMembership_Click(sender As System.Object, e As System.EventArgs) Handles tpMembership.
Enter
'Total Membership
Dim Total_Ms_count As Integer = Me.MembershipsBindingSource.Count
txtMsTotalMs.Text = Total_Ms_count
Try
Dim Ms_Active_con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|
DataDirectory|\core.mdf;Integrated Security=True;User Instance=True")
'Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=E:\My Files\VB
Projects\core\core\core.mdf;Integrated Security=True;User Instance=True")
Ms_Active_con.Open()
Dim ActiveMscmd As New SqlCommand("SELECT COUNT(*) FROM memberships WHERE end_date> '" &
Today & "'", Ms_Active_con)
E:\My Files\VB Projects\Back Up\CORE FITNESS\Testings\core-05122015-test5\core\Form1.vb 11
Dim PaidMscmd As New SqlCommand("SELECT COUNT(*) FROM memberships WHERE end_date> '" & Today
& "' and payment_status= 'Paid'", Ms_Active_con)
Dim NotPaidMscmd As New SqlCommand("SELECT COUNT(*) FROM memberships WHERE end_date> '" &
Today & "' and payment_status= 'Not Paid'", Ms_Active_con)
Dim CancelledMscmd As New SqlCommand("SELECT COUNT(*) FROM memberships WHERE end_date> '" &
Today & "' and payment_status= 'Cancelled'", Ms_Active_con)
Dim ActiveMscount, PaidMscount, NotPaidMscount, CancelledMscount As Integer
'Active Members
ActiveMscount = ActiveMscmd.ExecuteScalar()
txtMsActiveMs.Text = ActiveMscount
'Paid Members
PaidMscount = PaidMscmd.ExecuteScalar()
txtMsPaidMs.Text = PaidMscount
'Not Paid Members
NotPaidMscount = NotPaidMscmd.ExecuteScalar()
txtMsNotPaidMs.Text = NotPaidMscount
'Cancelled Members
CancelledMscount = CancelledMscmd.ExecuteScalar()
txtMsCancelledMs.Text = CancelledMscount
Catch ex As Exception
MsgBox("MS Details Error :" & ex.Message)
End Try
End Sub
End If
Catch ex As Exception
MsgBox("Payment Status Sorting Failure" & ex.Message)
End Try
End Sub
'3.1 Not in Use
Private Sub SortbyEndDateToolStripButton_Click(sender As System.Object, e As System.EventArgs)
Try
Me.MembershipsTableAdapter.SortbyEndDate(Me.CoreDataSet.memberships)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
End Sub
'TAB-4 ASSESSMENTS
Private Sub AS_Read()
txtAsFatPercentage.ReadOnly = False
txtAsHeight.ReadOnly = False
txtAsWeight.ReadOnly = False
cbAsActivity.Enabled = True
dtpAsDate.Enabled = True
End Sub
btnAsAddNew.BringToFront()
lblAsAsDetails.Visible = True
txtAsAsDetails.Visible = True
txtAsName.BringToFront()
txtAsMemId.BringToFront()
txtAsGender.BringToFront()
Me.AS_Readonly()
End Sub
height = Convert.ToDecimal(txtAsHeight.Text)
weight = Convert.ToDecimal(txtAsWeight.Text)
bmi = Format(weight / (height * height), "0.00")
txtAsBmi.Text = bmi
End Sub
'TAB-5 BILLING
'5.0 Generate Invoice
Private Sub BillClear()
txtBlAmount1.Clear()
txtBlAmount2.Clear()
txtBlAmount3.Clear()
txtBlDesc1.Clear()
txtBlDesc2.Clear()
txtBlDesc3.Clear()
txtBlL1DiscAmt.Clear()
txtBlL1TaxAmt.Clear()
txtBlL2DiscAmt.Clear()
txtBlL2TaxAmt.Clear()
txtBlL3DiscAmt.Clear()
txtBlL3TaxAmt.Clear()
txtBlMemFullAddress.Clear()
txtBlMemId.Clear()
txtBlMemMobile.Clear()
txtBlMemName.Clear()
txtBlQty1.Clear()
txtBlQty2.Clear()
txtBlQty3.Clear()
txtBlRate1.Clear()
txtBlRate2.Clear()
txtBlRate3.Clear()
txtBlTax1.Clear()
txtBlTax2.Clear()
txtBlTax3.Clear()
txtBlTaxPercentage1.Clear()
txtBlTaxPercentage2.Clear()
txtBlTaxPercentage3.Clear()
txtBlTotal.Clear()
txtBlTotalTax.Clear()
txtBlTotalMs.Clear()
txtBlWordTotal.Clear()
txtBlInvNo.Clear()
E:\My Files\VB Projects\Back Up\CORE FITNESS\Testings\core-05122015-test5\core\Form1.vb 17
txtBlInvUser.Clear()
txtBlInvTime.Clear()
dtpBlInvDate.Value = Today
dtpBlMsStartDate.Value = Today
dtpBlMsEndDate.Value = Today
cbBlType1.Text = ""
cbBlType2.Text = ""
cbBlType3.Text = ""
cbBlDisc1.Text = ""
cbBlDisc2.Text = ""
cbBlDisc3.Text = ""
'cbBlMsPaymentStatus.Text = ""
End Sub
End Sub
Try
Me.MembershipsTableAdapter.FillByMemId(Me.CoreDataSet.memberships, txtBlMemId.Text)
Catch ex As System.Exception
MsgBox("Please Insert Value to Search")
End Try
'Sum of Column
Dim total As Double = 0
For i As Integer = 0 To MembershipsDataGridView.RowCount - 1
total += MembershipsDataGridView.Rows(i).Cells(4).Value
Next
E:\My Files\VB Projects\Back Up\CORE FITNESS\Testings\core-05122015-test5\core\Form1.vb 18
txtBlTotalMs.Text = total
txtBlMemId.Enabled = False
cbBlType1.Enabled = True
Catch ex As Exception
MsgBox("Error in getting value from Member ID")
End Try
End If
End Sub
End Sub
Try
'TO CALCULATE MS WE NEED-PROGRAM AMT,DISCOUNT,AMOUNT
Dim Rate, Disc, DisAmt, Amt As Decimal
Rate = txtBlRate1.Text
Disc = cbBlDisc1.Text
DisAmt = (Rate / 100) * Disc
txtBlL1DiscAmt.Text = DisAmt
Amt = Format((Rate - DisAmt), "0.00")
txtBlAmount1.Text = Amt
Catch ex As Exception
MessageBox.Show("Hey, " & txtUser.Text & "! Check the value you have entered" &
vbNewLine & vbNewLine & "Invalid : " & ex.Message)
End Try
Try
'TO CALCULATE PD WE NEED-PRODUCT AMT, QTY, DISC, TAX, AMOUNT
Dim Rate, Qty, Disc, DisAmt, DisRate, Tax, TaxAmt, Amt As Decimal
Rate = txtBlRate1.Text
Qty = txtBlQty1.Text
Disc = cbBlDisc1.Text
Tax = txtBlTaxPercentage1.Text
DisAmt = (Rate / 100) * Disc
DisRate = (Rate - DisAmt) * Qty
txtBlL1DiscAmt.Text = DisAmt
TaxAmt = (DisRate / 100) * Tax
txtBlL1TaxAmt.Text = TaxAmt
Amt = Format((DisRate + TaxAmt), "0.00")
txtBlAmount1.Text = Amt
Catch ex As Exception
MessageBox.Show("Hey, " & txtUser.Text & "! Check the value you have entered" &
vbNewLine & vbNewLine & "Invalid : " & ex.Message)
End Try
End If
Else
MsgBox("Hey, " & txtUser.Text & "! Already Amount Generated." & vbNewLine & vbNewLine & "If
you want to edit, start from the beginning...")
cbBlType1.Text = ""
txtBlDesc1.Clear()
txtBlRate1.Clear()
txtBlQty1.Clear()
cbBlDisc1.Text = ""
txtBlTax1.Clear()
txtBlTaxPercentage1.Clear()
txtBlAmount1.Clear()
cbBlDisc1.Enabled = True
txtBlQty1.ReadOnly = False
txtBlTax1.ReadOnly = False
txtBlTaxPercentage1.ReadOnly = False
End If
E:\My Files\VB Projects\Back Up\CORE FITNESS\Testings\core-05122015-test5\core\Form1.vb 21
End Sub
Try
'TO CALCULATE MS WE NEED-PROGRAM AMT,DISCOUNT,AMOUNT
Dim Rate, Disc, DisAmt, Amt As Decimal
Rate = txtBlRate2.Text
Disc = cbBlDisc2.Text
DisAmt = (Rate / 100) * Disc
txtBlL2DiscAmt.Text = DisAmt
Amt = Format((Rate - DisAmt), "0.00")
txtBlAmount2.Text = Amt
Catch ex As Exception
MessageBox.Show("Hey, " & txtUser.Text & "! Check the value you have entered" &
vbNewLine & vbNewLine & "Invalid : " & ex.Message)
End Try
Try
'TO CALCULATE PD WE NEED-PRODUCT AMT, QTY, DISC, TAX, AMOUNT
Dim Rate, Qty, Disc, DisAmt, DisRate, Tax, TaxAmt, Amt As Decimal
Rate = txtBlRate2.Text
Qty = txtBlQty2.Text
Disc = cbBlDisc2.Text
Tax = txtBlTaxPercentage2.Text
DisAmt = (Rate / 100) * Disc
txtBlL2DiscAmt.Text = DisAmt
DisRate = (Rate - DisAmt) * Qty
TaxAmt = (DisRate / 100) * Tax
txtBlL2TaxAmt.Text = TaxAmt
Amt = Format((DisRate + TaxAmt), "0.00")
txtBlAmount2.Text = Amt
Catch ex As Exception
MessageBox.Show("Hey, " & txtUser.Text & "! Check the value you have entered" &
vbNewLine & vbNewLine & "Invalid : " & ex.Message)
End Try
End If
Else
MsgBox("Hey, " & txtUser.Text & "! Already Amount Generated." & vbNewLine & vbNewLine & "If
you want to edit, start from the beginning...")
E:\My Files\VB Projects\Back Up\CORE FITNESS\Testings\core-05122015-test5\core\Form1.vb 22
cbBlType2.Text = ""
txtBlDesc2.Clear()
txtBlRate2.Clear()
txtBlQty2.Clear()
cbBlDisc2.Text = ""
txtBlTax2.Clear()
txtBlTaxPercentage2.Clear()
txtBlAmount2.Clear()
cbBlDisc2.Enabled = True
txtBlQty2.ReadOnly = False
txtBlTax2.ReadOnly = False
txtBlTaxPercentage2.ReadOnly = False
End If
End Sub
Try
'TO CALCULATE MS WE NEED-PROGRAM AMT,DISCOUNT,AMOUNT
Dim Rate, Disc, DisAmt, Amt As Decimal
Rate = txtBlRate3.Text
Disc = cbBlDisc3.Text
DisAmt = (Rate / 100) * Disc
txtBlL3DiscAmt.Text = DisAmt
Amt = Format((Rate - DisAmt), "0.00")
txtBlAmount3.Text = Amt
Catch ex As Exception
MessageBox.Show("Hey, " & txtUser.Text & "! Check the value you have entered" &
vbNewLine & vbNewLine & "Invalid : " & ex.Message)
End Try
Try
'TO CALCULATE PD WE NEED-PRODUCT AMT, QTY, DISC, TAX, AMOUNT
Dim Rate, Qty, Disc, DisAmt, DisRate, Tax, TaxAmt, Amt As Decimal
Rate = txtBlRate3.Text
Qty = txtBlQty3.Text
Disc = cbBlDisc3.Text
Tax = txtBlTaxPercentage3.Text
DisAmt = (Rate / 100) * Disc
txtBlL3DiscAmt.Text = DisAmt
DisRate = (Rate - DisAmt) * Qty
TaxAmt = (DisRate / 100) * Tax
txtBlL3TaxAmt.Text = TaxAmt
E:\My Files\VB Projects\Back Up\CORE FITNESS\Testings\core-05122015-test5\core\Form1.vb 23
Amt = Format((DisRate + TaxAmt), "0.00")
txtBlAmount3.Text = Amt
Catch ex As Exception
MessageBox.Show("Hey, " & txtUser.Text & "! Check the value you have entered" &
vbNewLine & vbNewLine & "Invalid : " & ex.Message)
End Try
End If
Else
MsgBox("Hey, " & txtUser.Text & "! Already Amount Generated." & vbNewLine & vbNewLine & "If
you want to edit, start from the beginning...")
cbBlType3.Text = ""
txtBlDesc3.Clear()
txtBlRate3.Clear()
txtBlQty3.Clear()
cbBlDisc3.Text = ""
txtBlTax3.Clear()
txtBlTaxPercentage3.Clear()
txtBlAmount3.Clear()
cbBlDisc3.Enabled = True
txtBlQty3.ReadOnly = False
txtBlTax3.ReadOnly = False
txtBlTaxPercentage3.ReadOnly = False
End If
End Sub
'CALCULATING TOTAL
Try
Dim Line1, Line2, Line3, Total As Decimal
Catch ex As Exception
MessageBox.Show("Hey, " & txtUser.Text & "!" & vbNewLine & vbNewLine & "Invalid :" & ex.
Message)
End Try
cbBlMsPaymentStatus.Enabled = True
End Sub
Try
Dim intAmount As Long = nAmount
If intAmount > 0 Then
nSet = IIf((intAmount.ToString.Trim.Length / 3) _
> (CLng(intAmount.ToString.Trim.Length / 3)), _
CLng(intAmount.ToString.Trim.Length / 3) + 1, _
CLng(intAmount.ToString.Trim.Length / 3))
Dim eAmount As Long = Microsoft.VisualBasic.Left(intAmount.ToString.Trim, _
(intAmount.ToString.Trim.Length - ((nSet - 1) * 3)))
Dim multiplier As Long = 10 ^ (((nSet - 1) * 3))
intAmount = eAmount
cbBlDisc1.Enabled = True
txtBlQty1.ReadOnly = False
txtBlTax1.ReadOnly = False
txtBlTaxPercentage1.ReadOnly = False
cbBlDisc2.Enabled = True
txtBlQty2.ReadOnly = False
txtBlTax2.ReadOnly = False
txtBlTaxPercentage2.ReadOnly = False
cbBlDisc3.Enabled = True
txtBlQty3.ReadOnly = False
txtBlTax3.ReadOnly = False
txtBlTaxPercentage3.ReadOnly = False
'MsgBox("Invoice Successfully Saved")
Catch ex As Exception
MessageBox.Show("Error in Generating Invoice: " & ex.Message)
End Try
'Updating Ms Points
Dim PMsP, MsPv, TMsP As Double 'Previous Membership Points (PmsP), Membership Points Value
(MsPv), Total Membership Points (TMsP)
MsPv = txtBlMsPoints.Text
PMsP = txtBlTotalMs.Text
TMsP = MsPv + PMsP
Try
Dim update_member As String = "UPDATE members SET state=@state WHERE id=@id"
Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\core
.mdf;Integrated Security=True;User Instance=True")
'Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=E:\My Files\VB
Projects\core\core\core.mdf;Integrated Security=True;User Instance=True")
con.Open()
Dim cmd As New SqlCommand(update_member, con)
cmd.Parameters.Add("@id", SqlDbType.Int, 50).Value = txtBlMemId.Text
E:\My Files\VB Projects\Back Up\CORE FITNESS\Testings\core-05122015-test5\core\Form1.vb 29
cmd.Parameters.Add("@state", SqlDbType.NText, 50).Value = TMsP
cmd.ExecuteNonQuery()
con.Close()
Catch ex As Exception
MessageBox.Show("Error during update of member Info : " & ex.Message)
End Try
End Sub
'5.0.1 Invoice Printing
Private Sub pdocInvoice_PrintPage(sender As System.Object, e As System.Drawing.Printing.
PrintPageEventArgs) Handles pdocInvoice.PrintPage
'Fonts Used in Invoice
Dim myfont As New Font("Book Antiqua", 10)
Dim myfon As New Font("Book Antiqua", 8)
Dim myfor As New Font("Book Antiqua", 6)
Dim mytitle As New Font("Franklin Gothic Heavy", 20)
e.Graphics.PageUnit = GraphicsUnit.Inch
End Sub
'Print
pdiaInvoice.Document = pdocInvoice 'open the print preview'PrintDialog associate with
PrintDocument.
If pdiaInvoice.ShowDialog() = DialogResult.OK Then
pdocInvoice.Print()
btnBlSaveInvoice.PerformClick()
E:\My Files\VB Projects\Back Up\CORE FITNESS\Testings\core-05122015-test5\core\Form1.vb 32
Me.BillClear()
End If
End Sub
'5.1 Search Invoice
Private Sub btnBlInvoice_Click(sender As System.Object, e As System.EventArgs) Handles btnBlInvoice.
Click
gbBlInvoice.BringToFront()
btnBlSearchInvoice.BringToFront()
btnBlReset.Visible = True
End Sub
e.Graphics.PageUnit = GraphicsUnit.Inch
End Sub
End Sub
'TAB-7 SETTINGS
'Settings Navigation
Private Sub llblStInvoice_LinkClicked(sender As System.Object, e As System.Windows.Forms.
LinkLabelLinkClickedEventArgs) Handles llblStInvoice.LinkClicked
gbStInvoice.BringToFront()
End Sub
End Class