Example #1
0
        public Form1()
        {
            InitializeComponent();

            trips     = TripControl.getTrips(@"data\Trips.xml");
            locations = TripControl.getLocations(@"data\Location.xml");

            dataSetTrips.ReadXml(@"data\Trips.xml");
            dataSetTrips.ReadXmlSchema(@"data\TripsSchema.xml");
            bindingSourceTrips.DataSource = dataSetTrips;
            bindingSourceTrips.DataMember = "trip";

            listBoxTrips.DataSource    = bindingSourceTrips;
            listBoxTrips.DisplayMember = "tripName";

            dataSetLocations.ReadXml(@"data\Location.xml");
            dataSetLocations.ReadXmlSchema(@"data\LocationSchema.xml");
            bindingSourceLocations.DataSource = dataSetLocations;
            bindingSourceLocations.DataMember = "location";
            getSavedLocation = true;
            listBoxSavedLocations.DataSource    = bindingSourceLocations;
            listBoxSavedLocations.DisplayMember = "locationName";



            labelDescription.MaximumSize = new Size(panelTripDetails.Width - 10, 0);
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var nameForm = new Forms.frmName();


            DialogResult res = nameForm.ShowDialog();

            if (res == DialogResult.OK)
            {
                string          tname     = nameForm.TripName;
                string          tdesc     = nameForm.Description;
                List <string>   lnames    = new List <string>();
                List <Location> locations = new List <Location>();

                foreach (ComboBox b in boxes)
                {
                    if (b.Enabled && (b.Text != String.Empty || b.Text != null))
                    {
                        lnames.Add(b.Text);
                    }
                }
                List <Location> lSaved = TripControl.getLocations(@"data\Location.xml");
                foreach (Location sav in lSaved)
                {
                    if (lnames.Contains(sav.locationName))
                    {
                        locations.Add(sav);
                    }
                }
                this.Close();
            }
        }
Example #3
0
        private void buttonSaveLocation_Click(object sender, EventArgs e)
        {
            string name         = textBoxName.Text;
            string address      = textBoxAddress.Text;
            string locationCode = textBoxLocationCode.Text;

            TripControl.WriteLocationToXml(new Location(name, address, locationCode), @"data\Location.xml");
            this.Close();
        }
Example #4
0
        private void buttonRemoveLocation_Click(object sender, EventArgs e)
        {
            var     view = listBoxSavedLocations.SelectedItem;
            DataRow row  = ((DataRowView)view).Row;
            string  n    = row.ItemArray[0].ToString();

            foreach (Location l in locations)
            {
                if (l.locationName == n)
                {
                    TripControl.RemoveLocation(l, @"data\Location.xml");
                }
            }
        }
Example #5
0
        private void updateLocationsBox()
        {
            dataSetLocations = new DataSet();
            dataSetLocations.ReadXml(@"data\Location.xml");
            dataSetLocations.ReadXmlSchema(@"data\LocationSchema.xml");
            bindingSourceLocations            = new BindingSource();
            bindingSourceLocations.DataSource = dataSetLocations;
            bindingSourceLocations.DataMember = "location";
            getSavedLocation = true;
            listBoxSavedLocations.DataSource    = null;
            listBoxSavedLocations.DataSource    = bindingSourceLocations;
            listBoxSavedLocations.DisplayMember = "locationName";

            locations = TripControl.getLocations(@"data\Location.xml");
        }
Example #6
0
        private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
        {
            ComboBox box = (ComboBox)sender;

            if (box.SelectedIndex >= 0)
            {
                string          name      = (string)box.Items[box.SelectedIndex];
                List <Location> locations = TripControl.getLocations(@"data\Location.xml");
                foreach (Location l in locations)
                {
                    if (l.locationName == name)
                    {
                        getAssociatedLabel(box).Text = l.address;
                    }
                }
            }
        }
Example #7
0
        private void updateComboBox()
        {
            List <Location> locations = TripControl.getLocations(@"data\Location.xml");
            List <object>   names     = new List <object>();

            foreach (Location l in locations)
            {
                names.Add(l.locationName);
            }

            foreach (ComboBox b in boxes)
            {
                int ind = b.SelectedIndex;
                b.Items.Clear();
                b.Items.AddRange(names.ToArray());
                if (ind >= 0)
                {
                    b.SelectedIndex = ind;
                    b.Text          = b.Items[ind].ToString();
                }
            }
        }