Exemplo n.º 1
0
        private void btnlog_Click(object sender, EventArgs e)
        {
            if (txtuname.Text == "")
            {
                MessageBox.Show("Please fill in your username");
                txtuname.Focus();
                return;
            }

            /*if (txtpword.Text == "")
             * {
             *  MessageBox.Show("Please fill in your password");
             *  txtpword.Focus();
             *  return;
             * }*/
            else
            {
                con = new MySqlConnection(str);
                string en = encrypt(txtpword.Text);
                string q  = "select*from workers where(Role='" + cborole.Text + "' && Username='******' && Password='******')";
                try
                {
                    con.Open();
                    cmd     = new MySqlCommand(q, con);
                    adapter = new MySqlDataAdapter(cmd);
                    adapter.Fill(dt);
                    if (dt.Rows.Count == 1)
                    {
                        lblmessage.Text = "";
                        MessageBox.Show("Login Successifull");
                        MDImain  mdi = new MDImain();
                        fmmanage frm = new fmmanage(txtuname.Text, cborole.Text);
                        frm.StartPosition = FormStartPosition.CenterScreen;
                        mdi.Show();
                        this.Hide();
                        frm.Show();
                        txtuname.Clear();
                        txtpword.Clear();
                    }
                    else if (dt.Rows.Count > 1)
                    {
                        lblmessage.ForeColor = Color.Red;
                        lblmessage.Text      = "Your account is hacked";
                    }
                    else
                    {
                        lblmessage.ForeColor = Color.Red;
                        lblmessage.Text      = "Wrong Username or Password";
                        txtpword.Clear();
                        return;
                    }
                    con.Close();
                }
                catch (Exception x)
                {
                    MessageBox.Show("Table not found" + x.Message);
                }
            }
        }
Exemplo n.º 2
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     progressBar1.Increment(1);
     if (progressBar1.Value >= 100)
     {
         timer1.Stop();
         MDImain frm = new MDImain();
         frm.Show();
         this.Hide();
     }
 }