Protected Sub btnSubmit_click(ByVal sender As Object, ByVal e As EventArgs)
Dim empid As String = Session("Emp")
Dim ip As String = HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")
'lblID.Text = ip
Dim clientMachineName As String
clientMachineName = (Dns.GetHostEntry(Request.ServerVariables("remote_addr")).HostName)
For Each item As RepeaterItem In RepterDetails.Items
Dim Chkbox As CheckBox = TryCast(item.FindControl("CheckBox1"), CheckBox)
Dim lblProduct As Label = CType(item.FindControl("lblComment"), Label)
Dim product As String = lblProduct.Text
Dim subgroup As Label = CType(item.FindControl("Label1"), Label)
Dim subgroup_id As String = subgroup.Text
Dim FooterTemplate As Control = RepterDetails.Controls(RepterDetails.Controls.Count - 1).Controls(0)
Dim lblFooter As CheckBox = TryCast(FooterTemplate.FindControl("CheckBox2"), CheckBox)
If lblFooter IsNot Nothing AndAlso lblFooter.Checked Then
Response.Write(Chkbox.Text)
con.Open()
cmd = New SqlCommand("insert into Vote_CMT (Employee_ID,Group_ID,SubGroup_ID,IP_Address,Name_pc,Candidate_ID) values(@Employee_ID,@group_id,@subgroup_id,@ip,@pc_name,'0')", con)
cmd.Parameters.Clear()
cmd.Parameters.Add("@Employee_ID", SqlDbType.VarChar).Value = empid.ToString()
cmd.Parameters.Add("@candidate_id", SqlDbType.VarChar).Value = Chkbox.Text.ToString()
cmd.Parameters.Add("@group_id", SqlDbType.VarChar).Value = lblProduct.Text.ToString()
cmd.Parameters.Add("@subgroup_id", SqlDbType.VarChar).Value = subgroup.Text.ToString()
cmd.Parameters.Add("@ip", SqlDbType.VarChar).Value = ip
cmd.Parameters.Add("@pc_name", SqlDbType.VarChar).Value = clientMachineName
cmd.ExecuteNonQuery()
con.Close()
Exit For
ElseIf Chkbox IsNot Nothing AndAlso Chkbox.Checked Then
Response.Write(Chkbox.Text)
con.Open()
cmd = New SqlCommand("insert into Vote_CMT (Employee_ID,Group_ID,SubGroup_ID,IP_Address,Name_pc,Candidate_ID) values('" & empid & "',@group_id,@subgroup_id,@ip,@pc_name,@candidate_id)", con)
cmd.Parameters.Clear()
cmd.Parameters.Add("@candidate_id", SqlDbType.VarChar).Value = Chkbox.Text.ToString()
cmd.Parameters.Add("@group_id", SqlDbType.VarChar).Value = lblProduct.Text.ToString()
cmd.Parameters.Add("@subgroup_id", SqlDbType.VarChar).Value = subgroup.Text.ToString()
cmd.Parameters.Add("@ip", SqlDbType.VarChar).Value = ip
cmd.Parameters.Add("@pc_name", SqlDbType.VarChar).Value = clientMachineName
cmd.ExecuteNonQuery()
con.Close()
End If
Next
Updateuser_vote((Session("Emp")))
Response.Redirect("success.aspx")
'Server.Transfer("success.aspx", False)
'BindRepeater()
End Sub
Tag : .NET, Ms SQL Server 2012, Web (ASP.NET), VB.NET, C#