Exemplo n.º 1
0
 public Boolean Guardar(clsCuenta cuenta)
 {
     try
     {
         using (EntitiesContabilidad2 ent = new EntitiesContabilidad2())
         {
             Cuenta ct = new Cuenta()
             {
                 IdEmpresa         = cuenta.IdEmpresa,
                 IdCuenta          = cuenta.IdCuenta,
                 codigo_padre      = cuenta.codigo_padre,
                 nombre            = cuenta.nombre,
                 descripcion       = cuenta.descripcion,
                 IdNivelCuenta     = cuenta.IdNivelCuenta,
                 IdTipoCuenta      = cuenta.IdTipoCuenta,
                 naturaleza_cuenta = cuenta.naturaleza_cuenta,
                 IdUsuario         = 1,
                 //FechaModificacion = cuenta.IdEmpresa
             };
             ent.AddToCuenta(ct);
             ent.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        private Boolean GuardarDetalle(clsCabeceraComprobante dato)
        {
            try
            {
                int secuencia = 0;
                foreach (var item in dato.Detalle)
                {
                    secuencia = secuencia + 1;
                    using (EntitiesContabilidad2 ent = new EntitiesContabilidad2())
                    {
                        DetalleComprobante det = new DetalleComprobante()
                        {
                            IdEmpresa            = dato.IdEmpresa,
                            cabecera_comprobante = dato.numero_comprobante,
                            linea_comprobante    = secuencia,
                            cuenta = item.cuenta,
                            debe   = item.debe,
                            haber  = item.haber
                        };
                        ent.AddToDetalleComprobante(det);
                        ent.SaveChanges();
                    }
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 //MANTENIMIENTO ELIMIAR
 public void eliminar(clsTipoTransaccion tiptran)
 {
     using (EntitiesContabilidad2 ent = new EntitiesContabilidad2())
     {
         var x = (from q in ent.TipoTransaccion where q.IdTransaccion == tiptran.IdTransaccion select q).First();
         ent.DeleteObject(x);
         ent.SaveChanges();
     }
 }
Exemplo n.º 4
0
 //MANTENIMIENTO MODIFICAR
 public void modificar(clsTipoTransaccion tiptran)
 {
     using (EntitiesContabilidad2 ent = new EntitiesContabilidad2())
     {
         var x = (from q in ent.TipoTransaccion where q.IdTransaccion == tiptran.IdTransaccion select q).First();
         x.modulo        = tiptran.modulo;
         x.TipoDocumento = tiptran.TipoDocumento;
         x.descripcion   = tiptran.descripcion;
         ent.SaveChanges();
     }
 }
Exemplo n.º 5
0
 //MANTENIMIENTO GUARDAR
 public void guardar(clsTipoTransaccion tiptran)
 {
     using (EntitiesContabilidad2 ent = new EntitiesContabilidad2())
     {
         TipoTransaccion tt = new TipoTransaccion()
         {
             IdTransaccion = tiptran.IdTransaccion,
             modulo        = tiptran.modulo,
             TipoDocumento = tiptran.TipoDocumento,
             descripcion   = tiptran.descripcion
         };
         ent.AddToTipoTransaccion(tt);
         ent.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public Boolean RevertirC(decimal NumeroCom, int idEmpresa, ref decimal NumComRevert)
 {
     try
     {
         clsCabeceraComprobante dato = new clsCabeceraComprobante();
         dato = consultaComprobante(NumeroCom, idEmpresa);
         if (dato.Detalle.Sum(q => q.debe) != dato.Detalle.Sum(q => q.haber))
         {
             return(false);
         }
         EntitiesContabilidad2 enti = new EntitiesContabilidad2();
         decimal numero             = 0;
         try
         {
             numero = (from q in enti.CabeceraComprobante where q.IdEmpresa == 1 select q.numero_comprobante).Max() + 1;
         }
         catch (Exception)
         {
             numero = 1;
         }
         using (EntitiesContabilidad2 ent = new EntitiesContabilidad2())
         {
             CabeceraComprobante cab = new CabeceraComprobante()
             {
                 IdEmpresa          = dato.IdEmpresa,
                 numero_comprobante = numero,
                 fecha = dato.fecha,
                 glosa = "Reverso del Comprobante # " + Convert.ToString(dato.numero_comprobante) + " => " + dato.glosa
                         //periodo_contable
                         //periodo_contable_IdAFiscal
                         //IdUsuario
                         //FechaModificacion
             };
             dato.numero_comprobante = numero;
             ent.AddToCabeceraComprobante(cab);
             ent.SaveChanges();
             NumComRevert = numero;
         }
         RevertirD(dato);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 7
0
        public Boolean Modificar(clsCuenta cuenta)
        {
            try
            {
                EntitiesContabilidad2 ent = new EntitiesContabilidad2();
                var mod = (from q in ent.Cuenta where q.IdEmpresa == cuenta.IdEmpresa && q.IdCuenta == cuenta.IdCuenta select q).First();
                mod.descripcion       = cuenta.descripcion;
                mod.nombre            = cuenta.nombre;
                mod.FechaModificacion = DateTime.Now;
                ent.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 8
0
 public Boolean GuardarCabecera(ref clsCabeceraComprobante dato)
 {
     try
     {
         if (dato.Detalle.Sum(q => q.debe) != dato.Detalle.Sum(q => q.haber))
         {
             return(false);
         }
         EntitiesContabilidad2 enti = new EntitiesContabilidad2();
         decimal numero             = 0;
         try
         {
             numero = (from q in enti.CabeceraComprobante where q.IdEmpresa == 1 select q.numero_comprobante).Max() + 1;
         }
         catch (Exception)
         {
             numero = 1;
         }
         dato.numero_comprobante = numero;
         using (EntitiesContabilidad2 ent = new EntitiesContabilidad2())
         {
             CabeceraComprobante cab = new CabeceraComprobante()
             {
                 IdEmpresa          = dato.IdEmpresa,
                 numero_comprobante = numero,
                 fecha                      = dato.fecha,
                 glosa                      = dato.glosa,
                 periodo_contable           = Convert.ToDecimal((from q in ent.PeriodoContable where q.FechaInicio <DateTime.Now && q.FechaFin> DateTime.Now select q.IdPeriodoContable).First()),
                 periodo_contable_IdAFiscal = DateTime.Now.Year,
                 //IdUsuario
                 //FechaModificacion
             };
             ent.AddToCabeceraComprobante(cab);
             ent.SaveChanges();
         }
         GuardarDetalle(dato);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 9
0
 public Boolean Eliminar(clsCuenta cuenta)
 {
     try
     {
         EntitiesContabilidad2 ent = new EntitiesContabilidad2();
         var regcuenta             = (from q in ent.Cuenta where q.IdEmpresa == cuenta.IdEmpresa && q.IdCuenta == cuenta.IdCuenta select q).First();
         var count = (from q in ent.Cuenta where q.codigo_padre == cuenta.IdCuenta select q).Count();
         if (count == 0)
         {
             ent.DeleteObject(regcuenta);
             ent.SaveChanges();
         }
         else
         {
             return(false);
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 10
0
        public Boolean insert(List <clsvwComprobanteMayorizar> lista)
        {
            try
            {
                using (EntitiesContabilidad2 ent = new EntitiesContabilidad2())
                {
                    foreach (var item in lista)
                    {
                        var s = from q in ent.DetalleComprobante where q.IdEmpresa == item.IdEmpresa && q.cabecera_comprobante == item.numero_comprobante select q;
                        foreach (var item2 in s)
                        {
                            try
                            {
                                EntitiesContabilidad2 ent2 = new EntitiesContabilidad2();
                                DateTime fecha             = (from q in ent2.PeriodoContable where q.FechaInicio <item.fecha && q.FechaFin> item.fecha select q.FechaFin).First();
                                if ((from q in ent.Saldo where q.fecha == fecha select q).Count() > 0)
                                {
                                    var saldo = (from q in ent2.Saldo where q.fecha == fecha && q.cuenta == item2.cuenta select q).First();
                                    saldo.saldo_deudor   = saldo.saldo_deudor + item2.debe;
                                    saldo.saldo_acreedor = saldo.saldo_acreedor + item2.haber;
                                    ent2.SaveChanges();
                                }
                                else
                                {
                                    Saldo sald = new Saldo()
                                    {
                                        IdEmpresa = 1,
                                        cuenta    = item2.cuenta,
                                        //esta fecha debe ser la fechafinal del periodo
                                        fecha = Convert.ToDateTime((from q in ent.PeriodoContable where q.FechaInicio <item.fecha && q.FechaFin> item.fecha select q.FechaFin).First()),
                                        //el debe y el haber se debe acumular segun la cuenta y la fecha del periodo si ya existe en la base
                                        saldo_deudor      = item2.debe,
                                        saldo_acreedor    = item2.haber,
                                        IdUsuario         = 1,
                                        FechaModificacion = DateTime.Now
                                    };
                                    ent.AddToSaldo(sald);
                                }
                            }
                            catch (Exception)
                            {
                                Saldo sald = new Saldo()
                                {
                                    IdEmpresa = 1,
                                    cuenta    = item2.cuenta,
                                    //esta fecha debe ser la fechafinal del periodo
                                    fecha = Convert.ToDateTime((from q in ent.PeriodoContable where q.FechaInicio <item.fecha && q.FechaFin> item.fecha select q.FechaFin).First()),
                                    //el debe y el haber se debe acumular segun la cuenta y la fecha del periodo si ya existe en la base
                                    saldo_deudor      = item2.debe,
                                    saldo_acreedor    = item2.haber,
                                    IdUsuario         = 1,
                                    FechaModificacion = DateTime.Now
                                };
                                ent.AddToSaldo(sald);
                            }
                        }
                        SaldoxComprobante xc = new SaldoxComprobante()
                        {
                            IdEmpresa          = 1,
                            numero_comprobante = item.numero_comprobante
                        };
                        ent.AddToSaldoxComprobante(xc);
                    }

                    ent.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }