Exemple #1
0
        private bool DesasignOrderToAssigments(long assigmentId)
        {
            bool      accioncorrecta = false;
            DataTable routesTableByAssigmentsId;
            DataTable TripTableByIdFromRoutes;

            try
            {
                DSAssigmentsData dataset = new DSAssigmentsData();
                DSAssigmentsDataTableAdapters.AssignmentsTableAdapter assignmentsTable = new DSAssigmentsDataTableAdapters.AssignmentsTableAdapter();
                DSAssigmentsDataTableAdapters.RoutesTableAdapter      routesTable      = new DSAssigmentsDataTableAdapters.RoutesTableAdapter();
                DSAssigmentsDataTableAdapters.TripsTableAdapter       tripsTable       = new DSAssigmentsDataTableAdapters.TripsTableAdapter();

                //obtenemos todas las rutas asignadas a la asignación correspondiente
                routesTableByAssigmentsId = routesTable.GetRoutesByAssigmentId(AssigmentId);

                //recorremos toda la tabla de rutas para la asignación que se quiere eliminar
                foreach (DSAssigmentsData.RoutesRow row2 in routesTableByAssigmentsId.Rows)
                {
                    //recorremos todos los viajes para la ruta en concreto
                    TripTableByIdFromRoutes = tripsTable.GetDataTripsByRoutesIdByRoutes(row2.Id);

                    // por cada viaje de la ruta en concreto pondremos el atributo id_route a nullo
                    foreach (DSAssigmentsData.TripsRow row3 in TripTableByIdFromRoutes.Rows)
                    {
                        //ponemos el atributo RouteId a nulo
                        row3.SetRouteIdNull();
                        //actualizamos en la tabla viaje
                        tripsTable.Update(row3);
                    }
                }

                accioncorrecta = true;
            }
            catch (Exception e)
            {
                string excepcion = e.ToString();
                return(false);
            }
            return(accioncorrecta);
        }
Exemple #2
0
        private bool DeleteAssigmentsAndRelantionship(long assigmentId)
        {
            int       RutaId;
            bool      accioncorrecta = false;
            DataTable routesTableByAssigmentsId;

            try
            {
                DSAssigmentsData dataset = new DSAssigmentsData();
                DSAssigmentsDataTableAdapters.AssignmentsTableAdapter     assignmentsTable    = new DSAssigmentsDataTableAdapters.AssignmentsTableAdapter();
                DSAssigmentsDataTableAdapters.Assignments_ObsTableAdapter assignmentsObsTable = new DSAssigmentsDataTableAdapters.Assignments_ObsTableAdapter();
                DSAssigmentsDataTableAdapters.RoutesTableAdapter          routesTable         = new DSAssigmentsDataTableAdapters.RoutesTableAdapter();
                DSAssigmentsDataTableAdapters.TripsTableAdapter           tripsTable          = new DSAssigmentsDataTableAdapters.TripsTableAdapter();

                //obtenemos todas las rutas asignadas a la asignación correspondiente
                routesTableByAssigmentsId = routesTable.GetRoutesByAssigmentId(AssigmentId);

                //recorremos las rutas asignadas a la asignación
                foreach (DSAssigmentsData.RoutesRow row in routesTableByAssigmentsId.Rows)
                {
                    //borramos la ruta relacionada (tabla asignaction ID -> tablaroutes assignmentId)
                    routesTable.DeleteQueryRoutesByIdAssignmentsFromAssignments(AssigmentId);
                }
                //borramos las observaciones de la asignación
                assignmentsObsTable.DeleteQueryByIdAssignments(Convert.ToInt64(AssigmentId));

                //borramos la asignación seleccionada
                assignmentsTable.DeleteQueryAssigmentsById(Convert.ToInt64(AssigmentId));

                accioncorrecta = true;
                Close();
            }
            catch (Exception e)
            {
                string excepcion = e.ToString();
                return(false);
            }
            return(accioncorrecta);
        }