Пример #1
0
        private void BtnSubmit_Click(object sender, EventArgs e)
        {
            var newRouteForm = new RouteForm(_routes);

            newRouteForm.Show();
            Close();
        }
Пример #2
0
        private void BtnSearch_Click(object sender, EventArgs e)
        {
            var          bufferResult = new List <Route>();
            List <Route> searchResult;

            if (!String.IsNullOrWhiteSpace(textBoxNumber.Text))
            {
                foreach (var route in Program.DataRoutes)
                {
                    if (route.Number.Contains(textBoxNumber.Text))
                    {
                        bufferResult.Add(route);
                    }
                }
                if (!String.IsNullOrWhiteSpace(comboBoxTransportType.Text))
                {
                    searchResult = bufferResult;
                    bufferResult = new List <Route>();

                    foreach (var route in searchResult)
                    {
                        if (Program.VechileTypeEquals(comboBoxTransportType.Text) == route.VechileType)
                        {
                            bufferResult.Add(route);
                        }
                    }
                }
                if (!String.IsNullOrWhiteSpace(textBoxStreet.Text))
                {
                    searchResult = bufferResult;
                    bufferResult = new List <Route>();

                    foreach (
                        var route in
                        searchResult.Where(c => c.Stops.Any(d => d.Street == textBoxStreet.Text)))
                    {
                        bufferResult.Add(route);
                    }
                }
            }
            else
            {
                if (!String.IsNullOrWhiteSpace(comboBoxTransportType.Text))
                {
                    foreach (var route in Program.DataRoutes)
                    {
                        if (Program.VechileTypeEquals(comboBoxTransportType.Text) == route.VechileType)
                        {
                            bufferResult.Add(route);
                        }
                    }
                }
                else
                {
                    bufferResult = Program.DataRoutes;
                }
                if (!String.IsNullOrWhiteSpace(textBoxStreet.Text))
                {
                    searchResult = bufferResult;
                    bufferResult = new List <Route>();

                    foreach (
                        var route in
                        searchResult.Where(c => c.Stops.Any(d => d.Street == textBoxStreet.Text)))
                    {
                        bufferResult.Add(route);
                    }
                }
            }

            var routesForm = new RouteForm(bufferResult);

            routesForm.Show();
        }