on this page i am checking whether the username,password,wardno,electionid are matching with the one in DB.
if they are matching then i am checking whether the stat is voted.
if it is voted then i am giving a alert message that you have already voted.
if they(username,password,wardno,electionid) are not matching then i am giving a alert message "invalid entry".
i am having a user named krishna
he has already voted
so instead of showing you have already voted it is showing invalid entry.
please tel the necessary changes to be done
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class signin : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlCommand cmd = new SqlCommand("select * from users", con);
cmd.ExecuteNonQuery();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string uname = reader["UserName"].ToString();
string pwd = reader["Password"].ToString();
string wno = reader["WardNo"].ToString();
string eid = reader["ElectionId"].ToString();
string stat = reader["Status"].ToString();
if (uname == TextBox1.Text && pwd == TextBox2.Text && eid == TextBox3.Text && wno == DropDownList1.Text)
{
Session["name"] = TextBox1.Text;
Session["pass"] = TextBox2.Text;
if (stat == "Voted")
{
string script = "window.onload = function() { alert('You Have Already Voted!'); }";
ClientScript.RegisterStartupScript(this.GetType(), "alert", script, true);
}
else if (DropDownList1.Text == "171")
{
Response.Redirect("wardno171.aspx?ab=" + TextBox3.Text);
}
else
{
Response.Redirect("wardno180.aspx?ab=" + TextBox3.Text);
}
}
else
{
string script = "window.onload = function() { alert('Invalid Entry!'); }";
ClientScript.RegisterStartupScript(this.GetType(), "alert", script, true);
}
}
}
}