Ejemplo n.º 1
0
        private void label3_Click(object sender, EventArgs e)
        {
            int login = 0;

            using (SqlConnection con = new SqlConnection(Properties.Settings.Default.Mess))

            {
                con.Open();
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandText = "SELECT Count(*) FROM Users WHERE Email='" + NameText.Text + "' and Password='******'";
                SqlDataReader read = cmd.ExecuteReader();
                while (read.Read())
                {
                    login = Convert.ToInt32(read[0]);
                }
                con.Close();
            }
            if (login == 1)
            {
                /*-----------------------------------------------------------------------------*/
                using (SqlConnection con = new SqlConnection(Properties.Settings.Default.Mess))
                {
                    con.Open();
                    SqlCommand cmd1 = con.CreateCommand();
                    cmd1.CommandText = "SELECT id FROM Users WHERE Email='" + NameText.Text + "' ";
                    SqlDataReader rader1 = cmd1.ExecuteReader();
                    while (rader1.Read())
                    {
                        TEST = rader1["id"].ToString();
                    }
                    con.Close();

                    con.Open();
                    SqlCommand cmd2 = con.CreateCommand();
                    cmd2.CommandText = "SELECT FirstName FROM Users WHERE id = '" + TEST + "' ";
                    SqlDataReader rader2 = cmd2.ExecuteReader();
                    while (rader2.Read())
                    {
                        nam = rader2["FirstName"].ToString();
                    }

                    con.Close();
                }
                /*-----------------------------------------------------------------------------*/

                BigShaq1 BigShaq1 = new BigShaq1(this);
                BigShaq1.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Не правильный логин или пароль");
            }
        }
Ejemplo n.º 2
0
 private void label3_Click(object sender, EventArgs e)
 {
     try
     {
         user = userDAO.GetUser(NameText.Text, passwordText.Text);
         BigShaq1 BigShaq1 = new BigShaq1(user);
         BigShaq1.Show();
         this.Hide();
     }
     catch
     {
         MessageBox.Show("Не правильный логин или пароль");
     }
 }