示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            con.Open();
            String s = "select count(*) from aadhaar where UID='" + uidtextbox.Text + "';";

            cmd = new SqlCommand(s, con);
            dr1 = cmd.ExecuteReader();
            dr1.Read();
            if (dr1[0].Equals(1))
            {
                dr1.Close();
                String syn = "select password from aadhaar where UID='" + uidtextbox.Text + "';";
                cmd1 = new SqlCommand(syn, con);
                dr2  = cmd1.ExecuteReader();
                dr2.Read();
                String UIDpass = dr2[0].ToString();
                String pass    = passwordtextbox.Text;
                dr2.Close();
                if (pass.Equals(UIDpass))
                {
                    String str = "select count(*) from Eligible_For where UID='" + uidtextbox.Text + "';";
                    cmd2 = new SqlCommand(str, con);
                    dr3  = cmd2.ExecuteReader();
                    dr3.Read();
                    String i = dr3[0].ToString();
                    int    j = Convert.ToInt32(i);
                    dr3.Close();
                    if (j > 0)
                    {
                        Eligible obe = new Eligible(uidtextbox.Text);
                        this.Hide();
                        obe.Show();
                    }
                    else
                    {
                        Services observ = new Services(uidtextbox.Text.ToString());
                        this.Hide();
                        observ.Show();
                    }
                }

                else
                {
                    // don't login
                    MessageBox.Show("Log In Failed.Invalid Credentials!");
                }
            }
            else
            {
                // don't login
                MessageBox.Show("Log In Failed.Invalid Credentials!");
            }
            con.Close();
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                con.Open();
                String s = "select count(*) from Eligible_for where UID='" + UID + "';";
                c   = new SqlCommand(s, con);
                dr4 = c.ExecuteReader();
                dr4.Read();
                if (dr4[0].Equals(0))
                {
                    dr4.Close();
                    comnd = new SqlCommand("SELECT DOB,Annual_Income,Occupation from PAN where UID =@UID; ", con);
                    comnd.Parameters.AddWithValue("@UID", UID);
                    dr1 = comnd.ExecuteReader();
                    dr1.Read();
                    String   AnnualIncome = dr1[1].ToString();
                    String   Occupation   = dr1[2].ToString();
                    int      income       = Int32.Parse(AnnualIncome);
                    String   DOB          = dr1[0].ToString();
                    DateTime newDate      = Convert.ToDateTime(DOB);
                    int      age          = CalculateAge(newDate);
                    dr1.Close();

                    cmd2 = new SqlCommand("SELECT Gender from Aadhaar where UID =@UID; ", con);
                    cmd2.Parameters.AddWithValue("@UID", UID);
                    dr3 = cmd2.ExecuteReader();
                    dr3.Read();
                    String gender = dr3[0].ToString();
                    dr3.Close();
                    String        code = "0000";
                    StringBuilder sb   = new StringBuilder(code);
                    if (income < 500000)
                    {
                        sb[0] = '1';
                    }
                    else
                    {
                        sb[0] = '2';
                    }

                    if (age <= 18)
                    {
                        sb[1] = '1';
                    }
                    else
                    {
                        sb[1] = '2';
                    }
                    switch (Occupation)
                    {
                    case "Student": sb[2] = '1'; break;

                    case "Business": sb[2] = '2'; break;

                    case "Housewife": sb[2] = '3'; break;

                    case "Entrepreneur": sb[2] = '4'; break;

                    case "Agriculture": sb[2] = '5'; break;

                    case "Employed": sb[2] = '6'; break;

                    case "Unemployed": sb[2] = '7'; break;

                    case "Retired": sb[2] = '8'; break;
                    }
                    if (gender.Equals("Male"))
                    {
                        sb[3] = '1';
                    }
                    else
                    {
                        sb[3] = '2';
                    }


                    if (sb[1] == '2')
                    {
                        c1 = new SqlCommand("Insert into ELIGIBLE_FOR values('" + UID + "','10521');", con);
                        c1.ExecuteNonQuery();
                        c2 = new SqlCommand("Insert into ELIGIBLE_FOR values('" + UID + "','10591');", con);
                        c2.ExecuteNonQuery();
                    }
                    if (sb[0] == '1' && sb[1] == '2')
                    {
                        c3 = new SqlCommand("Insert into ELIGIBLE_FOR values('" + UID + "','10531');", con);
                        c3.ExecuteNonQuery();
                        c4 = new SqlCommand("Insert into ELIGIBLE_FOR values('" + UID + "','10551');", con);
                        c4.ExecuteNonQuery();
                    }
                    if (sb[1] == '1' && sb[3] == '2')
                    {
                        c5 = new SqlCommand("Insert into ELIGIBLE_FOR values('" + UID + "','10541');", con);
                        c5.ExecuteNonQuery();
                        c6 = new SqlCommand("Insert into ELIGIBLE_FOR values('" + UID + "','10611');", con);
                        c6.ExecuteNonQuery();
                    }
                    if (sb[2] == '5')
                    {
                        c7 = new SqlCommand("Insert into ELIGIBLE_FOR values('" + UID + "','10561');", con);
                        c7.ExecuteNonQuery();
                        c8 = new SqlCommand("Insert into ELIGIBLE_FOR values('" + UID + "','10581');", con);
                        c8.ExecuteNonQuery();
                    }
                    if (sb[2] == '4')
                    {
                        c9 = new SqlCommand("Insert into ELIGIBLE_FOR values('" + UID + "','10571');", con);
                        c9.ExecuteNonQuery();
                    }
                    if (sb[0] == '1' && sb[2] == '1')
                    {
                        c10 = new SqlCommand("Insert into ELIGIBLE_FOR values('" + UID + "','10621');", con);
                        c10.ExecuteNonQuery();
                    }
                    if (sb[1] == '1' && sb[2] == '1')
                    {
                        c11 = new SqlCommand("Insert into ELIGIBLE_FOR values('" + UID + "','10631');", con);
                        c11.ExecuteNonQuery();
                    }
                }


                Eligible obj5 = new Eligible(UID);
                this.Hide();
                obj5.Show();
            }
            catch (System.Exception excp)
            {
                MessageBox.Show("Error is :" + excp);
                con.Close();
            }
        }