private void home_addpanel_Click(object sender, EventArgs e)
        {
            slidepanel3.Height = home_addpanel.Height;
            slidepanel3.Top    = home_addpanel.Top;

            this.Hide();
            Admincs ad = new Admincs();

            ad.Show();
        }
        private void homepage_rep_Click(object sender, EventArgs e)
        {
            slidepanel2.Height = homepage_rep.Height;
            slidepanel2.Top    = homepage_rep.Top;

            this.Hide();
            Admincs ad = new Admincs();

            ad.Show();
        }
Пример #3
0
        private void login_button_Click(object sender, EventArgs e)
        {
            //DataTable dta = new DataTable();
            SqlDataAdapter sda = new SqlDataAdapter();

            sda.SelectCommand = new SqlCommand("select * from login where Username= @un and Password =@pswd", con);
            sda.SelectCommand.Parameters.AddWithValue("@un", name.Text);
            sda.SelectCommand.Parameters.AddWithValue("@pswd", pass.Text);
            SqlDataReader reader;

            try
            {
                con.Open();
                //sda.Fill(dta);
                reader = sda.SelectCommand.ExecuteReader();
                int count = 0;

                while (reader.Read())
                {
                    count = count + 1;
                }
                //if (dta.Rows.Count == 1)
                if (count == 1)
                {
                    //MessageBox.Show("Login Successfully", "Congrats", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Hide();
                    Admincs ad = new Admincs();
                    ad.Show();
                }
                else if (count > 1)
                {
                    MessageBox.Show("Duplicate Username or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    name.Text     = "";
                    pass.Text     = "";
                    error.Visible = true;
                    name.Focus();
                }
                con.Close();
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message.ToString());
            }
        }