Exemplo n.º 1
0
        private void login()
        {
            Task.Delay(30000);
            //MODELO SELECT
            string conexaostr = "Server=den1.mysql2.gear.host; User Id=bdmyschool; password=123456.;database=bdmyschool";

            MySqlConnection conexao = null;

            try
            {
                conexao = new MySqlConnection(conexaostr);
                conexao.Open();
                MySqlCommand comando = new MySqlCommand();
                comando.Connection = conexao;
                //COMANDO SQL
                comando.CommandText = "SELECT email_professor, senha_professor, nome_professor FROM tb_professor WHERE email_professor=@email and senha_professor=@senha";

                //VARIAVEIS
                comando.Parameters.AddWithValue("@email", textBox1.Text);
                comando.Parameters.AddWithValue("@senha", textBox2.Text);

                comando.ExecuteNonQuery();

                MySqlDataReader leitor = comando.ExecuteReader();
                //se há linhas
                if (leitor.HasRows)
                {
                    leitor.Read();
                    nomeprof = leitor.GetString(2);

                    Form home = new Home();
                    home.Closed += (s, args) => this.Close();
                    carregamento.Close();
                    home.Show();
                }
                else
                {
                    carregamento.Hide();
                    this.Show();
                    textBox1.Text = "";
                    textBox2.Text = "";
                    MessageBox.Show("Usuario e/ou senha incorretos");
                }
            }
            finally
            {
                if (conexao != null)
                {
                    conexao.Close();
                }
            }
            //MODELO SELECT
        }
Exemplo n.º 2
0
 private void InfoTactical_KeyDown(object sender, KeyEventArgs e)
 {
     switch (e.KeyCode)
     {
     case Keys.Escape:
     {
         var frm = new Home();
         this.Hide();
         frm.Show();
         break;
     }
     }
 }
Exemplo n.º 3
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            // 아이디 비번 찾는 쿼리문 비밀번호는 MD5암호화 후 전송
            string findCommand = "SELECT count(ID) FROM user WHERE ID='" + idTextBox.Text + "' AND PW='" + MD5HashFunc(pwTextBox.Text) + "';";
            int    cnt         = 0;

            // db접속

            db.connection.Open();

            if (idTextBox.Text.Length > 0)
            {
                if (pwTextBox.Text.Length > 0)
                {
                    // db query 명령어
                    MySqlCommand command = new MySqlCommand(findCommand, db.connection);
                    // 명령어 실행
                    cnt = Convert.ToInt32(command.ExecuteScalar());

                    // 아이디, 비밀번호가 일치하는 컬럼 개수가 0이상이면 성공
                    if (cnt > 0)
                    {
                        // 로그인후 ID를 계속 갖기 위해, user 객체생성(생성자를 통해 ID 넘겨줌)

                        member.set(idTextBox.Text);
                        db.connection.Close();
                        home.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("아이디,비밀번호가 일치하지 않습니다.");
                    }
                }
                else
                {
                    MessageBox.Show("비밀번호를 입력하시오");
                }
            }
            else
            {
                MessageBox.Show("아이디를 입력하시오.");
            }

            db.connection.Close();
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection  cn    = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\Akoch\Documents\Table.mdf; Integrated Security = True; Connect Timeout = 30");
            string         query = "Select * from Login Where UserName ='******' and PassWord ='******' ";
            SqlDataAdapter sda   = new SqlDataAdapter(query, cn);
            DataTable      dt    = new DataTable();

            sda.Fill(dt);

            if (dt.Rows.Count == 1)
            {
                this.Hide();
                Home h = new Home();
                h.Show();
            }
            else
            {
                MessageBox.Show("please check your username and password!");
            }
        }
        private void Button1_Click(object sender, EventArgs e)
        {
            string psw;

            unm = textBox1.Text;
            psw = textBox2.Text;

            manager mn = new manager();
            int     a  = mn.log(unm, psw);

            if (a == 0)
            {
                MessageBox.Show("username password dosent match");
            }
            else
            {
                Home hm = new Home();
                this.Hide();
                hm.Show();
            }
        }
Exemplo n.º 6
0
 private void login_button_Click(object sender, EventArgs e)
 {
     AntiBruteForce++;
     if (AntiBruteForce > 5)
     {
         timer1.Interval = 1000;
         timer1.Start();
         login_button.Enabled   = false;
         login_result.Text      = "You've attemped to Login more than 5 times.";
         login_result.ForeColor = Color.Red;
     }
     else if (Usernames.Contains(login_username.Text))
     {
         StreamReader sr          = new StreamReader(Path_Accounts + login_username.Text + ".txt");
         string[]     Identifiers = sr.ReadLine().Split(' ');
         if (login_password.Text == Identifiers[1])
         {
             UsernameLogged         = login_username.Text;
             login_username.Text    = "";
             login_password.Text    = "";
             login_checkbox.Checked = false;
             login_password.UseSystemPasswordChar = true;
             login_checkbox.Text = "Show";
             Home Home = new Home();
             Hide();
             Home.Show();
         }
         else
         {
             login_result.Text      = "Password incorrect.";
             login_result.ForeColor = Color.Red;
         }
     }
     else
     {
         login_result.Text      = "Username or password incorrect.";
         login_result.ForeColor = Color.Red;
     }
 }
