private void button1_Click(object sender, EventArgs e)
        {
            frm_menu fm = new frm_menu();

            fm.Show();
            this.Close();
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.TextLength == 0)
            {
                errorProvider1.SetError(textBox1, "Enter Username");
            }
            else
            {
                errorProvider1.Clear();
            }

            if (textBox2.TextLength == 0)
            {
                errorProvider2.SetError(textBox2, "Enter Password");
            }
            else
            {
                errorProvider2.Clear();
            }

            if (textBox1.TextLength != 0 && textBox2.TextLength != 0)
            {
                try
                {
                    sc.Open();
                    SqlDataAdapter sda = new SqlDataAdapter("select count(*) from log where u_nsme ='" + textBox1.Text + "'and pass = '******' ", sc);
                    DataTable      dt  = new DataTable();
                    sda.Fill(dt);
                    if (dt.Rows[0][0].ToString() == "1")
                    {
                        //MessageBox.Show("hari");
                        frm_menu fm = new frm_menu();
                        fm.Show();

                        textBox1.Clear();
                        textBox2.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Please Check Your Username & Password", " Warning !!! ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    sc.Close();
                }


                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (textBox2.TextLength != 0 && textBox1.TextLength != 0)
            {
                MessageBox.Show("Password or username incorrect", " Warning !!! ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }