示例#1
0
 public tb_sucursal_Info GetInfo(int IdEmpresa, string CodigoEstablecimiento)
 {
     try
     {
         tb_sucursal_Info info = new tb_sucursal_Info();
         using (Entities_general Context = new Entities_general())
         {
             tb_sucursal Entity = Context.tb_sucursal.Where(q => q.IdEmpresa == IdEmpresa && q.Su_CodigoEstablecimiento == CodigoEstablecimiento).FirstOrDefault();
             if (Entity == null)
             {
                 return(null);
             }
             info = new tb_sucursal_Info
             {
                 IdEmpresa                = Entity.IdEmpresa,
                 IdSucursal               = Entity.IdSucursal,
                 Su_Descripcion           = Entity.Su_Descripcion,
                 codigo                   = Entity.codigo,
                 Estado                   = Entity.Estado,
                 Es_establecimiento       = Entity.Es_establecimiento,
                 Su_CodigoEstablecimiento = Entity.Su_CodigoEstablecimiento,
                 Su_Direccion             = Entity.Su_Direccion,
                 Su_JefeSucursal          = Entity.Su_JefeSucursal,
                 Su_Ruc                   = Entity.Su_Ruc,
                 Su_Telefonos             = Entity.Su_Telefonos
             };
         }
         return(info);
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#2
0
        public ActionResult Index()
        {
            #region Validar Session
            if (string.IsNullOrEmpty(SessionFixed.IdTransaccionSession))
            {
                return(RedirectToAction("Login", new { Area = "", Controller = "Account" }));
            }
            SessionFixed.IdTransaccionSession       = (Convert.ToDecimal(SessionFixed.IdTransaccionSession) + 1).ToString();
            SessionFixed.IdTransaccionSessionActual = SessionFixed.IdTransaccionSession;
            #endregion

            #region Permisos
            seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "General", "Sucursal", "Index");
            ViewBag.Nuevo = info.Nuevo;
            #endregion

            tb_sucursal_Info model = new tb_sucursal_Info
            {
                IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession),
                IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa)
            };

            var lst = bus_sucursal.get_list(model.IdEmpresa, true);
            Lista_Sucursal.set_list(lst, model.IdTransaccionSession);
            return(View(model));
        }
