TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
PK Singh
NA
165
14.6k
this is Visual Basic code any one convert in C# pleas help
Feb 11 2021 5:49 AM
this is Visual Basic code
any on convert in C#
Imports System.Data.SqlClient
Imports System.Data
Imports System.Text
Public Class frmFeeHeads
Dim objDAl As New DataAccessLayer
'Dim FID As Integer
Dim FeeHeadID As Integer
Shadows Validated As New Validations()
Dim sqlcon As SqlConnection = objDAl.Connection()
Public Sub LoadFeeHeads()
Dim dtFeeHeads As New DataTable
dtFeeHeads = objDAl.FillDataTable_Query("Select * from mstFeeHead")
dgvFeeHeads.DataSource = dtFeeHeads
dgvFeeHeads.Columns.Item(0).Visible = False
For m As Integer = 4 To 15
dgvFeeHeads.Columns.Item(m).Visible = False
Next
For i As Integer = 0 To dgvFeeHeads.Columns.Count - 1
dgvFeeHeads.Columns.Item(i).SortMode = DataGridViewColumnSortMode.NotSortable
dgvFeeHeads.Columns(i).Width = 124
Next
End Sub
Public Function InsertFeeHead(ByVal procedurename As String) As Boolean
Dim arr(,) As String = {{"January", 0}, {"Februry", 0}, {"March", 0}, {"April", 0}, {"May", 0}, {"June", 0}, {"July", 0}, {"August", 0}, {"September", 0}, {"October", 0}, {"November", 0}, {"December", 0}}
Dim flag As Boolean = False
Try
Dim sqlcon As SqlConnection = objDAl.Connection()
Dim sqlcmd As New SqlCommand(procedurename, sqlcon)
sqlcmd.CommandType = CommandType.Text
If rbtnMonthly.Checked = True Then
If chklbMonth.GetItemChecked(3) Then
arr(3, 1) = 1
End If
If chklbMonth.GetItemChecked(4) Then
arr(4, 1) = 1
End If
If chklbMonth.GetItemChecked(5) Then
arr(5, 1) = 1
End If
If chklbMonth.GetItemChecked(6) Then
arr(6, 1) = 1
End If
If chklbMonth.GetItemChecked(7) Then
arr(7, 1) = 1
End If
If chklbMonth.GetItemChecked(8) Then
arr(8, 1) = 1
End If
If chklbMonth.GetItemChecked(9) Then
arr(9, 1) = 1
End If
If chklbMonth.GetItemChecked(10) Then
arr(10, 1) = 1
End If
If chklbMonth.GetItemChecked(11) Then
arr(11, 1) = 1
End If
If chklbMonth.GetItemChecked(0) Then
arr(0, 1) = 1
End If
If chklbMonth.GetItemChecked(1) Then
arr(1, 1) = 1
End If
If chklbMonth.GetItemChecked(2) Then
arr(2, 1) = 1
End If
Dim counter As Integer = 0
For i As Integer = 0 To chklbMonth.Items.Count - 1
If chklbMonth.GetItemCheckState(i) Then
counter = counter + 1
End If
Next
If counter <> 12 Then
MsgBox("Select all Months!!!!!!!!!")
Exit Function
End If
ElseIf rbtnQuarterly.Checked = True Then
If chklbMonth.GetItemChecked(3) Then
arr(3, 1) = 1
End If
If chklbMonth.GetItemChecked(4) Then
arr(4, 1) = 1
End If
If chklbMonth.GetItemChecked(5) Then
arr(5, 1) = 1
End If
If chklbMonth.GetItemChecked(6) Then
arr(6, 1) = 1
End If
If chklbMonth.GetItemChecked(7) Then
arr(7, 1) = 1
End If
If chklbMonth.GetItemChecked(8) Then
arr(8, 1) = 1
End If
If chklbMonth.GetItemChecked(9) Then
arr(9, 1) = 1
End If
If chklbMonth.GetItemChecked(10) Then
arr(10, 1) = 1
End If
If chklbMonth.GetItemChecked(11) Then
arr(11, 1) = 1
End If
If chklbMonth.GetItemChecked(0) Then
arr(0, 1) = 1
End If
If chklbMonth.GetItemChecked(1) Then
arr(1, 1) = 1
End If
If chklbMonth.GetItemChecked(2) Then
arr(2, 1) = 1
End If
Dim counter As Integer = 0
For i As Integer = 0 To chklbMonth.Items.Count - 1
If chklbMonth.GetItemCheckState(i) Then
counter = counter + 1
End If
Next
If counter <> 4 Then
MsgBox("Select any 4 Months!!!!!!!!!")
Exit Function
End If
ElseIf rbtnHalfYearly.Checked = True Then
If chklbMonth.GetItemChecked(3) Then
arr(3, 1) = 1
End If
If chklbMonth.GetItemChecked(4) Then
arr(4, 1) = 1
End If
If chklbMonth.GetItemChecked(5) Then
arr(5, 1) = 1
End If
If chklbMonth.GetItemChecked(6) Then
arr(6, 1) = 1
End If
If chklbMonth.GetItemChecked(7) Then
arr(7, 1) = 1
End If
If chklbMonth.GetItemChecked(8) Then
arr(8, 1) = 1
End If
If chklbMonth.GetItemChecked(9) Then
arr(9, 1) = 1
End If
If chklbMonth.GetItemChecked(10) Then
arr(10, 1) = 1
End If
If chklbMonth.GetItemChecked(11) Then
arr(11, 1) = 1
End If
If chklbMonth.GetItemChecked(0) Then
arr(0, 1) = 1
End If
If chklbMonth.GetItemChecked(1) Then
arr(1, 1) = 1
End If
If chklbMonth.GetItemChecked(2) Then
arr(2, 1) = 1
End If
Dim counter As Integer = 0
For i As Integer = 0 To chklbMonth.Items.Count - 1
If chklbMonth.GetItemCheckState(i) Then
counter = counter + 1
End If
Next
If counter <> 2 Then
MsgBox("Select any two Months!!!!!!!!!")
Exit Function
End If
ElseIf rbtnVariant.Checked = True Then
If chklbMonth.GetItemChecked(3) Then
arr(3, 1) = 1
End If
If chklbMonth.GetItemChecked(4) Then
arr(4, 1) = 1
End If
If chklbMonth.GetItemChecked(5) Then
arr(5, 1) = 1
End If
If chklbMonth.GetItemChecked(6) Then
arr(6, 1) = 1
End If
If chklbMonth.GetItemChecked(7) Then
arr(7, 1) = 1
End If
If chklbMonth.GetItemChecked(8) Then
arr(8, 1) = 1
End If
If chklbMonth.GetItemChecked(9) Then
arr(9, 1) = 1
End If
If chklbMonth.GetItemChecked(10) Then
arr(10, 1) = 1
End If
If chklbMonth.GetItemChecked(11) Then
arr(11, 1) = 1
End If
If chklbMonth.GetItemChecked(0) Then
arr(0, 1) = 1
End If
If chklbMonth.GetItemChecked(1) Then
arr(1, 1) = 1
End If
If chklbMonth.GetItemChecked(2) Then
arr(2, 1) = 1
End If
Dim counter As Integer = 0
For i As Integer = 0 To chklbMonth.Items.Count - 1
If chklbMonth.GetItemCheckState(i) Then
counter = counter + 1
End If
Next
If counter = 0 Then
MsgBox("Select atleast any one Month!!!!!!!!")
Exit Function
End If
ElseIf rbtnAnually.Checked = True Then
If chklbMonth.GetItemChecked(3) Then
arr(3, 1) = 1
End If
If chklbMonth.GetItemChecked(4) Then
arr(4, 1) = 1
End If
If chklbMonth.GetItemChecked(5) Then
arr(5, 1) = 1
End If
If chklbMonth.GetItemChecked(6) Then
arr(6, 1) = 1
End If
If chklbMonth.GetItemChecked(7) Then
arr(7, 1) = 1
End If
If chklbMonth.GetItemChecked(8) Then
arr(8, 1) = 1
End If
If chklbMonth.GetItemChecked(9) Then
arr(9, 1) = 1
End If
If chklbMonth.GetItemChecked(10) Then
arr(10, 1) = 1
End If
If chklbMonth.GetItemChecked(11) Then
arr(11, 1) = 1
End If
If chklbMonth.GetItemChecked(0) Then
arr(0, 1) = 1
End If
If chklbMonth.GetItemChecked(1) Then
arr(1, 1) = 1
End If
If chklbMonth.GetItemChecked(2) Then
arr(2, 1) = 1
End If
Dim counter As Integer = 0
For i As Integer = 0 To chklbMonth.Items.Count - 1
If chklbMonth.GetItemCheckState(i) Then
counter = counter + 1
End If
Next
If counter <> 1 Then
MsgBox("Select any one Month!!!!!!!!")
Exit Function
End If
End If
sqlcmd.Parameters.Add("@FeeHeadName", SqlDbType.VarChar).Value = txtNameofHead.Text.Trim()
If rbtnRefundable.Checked = True Then
sqlcmd.Parameters.Add("@TypeofHead", SqlDbType.VarChar).Value = "Refundable"
Else
sqlcmd.Parameters.Add("@TypeofHead", SqlDbType.VarChar).Value = "NonRefundable"
End If
If rbtnAnually.Checked = True Then
sqlcmd.Parameters.Add("@Frequency", SqlDbType.VarChar).Value = "Annualy"
ElseIf rbtnHalfYearly.Checked = True Then
sqlcmd.Parameters.Add("@Frequency", SqlDbType.VarChar).Value = "Half Yearly"
ElseIf rbtnQuarterly.Checked = True Then
sqlcmd.Parameters.Add("@Frequency", SqlDbType.VarChar).Value = "Quarterly"
ElseIf rbtnMonthly.Checked = True Then
sqlcmd.Parameters.Add("@Frequency", SqlDbType.VarChar).Value = "Monthly"
ElseIf rbtnVariant.Checked = True Then
sqlcmd.Parameters.Add("@Frequency", SqlDbType.VarChar).Value = "Variant"
End If
sqlcmd.Parameters.Add("@January", SqlDbType.VarChar).Value = (arr(0, 1))
sqlcmd.Parameters.Add("@February", SqlDbType.VarChar).Value = (arr(1, 1))
sqlcmd.Parameters.Add("@March", SqlDbType.VarChar).Value = (arr(2, 1))
sqlcmd.Parameters.Add("@April", SqlDbType.VarChar).Value = (arr(3, 1))
sqlcmd.Parameters.Add("@May", SqlDbType.VarChar).Value = (arr(4, 1))
sqlcmd.Parameters.Add("@June", SqlDbType.VarChar).Value = (arr(5, 1))
sqlcmd.Parameters.Add("@July", SqlDbType.VarChar).Value = (arr(6, 1))
sqlcmd.Parameters.Add("@August", SqlDbType.VarChar).Value = (arr(7, 1))
sqlcmd.Parameters.Add("@September", SqlDbType.VarChar).Value = (arr(8, 1))
sqlcmd.Parameters.Add("@October", SqlDbType.VarChar).Value = (arr(9, 1))
sqlcmd.Parameters.Add("@November", SqlDbType.VarChar).Value = (arr(10, 1))
sqlcmd.Parameters.Add("@December", SqlDbType.VarChar).Value = (arr(11, 1))
sqlcon.Open()
Dim rowAffected As Integer = sqlcmd.ExecuteNonQuery()
MsgBox("Fee Head is Saved Successfully!!!")
sqlcon.Close()
sqlcon.Dispose()
flag = True
Return flag
Catch ex As Exception
flag = False
MsgBox("Error in Saving. Select Relevant Information !!!", MsgBoxStyle.Exclamation)
Return flag
End Try
End Function
Public Sub DisplayFeeHead()
Dim dt As New DataTable()
dt = objDAl.FillDataTable_Query("Select * From mstFeeHead")
dgvFeeHeads.DataSource = dt
End Sub
Public Function DeleteFeeHead(ByVal procedurename As String) As Boolean
Dim flag As Boolean = False
Try
Dim sqlcon As SqlConnection = objDAl.Connection
Dim sqlcmd As New SqlCommand(procedurename, sqlcon)
sqlcmd.CommandType = CommandType.Text
sqlcmd.Parameters.Add("@FeeHeadID", SqlDbType.Int).Value = FeeHeadID
sqlcon.Open()
Dim rowaffected As Integer = sqlcmd.ExecuteNonQuery()
sqlcmd.Dispose()
sqlcon.Close()
MsgBox("Fee Head is Successfully Deleted")
flag = True
Return flag
Catch ex As SqlException
If (ex.Number = 547) Then
MsgBox("This Fee Head cannot be deleted. Please Delete Allocated Fee Plans and Students first!!", MsgBoxStyle.Exclamation)
Return flag
End If
Catch ex As Exception
MsgBox("Unsuccessful")
Return flag
End Try
End Function
Private Sub frmFeeHeads_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.MdiParent = MainForm
Me.Dock = DockStyle.Fill
Me.Location = New Point(0, 0)
LoadFeeHeads()
btnDelete.Enabled = False
btnCreate.Enabled = False
rbtnAnually.Checked = False
rbtnHalfYearly.Checked = False
rbtnMonthly.Checked = False
rbtnQuarterly.Checked = False
rbtnNonRefundable.Checked = False
rbtnRefundable.Checked = False
btnCreate.Enabled = True
btnDelete.Enabled = False
rbtnVariant.Checked = False
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
MainForm.objOpenedForm = New Form()
End Sub
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
Dim str As New StringBuilder
str.Append(Validated.Validate(txtNameofHead, True, Validated.StringAll, "NameofHead"))
If str.Length <> 0 Then
MessageBox.Show(str.ToString())
Return
End If
Dim cmd As New SqlCommand("Select FeeHeadName from mstFeeHead where FeeHeadName=@FeeHeadName", sqlcon)
cmd.Parameters.Add("@FeeHeadName", SqlDbType.VarChar).Value = txtNameofHead.Text.Trim()
Dim dt As New DataTable
Dim adp As New SqlDataAdapter(cmd)
adp.Fill(dt)
If dt.Rows.Count Then
MsgBox("Fee Head Name is already existed!!!!!")
Clear()
Exit Sub
End If
InsertFeeHead("insert into mstFeeHead([FeeHeadName],[TypeofHead],[Frequency],[January],[February],[March],[April],[May],[June],[July],[August],[September],[October],[November],[December]) values (@FeeHeadName,@TypeofHead,@Frequency,@January,@February,@March,@April,@May,@June,@July,@August,@September,@October,@November,@December)")
LoadFeeHeads()
txtNameofHead.Text = ""
rbtnAnually.Checked = False
rbtnHalfYearly.Checked = False
rbtnMonthly.Checked = False
rbtnQuarterly.Checked = False
rbtnNonRefundable.Checked = False
rbtnRefundable.Checked = False
rbtnVariant.Checked = False
btnCreate.Enabled = False
For i As Integer = 0 To chklbMonth.Items.Count - 1
chklbMonth.SetItemCheckState(i, CheckState.Unchecked)
Next
txtNameofHead.Focus()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
Dim msgresult As MsgBoxResult = MsgBox("Do you really want to delete!!!!", MsgBoxStyle.YesNo)
If msgresult = MsgBoxResult.Yes Then
DeleteFeeHead(" delete from mstFeeHead where FeeHeadID=@FeeHeadID")
End If
LoadFeeHeads()
txtNameofHead.Text = Nothing
rbtnAnually.Checked = False
rbtnHalfYearly.Checked = False
rbtnMonthly.Checked = False
rbtnQuarterly.Checked = False
rbtnNonRefundable.Checked = False
rbtnRefundable.Checked = False
rbtnVariant.Checked = False
btnDelete.Enabled = False
btnCreate.Enabled = False
For i As Integer = 0 To chklbMonth.Items.Count - 1
chklbMonth.SetItemCheckState(i, CheckState.Unchecked)
Next
txtNameofHead.Focus()
End Sub
Private Sub dgvFeeHeads_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvFeeHeads.CellDoubleClick
If dgvFeeHeads.RowCount > 0 Then
btnDelete.Enabled = True
btnCreate.Enabled = False
For index As Integer = 0 To chklbMonth.Items.Count - 1
chklbMonth.SetItemChecked(index, False)
Next
FeeHeadID = dgvFeeHeads.CurrentRow.Cells("FeeHeadID").Value
txtNameofHead.Text = dgvFeeHeads.CurrentRow.Cells("FeeHeadName").Value
If dgvFeeHeads.CurrentRow.Cells("Frequency").Value.ToString() = "Quarterly" Then
rbtnQuarterly.Checked = True
ElseIf dgvFeeHeads.CurrentRow.Cells("Frequency").Value.ToString() = "Half Yearly" Then
rbtnHalfYearly.Checked = True
ElseIf dgvFeeHeads.CurrentRow.Cells("Frequency").Value.ToString() = "Annualy" Then
rbtnAnually.Checked = True
ElseIf dgvFeeHeads.CurrentRow.Cells("Frequency").Value.ToString() = "Monthly" Then
rbtnMonthly.Checked = True
ElseIf dgvFeeHeads.CurrentRow.Cells("Frequency").Value.ToString() = "Variant" Then
rbtnVariant.Checked = True
End If
If dgvFeeHeads.CurrentRow.Cells("TypeofHead").Value.ToString().Trim() = "Refundable" Then
rbtnRefundable.Checked = True
End If
If dgvFeeHeads.CurrentRow.Cells("TypeofHead").Value.ToString().Trim() = "NonRefundable" Then
rbtnNonRefundable.Checked = True
End If
If dgvFeeHeads.CurrentRow.Cells("January").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(0, True)
End If
If dgvFeeHeads.CurrentRow.Cells("February").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(1, True)
End If
If dgvFeeHeads.CurrentRow.Cells("March").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(2, True)
End If
If dgvFeeHeads.CurrentRow.Cells("April").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(3, True)
End If
If dgvFeeHeads.CurrentRow.Cells("May").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(4, True)
End If
If dgvFeeHeads.CurrentRow.Cells("June").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(5, True)
End If
If dgvFeeHeads.CurrentRow.Cells("July").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(6, True)
End If
If dgvFeeHeads.CurrentRow.Cells("August").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(7, True)
End If
If dgvFeeHeads.CurrentRow.Cells("September").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(8, True)
End If
If dgvFeeHeads.CurrentRow.Cells("October").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(9, True)
End If
If dgvFeeHeads.CurrentRow.Cells("November").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(10, True)
End If
If dgvFeeHeads.CurrentRow.Cells("December").Value.ToString() = "True" Then
chklbMonth.SetItemChecked(11, True)
End If
btnCreate.Enabled = False
End If
End Sub
Private Sub txtNameofHead_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtNameofHead.TextChanged
btnCreate.Enabled = True
End Sub
Private Sub txtNameofHead_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtNameofHead.KeyDown
If e.KeyCode = Keys.Enter Then
rbtnMonthly.Focus()
End If
End Sub
Private Sub rbtnMonthly_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles rbtnMonthly.KeyDown
If e.KeyCode = Keys.Down Then
rbtnQuarterly.Focus()
End If
End Sub
Private Sub rbtnQuarterly_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles rbtnQuarterly.KeyDown
If e.KeyCode = Keys.Enter Then
rbtnHalfYearly.Focus()
End If
End Sub
Private Sub rbtnHalfYearly_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles rbtnHalfYearly.KeyDown
If e.KeyCode = Keys.Enter Then
rbtnAnually.Focus()
End If
End Sub
Private Sub rbtnAnually_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles rbtnAnually.KeyDown
If e.KeyCode = Keys.Enter Then
rbtnVariant.Focus()
End If
End Sub
Private Sub rbtnVariant_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles rbtnVariant.KeyDown
If e.KeyCode = Keys.Enter Then
chklbMonth.Focus()
End If
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
Clear()
txtNameofHead.Focus()
End Sub
Private Sub Clear()
For index As Integer = 0 To chklbMonth.Items.Count - 1
chklbMonth.SetItemChecked(index, False)
Next
txtNameofHead.Text = ""
rbtnAnually.Checked = False
rbtnHalfYearly.Checked = False
rbtnMonthly.Checked = False
rbtnQuarterly.Checked = False
rbtnNonRefundable.Checked = False
rbtnRefundable.Checked = False
rbtnVariant.Checked = False
btnCreate.Enabled = True
btnDelete.Enabled = False
End Sub
Private Sub rbtnRefundable_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles rbtnRefundable.KeyDown
If e.KeyCode = Keys.Down Then
rbtnNonRefundable.Focus()
End If
End Sub
Private Sub rbtnNonRefundable_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles rbtnNonRefundable.KeyDown
If e.KeyCode = Keys.Down Then
rbtnRefundable.Focus()
End If
End Sub
Private Sub frmFeeHeads_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyValue = 27 Then
Me.Close()
MainForm.objOpenedForm = New Form()
End If
End Sub
End Class
Reply
Answers (
3
)
Powerpoint presentation using c#
Asp.Net core Equivalent for SqlCacheDependency