Beispiel #1
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                Entrega e = new Entrega();
                e.Id         = id;
                e.Estado     = collection["nEstado"];
                e.Cidade     = collection["nCidade"];
                e.Rua        = collection["nRua"];
                e.Numero     = Convert.ToInt32(collection["nNumero"]);
                e.Referencia = collection["nReferencia"];
                e.Venda      = VendaDAO.BuscarPorId(Convert.ToInt32(collection["Venda.Id"]));

                if (!string.IsNullOrEmpty(collection["nData"]))
                {
                    e.Data = Convert.ToDateTime(collection["nData"]);
                }
                else
                {
                    e.Data = DateTime.Now;
                }


                if (!EntregaDAO.Persistir(e))
                {
                    return(View());
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #2
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                Entrega e = new Entrega();
                e.Data       = DateTime.Now;
                e.Estado     = collection["nEstado"];
                e.Cidade     = collection["nCidade"];
                e.Rua        = collection["nRua"];
                e.Numero     = Convert.ToInt32(collection["nNumero"]);
                e.Referencia = collection["nReferencia"];
                e.Venda      = VendaDAO.BuscarPorId(Convert.ToInt32(collection["Venda.Id"]));

                if (!EntregaDAO.Persistir(e))
                {
                    return(View());
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        /// <summary>
        /// Revisa si es posible asignar el docente seleccionado al alumno en
        /// cuestion, de ser así se almacena la asignación en la base de datos,
        /// de lo contrario muestra un mensaje sobre el problema.
        /// </summary>
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (listaDocentes[cbxAsesor.SelectedIndex].Estatus == "Inactivo")
            {
                MessageBox.Show("El docente seleccionado está actualmente inactivo\npor lo tanto no puede ser su asesor",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (btnAceptar.Text == "Aceptar")
            {
                DialogResult dr = MessageBox.Show("Asignar el asesor:\n" +
                                                  listaDocentes[cbxAsesor.SelectedIndex].NombreCompleto +
                                                  "\nal alumno:\n" +
                                                  AlumnoDAO.ObtenerAlumno(matricula).NombreCompleto, "Info",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.No)
                {
                    return;
                }

                DocenteDAO.AsignarAsesorado(matricula, listaDocentes[cbxAsesor.SelectedIndex].ID);
                EntregaDAO.InsertarDocumentosPendientes(matricula);
            }
            else
            {
                DocentePOJO docenteAnterior = DocenteDAO.ObtenerDocenteXMatricula(matricula);
                if (docenteAnterior.ID == listaDocentes[cbxAsesor.SelectedIndex].ID)
                {
                    MessageBox.Show("El docente seleccionado, actualmente es el asesor del alumno:\n" +
                                    AlumnoDAO.ObtenerAlumno(matricula).NombreCompleto +
                                    "\nsi desea cambiar de asesor, pruebe con otro", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DialogResult dr = MessageBox.Show("Asignar el asesor:\n" +
                                                  listaDocentes[cbxAsesor.SelectedIndex].NombreCompleto +
                                                  "\nal alumno:\n" +
                                                  AlumnoDAO.ObtenerAlumno(matricula).NombreCompleto, "Info",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.No)
                {
                    return;
                }

                DocenteDAO.CambiarAsesor(listaDocentes[cbxAsesor.SelectedIndex].ID, matricula, docenteAnterior.ID);
                if (docenteAnterior.ID == DocenteDAO.ObtenerDocenteXMatricula(matricula).ID)
                {
                    MessageBox.Show("El docente seleccionado ya cumple un rol con el alumno:\n" +
                                    AlumnoDAO.ObtenerAlumno(matricula).NombreCompleto + "\npor lo tanto no puede ser su asesor",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            MessageBox.Show("El docente fue asignado como asesor correctamente", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
Beispiel #4
0
        public List <Entrega> SeleccionarEntregasPorTransporte(long numeroManifiesto)
        {
            EntregaDAO entregaDAO = new EntregaDAO();


            List <Entrega> entregas = new List <Entrega>();

            entregas = entregaDAO.SeleccionarEntregasPorTransporte(numeroManifiesto);
            return(entregas);
        }
Beispiel #5
0
        // GET: Entrega/Edit/5
        public ActionResult Edit(int id)
        {
            ViewBag.Vendas = VendaDAO.BuscarTodos();
            Entrega e = EntregaDAO.BuscarPorId(id);

            if (e == null)
            {
                return(HttpNotFound());
            }
            return(View(e));
        }
        public void PersistirAtualizar()
        {
            Entrega e = EntregaDAO.BuscarPorId(EntregaDAO.getLastId());

            e.Data       = DateTime.Now;
            e.Estado     = "Minas Gerais";
            e.Cidade     = "Juiz de Fora";
            e.Rua        = "Rua atualizada";
            e.Numero     = 781;
            e.Bairro     = "Bairro atualizado";
            e.Referencia = "Referencia atualizada";
            e.Venda      = VendaDAO.BuscarPorId(2);

            Assert.IsTrue(EntregaDAO.Persistir(e));
        }
        public void PersistirInserir()
        {
            Entrega e = new Entrega();

            e.Data       = Convert.ToDateTime("25/05/2019");
            e.Estado     = "Rio de Janeiro";
            e.Cidade     = "Rio de Janeiro";
            e.Rua        = "Nova rua";
            e.Numero     = 187;
            e.Bairro     = "Novo bairro";
            e.Referencia = "Nova referencia";
            e.Venda      = VendaDAO.BuscarPorId(VendaDAO.getLastId());

            Assert.IsTrue(EntregaDAO.Persistir(e));
        }
 /// <summary>
 /// Revisa cuales documentos ya fueron entregados para marcarlos
 /// en las casillas de verificación.
 /// </summary>
 public void palomearChecks()
 {
     for (int i = 3; i < 9; i++)
     {
         if (EntregaDAO.ObtenerEntrega(matricula, i).Estado == "Entregado")
         {
             tablaDocumentos[1, (i - 3)].Value = true;
         }
         else
         {
             tablaDocumentos[1, (i - 3)].Value = false;
         }
     }
     entregoTodos();
 }
Beispiel #9
0
        public bool UpdateEntrega(int IdEntrega
                                  , string Status)

        {
            EntregaDAO entrega = new EntregaDAO();

            entrega.AtualizarStatus(IdEntrega, Status);
            if (entrega.valor == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #10
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         if (EntregaDAO.Excluir(id))
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(EntregaDAO.BuscarPorId(id)));
         }
     }
     catch
     {
         return(View(EntregaDAO.BuscarPorId(id)));
     }
 }
Beispiel #11
0
        public Entrega GuardarEntrega(Entrega entrega)
        {
            EntregaDAO entregaDAO = new EntregaDAO();

            return(entregaDAO.GuardarEntrega(entrega));
        }
        private List <TipoEventoLogistico> ValidarEventosLogisticosSucesoresPorUltimoEvento(EventoLogistico ultimoEventoRegistrado, List <EventoLogistico> eventosRegistrados, List <TipoEventoLogistico> tipoEventos, long numeroManifiesto)
        {
            List <TipoEventoLogistico> eventosSucesores = new List <TipoEventoLogistico>();

            //Si el ultimo evento registrado fue activación, valida si es un vacio para mostrar el evento inicio de viaje
            if (ultimoEventoRegistrado.IdTipoEvento == (int)TipoEventoLogisticoEnum.ActivarViaje)
            {
                HistorialActivacionManifiestoDAO historialActivacionDAO = new HistorialActivacionManifiestoDAO();
                HistorialActivacionManifiesto    transporte             = historialActivacionDAO.SeleccionarHistorialActivacionManifiesto(ultimoEventoRegistrado.NumeroManifiesto);
                if (transporte != null)
                {
                    if (transporte.ClaseTransporte == "ZT17" || transporte.ClaseTransporte == "ZT18")
                    {
                        eventosSucesores = tipoEventos.Where(t => t.CodigoEvento == (int)TipoEventoLogisticoEnum.IniciaViaje ||
                                                             t.CodigoEvento == (int)TipoEventoLogisticoEnum.Otro).ToList();
                        return(eventosSucesores);
                    }
                }
            }

            //si tiene inicios de cargue sin fin cargue, muestra solo fin cargue
            if (ultimoEventoRegistrado.IdTipoEvento == (int)TipoEventoLogisticoEnum.IniciaCargue)
            {
                eventosSucesores = tipoEventos.Where(t => t.CodigoEvento == (int)TipoEventoLogisticoEnum.FinCargue ||
                                                     t.CodigoEvento == (int)TipoEventoLogisticoEnum.Otro).ToList();
                return(eventosSucesores);
            }

            //si valida tiene mas entregas pendientes por registrarle datos de cargue
            EntregaDAO     entregaDAO         = new EntregaDAO();
            List <Entrega> entregasManifiesto = entregaDAO.SeleccionarEntregasPorTransporte(numeroManifiesto);

            if (ultimoEventoRegistrado.IdTipoEvento == (int)TipoEventoLogisticoEnum.FinCargue)
            {
                int entregasCargadas = 0;
                foreach (Entrega entrega in entregasManifiesto)
                {
                    var llegadaCargue = (from e in eventosRegistrados
                                         where e.IdTipoEvento == (int)TipoEventoLogisticoEnum.LlegadaCargue
                                         where e.campo1 == entrega.NumeroEntrega.ToString()
                                         select e).ToList();
                    var finCargue = (from e in eventosRegistrados
                                     where e.IdTipoEvento == (int)TipoEventoLogisticoEnum.FinCargue
                                     where e.campo1 == entrega.NumeroEntrega.ToString()
                                     select e).ToList();
                    if (llegadaCargue != null && finCargue != null)
                    {
                        entregasCargadas += 1;
                    }
                }
                if (entregasCargadas < entregasManifiesto.Count)
                {
                    eventosSucesores = tipoEventos.Where(t => t.CodigoEvento == (int)TipoEventoLogisticoEnum.LlegadaCargue ||
                                                         t.CodigoEvento == (int)TipoEventoLogisticoEnum.Otro).ToList();
                    return(eventosSucesores);
                }
            }
            //si tiene inicios de descargue sin fin descargue, muestra solo fin descargue
            if (ultimoEventoRegistrado.IdTipoEvento == (int)TipoEventoLogisticoEnum.IniciaDescargue)
            {
                eventosSucesores = tipoEventos.Where(t => t.CodigoEvento == (int)TipoEventoLogisticoEnum.FinDescargue ||
                                                     t.CodigoEvento == (int)TipoEventoLogisticoEnum.Otro).ToList();
                return(eventosSucesores);
            }
            //si valida tiene mas entregas pendientes por registrarle datos de descargue
            if (ultimoEventoRegistrado.IdTipoEvento == (int)TipoEventoLogisticoEnum.FinDescargue)
            {
                bool existenEntregasSinDescargar = false;


                int entregasDescargadasoDesegachadas = 0;

                foreach (Entrega entrega in entregasManifiesto)
                {
                    var llegadaDescargue = (from e in eventosRegistrados
                                            where e.IdTipoEvento == (int)TipoEventoLogisticoEnum.LlegadaDestino
                                            where e.campo1 == entrega.NumeroEntrega.ToString()
                                            select e).FirstOrDefault();
                    var finDescargue = (from e in eventosRegistrados
                                        where e.IdTipoEvento == (int)TipoEventoLogisticoEnum.FinDescargue
                                        where e.campo1 == entrega.NumeroEntrega.ToString()
                                        select e).FirstOrDefault();

                    if (llegadaDescargue != null && finDescargue != null)
                    {
                        entregasDescargadasoDesegachadas = entregasDescargadasoDesegachadas + 1;
                    }
                    else
                    {
                        var desenganche = (from e in eventosRegistrados
                                           where e.IdTipoEvento == (int)TipoEventoLogisticoEnum.Desenganche
                                           select e).FirstOrDefault();

                        if (desenganche != null)
                        {
                            int remesesasDesengachadas = 0;
                            if (int.TryParse(desenganche.campo1, out remesesasDesengachadas))
                            {
                                entregasDescargadasoDesegachadas = entregasDescargadasoDesegachadas + remesesasDesengachadas;
                            }
                        }
                    }
                }
                if (entregasDescargadasoDesegachadas < entregasManifiesto.Count())
                {
                    existenEntregasSinDescargar = true;
                }

                if (existenEntregasSinDescargar)
                {
                    eventosSucesores = tipoEventos.Where(t => t.CodigoEvento == (int)TipoEventoLogisticoEnum.LlegadaDestino ||
                                                         t.CodigoEvento == (int)TipoEventoLogisticoEnum.Otro).ToList();
                    return(eventosSucesores);
                }
            }
            //si tiene inicios de paradas sin continuacion viaje, muestra solo eventos que puede registrar en esta parado
            if (ultimoEventoRegistrado.IdTipoEvento == (int)TipoEventoLogisticoEnum.ParadaCamino)
            {
                eventosSucesores = tipoEventos.Where(t => t.CodigoEvento == (int)TipoEventoLogisticoEnum.ContinuacionViaje ||
                                                     t.CodigoEvento == (int)TipoEventoLogisticoEnum.Otro).ToList();
                return(eventosSucesores);
            }

            return(eventosSucesores);
        }
        public void BuscarTodos()
        {
            List <Entrega> entregas = EntregaDAO.BuscarTodos();

            Assert.IsTrue(entregas.Count > 0);
        }
        /// <summary>
        /// Almacena todos los cambios realizados en la
        /// base de datos.
        /// </summary>
        private void btnGuardarCambios_Click(object sender, EventArgs e)
        {
            if (spnCalificacionFinal.Enabled == false)
            {
                DialogResult dr = MessageBox.Show("¿Mantener los cambios realizados?", "Info",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.No)
                {
                    return;
                }

                for (int i = 3; i < 9; i++)
                {
                    if (tablaDocumentos[1, (i - 3)].Value.Equals(true))
                    {
                        EntregaDAO.CambiarEstadoDocumento("Entregado", matricula, i);
                    }
                    else
                    {
                        EntregaDAO.CambiarEstadoDocumento("Pendiente", matricula, i);
                    }
                }
                MessageBox.Show("Documentos guardados con exito", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnGuardarCambios.Enabled = false;
                entregoTodos();
            }
            else if (spnCalificacionFinal.Enabled == true)
            {
                DialogResult dr = MessageBox.Show("Crear el dictamen \"liberación asesor\" con una calificación final de " + spnCalificacionFinal.Value, "Info",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.No)
                {
                    return;
                }

                ResidenciaPOJO residencia = ResidenciaDAO.ObtenerResidenciaXMatricula(matricula);
                String         estatus;
                if (spnCalificacionFinal.Value >= 70)
                {
                    estatus = "Aceptado";
                }
                else
                {
                    estatus = "Rechazado";
                }
                String       fecha         = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day;
                DictamenPOJO nuevoDictamen = new DictamenPOJO(0, residencia.ID, idDocente, "LiberacionAsesor",
                                                              estatus, txtaComentario.Text, int.Parse(spnCalificacionFinal.Value + ""), DateTime.Parse(fecha));
                DictamenDAO.InsertarDictamen(nuevoDictamen);
                MessageBox.Show("Dictamen creado con exito", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                llenarTablaAlumno();
                bloquearDesbloquear(false);
                btnGuardarCambios.Enabled  = false;
                spnCalificacionFinal.Value = 0;
                limpiarChecks();
                tablaDocumentos.Enabled = false;
                if (tablaAlumnos.Rows.Count == 0)
                {
                    lblNombreAlumno.Text = "NO HAY ASESORADOS CON DOCUMENTACIÓN PENDIENTE";
                    btnCorregir.Visible  = false;
                    tablaAlumnos.Enabled = false;
                }
                else
                {
                    tablaAlumnos.Rows[0].Selected = true;
                    llenarEspacios(0);
                    //lblNombreAlumno.Text = "SELECCIONE UN ALUMNO";
                    btnGuardarCambios.Enabled = true;
                }
            }
        }
        public void BuscarID()
        {
            Entrega e = EntregaDAO.BuscarPorId(EntregaDAO.getLastId());

            Assert.IsNotNull(e);
        }
        public void Deletar()
        {
            Entrega e = EntregaDAO.BuscarPorId(EntregaDAO.getLastId());

            Assert.IsTrue(EntregaDAO.Excluir(EntregaDAO.getLastId()));
        }
        public void Buscar()
        {
            List <Entrega> entregas = EntregaDAO.buscar("aa");

            Assert.IsTrue(entregas.Count > 0);
        }
Beispiel #18
0
 // GET: Entrega/Details/5
 public ActionResult Details(int id)
 {
     return(View(EntregaDAO.BuscarPorId(id)));
 }
Beispiel #19
0
 // GET: Entrega
 public ActionResult Index()
 {
     return(View(EntregaDAO.BuscarTodos()));
 }