Exemplo n.º 7
0
        private void bttnSubmit_Click(object sender, EventArgs e)
        {
            Functionality.ValidateLogin valid = new Functionality.ValidateLogin();
            string User        = txtbxUser.Text;
            string Password    = txtbxPWD.Text;
            int    permissions = valid.Validation(User, Password);

            if (permissions > 0)
            {
                //  Validate Valid = new Validate();//testing Database
                //Home next = new Home();
                Home next = new Home();
                next.Show();
                next.name(User);
                next.logName("logout");
                //  Valid.ConnectDB(User, Password);//testing Database
                this.Hide();
            }
            else
            {
                txtError.Visible = true;
            }
        }
        private void btnIngreso_Click(object sender, EventArgs e)
        {
            try
            {
                //creando la conexion
                SqlConnection miConecion = new SqlConnection("Data Source=.;Initial Catalog=HorasExtrasLacteosOsorno;Integrated Security=True;MultipleActiveResultSets=True;");
                //abriendo conexion
                miConecion.Open();

                SqlCommand comando = new SqlCommand("select Usuario, Clave, Seccion, TipoUsuario from Usuarios where Usuario = '" + txtUsuario.Text + "'And Clave = '" + txtContraseña.Text + "'And Seccion = '" + cbxArea.Text + "'And TipoUsuario = '" + cbxTipoUsuario + "' ", miConecion);

                //ejecuta una instruccion de sql devolviendo el numero de las filas afectadas
                comando.ExecuteNonQuery();
                DataSet        ds = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter(comando);

                //Llenando el dataAdapter
                da.Fill(ds, "HorasExtrasLacteosOsorno");
                //utilizado para representar una fila de la tabla q necesitas en este caso usuario
                DataRow DR;
                DR = ds.Tables["Usuarios"].Rows[0];

                //evaluando que la contraseña,usuario y area sean correctos
                if ((txtUsuario.Text == DR["Usuario"].ToString()) || (txtContraseña.Text == DR["Clave"].ToString()) || (cbxArea.Text == DR["Seccion"].ToString()) || (cbxTipoUsuario.Text == DR["TipoUsuario"].ToString()))
                {
                    //instanciando el formulario principal
                    Home frmPrincipal = new Home();
                    frmPrincipal.Show(); //abriendo el formulario principal
                    this.Hide();         //esto sirve para ocultar el formulario de login
                }
            }
            catch
            {
                MessageBox.Show("Error! Su usuario o contraseña es incorrecta", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 9
0
        //private void Welcome_Load(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        cn.Open();
        //        string qry = "SELECT Role FROM Auth";
        //        SqlDataReader dr = new SqlCommand(qry, cn).ExecuteReader();
        //        while (dr.Read())
        //        {
        //            cbox.Items.Add(dr.GetValue(0).ToString());
        //        }
        //        dr.Close();
        //    }
        //    catch (SqlException x)
        //    {
        //        MessageBox.Show(x.Message);
        //    }
        //    cn.Close();

        //}

        private void Submit_Click(object sender, EventArgs e)
        {
            try
            {
                if (attempt == 0)
                {
                    lbl_Msg.Text = ("ALL 3 ATTEMPTS HAVE FAILED - CONTACT ADMIN");
                    tb1.Enabled  = false;
                    tb2.Enabled  = false;
                    tb1.Clear();
                    tb2.Clear();
                    return;
                }
                cmd = new SqlCommand("select count(*) from Auth where login=@login and pass=@pass", cn);
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@login", tb1.Text);
                cmd.Parameters.AddWithValue("@pass", tb2.Text);
                cn.Open();

                if (cmd.ExecuteScalar().ToString() == "1")
                {
                    errorlogin.Icon = Properties.Resources.ok;
                    errorlogin.SetError(tb1, "تم");
                    errorpass.Icon = Properties.Resources.ok;
                    errorpass.SetError(tb2, "تم");
                    MessageBox.Show(" تم الدخول بنجاح ");
                    this.Hide();
                    var sh = new Home(tb1.Text + "  :مرحبا  ");
                    sh.Closed += (s, args) => this.Close();
                    sh.Show();
                }

                //    cmd SelectCommand = new MySqlCommand("Select role form Auth", cn);
                //    DataTable dt = new DataTable();
                //    sda.Fill(dt);
                //    if (dt.Rows.Count == 1)
                //    {
                //        this.Hide();
                //        var sh = new Home(tb1.Text + "  :مرحبا  ");
                //        sh.Closed += (s, args) => this.Close();
                //        sh.Show();
                //    }else
                //    {
                //        this.Hide();
                //        var sh1 = new Home1(tb1.Text + "  :مرحبا  ");
                //        sh1.Closed += (s, args) => this.Close();
                //        sh1.Show();
                //    }
                //}

                else
                {
                    errorlogin.Icon = Properties.Resources.err;
                    errorlogin.SetError(tb1, "خطأ في اسم المستخدم");
                    errorpass.Icon = Properties.Resources.err;
                    errorpass.SetError(tb2, "خطأ في  كلمة المرور");
                    MessageBox.Show("  لا يمكن الدخول \n الرجاء اعادة اسم المستخدم و كلمة السر ");
                    lbl_Msg.Text = (" لديك فقط  " + Convert.ToString(attempt) + "  محاولات للاعادة ");
                    --attempt;
                    tb1.Clear();
                    tb2.Clear();
                }
                cn.Close();
            }
            catch
            {
                //nothing here
            }
        }