コード例 #1
0
        public uFacturaEDatos.Sucursales Obten(uFacturaEDatos.Sucursales sucursal)
        {
            try
            {
                //Para cargar el objeto y al mismo tiempo traer todos los elementos internos que estan relacionados
                //_db.DeferredLoadingEnabled = false;

                var vSucursal = from suc in _db.Sucursales where suc.idSucursal == sucursal.idSucursal select suc;

                if (vSucursal.Count() > 0)
                {
                    return(vSucursal.First());
                }
                else
                {
                    _mensajeErrorUsuario = "El idSucursal " + sucursal.idSucursal.ToString() + " no existe y no es posible obtener el registro.";
                    return(null);
                }
            }
            catch (Exception ex)
            {
                _mensajeErrorSistema = ex.Message;
                GrabarLogError(ex);

                return(null);
            }
        }
コード例 #2
0
        public bool Eliminar(uFacturaEDatos.Sucursales sucursal)
        {
            bool resultado = false;

            try
            {
                var vSucursal = from suc in _db.Sucursales where suc.idSucursal == sucursal.idSucursal select suc;

                if (vSucursal.Count() > 0)
                {
                    sucursal = vSucursal.First();
                    _db.Sucursales.DeleteOnSubmit(sucursal);
                    _db.SubmitChanges();

                    resultado = true;
                }
                else
                {
                    _mensajeErrorUsuario = "El idSucursal " + sucursal.idSucursal.ToString() + " no existe y no es posible eliminar el registro.";
                    resultado            = false;
                }
            }
            catch (Exception ex)
            {
                resultado            = false;
                _mensajeErrorSistema = ex.Message;
                GrabarLogError(ex);
            }

            return(resultado);
        }
コード例 #3
0
        public uFacturaEDatos.Documento Obten(int idFormato, uFacturaEDatos.Sucursales sucursal)
        {
            try
            {
                var vDocumento = from doc in _db.Documentos where doc.idSucursal == sucursal.idSucursal && doc.idFormato == idFormato && doc.Activo == true select doc;

                if (vDocumento.Count() > 0)
                {
                    uFacturaEDatos.Documento d = new uFacturaEDatos.Documento();
                    d.Activo        = vDocumento.FirstOrDefault().Activo;
                    d.AnoAprobacion = vDocumento.FirstOrDefault().AnoAprobacion;
                    d.Comprobantes  = vDocumento.FirstOrDefault().Comprobantes;
                    d.FolioInicial  = vDocumento.FirstOrDefault().FolioInicial;
                    d.FoliosFinal   = vDocumento.FirstOrDefault().FoliosFinal;
                    d.FoliosSerie   = vDocumento.FirstOrDefault().FoliosSerie;
                    d.idDocumento   = vDocumento.FirstOrDefault().idDocumento;
                    d.idFormato     = vDocumento.FirstOrDefault().idFormato;
                    d.idSucursal    = vDocumento.FirstOrDefault().idSucursal;
                    d.Impuestos_TasaIEPSTraslado = vDocumento.FirstOrDefault().Impuestos_TasaIEPSTraslado;
                    d.Impuestos_TasaISRRetencion = vDocumento.FirstOrDefault().Impuestos_TasaISRRetencion;
                    d.Impuestos_TasaIVARetencion = vDocumento.FirstOrDefault().Impuestos_TasaIVARetencion;
                    d.Impuestos_TasaIVATraslado  = vDocumento.FirstOrDefault().Impuestos_TasaIVATraslado;
                    d.NoAprobacion = vDocumento.FirstOrDefault().NoAprobacion;
                    d.Nombre       = vDocumento.FirstOrDefault().Nombre;
                    d.OpLabel1     = vDocumento.FirstOrDefault().OpLabel1;
                    d.OpLabel2     = vDocumento.FirstOrDefault().OpLabel2;
                    d.OpLabel3     = vDocumento.FirstOrDefault().OpLabel3;
                    d.OpLabel4     = vDocumento.FirstOrDefault().OpLabel4;
                    d.OpLabel5     = vDocumento.FirstOrDefault().OpLabel5;
                    d.OpLabel6     = vDocumento.FirstOrDefault().OpLabel6;
                    d.OpLabel7     = vDocumento.FirstOrDefault().OpLabel7;
                    d.OpLabel8     = vDocumento.FirstOrDefault().OpLabel8;
                    d.OpLabel9     = vDocumento.FirstOrDefault().OpLabel9;
                    d.OpLabel10    = vDocumento.FirstOrDefault().OpLabel10;

                    d.Tipo          = vDocumento.FirstOrDefault().Tipo;
                    d.Version       = vDocumento.FirstOrDefault().Version;
                    d.VigenciaDesde = vDocumento.FirstOrDefault().VigenciaDesde;
                    d.VigenciaHasta = vDocumento.FirstOrDefault().VigenciaHasta;
                    return(d);
                }
                else
                {
                    _mensajeErrorUsuario = "El tipo de documento no existe o no esta activo.";

                    return(null);
                }
            }
            catch (Exception ex)
            {
                _mensajeErrorSistema = ex.Message;
                GrabarLogError(ex);

                return(null);
            }
        }
