Exemple #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            string Msg;

            if (!Validate(out Msg))
            {
                MessageBox.Show(Msg);
                return;
            }
            BayWind.Address addr = new BayWind.Address()
            {
                Street    = textBoxStreet.Text,
                City      = textBoxCity.Text,
                State     = textBoxState.Text,
                Country   = textBoxCountry.Text,
                ZipCode   = textBoxZip.Text,
                AddressID = (int)AddressStore.GetNextSequence()
            };
            BayWind.Person p = new BayWind.Person()
            {
                FirstName   = textBoxFirstName.Text,
                LastName    = textBoxLastName.Text,
                PhoneNumber = textBoxPhone.Text,
                AddressID   = addr.AddressID
            };
            PeopleStore.Add(p.GetKey(), p);
            AddressStore.Add(addr.AddressID, addr);
            GoPreviousPage();
            DisplayPage();
        }
Exemple #2
0
 private void dataGridViewPeople_SelectionChanged(object sender, EventArgs e)
 {
     BayWind.Person p = GetSelectedPerson();
     if (p != null)
     {
         DisplayFields(p);
     }
 }
Exemple #3
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     BayWind.Person p = GetSelectedPerson();
     if (p != null)
     {
         PeopleStore.Remove(p.GetKey());
         GoPreviousPage();
         DisplayPage();
     }
 }
Exemple #4
0
 void DisplayFields(BayWind.Person p)
 {
     textBoxFirstName.Text = p.FirstName;
     textBoxLastName.Text  = p.LastName;
     textBoxPhone.Text     = p.PhoneNumber;
     if (AddressStore.Search(p.AddressID))
     {
         BayWind.Address addr = AddressStore.CurrentValue;
         textBoxStreet.Text  = addr.Street;
         textBoxCity.Text    = addr.City;
         textBoxState.Text   = addr.State;
         textBoxCountry.Text = addr.Country;
         textBoxZip.Text     = addr.ZipCode;
     }
 }
Exemple #5
0
        void DisplayPage()
        {
            BayWind.Person[] PeopleInPage = new BayWind.Person[PageSize];
            int i = 0;

            while (i < PeopleInPage.Length &&
                   !PeopleStore.EndOfTree())
            {
                PeopleInPage[i++] = PeopleStore.CurrentValue;
                if (!PeopleStore.MoveNext())
                {
                    break;
                }
            }
            if (PeopleStore.EndOfTree())
            {
                PeopleStore.MoveLast();
            }
            dataGridViewPeople.AutoGenerateColumns = true;
            dataGridViewPeople.DataSource          = PeopleInPage;
            textBoxCount.Text = PeopleStore.Count.ToString();
        }