Beispiel #1
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            SA46Team10BsportsEntities context = new SA46Team10BsportsEntities();
            string userID = loginTBox.Text;
            string pw     = passwordTBox.Text;

            try
            {
                var        q   = from x in context.UserMasters where x.LoginName.Equals(userID) select x;
                UserMaster obj = q.First();

                if (obj.Password.Equals(pw))
                {
                    rect.Visible      = true;
                    rectOuter.Visible = true;
                    timer3.Start();
                }

                else
                {
                    MessageBox.Show("Incorrect User Name or Password!");
                }
            }

            catch (System.InvalidOperationException exc)
            {
                System.InvalidOperationException e2 = exc;
                MessageBox.Show("Incorrect User Name or Password!");
            }
        }
Beispiel #2
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            SA46Team10BsportsEntities ctx = new SA46Team10BsportsEntities();
            int           CID             = Convert.ToInt32(CustomerIDTextBox.Text);
            CustomerTable c = ctx.CustomerTables.Where(x => x.CustomerID == CID).First();

            c.Flag = "inactive";
            ctx.SaveChanges();
            MessageBox.Show(c.FirstName + "'s id has been deleted");
            ClearContent();
        }
Beispiel #3
0
        private void SearchBox_TextChanged_1(object sender, EventArgs e)
        {
            SA46Team10BsportsEntities context = new SA46Team10BsportsEntities();
            string s = "active";
            var    q = from x in context.CustomerTables
                       where ((x.FirstName.Contains(SearchBox.Text) || x.LastName.Contains(SearchBox.Text) || x.Address.Contains(SearchBox.Text) || x.Email.Contains(SearchBox.Text) || x.PhoneNumber.Contains(SearchBox.Text)) &&
                              (x.Flag.Equals(s)))
                       select x;

            dataGridView1.DataSource = q.ToList();
        }
Beispiel #4
0
        private void LookUpButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!(string.IsNullOrWhiteSpace(CustomerIDTextBox.Text)))
                {
                    SA46Team10BsportsEntities ctx = new SA46Team10BsportsEntities();
                    int           CID             = Convert.ToInt32(CustomerIDTextBox.Text);
                    CustomerTable c = ctx.CustomerTables.Where(x => x.CustomerID == CID).First();
                    LockCustomerIDTextBox();
                    FirstNameTextBox.Text  = c.FirstName;
                    LastNameTextBox.Text   = c.LastName;
                    PhoneTextBox.Text      = c.PhoneNumber;
                    EmailTextBox.Text      = c.Email;
                    AddressTextBox.Text    = c.Address;
                    PostalCodeTextBox.Text = c.PostalCode;
                    CountyTextBox.Text     = c.Country;
                }
                else
                {
                    CIDLookoutForm luf = new CIDLookoutForm();
                    luf.ShowDialog();
                    this.CustomerIDTextBox.Text = luf.CIDFromGrid;
                    if (CustomerIDTextBox.Text != " ")
                    {
                        LockCustomerIDTextBox();
                    }
                    this.FirstNameTextBox.Text  = luf.FirstNameFromGrid;
                    this.LastNameTextBox.Text   = luf.LastNameFromGrid;
                    this.PhoneTextBox.Text      = luf.PhoneFromGrid;
                    this.EmailTextBox.Text      = luf.EmailFromGrid;
                    this.AddressTextBox.Text    = luf.AddressFromGrid;
                    this.PostalCodeTextBox.Text = luf.PostalcodeFromGrid;
                    this.CountyTextBox.Text     = luf.CountryFromGrid;
                }
            }

            catch (System.ArgumentOutOfRangeException a)
            {
                MessageBox.Show("Please ensure all fields have relevant data before updating.");
            }

            catch (System.FormatException a)
            {
                MessageBox.Show("Please enter the correct ID");
            }

            catch (System.InvalidOperationException a)
            {
                MessageBox.Show("This ID does not exist");
            }
        }