コード例 #4
0
 public List <uFacturaEDatos.Documento> ObtenLista(uFacturaEDatos.Sucursales sucursal)
 {
     try
     {
         var vDocumento = from doc in _db.Documentos where doc.idSucursal == sucursal.idSucursal select doc;
         return(vDocumento.ToList());
     }
     catch (Exception ex)
     {
         _mensajeErrorSistema = ex.Message;
         GrabarLogError(ex);
         return(new List <uFacturaEDatos.Documento>());
     }
 }
コード例 #5
0
        public int GetFolioNuevo(uFacturaEDatos.Documento documento, uFacturaEDatos.Sucursales sucursal)
        {
            BasedatosDataContext db = new BasedatosDataContext(_connectionString);
            string resultado        = db.GenerarFolioComprobante(documento.idDocumento, sucursal.idSucursal);

            if (resultado.Contains("Error:"))
            {
                throw new Exception(resultado);
            }
            else
            {
                return(Convert.ToInt32(resultado.Trim()));
            }
        }
コード例 #6
0
 public List <uFacturaEDatos.Comprobante> ObtenLista(uFacturaEDatos.Sucursales sucursal)
 {
     try
     {
         var vComprobante = from cf in _db.Comprobantes where cf.idSucursal == sucursal.idSucursal select cf;
         return(vComprobante.ToList());
     }
     catch (Exception ex)
     {
         _mensajeErrorSistema = ex.Message;
         GrabarLogError(ex);
         return(new List <uFacturaEDatos.Comprobante>());
     }
 }
コード例 #7
0
        public bool Guardar(uFacturaEDatos.Sucursales sucursal)
        {
            uFacturaEDatos.Operaciones.Documentos.Documento docDefault = null;
            bool resultado = false;

            using (TransactionScope vTrasaction = new TransactionScope())
            {
                try
                {
                    var vSucursal = from suc in _db.Sucursales where suc.idSucursal == sucursal.idSucursal select suc;
                    if (vSucursal.Count() == 0)
                    {
                        //Crear documentos Default
                        docDefault = new Documentos.Documento();
                        List <uFacturaEDatos.Documento> lstDoc = docDefault.GenerarDocsDefault();
                        _db.Documentos.InsertAllOnSubmit(lstDoc);

                        _db.Sucursales.InsertOnSubmit(sucursal);
                    }

                    _db.SubmitChanges();

                    resultado = true;

                    vTrasaction.Complete();
                }
                catch (Exception ex)
                {
                    resultado            = false;
                    _mensajeErrorSistema = ex.Message;
                    GrabarLogError(ex);
                    throw new Exception("No fué posible guardar la sucursal");
                }
            }

            return(resultado);
        }