Ejemplo n.º 1
0
        public objRes update(planillarecaudoDTO pRDTO)
        {
            using (ctx = new tvEntities())
            {
                objRes          Respuesta = new objRes();
                planillarecaudo pR;

                try
                {
                    pR = ctx.planillarecaudo.Where(t => t.id == pRDTO.id).FirstOrDefault();
                    if (pR != null)
                    {
                        Mapper.Map(pRDTO, pR);
                        Mapper.Map(pRDTO.gastos, pR.gastos);
                        ctx.SaveChanges();
                        Respuesta.Error   = false;
                        Respuesta.Mensaje = "Operacion realizada satisfactoriamente!!!";
                        return(Respuesta);
                    }
                    else
                    {
                        Respuesta.Error   = true;
                        Respuesta.Mensaje = "No se encuentro registrada la planilla de reacaudo a actualizar...";
                        return(Respuesta);
                    }
                }
                catch (Exception e)
                {
                    Respuesta.Error   = true;
                    Respuesta.Mensaje = e.Message;
                    return(Respuesta);
                }
            }
        }
Ejemplo n.º 2
0
 public objRes update(planillarecaudoDTO pR)
 {
     return((new mPlanillaRecaudo()).update(pR));
 }
Ejemplo n.º 3
0
        public List <planillarecaudoDTO> get(DateTime fecha, int grupo)
        {
            fecha = fecha.Date;//new DateTime(fecha.Year,fecha.Month,fecha.d)
            DateTime fechaFin = new DateTime(fecha.Year, fecha.Month, fecha.Day, 23, 59, 59);
            List <planillarecaudoDTO> lPlaRecDto;
            planillarecaudo           pR;
            planillarecaudo           pRaux;
            planillarecaudoDTO        pRDto;
            gastos   gastos;
            DateTime fecha2;

            using (ctx = new tvEntities()) {
                planillacontrol PlaCtr = ctx.planillacontrol.Where(t => t.Fecha == fecha && t.Grupo == grupo).FirstOrDefault();

                if (PlaCtr != null)
                {
                    lPlaRecDto = new List <planillarecaudoDTO>();

                    List <detallesplanilla> lDePla = PlaCtr.detallesplanilla.OrderBy(t => t.id).Where(t => t.idPlanillaControl == PlaCtr.id).ToList();

                    foreach (detallesplanilla dP in lDePla)
                    {
                        pR    = ctx.planillarecaudo.OrderBy(t => t.idDetallesPlanilla).Where(t => t.idDetallesPlanilla == dP.id).FirstOrDefault();
                        pRDto = new planillarecaudoDTO();

                        if (pR == null)
                        {
                            pR     = new planillarecaudo();
                            gastos = new gastos();
                            pR.idDetallesPlanilla = dP.id;
                            pR.Recorridos         = ctx.entradassalidas.Where(t => t.Fecha > fecha &&
                                                                              t.Fecha < fechaFin &&
                                                                              t.Placa == dP.PlacaBus && t.Estado == "E").Count();// Calcular el numero de Recorridos. Corregir
                            pR.Fecha = fecha;
                            ctx.planillarecaudo.Add(pR);
                            ctx.SaveChanges();

                            gastos.idplanillarecaudo = pR.id;
                            ctx.gastos.Add(gastos);
                            ctx.SaveChanges();

                            //pRaux=ctx.planillarecaudo.OrderByDescending(t=> t.detallesplanilla.id)
                            //    .Where(t=> t.detallesplanilla.id<pR.idDetallesPlanilla &&
                            //        t.detallesplanilla.PlacaBus==
                            //        (ctx.detallesplanilla.Where(y=>y.id==pR.idDetallesPlanilla).FirstOrDefault().PlacaBus))
                            //    .FirstOrDefault();
                            fecha2 = fecha.AddDays(-1);
                            pRaux  = ctx.planillarecaudo.Where(t => t.Fecha == fecha2 && t.detallesplanilla.PlacaBus == dP.PlacaBus).FirstOrDefault();

                            if (pRaux == null)
                            {
                                pR.InicioTorniquete = 0;
                            }
                            else
                            {
                                pR.InicioTorniquete = pRaux.FinTorniquete;
                            }

                            ctx.SaveChanges();
                        }

                        Mapper.Map(pR, pRDto);
                        pRDto.Time = dP.HoraSalida.ToString();
                        Mapper.Map(pR.gastos, pRDto.gastos);
                        lPlaRecDto.Add(pRDto);
                    }

                    return(lPlaRecDto);
                }
                else
                {
                    return(null);
                }
            }
        }