Beispiel #5
0
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            bool PhoneNumberOk = false;
            bool PostalCodeOk  = false;

            int  i;
            bool PhoneNumberisInteger = int.TryParse(PhoneTextBox.Text, out i);

            if (PhoneNumberisInteger)
            {
                if (PhoneTextBox.Text.Length == 8)
                {
                    PhoneNumberOk = true;
                }
                else
                {
                    MessageBox.Show("Phone Number must be exactly 8 digits");
                }
            }
            else
            {
                MessageBox.Show("Phone Number must be in digits (8 digits)");
            }

            int  ii;
            bool PostalCodeIsInteger = int.TryParse(PostalCodeTextBox.Text, out ii);

            if (PostalCodeIsInteger)
            {
                if (PostalCodeTextBox.Text.Length == 6)
                {
                    PostalCodeOk = true;
                }
                else
                {
                    PostalCodeOk = false;
                    MessageBox.Show("Postal Code must be exactly 6 digits");
                }
            }
            else
            {
                PostalCodeOk = false;
                MessageBox.Show("Postal Code must be in digits (6 digits)");
            }



            if (PhoneNumberOk && PostalCodeOk)
            {
                try
                {
                    SA46Team10BsportsEntities ctx = new SA46Team10BsportsEntities();
                    int           CID             = Convert.ToInt32(CustomerIDTextBox.Text);
                    CustomerTable c = ctx.CustomerTables.Where(x => x.CustomerID == CID).First();
                    c.FirstName   = FirstNameTextBox.Text;
                    c.LastName    = LastNameTextBox.Text;
                    c.PhoneNumber = PhoneTextBox.Text;
                    c.Email       = EmailTextBox.Text;
                    c.Address     = AddressTextBox.Text;
                    c.PostalCode  = PostalCodeTextBox.Text;
                    c.Country     = CountyTextBox.Text;
                    ctx.SaveChanges();
                    MessageBox.Show("Update Successful");
                    ClearContent();
                }

                catch (System.ArgumentOutOfRangeException a)
                {
                    MessageBox.Show("Please ensure all fields are filled before updating");
                }

                catch (System.FormatException b)
                {
                    MessageBox.Show("Please ensure all fields are filled before updating");
                }
            }
        }
Beispiel #6
0
        private void crAcctSaveBtn_Click(object sender, EventArgs e)
        {
            bool PhoneNumberOk = false;
            bool PostalCodeOk  = false;

            int  i;
            bool isPhoneNumberInteger = int.TryParse(phoneTBox.Text, out i);

            if (isPhoneNumberInteger)
            {
                if (phoneTBox.Text.Length == 8)
                {
                    PhoneNumberOk = true;
                }
                else
                {
                    MessageBox.Show("Phone Number must be exactly 8 digits");
                }
            }
            else
            {
                MessageBox.Show("Phone Number must be in digits (8 digits) ");
            }


            int  ii;
            bool isPostalCodeInteger = int.TryParse(postalTBox.Text, out ii);

            if (isPostalCodeInteger)
            {
                if (postalTBox.Text.Length == 6)
                {
                    PostalCodeOk = true;
                }
                else
                {
                    MessageBox.Show("Postal Code must be exactly 6 digits");
                }
            }
            else
            {
                MessageBox.Show("Postal Code must be in digits (6 digits) ");
            }

            if (PhoneNumberOk && PostalCodeOk)
            {
                if ((firstNameTBox.Text == "" || LastNameTBox.Text == "" || addressTBox.Text == "" || postalTBox.Text == "" || ctyTBox.Text == "") || (maleRadBtn.Checked == false && femaleRadBtn.Checked == false))
                {
                    MessageBox.Show("Please fill in all fields!");
                }
                else
                {
                    SA46Team10BsportsEntities ctx = new SA46Team10BsportsEntities();
                    CustomerTable             c   = new CustomerTable();

                    try
                    {
                        c.FirstName   = firstNameTBox.Text;
                        c.LastName    = LastNameTBox.Text;
                        c.DOB         = Convert.ToDateTime(dobDatePicker.Text);
                        c.PhoneNumber = phoneTBox.Text;
                        c.Email       = EmailTBox.Text;
                        c.Address     = addressTBox.Text;
                        c.PostalCode  = postalTBox.Text;
                        c.Country     = ctyTBox.Text;

                        if (maleRadBtn.Checked == true)
                        {
                            c.Gender = "Male";
                        }
                        else
                        {
                            c.Gender = "Female";
                        }
                        ctx.CustomerTables.Add(c);
                        ctx.SaveChanges();
                        MessageBox.Show("User Account " + c.CustomerID + " successfully created!");
                        ClearContent();
                    }

                    catch (System.FormatException a)
                    {
                        MessageBox.Show("Please fill in all fields!");
                    }
                }
            }
        }