Exemple #1
0
        private void FetchMemberStatusButton_Click(object sender, EventArgs e)
        {
            try
            {
                SqlMemberRepository members = new SqlMemberRepository(connectionString);

                List <MemberStatus> member     = new List <MemberStatus>();
                MemberStatus        memberList = members.FetchMemberStatus(Convert.ToInt32(MemberIdTextbox.Text));
                member.Add(memberList);
                dataGridView1.DataSource = member;

                for (int i = 0; i < dataGridView1.Columns.Count; i++)
                {
                    DataGridViewColumn columnOne = dataGridView1.Columns[0];
                    columnOne.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                    DataGridViewColumn columnTwo = dataGridView1.Columns[3];
                    columnTwo.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                    DataGridViewColumn columnThree = dataGridView1.Columns[4];
                    columnTwo.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                }
            }catch (Exception ex)
            {
                MessageBox.Show("Incorrect input. Parameter takes an int.");
            }
        }
Exemple #2
0
        private void uxSubmit_Click(object sender, EventArgs e)
        {
            const string connectionString = @"Server=(localdb)\MSSQLLocalDb;Database=LibraryDB;Integrated Security=SSPI;";

            SqlMemberRepository SqlMem = new SqlMemberRepository(connectionString);


            if (!(uxLibraryChoose.SelectedIndex > -1) || (string.IsNullOrWhiteSpace(uxEmailText.Text) && uxEmailText.Text.Length > 0) ||
                (string.IsNullOrWhiteSpace(uxFirstNameText.Text) && uxFirstNameText.Text.Length > 0) ||
                (string.IsNullOrWhiteSpace(uxLastNameText.Text) && uxLastNameText.Text.Length > 0) ||
                (string.IsNullOrWhiteSpace(uxPhoneText.Text) && uxPhoneText.Text.Length > 0) || uxEmailText.Text.Equals("") ||
                uxFirstNameText.Text.Equals("") || uxLastNameText.Text.Equals("") || uxPhoneText.Text.Equals(""))
            {
                MessageBox.Show("Null or invalid inputs");
                MessageBox.Show(uxLibraryChoose.GetItemText(uxLibraryChoose.SelectedItem));
            }
            else
            {
                Library2 lib = SqlMem.RetrieveLibraryByName(uxLibraryChoose.GetItemText(uxLibraryChoose.SelectedItem));
                SqlMem.CreateMember(lib.LibraryID, uxFirstNameText.Text.Trim(), uxLastNameText.Text.Trim(),
                                    uxEmailText.Text.Trim(), uxPhoneText.Text.Trim());
                MessageBox.Show("New membership was created for " + uxFirstNameText.Text + " " + uxLastNameText.Text + " at "
                                + uxLibraryChoose.SelectedItem.ToString());
                Close();
            }
        }
Exemple #3
0
        private void memberPoints_Click(object sender, EventArgs e)
        {
            SqlMemberRepository    members    = new SqlMemberRepository(connectionString);
            IReadOnlyList <Member> memberList = members.RetrieveMemberPoints();

            dataGridView1.DataSource = memberList;
        }
Exemple #4
0
        private void GetMemberIdButton_Click(object sender, EventArgs e)
        {
            SqlMemberRepository members = new SqlMemberRepository(connectionString);

            Member        member     = members.GetMemberId(EmailTextbox.Text);
            List <Member> memberList = new List <Member>();

            memberList.Add(member);
            dataGridView1.DataSource = memberList;
        }
Exemple #5
0
        private void UpdateMemberButton_Click(object sender, EventArgs e)
        {
            try
            {
                MembersData ed = new MembersData();

                SqlMemberRepository members = new SqlMemberRepository(connectionString);
                members.UpdateMember(Convert.ToInt32(MemberIdTextbox.Text), EmailTextBox.Text, FirstNameTextBox.Text, LastNameTextBox.Text, PhoneTextBox.Text, BillingAddressTextBox.Text, Convert.ToInt32(PointsTextBox.Text), Convert.ToDateTime(JoinedOnTextBox.Text), Convert.ToDateTime(BirthDateTextBox.Text), StatusTextBox.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #6
0
        private void retrieveMembers_Click(object sender, EventArgs e)
        {
            SqlMemberRepository    members    = new SqlMemberRepository(connectionString);
            IReadOnlyList <Member> memberList = members.RetrieveMember();

            dataGridView1.DataSource = memberList;

            for (int i = 0; i < dataGridView1.Columns.Count; i++)
            {
                DataGridViewColumn columnFour = dataGridView1.Columns[6];
                columnFour.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                DataGridViewColumn columnFive = dataGridView1.Columns[9];
                columnFive.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
        }
Exemple #7
0
        private void CreateMemberButton_Click(object sender, EventArgs e)
        {
            try
            {
                SqlMemberRepository members = new SqlMemberRepository(connectionString);

                Member createMember = members.CreateMember(EmailTextBox.Text, FirstNameTextBox.Text, LastNameTextBox.Text, PhoneTextBox.Text, BillingAddressTextBox.Text, Convert.ToInt32(PointsTextBox.Text), Convert.ToDateTime(JoinedOnTextBox.Text), Convert.ToDateTime(BirthDateTextBox.Text), StatusTextBox.Text);
                list.Add(createMember);

                MembersData md = new MembersData();
                md.dataGridView1.DataSource = list;
            }
            catch (Exception ex)
            {
                MessageBox.Show("There cannot be any empty or incorrectly entered parameters.Check submission.");
            }
        }
Exemple #8
0
        private void uxSignInButton_Click(object sender, EventArgs e)
        {
            const string connectionString = @"Server=(localdb)\MSSQLLocalDb;Database=LibraryDB;Integrated Security=SSPI;";

            SqlMemberRepository SqlMem = new SqlMemberRepository(connectionString);
            Member m = SqlMem.GetMemberbyEmail(uxSignInTextBox.Text.Trim());

            if ((string.IsNullOrWhiteSpace(uxSignInTextBox.Text) && uxSignInTextBox.Text.Length > 0) || m == null)
            {
                MessageBox.Show("Invalid Email Value");
            }

            else
            {
                var options = new Options(m);
                options.Show();
            }
        }
 public void InitializeTest()
 {
     mem = new SqlMemberRepository(connectionString);
 }