Exemplo n.º 1
0
        private void mem_Login_Click(object sender, EventArgs e)
        {
            // Open database to look for correct ID and password.
            // The branch and ID is Saved for all other forms.
            if ((member_Id.TextLength > 0) && (member_pw.TextLength > 0))
            {
                string email, pw;

                SqlConnection sq = new SqlConnection();
                sq.ConnectionString = "Data Source=DESKTOP-863JJKV;Initial Catalog=Project;Integrated Security=True";
                SqlCommand cmd = new SqlCommand("select * from [Members] where email=@username and Password=@password ", sq);
                cmd.Parameters.AddWithValue("@username", member_Id.Text);
                cmd.Parameters.AddWithValue("@password", member_pw.Text);
                sq.Open();
                SqlDataReader sq_reader = cmd.ExecuteReader();

                bool match = false;


                while ((sq_reader.Read()))
                {
                    email = sq_reader["email"].ToString();
                    pw    = sq_reader["Password"].ToString();

                    if ((member_Id.Text.Trim() == email.Trim()) && (member_pw.Text.Trim() == pw.Trim()))
                    {
                        match     = true;
                        member_ID = Convert.ToInt32(sq_reader["ID"]);
                        branch_ID = Convert.ToInt32(sq_reader["Branch_ID"]);
                        MessageBox.Show("Successful log-in!");
                        // Passing both these objects for Branch and ID
                        Member_login member = new Member_login(home, this);
                        member.Show();
                        this.Close();
                    }
                }
                // If none found.
                if (!match)
                {
                    MessageBox.Show("Incorrect credentials, Try again!");
                    home.Show();
                    this.Close();
                    sq_reader.Close();
                    sq.Close();
                }
            }
        }
Exemplo n.º 2
0
        public Packages(Member_login me)
        {
            member = me;
            InitializeComponent();

            SqlConnection sq      = new SqlConnection("Data Source=DESKTOP-863JJKV;Initial Catalog=Project;Integrated Security=True");
            SqlCommand    command = new SqlCommand();

            sq.Open();
            command.CommandText = "select p.ID,p.Package_Type,p.Package_Name,p.Package_Detail,p.Price from Packages p inner join Branches b on b.ID=p.Branch_ID where b.ID = 1";
            command.Connection  = sq;

            DataSet        ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(command);

            da.Fill(ds);
            package_view.DataSource = ds;
            package_view.DataMember = ds.Tables[0].ToString();
        }
Exemplo n.º 3
0
        public Rating(int m, int b, Member_login me)
        {
            member    = me;
            member_id = m;
            b_id      = b;
            InitializeComponent();

            SqlConnection sq      = new SqlConnection("Data Source=DESKTOP-863JJKV;Initial Catalog=Project;Integrated Security=True");
            SqlCommand    command = new SqlCommand();

            sq.Open();
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "your_trainers";
            command.Connection  = sq;
            command.Parameters.AddWithValue("@branch_id", b_id);

            DataSet        ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(command);

            da.Fill(ds);
            trainer_view.DataSource = ds;
            trainer_view.DataMember = ds.Tables[0].ToString();
        }
Exemplo n.º 4
0
        public Schedule(Member_login me, int b)
        {
            member = me;
            branch = b;
            InitializeComponent();


            SqlConnection sq      = new SqlConnection("Data Source=DESKTOP-863JJKV;Initial Catalog=Project;Integrated Security=True");
            SqlCommand    command = new SqlCommand();


            sq.Open();
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "class_show";
            command.Connection  = sq;
            command.Parameters.AddWithValue("@branch_id", branch);

            DataSet        ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(command);

            da.Fill(ds);
            schdeule_view.DataSource = ds;
            schdeule_view.DataMember = ds.Tables[0].ToString();
        }