Пример #1
0
        private void btnRouteSave_Click(object sender, EventArgs e)
        {
            if (isValid.isStartFinishValid(cbEditRouteStart.SelectedIndex, cbEditRouteFinish.SelectedIndex) && isValid.isDistanceValid(tbEditRouteDistance.Text))
            {
                Route route = routesDataLink.Retrieve(routeToEdit.RouteID);
                route.Start    = cbEditRouteStart.SelectedItem.ToString();
                route.Finish   = cbEditRouteFinish.SelectedItem.ToString();
                route.Distance = Convert.ToInt32(tbEditRouteDistance.Text);
                routesDataLink.Update(route);

                this.Hide();
            }
        }
Пример #2
0
        private void btnAddRoute_Click(object sender, EventArgs e)//___________________Add__________________
        {
            if (isValid.isStartFinishValid(cbRouteStart.SelectedIndex, cbRouteFinish.SelectedIndex) && isValid.isDistanceValid(tbDistance.Text))
            {
                Route route = new Route()
                {
                    Start    = cbRouteStart.SelectedItem.ToString(),
                    Finish   = cbRouteFinish.SelectedItem.ToString(),
                    Distance = Convert.ToInt32(tbDistance.Text)
                };

                routesDataLink.Add(route);

                fillRouteTable();

                cbRouteStart.SelectedIndex  = -1;
                cbRouteFinish.SelectedIndex = -1;
                tbDistance.Text             = "";
            }
        }