Beispiel #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            gastos gastos = db.gastos.Find(id);

            db.gastos.Remove(gastos);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
 public ActionResult Edit(gastos gastos)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gastos).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gastos));
 }
Beispiel #3
0
        public List <gastos> get_gastos(int id)
        {
            List <gastos> visModel  = new List <gastos>();
            string        str_query = "select ga.id, ga.total, fo.nome, data, numero_documento from gastos ga " +
                                      " join fornecedores fo on fo.id = ga.fornecedores_id where ga.ope_itens_id = @id";

            using (SqlConnection conn = new SqlConnection(str_connection))
                using (SqlCommand cmd = new SqlCommand(str_query, conn))
                {
                    cmd.Parameters.AddWithValue("@id", id);

                    conn.Open();

                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        int     nId                = Convert.ToInt32(reader["id"]);
                        decimal total              = Convert.ToDecimal(reader["total"]);
                        string  data               = reader["data"].ToString();
                        string  numero_documento   = reader["numero_documento"].ToString();
                        int     memo               = Convert.ToInt32(reader["memo"]);
                        int     fornecedores_id    = Convert.ToInt32(reader["fornecedores_id"]);
                        int     tipo_documentos_id = Convert.ToInt32(reader["tipo_documentos_id"]);
                        int     ope_itens_id       = Convert.ToInt32(reader["ope_itens_id"]);

                        gastos objVis = new gastos();
                        objVis.id = nId;

                        objVis.data               = data;
                        objVis.numero_documento   = numero_documento;
                        objVis.memo               = memo;
                        objVis.fornecedores_id    = fornecedores_id;
                        objVis.tipo_documentos_id = tipo_documentos_id;
                        objVis.ope_itens_id       = ope_itens_id;

                        visModel.Add(objVis);
                    }
                    return(visModel);
                }
        }
Beispiel #4
0
        //
        // GET: /gastos/Delete/5

        public ActionResult Delete(int id)
        {
            gastos gastos = db.gastos.Find(id);

            return(View(gastos));
        }
Beispiel #5
0
        //
        // GET: /gastos/Details/5

        public ViewResult Details(int id)
        {
            gastos gastos = db.gastos.Find(id);

            return(View(gastos));
        }
Beispiel #6
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);
                }
            }
        }