private void Btn_Viewdetails_Click(object sender, EventArgs e)
        {
            employeegrid eg = new employeegrid();

            eg.Show();
            this.Hide();
        }
Пример #2
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            string Password = string.IsNullOrWhiteSpace(txt_Password.Text).ToString();

            if (string.IsNullOrWhiteSpace(txt_UserName.Text))
            {
                string Username = txt_UserName.Text;
            }
            if (!string.IsNullOrWhiteSpace(txt_Password.Text))
            {
                SqlConnection  conn = new SqlConnection("Server=ATMECSINLT-698\\SQLEXPRESS;database=db;Trusted_connection=true;");
                SqlCommand     cmd  = new SqlCommand("SELECT * from Registration WHERE Username='******' and Password='******'", conn);
                SqlDataAdapter da   = new SqlDataAdapter(cmd);
                DataTable      dt   = new DataTable();
                da.Fill(dt);
                // checking whether datatable has any rows or not
                if (dt.Rows.Count == 1)
                {
                    employeegrid ed = new employeegrid();
                    ed.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Enter valid username and password");
                }
            }
        }