示例#3
0
        public bool anularDB(tb_sucursal_Info info)
        {
            try
            {
                using (Entities_general Context = new Entities_general())
                {
                    tb_sucursal Entity = Context.tb_sucursal.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdSucursal == info.IdSucursal);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.Estado = info.Estado = "I";

                    Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                    Entity.Fecha_UltAnu    = info.Fecha_UltAnu = DateTime.Now;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#4
0
        public ActionResult Consultar(int IdEmpresa = 0, int IdSucursal = 0, bool Exito = false)
        {
            tb_sucursal_Info model = bus_sucursal.get_info(IdEmpresa, IdSucursal);

            if (model == null)
            {
                return(RedirectToAction("Index"));
            }

            #region Permisos
            seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "General", "Sucursal", "Index");
            if (model.Estado == "I")
            {
                info.Modificar = false;
                info.Anular    = false;
            }
            model.Nuevo     = (info.Nuevo == true ? 1 : 0);
            model.Modificar = (info.Modificar == true ? 1 : 0);
            model.Anular    = (info.Anular == true ? 1 : 0);
            #endregion

            if (Exito)
            {
                ViewBag.MensajeSuccess = MensajeSuccess;
            }

            model.IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            model.ListaNivelDescuento  = bus_formapago_x_niveldescuento.GetList(IdEmpresa, model.IdSucursal);
            FormaPago_x_NivelDescuento_List.set_list(model.ListaNivelDescuento, model.IdTransaccionSession);

            return(View(model));
        }
示例#5
0
        public bool modificarDB(tb_sucursal_Info info)
        {
            try
            {
                using (Entities_general Context = new Entities_general())
                {
                    tb_sucursal Entity = Context.tb_sucursal.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdSucursal == info.IdSucursal);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.codigo                   = info.codigo;
                    Entity.Su_Descripcion           = info.Su_Descripcion;
                    Entity.Su_CodigoEstablecimiento = info.Su_CodigoEstablecimiento;
                    Entity.Su_Ruc                   = info.Su_Ruc;
                    Entity.Su_JefeSucursal          = info.Su_JefeSucursal;
                    Entity.Su_Telefonos             = info.Su_Telefonos;
                    Entity.Su_Direccion             = info.Su_Direccion;
                    Entity.Es_establecimiento       = info.Es_establecimiento;
                    Entity.IdCtaCble_cxp            = info.IdCtaCble_cxp;
                    Entity.IdCtaCble_vtaIVA         = info.IdCtaCble_vtaIVA;
                    Entity.IdCtaCble_vtaIVA0        = info.IdCtaCble_vtaIVA0;

                    Entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    Entity.Fecha_UltMod    = info.Fecha_UltMod = DateTime.Now;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#6
0
        public bool guardarDB(tb_sucursal_Info info)
        {
            try
            {
                using (Entities_general Context = new Entities_general())
                {
                    tb_sucursal Entity = new tb_sucursal
                    {
                        IdEmpresa                = info.IdEmpresa,
                        IdSucursal               = info.IdSucursal = get_id(info.IdEmpresa),
                        codigo                   = info.codigo,
                        Su_Descripcion           = info.Su_Descripcion,
                        Su_CodigoEstablecimiento = info.Su_CodigoEstablecimiento,
                        Su_Ubicacion             = info.Su_Ubicacion,
                        Su_Ruc                   = info.Su_Ruc,
                        Su_JefeSucursal          = info.Su_JefeSucursal,
                        Su_Telefonos             = info.Su_Telefonos,
                        Su_Direccion             = info.Su_Direccion,
                        Es_establecimiento       = info.Es_establecimiento,
                        Estado                   = info.Estado = "A",

                        IdUsuario     = info.IdUsuario,
                        Fecha_Transac = info.Fecha_Transac = DateTime.Now
                    };
                    Context.tb_sucursal.Add(Entity);
                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#7
0
        public tb_sucursal_Info get_info(int IdEmpresa, int IdSucursal)
        {
            tb_sucursal_Info info = new tb_sucursal_Info();

            Entities_general context_g = new Entities_general();

            info = (from q in context_g.tb_sucursal
                    where q.Estado == "A" &&
                    q.IdEmpresa == IdEmpresa &&
                    q.IdSucursal == IdSucursal
                    select new tb_sucursal_Info
            {
                IdSucursal = q.IdSucursal,
                Su_Descripcion = q.Su_Descripcion,
                codigo = q.codigo,
                Estado = q.Estado,
                Es_establecimiento = q.Es_establecimiento,
                IdEmpresa = q.IdEmpresa,
                Su_CodigoEstablecimiento = q.Su_CodigoEstablecimiento,
                Su_Direccion = q.Su_Direccion,
                Su_JefeSucursal = q.Su_JefeSucursal,
                Su_Ruc = q.Su_Ruc,
                Su_Telefonos = q.Su_Telefonos,
                IdCtaCble_cxp = q.IdCtaCble_cxp,
                IdCtaCble_vtaIVA = q.IdCtaCble_vtaIVA,
                IdCtaCble_vtaIVA0 = q.IdCtaCble_vtaIVA0
            }).FirstOrDefault();

            context_g.Dispose();

            return(info);
        }
示例#8
0
 public ActionResult Nuevo(tb_sucursal_Info model)
 {
     if (!bus_sucursal.guardarDB(model))
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
示例#9
0
 public ActionResult Anular(tb_sucursal_Info model)
 {
     if (!bus_sucursal.anularDB(model))
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
示例#10
0
        public ActionResult Nuevo(int IdEmpresa = 0)
        {
            tb_sucursal_Info model = new tb_sucursal_Info
            {
                IdEmpresa = IdEmpresa
            };

            return(View(model));
        }
        public bool modificarDB(tb_sucursal_Info info)
        {
            try
            {
                using (Entities_general Context = new Entities_general())
                {
                    tb_sucursal Entity = Context.tb_sucursal.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdSucursal == info.IdSucursal);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.codigo                   = info.codigo;
                    Entity.Su_Descripcion           = info.Su_Descripcion;
                    Entity.Su_CodigoEstablecimiento = info.Su_CodigoEstablecimiento;
                    Entity.Su_Ruc                   = info.Su_Ruc;
                    Entity.Su_JefeSucursal          = info.Su_JefeSucursal;
                    Entity.Su_Telefonos             = info.Su_Telefonos;
                    Entity.Su_Direccion             = info.Su_Direccion;
                    Entity.Es_establecimiento       = info.Es_establecimiento;
                    Entity.IdCtaCble_cxp            = info.IdCtaCble_cxp;
                    Entity.IdCtaCble_vtaIVA         = info.IdCtaCble_vtaIVA;
                    Entity.IdCtaCble_vtaIVA0        = info.IdCtaCble_vtaIVA0;

                    Entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    Entity.Fecha_UltMod    = info.Fecha_UltMod = DateTime.Now;

                    var lst_det_grupo = Context.tb_sucursal_FormaPago_x_fa_NivelDescuento.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdSucursal == info.IdSucursal).ToList();
                    Context.tb_sucursal_FormaPago_x_fa_NivelDescuento.RemoveRange(lst_det_grupo);

                    if (info.ListaNivelDescuento != null)
                    {
                        int Secuencia = 1;

                        foreach (var item in info.ListaNivelDescuento)
                        {
                            Context.tb_sucursal_FormaPago_x_fa_NivelDescuento.Add(new tb_sucursal_FormaPago_x_fa_NivelDescuento
                            {
                                IdEmpresa  = info.IdEmpresa,
                                IdSucursal = info.IdSucursal,
                                Secuencia  = Secuencia++,
                                IdCatalogo = item.IdCatalogo,
                                IdNivel    = item.IdNivel
                            });
                        }
                    }

                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#12
0
        public ActionResult Nuevo(tb_sucursal_Info model)
        {
            model.ListaNivelDescuento = FormaPago_x_NivelDescuento_List.get_list(model.IdTransaccionSession);

            if (!bus_sucursal.guardarDB(model))
            {
                return(View(model));
            }
            return(RedirectToAction("Index"));
        }
示例#13
0
        public ActionResult Nuevo(tb_sucursal_Info model)
        {
            model.ListaNivelDescuento = FormaPago_x_NivelDescuento_List.get_list(model.IdTransaccionSession);

            if (!bus_sucursal.guardarDB(model))
            {
                return(View(model));
            }
            return(RedirectToAction("Consultar", new { IdEmpresa = model.IdEmpresa, IdSucursal = model.IdSucursal, Exito = true }));
        }
示例#14
0
        public ActionResult Anular(int IdEmpresa = 0, int IdSucursal = 0)
        {
            tb_sucursal_Info model = bus_sucursal.get_info(IdEmpresa, IdSucursal);

            if (model == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
 public bool anularDB(tb_sucursal_Info info)
 {
     try
     {
         return(odata.anularDB(info));
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#16
0
        public ActionResult Modificar(tb_sucursal_Info model)
        {
            model.ListaNivelDescuento = FormaPago_x_NivelDescuento_List.get_list(Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual));

            if (!bus_sucursal.modificarDB(model))
            {
                return(View(model));
            }

            return(RedirectToAction("Index"));
        }
示例#17
0
        public ActionResult Modificar(tb_sucursal_Info model)
        {
            model.ListaNivelDescuento = FormaPago_x_NivelDescuento_List.get_list(Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual));

            if (!bus_sucursal.modificarDB(model))
            {
                return(View(model));
            }

            return(RedirectToAction("Consultar", new { IdEmpresa = model.IdEmpresa, IdSucursal = model.IdSucursal, Exito = true }));
        }
        public bool guardarDB(tb_sucursal_Info info)
        {
            try
            {
                using (Entities_general Context = new Entities_general())
                {
                    tb_sucursal Entity = new tb_sucursal
                    {
                        IdEmpresa                = info.IdEmpresa,
                        IdSucursal               = info.IdSucursal = get_id(info.IdEmpresa),
                        codigo                   = info.codigo,
                        Su_Descripcion           = info.Su_Descripcion,
                        Su_CodigoEstablecimiento = info.Su_CodigoEstablecimiento,
                        Su_Ruc                   = info.Su_Ruc,
                        Su_JefeSucursal          = info.Su_JefeSucursal,
                        Su_Telefonos             = info.Su_Telefonos,
                        Su_Direccion             = info.Su_Direccion,
                        Es_establecimiento       = info.Es_establecimiento,
                        Estado                   = info.Estado = "A",
                        IdCtaCble_cxp            = info.IdCtaCble_cxp,
                        IdCtaCble_vtaIVA         = info.IdCtaCble_vtaIVA,
                        IdCtaCble_vtaIVA0        = info.IdCtaCble_vtaIVA0,

                        IdUsuario     = info.IdUsuario,
                        Fecha_Transac = info.Fecha_Transac = DateTime.Now
                    };
                    Context.tb_sucursal.Add(Entity);

                    if (info.ListaNivelDescuento != null)
                    {
                        int Secuencia = 1;
                        foreach (var item in info.ListaNivelDescuento)
                        {
                            Context.tb_sucursal_FormaPago_x_fa_NivelDescuento.Add(new tb_sucursal_FormaPago_x_fa_NivelDescuento
                            {
                                IdEmpresa  = info.IdEmpresa,
                                IdSucursal = info.IdSucursal,
                                Secuencia  = Secuencia++,
                                IdCatalogo = item.IdCatalogo,
                                IdNivel    = item.IdNivel
                            });
                        }
                    }

                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#19
0
        public ActionResult Nuevo(int IdEmpresa = 0)
        {
            tb_sucursal_Info model = new tb_sucursal_Info
            {
                IdEmpresa = IdEmpresa
            };

            model.IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession);
            model.ListaNivelDescuento  = new List <tb_sucursal_FormaPago_x_fa_NivelDescuento_Info>();
            FormaPago_x_NivelDescuento_List.set_list(model.ListaNivelDescuento, model.IdTransaccionSession);

            return(View(model));
        }
示例#20
0
        public tb_sis_Documento_Tipo_Talonario_Info get_info_ultimo_no_usado(int IdEmpresa, string CodDocumentoTipo, int IdSucursal)
        {
            try
            {
                tb_sucursal_Bus  bus_sucursal  = new tb_sucursal_Bus();
                tb_sucursal_Info info_sucursal = new tb_sucursal_Info();
                info_sucursal = bus_sucursal.get_info(IdEmpresa, IdSucursal);

                return(odata.get_info_ultimo_no_usado(IdEmpresa, CodDocumentoTipo, IdSucursal, info_sucursal.Su_CodigoEstablecimiento));
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#21
0
        public ActionResult Anular(int IdEmpresa = 0, int IdSucursal = 0)
        {
            tb_sucursal_Info model = bus_sucursal.get_info(IdEmpresa, IdSucursal);

            model.IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession);
            model.ListaNivelDescuento  = bus_formapago_x_niveldescuento.GetList(IdEmpresa, model.IdSucursal);
            FormaPago_x_NivelDescuento_List.set_list(model.ListaNivelDescuento, model.IdTransaccionSession);

            if (model == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
示例#22
0
        public tb_sucursal_Info get_info_demanda(int IdEmpresa, int value)
        {
            tb_sucursal_Info info = new tb_sucursal_Info();

            using (Entities_general Contex = new Entities_general())
            {
                info = (from q in Contex.tb_sucursal
                        where q.IdEmpresa == IdEmpresa &&
                        q.IdSucursal == value
                        select new tb_sucursal_Info
                {
                    IdSucursal = q.IdSucursal,
                    codigo = q.codigo,
                    Su_Descripcion = q.Su_Descripcion
                }).FirstOrDefault();
            }
            return(info);
        }
示例#23
0
        public ActionResult Nuevo(int IdEmpresa = 0)
        {
            #region Permisos
            seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "General", "Sucursal", "Index");
            if (!info.Nuevo)
            {
                return(RedirectToAction("Index"));
            }
            #endregion
            tb_sucursal_Info model = new tb_sucursal_Info
            {
                IdEmpresa = IdEmpresa
            };

            model.IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession);
            model.ListaNivelDescuento  = new List <tb_sucursal_FormaPago_x_fa_NivelDescuento_Info>();
            FormaPago_x_NivelDescuento_List.set_list(model.ListaNivelDescuento, model.IdTransaccionSession);

            return(View(model));
        }
示例#24
0
        public ActionResult Anular(int IdEmpresa = 0, int IdSucursal = 0)
        {
            #region Permisos
            seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "General", "Sucursal", "Index");
            if (!info.Anular)
            {
                return(RedirectToAction("Index"));
            }
            #endregion
            tb_sucursal_Info model = bus_sucursal.get_info(IdEmpresa, IdSucursal);
            model.IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession);
            model.ListaNivelDescuento  = bus_formapago_x_niveldescuento.GetList(IdEmpresa, model.IdSucursal);
            FormaPago_x_NivelDescuento_List.set_list(model.ListaNivelDescuento, model.IdTransaccionSession);

            if (model == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
示例#25
0
        public tb_sucursal_Info get_info(int IdEmpresa, int IdSucursal)
        {
            tb_sucursal_Info info = new tb_sucursal_Info();

            using (SqlConnection connection = new SqlConnection(ConexionesERP.GetConnectionString()))
            {
                connection.Open();
                string     query         = "Select IdEmpresa, IdSucursal, codigo, Estado, Es_establecimiento, Su_CodigoEstablecimiento, Su_Ruc, Su_Direccion, Su_JefeSucursal, IdCtaCble_cxp, IdCtaCble_vtaIVA, IdCtaCble_vtaIVA0 from tb_sucursal where IdEmpresa = " + IdEmpresa.ToString() + " and IdSucursal = " + IdSucursal.ToString() + " and Estado = 'A'";
                SqlCommand command       = new SqlCommand(query, connection);
                var        ValidateValue = command.ExecuteScalar();
                if (ValidateValue == null)
                {
                    return(null);
                }

                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    info = new tb_sucursal_Info
                    {
                        IdEmpresa                = Convert.ToInt32(reader["IdEmpresa"]),
                        IdSucursal               = Convert.ToInt32(reader["IdSucursal"]),
                        codigo                   = Convert.ToString(reader["codigo"]),
                        Estado                   = Convert.ToString(reader["Estado"]),
                        Es_establecimiento       = Convert.ToBoolean(reader["Es_establecimiento"]),
                        Su_CodigoEstablecimiento = Convert.ToString(reader["Su_CodigoEstablecimiento"]),
                        Su_Direccion             = Convert.ToString(reader["Su_Direccion"]),
                        Su_JefeSucursal          = Convert.ToString(reader["Su_JefeSucursal"]),
                        Su_Ruc                   = Convert.ToString(reader["Su_Ruc"]),
                        IdCtaCble_cxp            = Convert.ToString(reader["IdCtaCble_cxp"]),
                        IdCtaCble_vtaIVA         = Convert.ToString(reader["IdCtaCble_vtaIVA"]),
                        IdCtaCble_vtaIVA0        = Convert.ToString(reader["IdCtaCble_vtaIVA0"]),
                    };
                }
                reader.Close();
            }
            return(info);
        }
示例#26
0
        public tb_sucursal_Info get_info(int IdEmpresa, int IdSucursal)
        {
            try
            {
                tb_sucursal_Info info = new tb_sucursal_Info();

                using (Entities_general Context = new Entities_general())
                {
                    tb_sucursal Entity = Context.tb_sucursal.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdSucursal == IdSucursal);
                    if (Entity == null)
                    {
                        return(null);
                    }

                    info = new tb_sucursal_Info
                    {
                        IdEmpresa                = Entity.IdEmpresa,
                        IdSucursal               = Entity.IdSucursal,
                        codigo                   = Entity.codigo,
                        Su_Descripcion           = Entity.Su_Descripcion,
                        Su_CodigoEstablecimiento = Entity.Su_CodigoEstablecimiento,
                        Su_Ubicacion             = Entity.Su_Ubicacion,
                        Su_Ruc                   = Entity.Su_Ruc,
                        Su_JefeSucursal          = Entity.Su_JefeSucursal,
                        Su_Telefonos             = Entity.Su_Telefonos,
                        Su_Direccion             = Entity.Su_Direccion,
                        Es_establecimiento       = Entity.Es_establecimiento == null ? false : Convert.ToBoolean(Entity.Es_establecimiento),
                        Estado                   = Entity.Estado,
                    };
                }

                return(info);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#27
0
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            #region Variables

            ba_Banco_Cuenta_List        ListaBanco  = new ba_Banco_Cuenta_List();
            List <ba_Banco_Cuenta_Info> Lista_Banco = new List <ba_Banco_Cuenta_Info>();
            ba_Banco_Cbte_List          ListaCbte   = new ba_Banco_Cbte_List();
            List <ba_Cbte_Ban_Info>     Lista_Cbte  = new List <ba_Cbte_Ban_Info>();
            tb_banco_Bus    bus_banco    = new tb_banco_Bus();
            tb_sucursal_Bus bus_sucursal = new tb_sucursal_Bus();

            int     cont = 0;
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            int     IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa);
            #endregion


            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);
            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                #region Banco
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        ba_Banco_Cuenta_Info info = new ba_Banco_Cuenta_Info
                        {
                            IdEmpresa          = IdEmpresa,
                            IdBanco            = Convert.ToInt32(reader.GetValue(0)),
                            IdBanco_Financiero = Convert.ToInt32(reader.GetValue(1)),
                            ba_Tipo            = Convert.ToString(reader.GetValue(2)),
                            ba_Num_Cuenta      = Convert.ToString(reader.GetValue(3)),
                            ba_num_digito_cheq = Convert.ToInt32(reader.GetValue(4)),
                            IdCtaCble          = null,
                            IdUsuario          = SessionFixed.IdUsuario,
                        };
                        #region GetInfo
                        tb_banco_Info banco = bus_banco.get_info(info.IdBanco);
                        info.ba_descripcion          = banco.ba_descripcion + " " + info.ba_Tipo + " " + info.ba_Num_Cuenta;
                        info.Imprimir_Solo_el_cheque = false;
                        Lista_Banco.Add(info);
                        #endregion
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaBanco.set_list(Lista_Banco, IdTransaccionSession);
                #endregion

                cont = 0;
                //Para avanzar a la siguiente hoja de excel
                reader.NextResult();

                #region Cbte
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        ba_Cbte_Ban_Info info = new ba_Cbte_Ban_Info
                        {
                            IdEmpresa      = IdEmpresa,
                            IdTipo_Persona = Convert.ToString(reader.GetValue(0)),
                            Su_Descripcion = Convert.ToString(reader.GetValue(1)),
                            IdBanco        = Convert.ToInt32(reader.GetValue(2)),
                            cb_Fecha       = Convert.ToDateTime(reader.GetValue(3)),
                            cb_Observacion = Convert.ToString(reader.GetValue(4)),
                            cb_Valor       = Convert.ToInt32(reader.GetValue(5)),


                            IdUsuario = SessionFixed.IdUsuario,
                        };
                        #region GetInfo
                        tb_sucursal_Info sucursal = bus_sucursal.GetInfo(IdEmpresa, info.Su_Descripcion);
                        info.Su_Descripcion = sucursal.Su_Descripcion;
                        info.IdSucursal     = sucursal.IdSucursal;

                        Lista_Cbte.Add(info);
                        #endregion
                    }
                    else
                    {
                        cont++;
                    }
                }
                var ListCuenta = ListaBanco.get_list(IdTransaccionSession);

                var lst = (from q in ListCuenta
                           join c in Lista_Cbte
                           on q.IdBanco equals c.IdBanco
                           select new ba_Cbte_Ban_Info
                {
                    IdEmpresa = c.IdEmpresa,
                    IdTipo_Persona = c.IdTipo_Persona,
                    IdSucursal = c.IdSucursal,
                    ba_descripcion = q.ba_descripcion,
                    Su_Descripcion = c.Su_Descripcion,
                    IdBanco = c.IdBanco,
                    cb_Valor = c.cb_Valor,
                    cb_Fecha = c.cb_Fecha,
                    cb_Observacion = c.cb_Observacion
                }).ToList();

                Lista_Cbte = lst;
                ListaCbte.set_list(Lista_Cbte, IdTransaccionSession);
                #endregion
            }
        }
示例#28
0
        public ActionResult CmbCuenta_Sucursal_IVA0()
        {
            tb_sucursal_Info model = new tb_sucursal_Info();

            return(PartialView("_CmbCuenta_Sucursal_IVA0", model));
        }
示例#29
0
        public iva get_ats(int IdEmpresa, int IdPeriodo, int IdSucursal)
        {
            try
            {
                string registro = "";
                iva    ats      = new iva();
                info_periodo = data_periodo.get_info(IdEmpresa, IdPeriodo);
                info_empresa = data_empresa.get_info(IdEmpresa);
                ats_Info info_ats = get_info(IdEmpresa, IdPeriodo);

                #region cabecera del xml
                ats.IdInformante     = info_empresa.em_ruc;
                ats.razonSocial      = info_empresa.RazonSocial.Replace(".", " ").Replace("ñ", "n").Replace("Ñ", "N");
                ats.Anio             = info_periodo.IdanioFiscal.ToString();
                ats.Mes              = info_periodo.pe_mes.ToString().PadLeft(2, '0');
                info_sucursal        = data_sucursal.get_info(IdEmpresa, IdSucursal);
                ats.numEstabRuc      = info_sucursal.Su_CodigoEstablecimiento.ToString().PadLeft(3, '0');
                ats.TipoIDInformante = ivaTypeTipoIDInformante.R;
                ats.codigoOperativo  = codigoOperativoType.IVA;
                ats.totalVentas      = info_ats.lst_ventas.Sum(v => v.baseImpGrav + v.baseImpGrav);
                #endregion

                #region listado de compras
                if (info_ats.lst_compras != null)
                {
                    if (info_ats.lst_compras.Count() > 0)
                    {
                        ats.compras = new List <detalleCompras>();
                    }
                    info_ats.lst_compras.ForEach(
                        comp =>
                    {
                        detalleCompras comp_det = new detalleCompras();

                        registro                           = comp.denopr + " " + comp.secuencial;
                        comp.denopr                        = cl_funciones.QuitartildesEspaciosPuntos(comp.denopr);
                        comp_det.codSustento               = comp.codSustento;
                        comp_det.tpIdProv                  = comp.tpIdProv;
                        comp_det.idProv                    = comp.idProv;
                        comp_det.tipoComprobante           = comp.tipoComprobante;
                        comp_det.parteRel                  = parteRelType.NO;
                        comp_det.fechaRegistro             = comp.fechaRegistro.ToString().Substring(0, 10);
                        comp_det.establecimiento           = comp.establecimiento;
                        comp_det.puntoEmision              = comp.puntoEmision;
                        comp_det.secuencial                = comp.secuencial;
                        comp_det.fechaEmision              = comp.fechaEmision.ToString().Substring(0, 10);
                        comp_det.autorizacion              = comp.autorizacion;
                        comp_det.baseNoGraIva              = comp.baseNoGraIva.ToString("n2");
                        comp_det.baseImponible             = comp.baseImponible.ToString("n2");
                        comp_det.baseImpGrav               = comp.baseImpGrav.ToString("n2");
                        comp_det.baseImpExe                = comp.baseImpExe.ToString("n2");
                        comp_det.montoIce                  = comp.montoIce.ToString("n2");
                        comp_det.montoIva                  = comp.montoIva.ToString("n2");
                        comp_det.valRetBien10              = "0.00";
                        comp_det.valRetServ20              = "0.00";
                        comp_det.valorRetBienes            = "0.00";
                        comp_det.valRetServ50              = "0.00";
                        comp_det.valorRetServicios         = "0.00";
                        comp_det.valRetServ100             = "0.00";
                        comp_det.totbasesImpReemb          = "0.00";
                        comp_det.valRetBien10Specified     = true;
                        comp_det.valRetServ20Specified     = true;
                        comp_det.valRetServ50Specified     = true;
                        comp_det.totbasesImpReembSpecified = true;
                        pagoExterior item_pago             = new pagoExterior();
                        item_pago.pagoLocExt               = (comp.pagoLocExt == "LOC") ? pagoLocExtType.Item01 : pagoLocExtType.Item02;
                        item_pago.paisEfecPago             = (item_pago.pagoLocExt == pagoLocExtType.Item01) ? "NA" : (comp.pagoLocExt != null || comp.pagoLocExt != "") ? comp.pagoLocExt : "NA";
                        item_pago.aplicConvDobTrib         = aplicConvDobTribType.NA;
                        item_pago.pagExtSujRetNorLeg       = aplicConvDobTribType.NA;
                        comp_det.pagoExterior              = item_pago;
                        if (comp_det.secuencial == "000001512")
                        {
                        }
                        if (Convert.ToDecimal(comp.baseImponible) + Convert.ToDecimal(comp.baseImpGrav) >= 1000)
                        {
                            comp_det.formasDePago = null;
                            string[] AFormaPago   = { "20" };
                            comp_det.formasDePago = AFormaPago;
                        }
                        #region Reembolso
                        if (comp.codSustento == "41")
                        {
                            comp_det.codSustento               = "01";
                            comp_det.reembolsos                = new List <reembolso>();
                            reembolso reem                     = new reembolso();
                            reem.tipoComprobanteReemb          = "01";
                            reem.tpIdProvReemb                 = comp.tpIdProv;
                            reem.idProvReemb                   = comp.idProv;
                            reem.establecimientoReemb          = comp.establecimiento;
                            reem.puntoEmisionReemb             = comp.puntoEmision;
                            reem.secuencialReemb               = comp.secuencial;
                            reem.fechaEmisionReemb             = comp.fechaEmision.ToString().Substring(0, 10);
                            reem.autorizacionReemb             = comp.autorizacion;
                            reem.baseImponibleReemb            = comp.baseImponible;
                            reem.baseImpGravReemb              = comp.baseImpGrav;
                            reem.baseImpExeReemb               = comp.baseImpExe;
                            reem.montoIceRemb                  = comp.montoIce;
                            reem.montoIvaRemb                  = comp.montoIva;
                            comp_det.totbasesImpReembSpecified = true;
                            comp_det.totbasesImpReemb          = Convert.ToString(Convert.ToDecimal(comp.baseImponible) + Convert.ToDecimal(comp.baseImpGrav));
                            comp_det.reembolsos.Add(reem);
                        }
                        #endregion

                        #region retencion por facturas
                        if (info_ats.lst_retenciones != null)
                        {
                            if (info_ats.lst_retenciones.Count() > 0)
                            {
                                var lstret_x_fac = info_ats.lst_retenciones.Where(r => r.Cedula_ruc == comp.idProv & r.co_serie == comp.establecimiento + "-" + comp.puntoEmision & comp.secuencial == r.co_factura);
                                if (lstret_x_fac != null)
                                {
                                    if (lstret_x_fac.Count() > 0)
                                    {
                                        comp_det.air = new List <detalleAir>();
                                        foreach (var item in lstret_x_fac)
                                        {
                                            if (item.re_tipo_Ret == "RTF")
                                            {
                                                comp_det.air.Add(new detalleAir
                                                {
                                                    codRetAir     = item.codRetAir.ToString(),
                                                    baseImpAir    = item.baseImpAir.ToString(),
                                                    porcentajeAir = item.porcentajeAir.ToString(),
                                                    valRetAir     = item.valRetAir.ToString(),
                                                });
                                            }
                                            else
                                            {
                                                if (item.porcentajeAir == "10")
                                                {
                                                    comp_det.valRetBien10 = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "20")
                                                {
                                                    comp_det.valRetServ20 = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "30")
                                                {
                                                    comp_det.valorRetBienes = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "50")
                                                {
                                                    comp_det.valRetServ50 = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "70")
                                                {
                                                    comp_det.valorRetServicios = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "100")
                                                {
                                                    comp_det.valRetServ100 = item.valRetAir.ToString();
                                                }
                                            }
                                        }
                                    }
                                    else   // si no tiene retencion
                                    {
                                        comp_det.air = new List <detalleAir>();
                                        comp_det.air.Add(new detalleAir
                                        {
                                            codRetAir     = "332",
                                            baseImpAir    = Convert.ToDecimal(comp.baseImpGrav + comp.baseImponible).ToString(),
                                            porcentajeAir = "0",
                                            valRetAir     = "0.00",
                                        });
                                    }
                                }
                            }
                        }
                        #endregion
                        ats.compras.Add(comp_det);
                    });
                }
                #endregion

                #region Ventas
                if (info_ats.lst_ventas != null)
                {
                    if (info_ats.lst_ventas.Count() > 0)
                    {
                        ats.ventas = new List <detalleVentas>();
                        info_ats.lst_ventas.ForEach(
                            vent =>
                        {
                            detalleVentas det_ventas = new detalleVentas();
                            det_ventas.tpIdCliente   = vent.tpIdCliente;
                            det_ventas.idCliente     = vent.idCliente;
                            if (det_ventas.tpIdCliente == " 04" | det_ventas.tpIdCliente == " 05" | det_ventas.tpIdCliente == " 06")
                            {
                                det_ventas.parteRelVtas = parteRelType.NO;
                            }
                            vent.DenoCli = cl_funciones.QuitartildesEspaciosPuntos(vent.DenoCli);
                            det_ventas.tipoComprobante    = vent.tipoComprobante;
                            det_ventas.tipoEmision        = tipoEmisionType.F;
                            det_ventas.numeroComprobantes = vent.numeroComprobantes.ToString();
                            det_ventas.baseNoGraIva       = vent.baseNoGraIva;
                            det_ventas.baseImponible      = vent.baseImponible;
                            det_ventas.baseImpGrav        = vent.baseImpGrav;
                            det_ventas.montoIva           = vent.montoIva;
                            det_ventas.montoIce           = vent.montoIce;
                            det_ventas.valorRetIva        = vent.valorRetIva.ToString("n2");
                            det_ventas.valorRetRenta      = vent.valorRetRenta.ToString("n2");
                            det_ventas.montoIceSpecified  = true;
                            det_ventas.formasDePago       = null;
                            string[] AFormaPago           = { "20" };
                            det_ventas.formasDePago       = AFormaPago;

                            ats.ventas.Add(det_ventas);
                        }
                            );
                    }
                }
                #endregion

                #region ventas por establecimientos
                if (info_ats.lst_ventas != null)
                {
                    if (info_ats.lst_ventas.Count() > 0)
                    {
                        ats.ventasEstablecimiento = new List <ventaEst>();

                        var vtas = info_ats.lst_ventas.GroupBy(x => x.codEstab)
                                   .Select(x => new
                        {
                            codEstab    = x.Key,
                            ventasEstab = x.Sum(y => y.ventasEstab)
                        }).ToList();

                        foreach (var item in vtas)
                        {
                            ventaEst vtas_esta = new ventaEst();
                            vtas_esta.codEstab    = item.codEstab;
                            vtas_esta.ventasEstab = item.ventasEstab;
                            vtas_esta.ivaComp     = Convert.ToDecimal("0.00");
                            ats.ventasEstablecimiento.Add(vtas_esta);
                        }
                    }
                }
                #endregion

                #region exportaciones
                if (info_ats.lst_exportaciones != null)
                {
                    if (info_ats.lst_exportaciones.Count() > 0)
                    {
                        ats.exportaciones = new List <detalleExportacionesType>();
                        info_ats.lst_exportaciones.ForEach
                        (
                            exp =>
                        {
                            detalleExportacionesType exp_det = new detalleExportacionesType();
                            exp_det.tpIdClienteEx            = exp.tpIdClienteEx;
                            exp_det.idClienteEx         = exp.idClienteEx;
                            exp_det.parteRelExp         = parteRelType.NO;
                            exp_det.tipoCli             = "02";
                            exp_det.denoExpCli          = exp.denoExpCli = cl_funciones.QuitartildesEspaciosPuntos(exp.denoExpCli);
                            exp_det.tipoRegi            = tipoRegiType.Item01;
                            exp_det.paisEfecPagoGen     = exp.paisEfecPagoGen;
                            exp_det.paisEfecExp         = exp.paisEfecExp;
                            exp_det.exportacionDe       = exp.exportacionDe;
                            exp_det.tipoComprobante     = exp.tipoComprobante;
                            exp_det.fechaEmbarque       = exp.fechaEmbarque.ToString().Substring(0, 10);
                            exp_det.valorFOB            = (exp.valorFOB) == null?Convert.ToDecimal(0.00):Convert.ToDecimal(exp.valorFOB);
                            exp_det.valorFOBComprobante = (exp.valorFOB) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(exp.valorFOBComprobante);
                            exp_det.establecimiento     = exp.establecimiento;
                            exp_det.puntoEmision        = exp.puntoEmision;
                            exp_det.secuencial          = exp.secuencial;
                            exp_det.autorizacion        = (exp.autorizacion) == null?"34345454656453":exp.autorizacion;
                            exp_det.fechaEmision        = exp.fechaEmision.ToString().Substring(0, 10);
                            //exp_det.pagoRegFisSpecified = true;
                            exp_det.parteRelExpSpecified = true;
                            exp_det.tipoRegiSpecified    = true;
                            //exp_det.impuestoOtroPaisSpecified = true;
                            //exp_det.ingExtGravOtroPaisSpecified = true;
                            ats.exportaciones.Add(exp_det);
                        }
                        );
                    }
                }
                #endregion

                #region Anulados
                if (info_ats.lst_exportaciones != null)
                {
                    if (info_ats.lst_anulados.Count() > 0)
                    {
                        ats.anulados = new List <detalleAnulados>();
                        info_ats.lst_anulados.ForEach
                        (
                            anu =>
                        {
                            detalleAnulados anula  = new detalleAnulados();
                            anula.tipoComprobante  = anu.tipoComprobante;
                            anula.establecimiento  = anu.Establecimiento;
                            anula.puntoEmision     = anu.puntoEmision;
                            anula.secuencialInicio = anu.secuencialInicio;
                            anula.secuencialFin    = anu.secuencialFin;
                            anula.autorizacion     = anu.Autorizacion;

                            ats.anulados.Add(anula);
                        }
                        );
                    }
                }
                #endregion


                ats.totalVentas          = info_ats.lst_ventas.Sum(y => y.ventasEstab);
                ats.totalVentasSpecified = true;
                return(ats);
            }
            catch (Exception e)
            {
                throw;
            }
        }
示例#30
0
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            #region Variables
            tb_empresa_List         ListaEmpresa   = new tb_empresa_List();
            List <tb_empresa_Info>  Lista_Empresa  = new List <tb_empresa_Info>();
            tb_sucursal_List        ListaSucursal  = new tb_sucursal_List();
            List <tb_sucursal_Info> Lista_Sucursal = new List <tb_sucursal_Info>();
            tb_bodega_List          ListaBodega    = new tb_bodega_List();
            List <tb_bodega_Info>   Lista_Bodega   = new List <tb_bodega_Info>();


            int     cont = 0;
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            int     IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa);
            #endregion


            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);
            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                #region Empresa
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        tb_empresa_Info info = new tb_empresa_Info
                        {
                            IdEmpresa              = Convert.ToInt32(reader.GetValue(0)),
                            codigo                 = Convert.ToString(reader.GetValue(1)),
                            em_nombre              = Convert.ToString(reader.GetValue(2)),
                            RazonSocial            = Convert.ToString(reader.GetValue(3)),
                            NombreComercial        = Convert.ToString(reader.GetValue(4)),
                            ContribuyenteEspecial  = Convert.ToString(reader.GetValue(5)),
                            em_ruc                 = Convert.ToString(reader.GetValue(6)),
                            em_gerente             = Convert.ToString(reader.GetValue(7)),
                            em_contador            = Convert.ToString(reader.GetValue(8)),
                            em_rucContador         = Convert.ToString(reader.GetValue(9)),
                            em_telefonos           = Convert.ToString(reader.GetValue(10)),
                            em_direccion           = Convert.ToString(reader.GetValue(11)),
                            em_fechaInicioContable = reader.GetDateTime(12),
                            cod_entidad_dinardap   = Convert.ToString(reader.GetValue(13)),
                            em_Email               = Convert.ToString(reader.GetValue(14))
                        };
                        info.em_fechaInicioActividad = info.em_fechaInicioContable;
                        Lista_Empresa.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaEmpresa.set_list(Lista_Empresa, IdTransaccionSession);
                #endregion

                cont = 0;
                reader.NextResult();

                #region Sucursal
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        tb_sucursal_Info info = new tb_sucursal_Info
                        {
                            IdEmpresa                = Convert.ToInt32(reader.GetValue(0)),
                            IdSucursal               = Convert.ToInt32(reader.GetValue(1)),
                            codigo                   = Convert.ToString(reader.GetValue(2)),
                            Su_Descripcion           = Convert.ToString(reader.GetValue(3)),
                            Su_CodigoEstablecimiento = Convert.ToString(reader.GetValue(4)),
                            Su_Ruc                   = Convert.ToString(reader.GetValue(5)),
                            Su_JefeSucursal          = Convert.ToString(reader.GetValue(6)),
                            Su_Telefonos             = Convert.ToString(reader.GetValue(7)),
                            Su_Direccion             = Convert.ToString(reader.GetValue(8)),
                            IdUsuario                = SessionFixed.IdUsuario
                        };
                        Lista_Sucursal.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaSucursal.set_list(Lista_Sucursal, IdTransaccionSession);
                #endregion

                cont = 0;
                //Para avanzar a la siguiente hoja de excel
                reader.NextResult();

                #region Bodega
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        tb_bodega_Info info = new tb_bodega_Info
                        {
                            IdEmpresa       = Convert.ToInt32(reader.GetValue(0)),
                            IdSucursal      = Convert.ToInt32(reader.GetValue(1)),
                            IdBodega        = Convert.ToInt32(reader.GetValue(2)),
                            cod_bodega      = Convert.ToString(reader.GetValue(3)),
                            bo_Descripcion  = Convert.ToString(reader.GetValue(4)),
                            IdCtaCtble_Inve = Convert.ToString(reader.GetValue(5)),
                            IdUsuario       = SessionFixed.IdUsuario
                        };
                        Lista_Bodega.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaBodega.set_list(Lista_Bodega, IdTransaccionSession);
                #endregion
            }
        }