コード例 #1
0
        public bool anularDB(Af_Depreciacion_Info info)
        {
            try
            {
                using (Entities_activo_fijo Context = new Entities_activo_fijo())
                {
                    Af_Depreciacion Entity = Context.Af_Depreciacion.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdDepreciacion == info.IdDepreciacion);
                    if (Entity == null)
                    {
                        return(false);
                    }

                    Entity.Estado = info.Estado = "I";

                    Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                    Entity.Fecha_UltAnu    = DateTime.Now;
                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
 public bool guardarDB(Af_Depreciacion_Info info)
 {
     try
     {
         using (Entities_activo_fijo Context = new Entities_activo_fijo())
         {
             Af_Depreciacion Entity = new Af_Depreciacion
             {
                 IdEmpresa           = info.IdEmpresa,
                 IdDepreciacion      = info.IdDepreciacion = get_id(info.IdEmpresa),
                 IdPeriodo           = info.IdPeriodo,
                 Cod_Depreciacion    = info.Cod_Depreciacion,
                 Descripcion         = info.Descripcion,
                 Estado              = info.Estado = "A",
                 Fecha_Depreciacion  = info.Fecha_Depreciacion.Date,
                 Num_Act_Depre       = info.Num_Act_Depre,
                 Valor_Tot_Act       = info.Valor_Tot_Act,
                 Valor_Tot_Depre     = info.Valor_Tot_Depre,
                 Valor_Tot_DepreAcum = info.Valor_Tot_DepreAcum,
                 Valot_Tot_Importe   = info.Valot_Tot_Importe,
                 IdEmpresa_ct        = info.IdEmpresa_ct,
                 IdTipoCbte          = info.IdTipoCbte,
                 IdCbteCble          = info.IdCbteCble,
                 IdUsuario           = info.IdUsuario,
                 Fecha_Transac       = DateTime.Now,
             };
             Context.Af_Depreciacion.Add(Entity);
             int secuencia = 1;
             foreach (var item in info.lst_detalle)
             {
                 Af_Depreciacion_Det Entity_d = new Af_Depreciacion_Det
                 {
                     IdEmpresa          = info.IdEmpresa,
                     IdActivoFijo       = item.IdActivoFijo,
                     IdDepreciacion     = info.IdDepreciacion,
                     Concepto           = item.Concepto,
                     Porc_Depreciacion  = item.Porc_Depreciacion,
                     Secuencia          = item.Secuencia = secuencia++,
                     Valor_Compra       = item.Valor_Compra,
                     Valor_Depreciacion = item.Valor_Depreciacion,
                     Valor_Depre_Acum   = item.Valor_Depre_Acum,
                     Valor_Salvamento   = item.Valor_Salvamento,
                     Vida_Util          = item.Vida_Util
                 };
                 Context.Af_Depreciacion_Det.Add(Entity_d);
             }
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         tb_LogError_Data LogData = new tb_LogError_Data();
         LogData.GuardarDB(new tb_LogError_Info {
             Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "Af_Depreciacion_Data", Metodo = "guardarDB", IdUsuario = info.IdUsuario
         });
         return(false);
     }
 }
コード例 #3
0
        public bool modificarDB(Af_Depreciacion_Info info)
        {
            try
            {
                using (Entities_activo_fijo Context = new Entities_activo_fijo())
                {
                    Af_Depreciacion Entity = Context.Af_Depreciacion.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdDepreciacion == info.IdDepreciacion);
                    if (Entity == null)
                    {
                        return(false);
                    }

                    Entity.IdPeriodo           = info.IdPeriodo;
                    Entity.Cod_Depreciacion    = info.Cod_Depreciacion;
                    Entity.Descripcion         = info.Descripcion;
                    Entity.Fecha_Depreciacion  = info.Fecha_Depreciacion.Date;
                    Entity.Num_Act_Depre       = info.Num_Act_Depre;
                    Entity.Valor_Tot_Act       = info.Valor_Tot_Act;
                    Entity.Valor_Tot_Depre     = info.Valor_Tot_Depre;
                    Entity.Valor_Tot_DepreAcum = info.Valor_Tot_DepreAcum;
                    Entity.Valot_Tot_Importe   = info.Valot_Tot_Importe;

                    Entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    Entity.Fecha_UltMod    = DateTime.Now;
                    Context.Database.ExecuteSqlCommand("delete Af_Depreciacion_Det where IdEmpresa = " + info.IdEmpresa + "and IdDepreciacion = " + info.IdDepreciacion);
                    int secuencia = 1;
                    foreach (var item in info.lst_detalle)
                    {
                        Af_Depreciacion_Det Entity_d = new Af_Depreciacion_Det
                        {
                            IdEmpresa          = info.IdEmpresa,
                            IdActivoFijo       = item.IdActivoFijo,
                            IdDepreciacion     = info.IdDepreciacion,
                            Concepto           = item.Concepto,
                            Porc_Depreciacion  = item.Porc_Depreciacion,
                            Secuencia          = item.Secuencia = secuencia++,
                            Valor_Compra       = item.Valor_Compra,
                            Valor_Depreciacion = item.Valor_Depreciacion,
                            Valor_Depre_Acum   = item.Valor_Depre_Acum,
                            Valor_Salvamento   = item.Valor_Salvamento,
                            Vida_Util          = item.Vida_Util
                        };
                        Context.Af_Depreciacion_Det.Add(Entity_d);
                    }
                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                tb_LogError_Data LogData = new tb_LogError_Data();
                LogData.GuardarDB(new tb_LogError_Info {
                    Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "Af_Depreciacion_Data", Metodo = "modificarDB", IdUsuario = info.IdUsuario
                });
                return(false);
            }
        }
コード例 #4
0
        public Boolean GuardarDB(Af_Depreciacion_Info Info, ref decimal IdDepreciacion, ref string msjError)
        {
            try
            {
                using (EntitiesActivoFijo Context = new EntitiesActivoFijo())
                {
                    var Address = new Af_Depreciacion();
                    Address.IdEmpresa           = Info.IdEmpresa;
                    Address.IdDepreciacion      = Info.IdDepreciacion = IdDepreciacion = GetId(Info.IdEmpresa, Info.IdTipoDepreciacion);
                    Address.IdTipoDepreciacion  = Info.IdTipoDepreciacion;
                    Address.Cod_Depreciacion    = (Info.Cod_Depreciacion == "" || Info.Cod_Depreciacion == null) ? "Depre_" + Info.IdDepreciacion : Info.Cod_Depreciacion;
                    Address.IdPeriodo           = Info.IdPeriodo;
                    Address.Descripcion         = Info.Descripcion;
                    Address.Fecha_Depreciacion  = Info.Fecha_Depreciacion.Date;
                    Address.Num_Act_Depre       = Info.Num_Act_Depre;
                    Address.Valor_Tot_Act       = Info.Valor_Tot_Act;
                    Address.Valor_Tot_Depre     = Info.Valor_Tot_Depre;
                    Address.Valor_Tot_DepreAcum = Info.Valor_Tot_DepreAcum;
                    Address.Valot_Tot_Importe   = Info.Valot_Tot_Importe;
                    Address.IdUsuario           = Info.IdUsuario;
                    Address.Fecha_Transac       = Info.Fecha_Transac;
                    Address.nom_pc = Info.nom_pc;
                    Address.ip     = Info.ip;
                    Address.Estado = Info.Estado;
                    Context.Af_Depreciacion.Add(Address);
                    Context.SaveChanges();

                    dataDetalle.GuardarDB(Info.ListDetalle, Info.IdDepreciacion, Info.IdTipoDepreciacion, ref msjError);
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje  = ex.InnerException + " " + ex.Message;
                msjError = mensaje;
                throw new Exception(ex.InnerException.ToString());
            }
        }
コード例 #5
0
 public Af_Depreciacion_Info get_info(int IdEmpresa, decimal IdDepreciacion)
 {
     try
     {
         Af_Depreciacion_Info info = new Af_Depreciacion_Info();
         using (Entities_activo_fijo Context = new Entities_activo_fijo())
         {
             Af_Depreciacion Entity = Context.Af_Depreciacion.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdDepreciacion == IdDepreciacion);
             if (Entity == null)
             {
                 return(null);
             }
             info = new Af_Depreciacion_Info
             {
                 IdEmpresa           = Entity.IdEmpresa,
                 IdDepreciacion      = Entity.IdDepreciacion,
                 IdPeriodo           = Entity.IdPeriodo,
                 Cod_Depreciacion    = Entity.Cod_Depreciacion,
                 Descripcion         = Entity.Descripcion,
                 Estado              = Entity.Estado,
                 Fecha_Depreciacion  = Entity.Fecha_Depreciacion,
                 Num_Act_Depre       = Entity.Num_Act_Depre,
                 Valor_Tot_Act       = Entity.Valor_Tot_Act,
                 Valor_Tot_Depre     = Entity.Valor_Tot_Depre,
                 Valor_Tot_DepreAcum = Entity.Valor_Tot_DepreAcum,
                 Valot_Tot_Importe   = Entity.Valot_Tot_Importe,
                 IdEmpresa_ct        = Entity.IdEmpresa_ct,
                 IdTipoCbte          = Entity.IdTipoCbte,
                 IdCbteCble          = Entity.IdCbteCble
             };
         }
         return(info);
     }
     catch (Exception)
     {
         throw;
     }
 }