public ActionResult Edit([Bind(Include = "AccionAhorroID,DescripcionAccionAhorro,TipoEquipoID")] AccionAhorro accionAhorro)
        {
            if (ModelState.IsValid)
            {
                bool hasErrors = false;
                DbContextTransaction Transaction = null;

                try
                {
                    Transaction = db.Database.BeginTransaction();

                    db.Entry(accionAhorro).State = EntityState.Modified;
                    db.SaveChanges();
                    Transaction.Commit();
                }
                catch (Exception eX)
                {
                    if (Transaction != null)
                    {
                        Transaction.Rollback();
                    }

                    ModelState.AddModelError("", eX.Message);
                    hasErrors = true;
                }

                if (!hasErrors)
                {
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.TipoEquipoID = new SelectList(db.TiposEquipos, "TipoEquipoID", "NombreTipoEquipo", accionAhorro.TipoEquipoID);
            return(View(accionAhorro));
        }
Пример #2
0
        public ActionResult Edit([Bind(Include = "CiudadID,Ciudad,NivelTermicoID")] Ciudades ciudades)
        {
            if (ModelState.IsValid)
            {
                bool hasErrors = false;
                DbContextTransaction Transaction = null;

                try
                {
                    Transaction = db.Database.BeginTransaction();

                    db.Entry(ciudades).State = EntityState.Modified;
                    db.SaveChanges();
                    Transaction.Commit();
                }
                catch (Exception eX)
                {
                    if (Transaction != null)
                    {
                        Transaction.Rollback();
                    }

                    ModelState.AddModelError("", eX.Message);
                    hasErrors = true;
                }

                if (!hasErrors)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(ciudades));
        }
Пример #3
0
        public ActionResult Edit([Bind(Include = "PeriodoFacturacionID,Periodo,Dias")] PeriodoFacturacion periodoFacturacion)
        {
            if (ModelState.IsValid)
            {
                bool hasErrors = false;
                DbContextTransaction Transaction = null;

                try
                {
                    Transaction = db.Database.BeginTransaction();

                    db.Entry(periodoFacturacion).State = EntityState.Modified;
                    db.SaveChanges();
                    Transaction.Commit();
                }
                catch (Exception eX)
                {
                    if (Transaction != null)
                    {
                        Transaction.Rollback();
                    }

                    ModelState.AddModelError("", eX.Message);
                    hasErrors = true;
                }

                if (!hasErrors)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(periodoFacturacion));
        }
Пример #4
0
        public ActionResult Edit([Bind(Include = "FuenteID,Fuente,UnidadMedida")] FuenteEnergetica fuenteEnergetica)
        {
            if (ModelState.IsValid)
            {
                bool hasErrors = false;
                DbContextTransaction Transaction = null;

                try
                {
                    Transaction = db.Database.BeginTransaction();

                    db.Entry(fuenteEnergetica).State = EntityState.Modified;
                    db.SaveChanges();
                    Transaction.Commit();
                }
                catch (Exception eX)
                {
                    if (Transaction != null)
                    {
                        Transaction.Rollback();
                    }

                    ModelState.AddModelError("", eX.Message);
                    hasErrors = true;
                }

                if (!hasErrors)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(fuenteEnergetica));
        }
Пример #5
0
        public ActionResult Edit([Bind(Include = "DispositivoID,Nombre,SedeID,LineaBase,FuenteID,PeriodoFacturacionID")] Dispositivo dispositivo)
        {
            if (ModelState.IsValid)
            {
                bool hasErrors = false;
                DbContextTransaction Transaction = null;

                try
                {
                    Transaction = db.Database.BeginTransaction();

                    db.Entry(dispositivo).State = EntityState.Modified;
                    db.SaveChanges();
                    Transaction.Commit();
                }
                catch (Exception eX)
                {
                    if (Transaction != null)
                    {
                        Transaction.Rollback();
                    }

                    ModelState.AddModelError("", eX.Message);
                    hasErrors = true;
                }

                if (!hasErrors)
                {
                    return(RedirectToAction("Index"));
                }
            }

            SetViewBagListData(dispositivo.FuenteID, dispositivo.PeriodoFacturacionID, dispositivo.SedeID);
            return(View(dispositivo));
        }
Пример #6
0
        public ActionResult Edit([Bind(Include = "SedeID,ConsumoID,DispositivoID,FechaInicial,FechaFinal,LineaBase,PeriodoFacturacion,UnidadMedida,ConsumoPeriodo,Valor,ValorUnitario")] Consumo consumo)
        {
            if (ModelState.IsValid)
            {
                bool hasErrors = false;
                DbContextTransaction Transaction = null;

                try
                {
                    hasErrors = ModelNotIsValid(consumo);

                    if (!hasErrors)
                    {
                        Transaction = db.Database.BeginTransaction();

                        consumo.ValorUnitario = decimal.Round(consumo.ValorUnitario, 2);

                        db.Entry(consumo).State = EntityState.Modified;
                        db.SaveChanges();
                        Transaction.Commit();
                    }
                    else
                    {
                        var Dispositivo = db.Dispositivos.Include(d => d.PeriodosFacturacion).Include(d => d.Fuente).Where(d => d.DispositivoID.Equals(consumo.DispositivoID)).FirstOrDefault();
                        if (Dispositivo != null)
                        {
                            if (Dispositivo.PeriodosFacturacion != null)
                            {
                                consumo.PeriodoFacturacion = Dispositivo.PeriodosFacturacion.Periodo;
                            }

                            if (Dispositivo.Fuente != null)
                            {
                                consumo.UnidadMedida = Dispositivo.Fuente.UnidadMedida;
                            }
                        }
                    }
                }
                catch (Exception eX)
                {
                    if (Transaction != null)
                    {
                        Transaction.Rollback();
                    }

                    ModelState.AddModelError("", eX.Message);
                    hasErrors = true;
                }

                if (!hasErrors)
                {
                    return(RedirectToAction("Index"));
                }
            }

            SetViewBagData(consumo.SedeID, consumo.DispositivoID);
            return(View(consumo));
        }
Пример #7
0
        public ActionResult Edit([Bind(Exclude = "EmpresaPhoto", Include = "EmpresaID,Codigo,Nit,Nombre,RazonSocial,RepresentanteLegal,CiudadID,SectorEconomicoID,Direccion,Telefono,Celular,Email,SitioWeb,LogoUrl")] Empresa empresa)
        {
            if (ModelState.IsValid)
            {
                bool hasErrors = false;
                DbContextTransaction Transaction = null;

                try
                {
                    Transaction = db.Database.BeginTransaction();

                    string LogoUrl = GetEmpresaLogoUrl(empresa.LogoUrl);
                    if (!string.IsNullOrEmpty(LogoUrl))
                    {
                        empresa.LogoUrl = LogoUrl;
                    }

                    db.Entry(empresa).State = EntityState.Modified;
                    db.SaveChanges();
                    Transaction.Commit();
                }
                catch (Exception eX)
                {
                    if (Transaction != null)
                    {
                        Transaction.Rollback();
                    }

                    ModelState.AddModelError("", eX.Message);
                    hasErrors = true;
                }

                if (!hasErrors)
                {
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.CiudadID          = new SelectList(db.Ciudades, "CiudadID", "Ciudad", empresa.CiudadID);
            ViewBag.SectorEconomicoID = new SelectList(db.SectoresEconomicos, "SectorEconomicoID", "SectorEconomico", empresa.SectorEconomicoID);
            return(View(empresa));
        }
Пример #8
0
        public ActionResult Edit([Bind(Include = "PeticionID,FechaRegistro,Titulo,Descripcion,TipoPeticion,FechaSolucion,Solucion,ResueltaPor,UserID,EmpresaID")] Peticion peticion)
        {
            if (ModelState.IsValid)
            {
                bool hasErrors = false;
                DbContextTransaction Transaction = null;

                try
                {
                    if (!Helpers.ApplicationContext.CurrentUser.IsSuperAdmin)
                    {
                        peticion.EmpresaID = Helpers.ApplicationContext.CurrentUser.EmpresaID;
                    }

                    Transaction = db.Database.BeginTransaction();

                    db.Entry(peticion).State = EntityState.Modified;
                    db.SaveChanges();
                    Transaction.Commit();
                }
                catch (Exception eX)
                {
                    if (Transaction != null)
                    {
                        Transaction.Rollback();
                    }

                    ModelState.AddModelError("", eX.Message);
                    hasErrors = true;
                }

                if (!hasErrors)
                {
                    return(RedirectToAction("Index"));
                }
            }

            SetViewBagListData(peticion.EmpresaID);

            return(View(peticion));
        }
Пример #9
0
        public ActionResult Edit([Bind(Include = "SedeID,NombreSede,Responsable,Estrato,CiudadID,Direccion,Telefono,Celular,Email,EmpresaID")] Sede sede)
        {
            if (ModelState.IsValid)
            {
                bool hasErrors = false;
                DbContextTransaction Transaction = null;

                try
                {
                    Transaction = db.Database.BeginTransaction();

                    if (sede.EmpresaID < 1)
                    {
                        sede.EmpresaID = Helpers.ApplicationContext.CurrentUser.Empresa.EmpresaID;
                    }

                    db.Entry(sede).State = EntityState.Modified;
                    db.SaveChanges();
                    Transaction.Commit();
                }
                catch (Exception eX)
                {
                    if (Transaction != null)
                    {
                        Transaction.Rollback();
                    }

                    ModelState.AddModelError("", eX.Message);
                    hasErrors = true;
                }

                if (!hasErrors)
                {
                    return(RedirectToAction("Index"));
                }
            }

            SetViewBagListData(sede.CiudadID, sede.EmpresaID);
            return(View(sede));
        }