예제 #1
0
        private void btn_update_Click(object sender, EventArgs e)
        {
            con.Close();
            phone = txt_phone.Text;
            email = txt_email.Text;

            //to call stored procedure
            SqlCommand cmd = new SqlCommand("edit_data", con);

            cmd.CommandType = CommandType.StoredProcedure;
            //pass value
            cmd.Parameters.AddWithValue("@phone", phone);
            cmd.Parameters.AddWithValue("@email", email);
            cmd.Parameters.AddWithValue("@username", user);
            //exeute
            con.Open();
            cmd.ExecuteNonQuery();
            MessageBox.Show("Data updated");
            lbl_fullname uh = new lbl_fullname();

            uh.ShowDialog();
        }
예제 #2
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            username = txt_username.Text;
            u        = username;
            password = txt_password.Text;
            if (username == "admin" && password == "admin")
            {
                Admin_home ahome = new Admin_home();
                this.Hide();
                ahome.Show();
            }
            else
            {
                //sql coonection
                SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=productmanage;Integrated Security=true");
                //to call stored procedure
                SqlCommand cmd = new SqlCommand("logindata", con);
                cmd.CommandType = CommandType.StoredProcedure;
                //pass values
                cmd.Parameters.AddWithValue("@username", username);
                cmd.Parameters.AddWithValue("@password", password);
                //execute stored procedure
                con.Open();
                int i = (int)cmd.ExecuteScalar();
                if (i > 0)
                {
                    lbl_fullname ahom = new lbl_fullname();
                    this.Hide();
                    ahom.Show();
                }


                else
                {
                    MessageBox.Show("Invalid username&password");
                }
            }
        }