private void btn_Browse_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            foreach (Member m in MemberDB.GetMembers())
            {
                //put each genre object into a datagridview row object
                DataGridViewRow newRow = new DataGridViewRow();

                //creates cells using dataGridView1 as a template
                newRow.CreateCells(dataGridView1);
                newRow.Cells[0].Value  = m.id;
                newRow.Cells[1].Value  = m.joindate;
                newRow.Cells[2].Value  = m.firstname;
                newRow.Cells[3].Value  = m.lastname;
                newRow.Cells[4].Value  = m.address;
                newRow.Cells[5].Value  = m.city;
                newRow.Cells[6].Value  = m.state;
                newRow.Cells[7].Value  = m.zipcode;
                newRow.Cells[8].Value  = m.phone;
                newRow.Cells[9].Value  = m.member_status;
                newRow.Cells[10].Value = m.login_name;
                newRow.Cells[11].Value = m.password;
                newRow.Cells[12].Value = m.email;
                newRow.Cells[13].Value = m.subscription_id;
                newRow.Cells[14].Value = m.admin;

                dataGridView1.Rows.Add(newRow);
            }
        }
Пример #2
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     try
     {
         List <Member> myMemberList = new List <Member>();
         myMemberList             = MemberDB.GetMembers();
         dataGridView1.DataSource = myMemberList;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     //Call the MemberDB static class to fill the data grid
     try
     {
         List <Member> memberList = new List <Member>();
         memberList = MemberDB.GetMembers();
         dataGridView1.DataSource = memberList;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #4
0
        private void Reload_Data()
        {
            try
            {
                List <Member> memberList = new List <Member>();
                memberList = MemberDB.GetMembers();
                //dataGridView1.ColumnCount = 6;
                dataGridView1.DataSource = memberList;

                //dataGridView1.Columns.Add("number", "Member ID");
                //dataGridView1.Columns.Add("joindate", "Join Date");
                //dataGridView1.Columns.Add("status", "Member Status");
                //dataGridView1.Columns.Add()
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btn_Add_Click(object sender, EventArgs e)
        {
            try
            {
                Member newMem = GetMemberObjFromUI();

                if (newMem != null)
                {
                    //check if the username is taken
                    bool memberExists = false;
                    foreach (Member m in MemberDB.GetMembers())
                    {
                        if (m.login_name.ToLower() == newMem.login_name.ToLower()) //if that login name is in use
                        {
                            memberExists = true;
                            MessageBox.Show("Sorry, but that login name is already in use. Please choose a different one.");
                            break; //break out of the for loop, so we don't spend time looking at each account
                        }
                    }

                    //if the username is not taken, attempt to add the new member to the database
                    if (!memberExists)
                    {
                        if (MemberDB.AddMember(GetMemberObjFromUI()))
                        {
                            MessageBox.Show("Your account has been successfully created. You may now login to your new account");
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("Account creation failed. Make sure all information has been entered, and try again. If you continue " +
                                            "receiving this error message, please contact technical support.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was a technical error during the operation.\n\nMessage:\n" + ex.Message + "\n\nStack Trace:\n" + ex.StackTrace);
            }
        }
Пример #6
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            bool memberFound = false;

            foreach (Member m in MemberDB.GetMembers())
            {
                if (m.login_name.ToLower() == txt_LoginName.Text.Trim().ToLower() && m.password == txt_Password.Text.Trim())
                {
                    MessageBox.Show("You have been successfully logged in.\n\n" + "Welcome, " + m.firstname.Trim() + " " + m.lastname.Trim() + ". Have a nice day.");
                    Account     = m;
                    memberFound = true;
                    Close();
                    break;
                }
            }

            if (!memberFound)
            {
                MessageBox.Show("This login name and password combo was not found.");
            }
        }
Пример #7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtMemberNumber.Text.Trim()))
            {
                try
                {
                    List <Member> memberList = new List <Member>();
                    memberList = MemberDB.GetMembers();
                    int num = 1;
                    foreach (Member member in memberList)
                    {
                        if (num <= member.memberNumber)
                        {
                            num = member.memberNumber + 1;
                        }
                    }
                    txtMemberNumber.Text = num.ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            foreach (Control control in groupBoxMemberData.Controls)
            {
                if (string.IsNullOrEmpty(control.Text.Trim()))
                {
                    MessageBox.Show("Please enter a value for " + control.Name.ToString());
                    control.Focus();
                    return;
                }
            }

            Member objMember = new Member();

            objMember.memberNumber    = Convert.ToInt32(txtMemberNumber.Text);
            objMember.joinDate        = txtJoinDate.Text;
            objMember.firstName       = txtFirstName.Text;
            objMember.lastName        = txtLastName.Text;
            objMember.address         = txtAddress.Text;
            objMember.city            = txtCity.Text;
            objMember.state           = txtState.Text;
            objMember.zipcode         = Convert.ToInt32(txtZipCode.Text);
            objMember.phoneNumber     = txtPhoneNumber.Text.ToString();
            objMember.status          = RadioStatus();
            objMember.login           = txtLogin.Text;
            objMember.password        = txtPassword.Text;
            objMember.email           = txtEmail.Text;
            objMember.contact_method  = ContactMethod();
            objMember.subscription_id = 1;
            objMember.photo           = "Photo";


            //if(lblPicture.Text != string.Empty)
            //{
            //    objMember.photo = lblPicture.Text;
            //}


            try
            {
                bool status = MemberDB.AddMember(objMember);
                if (status) //You can use this syntax as well..if (status ==true)
                {
                    Reload_Data();
                    MessageBox.Show("Member added to the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Member was not added to database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }