Exemplo n.º 1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            string ciudad  = textBoxCiudad.Text;
            string dpto    = textBoxDpto.Text;
            string destino = textBoxDestino.Text;
            string dpto2   = textBoxDptoDestino.Text;
            int    tarifa  = int.Parse(txtTarifa.Text);
            Rutas  rutas   = new Rutas(ciudad, dpto, destino, dpto2, tarifa);
            Rutas  rutas2  = new Rutas(destino, dpto2, ciudad, dpto, tarifa);


            if (ciudad == destino)
            {
                result = MsgBox.Show("No ingrese el mismo valor en Origen y Destino", "Advertencia", MsgBox.Buttons.OK, MsgBox.Icon.Warning);
            }
            else
            {
                try
                {
                    result = MsgBox.Show(service.Guardar(rutas), "Informacion", MsgBox.Buttons.OK, MsgBox.Icon.Info);
                    service.Guardar(rutas2);
                    actualizar();
                }
                catch (Exception ex)
                {
                    result = MsgBox.Show(ex.Message, "Advertencia", MsgBox.Buttons.OK, MsgBox.Icon.Error);
                }
            }
        }
Exemplo n.º 2
0
        private void TomarLaterales()
        {
            var list = (from r in Rutas.GetRutas()
                        where r.Selected
                        select r).ToList();

            if (list.Count() > 0)
            {
                var det = new Detalle(list);
                det.TomarLateralesReferencia(false, true, false);
            }

/*
 *              var rowIndex = gridServicios.RowSel - 1;
 *
 *              if (rowIndex < 0) return;
 *
 *              var servicio = new BindingSource(gridServicios.DataSource, "");
 *              var obj = servicio[rowIndex] as ServicioView;
 *
 *              if (obj == null) return;
 *
 *              var serv = (from o in Rutas.GetRutas() where o.Id == obj.Id select o).FirstOrDefault();
 *
 *              if (serv.Motivo != null)
 *              {
 *                  var form = new Detalle(serv, true);
 *                  form.TomarLateralesReferencia(false,true,false);
 *                  serv.CalcularEstados();
 *              }
 */
        }
Exemplo n.º 3
0
        static void AgregarRuta()
        {
            try
            {
                Console.Clear();
                Rutas ruta = new Rutas();

                Console.WriteLine("                                        ~~~~~~~~~~ Creando ruta ~~~~~~~~~~\n");
                Console.Write("                                           > Ingrese la ciudad de origen de esta ruta: ");
                ruta.CDO = Console.ReadLine();
                Console.Write("\n                                           > Ingrese el destino de esta ruta: ");
                ruta.Destino = Console.ReadLine();
                Console.Write("\n                                           > Ingrese el costo de ticket para esta ruta: ");
                ruta.CDT = Convert.ToInt32(Console.ReadLine());
                Random rnd          = new Random();
                int    NumeroDeRuta = Convert.ToInt32(rnd.Next(1, 100));
                ruta.NDR = NumeroDeRuta;
                Console.Write("\n                                           > El numero de esta ruta generado automaticamente es: " + NumeroDeRuta);


                TheRutas.Add(ruta);
                Console.ReadKey();
                menu();
            }
            catch (Exception error)
            {
                Console.WriteLine("\n***        " + error.Message + "        ***");
            }
        }
Exemplo n.º 4
0
        public void CargarDatosRutas(Rutas ruta)
        {
            int id = Utility.ConvierteEntero(idRutatextBox.Text);

            ruta.RutaId      = id;
            ruta.Descripcion = descripcionRutatextBox.Text;
        }
Exemplo n.º 5
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Nombre,Abierto,Publico,Aprobado")] Rutas rutas)
        {
            this.UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(this.db));
            var   UserId = User.Identity.GetUserId();
            var   user   = UserManager.FindById(UserId);
            Rutas rutao  = db.Rutas.AsNoTracking().Single(x => x.Id.Equals(rutas.Id));

            rutas.User = user;

            if (!(User.IsInRole("Staff") || User.IsInRole("Administrador")))
            {
                rutas.Aprobado = rutao.Aprobado;
                ModelState.Remove("Aprobado");
            }


            ModelState.Remove("User");


            ModelState.Clear();

            if (ModelState.IsValid)
            {
                db.Entry(rutas).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(rutas));
        }
Exemplo n.º 6
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         Int32  codigo3      = Convert.ToInt32(codigo2.Text);
         string paisOrigen2  = comboPaisOrigen2.Text;
         string paisDestino2 = comboPaisDestino2.Text;
         string duracion2    = Hora2.Value.ToString("hh:mm");
         if (paisOrigen2.Equals(paisDestino2))
         {
             MessageBox.Show("El país de Destino debe ser digente del de Origen.", "Adventencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             Rutas guardarRuta = new Rutas();
             guardarRuta.modificarRuta(codigo3, paisOrigen2, paisDestino2, duracion2);
             cargar.Clear();
             cargarDataGridView();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("El codigo no debe quedar el espacio en blanco.", "Adventencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Exemplo n.º 7
0
        protected void guardarRuButton_Click(object sender, EventArgs e)
        {
            Rutas ruta = new Rutas();

            CargarDatos(ruta);
            if (idRutaTextBox.Text.Length <= 0)
            {
                if (ruta.Insertar())
                {
                    Utility.ShowToastr(this.Page, "Guardo Correctamente", "Message", "SUCCESS");
                    Limpiar();
                }
                else
                {
                    Utility.ShowToastr(this.Page, "Error al Guardar", "Message", "Error");
                }
            }
            CargarDatos(ruta);
            if (ruta.Modificar())
            {
                Utility.ShowToastr(this, "Edito Correctamente", "Message", "SUCCESS");
                Limpiar();
            }
            else
            {
                Utility.ShowToastr(this, "Error Al Editar", "Message", "Warning");
            }
        }
Exemplo n.º 8
0
        public async Task <ActionResult> Show(int?id)
        {
            if (User.IsInRole("Staff") || User.IsInRole("Administrador"))
            {
                ViewBag.Message = "Confirmado";
            }

            this.UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(this.db));
            var userId = (User.Identity.GetUserId());

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            List <Waypoint>  wps      = db.Waypoints.Where(w => w.rutaId == id).ToList();
            List <Servicios> srvs     = new List <Servicios>();
            List <string>    destinos = new List <string>();

            foreach (Waypoint wp in wps)
            {
                // todo: if servicio is available
                var srv = db.Servicios.Find(wp.ServiciosId);
                srvs.Add(srv);
                destinos.Add(srv.Nombre);
            }

            Rutas ruta = await db.Rutas.FindAsync(id);

            ViewBag.Nombre   = ruta.Nombre;
            ViewBag.Destinos = destinos;

            return(View(srvs.AsQueryable()));
        }
Exemplo n.º 9
0
        private void BuscarButton_Click(object sender, EventArgs e)
        {
            Rutas ruta = new Rutas();

            if (IdTextBox.Text.Trim() == "")
            {
                RutaerrorProvider.SetError(IdTextBox, "Especifica el Cliente Id");
                IdTextBox.Focus();
            }
            else
            {
                RutaerrorProvider.Clear();
            }
            if (IdTextBox.TextLength > 0)
            {
                if (ruta.Buscar(Validacion.ConvertirToInt(IdTextBox.Text)))
                {
                    DevolverDatos(ruta);
                    GuardarButton.Enabled  = true;
                    EliminarButton.Enabled = true;
                }
                else
                {
                    MessageBox.Show("NO EXISTE RUTA ID ");
                }
            }
        }
Exemplo n.º 10
0
        public async void Loadrutas(LoginResult User)
        {
            var rutas = await wSLservice.GetRutas(User.UserId);

            Rutas.Clear();


            if (rutas != null)
            {
                foreach (var ruta in rutas)
                {
                    Rutas.Add(new RutasItemViewModel
                    {
                        Nombre      = ruta.Nombre,
                        IdRuta      = ruta.IdRuta,
                        Descripcion = ruta.Descripcion,
                        CodBodega   = ruta.CodBodega,
                    });
                }
            }
            else
            {
                await dialogService.Showmessage("Error", "No hay");
            }
        }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Rutas ruta = new Rutas();
            ScriptResourceDefinition myScriptResDef = new ScriptResourceDefinition();

            myScriptResDef.Path         = "~/Scripts/jquery-1.4.2.min.js";
            myScriptResDef.DebugPath    = "~/Scripts/jquery-1.4.2.js";
            myScriptResDef.CdnPath      = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js";
            myScriptResDef.CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.js";
            ScriptManager.ScriptResourceMapping.AddDefinition("jquery", null, myScriptResDef);

            MsjLabel.Text = "";
            if (!IsPostBack)
            {
                Session["Modificando"] = false;
                int IdRuta = 0;
                IdRuta = Util.ObtenerEntero(Request.QueryString["IdRuta"]);

                if (IdRuta != 0)
                {
                    ClearButton.Visible = true;
                    SaveButton.Visible  = true;
                    IdTextBox.Text      = IdRuta.ToString();
                }
                if (ruta.Buscar())
                {
                    llenacampo(ruta);
                }
            }
        }
Exemplo n.º 12
0
        protected void impRutaButton_Click(object sender, EventArgs e)
        {
            Rutas ruta = new Rutas();

            Response.Redirect("~/Reportes/ReporteRuta.aspx");
            Response.Clear();
        }
Exemplo n.º 13
0
        private void guardarRutabutton_Click(object sender, EventArgs e)
        {
            Rutas ruta = new Rutas();

            CargarDatosRutas(ruta);
            if (idRutatextBox.Text == "")
            {
                if (descripcionRutatextBox.Text != "")
                {
                    if (ruta.Insertar())
                    {
                        Limpiar();
                        MessageBox.Show("Guardo Correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LlenarDataGrid();
                    }
                    else
                    {
                        MessageBox.Show("Error Al Guardar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Debe llenar los campos obligatorios", "Error al insertar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Exemplo n.º 14
0
        public string Insertar(Rutas ruta)
        {
            try
            {
                using (var cmd = Conexion.CreateCommand())
                {
                    cmd.CommandText = "INSERT INTO Rutas([Ciudad origen],[Departamento origen],[Ciudad destino],[Departamento destino],Tarifa)" +
                                      "VALUES(@origen,@dptoporigen,@destino,@dptodestino,@tarifa)";


                    cmd.Parameters.Add("@origen", SqlDbType.VarChar).Value      = ruta.Ciudad_Origen;
                    cmd.Parameters.Add("@dptoporigen", SqlDbType.VarChar).Value = ruta.Dpto_Origen;
                    cmd.Parameters.Add("@destino", SqlDbType.VarChar).Value     = ruta.Ciudad_Destino;
                    cmd.Parameters.Add("@dptodestino", SqlDbType.VarChar).Value = ruta.Dpto_Destino;
                    cmd.Parameters.Add("@Tarifa", SqlDbType.Int).Value          = ruta.Tarifa;


                    int i = cmd.ExecuteNonQuery();

                    return((i > 0) ? "se agrego con exito" : "No se agrego");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 15
0
        private void btnArchivo1_Click(object sender, EventArgs e)
        {
            openFileDialog1.FileName = string.Empty;
            //openFileDialog1.Filter = "Image Files (*.jpg;*.gif;*.jpeg;*.png)|*.jpg;*.gif;*.jpeg;*.png";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (!IsValidImageSize(openFileDialog1.FileName))
                {
                    return;
                }

                txtFileName1.Text = Path.GetFileName(openFileDialog1.FileName);

                Rutas oRutas = new Rutas();
                _rutas.RemoveAll(p => p.ServicioId == _ServicioId);

                oRutas.ServicioId = _ServicioId;
                oRutas.Paciente   = _Paciente;
                oRutas.RutaCorta  = Path.GetFileName(openFileDialog1.FileName);
                oRutas.RutaLarga  = openFileDialog1.FileName;
                oRutas.PersonId   = _PersonId;
                oRutas.ProtocolId = _ProtocolId;
                _rutas.Add(oRutas);

                grdData.DataSource = new List <Rutas>();
                grdData.DataSource = _rutas;
                txtFileName1.Text  = "";
            }
        }
Exemplo n.º 16
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter = "[LFP]|*.txt";
            string texto = "";
            string fila  = "";

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                string       ruta1        = openFile.FileName;
                StreamReader streamReader = new StreamReader(ruta1, System.Text.Encoding.UTF8);
                string       nombreC      = Path.GetFileNameWithoutExtension(openFile.FileName);
                while ((fila = streamReader.ReadLine()) != null)
                {
                    texto += fila + System.Environment.NewLine;
                }
                richTextBox1.Text = texto;
                streamReader.Close();

                rutas.Clear();
                Rutas path = new Rutas(ruta1, nombreC);
                rutas.Add(path);
                Path_actual  = ruta1;
                nombre_acual = nombreC;
                this.Text    = nombre_acual;
            }
        }
Exemplo n.º 17
0
        public async Task <IHttpActionResult> PutRutas(int id, Rutas rutas)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != rutas.IdRuta)
            {
                return(BadRequest());
            }

            db.Entry(rutas).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RutasExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 18
0
        private void CargarDropDList()
        {
            Rutas ruta = new Rutas();

            rutaPDropDownList.DataSource     = ruta.Listado("*", "1=1", "");
            rutaPDropDownList.DataTextField  = "NombreRuta";
            rutaPDropDownList.DataValueField = "RutaId";
            rutaPDropDownList.DataBind();
        }
Exemplo n.º 19
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Rutas rutas = await db.Rutas.FindAsync(id);

            db.Rutas.Remove(rutas);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Rutas ruta = new Rutas();
         rutasGridView.DataSource = ruta.Listado("*", "1=1", "");
         rutasGridView.DataBind();
     }
 }
Exemplo n.º 21
0
        private void menuItem2_Click(object sender, EventArgs e)
        {
            bool hizo = false;

/*                MessageBox.Show(@"Debe seleccionar servicios pendientes",
 *              string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Question,
 *              MessageBoxDefaultButton.Button1);*/


            var list = (from r in Rutas.GetRutas()
                        where r.Selected && (r.LlevaLaterales || r.LlevaReferencia)
                        select r).ToList();

            if (list.Count() > 0)
            {
                var det = new Detalle(list);
                det.TomarLateralesReferencia(false, true, true);
                hizo = true;
            }


            list = (from r in Rutas.GetRutas()
                    where r.Selected && (r.LlevaGPS)
                    select r).ToList();

            if (list.Count() > 0)
            {
                var det = new Detalle(list);
                det.TomarGps(false);
                hizo = true;
            }

            list = (from r in Rutas.GetRutas()
                    where r.Selected && (r.LlevaFoto)
                    select r).ToList();

            if (list.Count() > 0)
            {
                var det = new Detalle(list);
                det.TomarFoto(false);
                hizo = true;
            }


            if (!hizo)
            {
                MessageBox.Show(@"Debe seleccionar servicios pendientes",
                                string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                                MessageBoxDefaultButton.Button1);
            }

            Focus();
            return;

            //hacer
        }
        private void CargarDropDList()
        {
            Clientes cliente = new Clientes();
            Rutas    ruta    = new Rutas();

            clientePDropDownList.DataSource     = cliente.Listado("*", "1=1", "");
            clientePDropDownList.DataTextField  = "Nombres";
            clientePDropDownList.DataValueField = "ClienteId";
            clientePDropDownList.DataBind();
        }
Exemplo n.º 23
0
        /*
         * private void GuardarEstados()
         * {
         *  for (var j = 1; j < gridServicios.Rows.Count; j++)
         *  {
         *      if ((bool)gridServicios[j,2])
         *      {
         *          var id = (int) gridServicios[j, 1];
         *          var servicio = Rutas.GetRutas().Where(s => s.Id == id).FirstOrDefault();
         *          //var servicio = finbyid;
         *          servicio.Estado = EstadoServicio.Terminado;
         *          Rutas.AddRuta(servicio);
         *      }
         *  }
         * }*/

        private void ListServicios_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Enter))
            {
                gridServicios[gridServicios.RowSel, 2] = (bool)gridServicios[gridServicios.RowSel, 2] ? false: true;

                var rowIndex = gridServicios.RowSel - 1;

                if (rowIndex < 0)
                {
                    return;
                }
                Rutas.GetRutas()[rowIndex].Selected = (bool)gridServicios[gridServicios.RowSel, 2];
            }

            if ((e.KeyValue == 205)) //e
            {
                ShowSelectedServiceDetail(true);
            }

            if ((e.KeyValue == 222)) //l
            {
                TomarLaterales();
            }

            if ((e.KeyValue == 49)) //r
            {
                TomarReferencia();
            }

            if ((e.KeyValue == 53)) //g
            {
                TomarGPS();
            }

            if ((e.KeyValue == 52)) //f
            {
                TomarFoto();
            }
            if (e.KeyCode == Keys.T)
            {
                LoadGPS();
            }
            if (e.KeyCode == Keys.S)
            {
                var result = MessageBox.Show("¿Desea salir de la aplicación?", "Urbetrack Postal",
                                             MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                             MessageBoxDefaultButton.Button2);
                if (result == DialogResult.Yes)
                {
                    Disposing = true;
                    Application.Exit();
                }
            }
        }
Exemplo n.º 24
0
        private void BuscarButton_Click(object sender, EventArgs e)
        {
            Rutas  ruta   = new Rutas();
            string filtro = "";

            if (FiltroTextBox.Text.Length > 0)
            {
                filtro = FiltroComboBox.Text + " like '%" + FiltroTextBox.Text + "%'";
            }
            ConsultaDataGridView.DataSource = ruta.Listado("RutaId,NombreRuta ", filtro, "");
        }
Exemplo n.º 25
0
        public async Task <IHttpActionResult> GetRutas(int id)
        {
            Rutas rutas = await db.Rutas.FindAsync(id);

            if (rutas == null)
            {
                return(NotFound());
            }

            return(Ok(rutas));
        }
 void ReloadRoutes(List <Route> routes)
 {
     Rutas.Clear();
     foreach (var route in routes)
     {
         if (route != null)
         {
             Rutas.Add(route);
         }
     }
 }
Exemplo n.º 27
0
        private void Guardarbutton_Click(object sender, EventArgs e)
        {
            Rutas ruta = new Rutas();

            if (NombreRutatextBox.TextLength == 0 || RutaDetalletextBox.TextLength == 0)
            {
                MessageBox.Show("No puede dejar ningun campo vacio", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            if (RutaIdtextBox.TextLength == 0)
            {
                int id;
                int.TryParse(RutaIdtextBox.Text, out id);
                ruta.RutaId     = id;
                ruta.NombreRuta = NombreRutatextBox.Text;
                ruta.Detalle    = RutaDetalletextBox.Text;
                ruta.CobradorId = Convert.ToInt32(CobradorIdcomboBox.SelectedValue);

                for (int i = 0; i < CobradordataGridView.Rows.Count; i++)
                {
                    ruta.AgregarCobrador(ruta.CobradorId, CobradordataGridView.Rows[i].ToString(), "");
                }

                if (ruta.Insertar())
                {
                    MessageBox.Show("Ruta ha sido Registrada");
                }
                else
                {
                    MessageBox.Show("Ruta no ha podido ser Registrada");
                }
            }
            else if (RutaIdtextBox.TextLength > 0)
            {
                int id;
                int.TryParse(RutaIdtextBox.Text, out id);
                ruta.RutaId     = id;
                ruta.NombreRuta = NombreRutatextBox.Text;
                ruta.Detalle    = RutaDetalletextBox.Text;

                for (int i = 0; i < CobradorIdcomboBox.Items.Count; i++)
                {
                    //   ruta.CobradorId += (int)Convert.ToInt32(CobradorlistBox.Items[i]);
                }
                if (ruta.Editar())
                {
                    MessageBox.Show("Ruta ha sido Editada");
                }
                else
                {
                    MessageBox.Show("Ruta no ha sido Editada Correctamente");
                }
            }
        }
Exemplo n.º 28
0
        public Rutas Map(SqlDataReader reader)
        {
            Rutas rutas = new Rutas();

            rutas.Ciudad_Origen  = (string)reader["Ciudad origen"];
            rutas.Dpto_Origen    = (string)reader["Departamento origen"];
            rutas.Ciudad_Destino = (string)reader["Ciudad destino"];
            rutas.Dpto_Destino   = (string)reader["Departamento destino"];
            rutas.Tarifa         = (int)reader["Tarifa"];

            return(rutas);
        }
Exemplo n.º 29
0
        public ActionResult Create()
        {
            if (User.IsInRole("Staff") || User.IsInRole("Administrador"))
            {
                ViewBag.Message = "Confirmado";
            }

            Rutas model = new Rutas();

            model.Abierto = true;
            return(View(model));
        }
Exemplo n.º 30
0
        public void BuscarViaje(Reserva reserva)
        {
            var query = from q in Rutas
                        where q.Estaciones.Contains(reserva.Destino) &&
                        q.Estaciones.Contains(reserva.Salida) &&
                        q.FechaInicio >= reserva.Fecha
                        select q;

            query      = Rutas.Where(g => true).Select(g => g);
            Resultados = query.ToList();
            LVResultados.ItemsSource = Resultados;
        }