예제 #1
0
        public Boolean GuardarDB(List <fa_TipoNota_x_Empresa_x_Sucursal_Info> List, ref string Mensaje)
        {
            try
            {
                if (List.Count() == 0)
                {
                    return(false);
                }
                foreach (var item in List)
                {
                    using (EntitiesFacturacion Context = new EntitiesFacturacion())
                    {
                        var Address = new fa_TipoNota_x_Empresa_x_Sucursal();
                        Address.IdCtaCble  = item.IdCtaCble;
                        Address.IdEmpresa  = item.IdEmpresa;
                        Address.IdSucursal = item.IdSucursal;
                        Address.IdTipoNota = item.IdTipoNota;

                        Context.fa_TipoNota_x_Empresa_x_Sucursal.Add(Address);
                        Context.SaveChanges();
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                Mensaje = ex.ToString();
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref Mensaje);
                throw new Exception(ex.ToString());
            }
        }
예제 #2
0
        public bool modificarDB(fa_TipoNota_Info info)
        {
            try
            {
                using (Entities_facturacion Context = new Entities_facturacion())
                {
                    fa_TipoNota Entity = Context.fa_TipoNota.FirstOrDefault(q => q.IdTipoNota == info.IdTipoNota);
                    if (Entity == null)
                    {
                        return(false);
                    }

                    Entity.CodTipoNota     = info.CodTipoNota;
                    Entity.No_Descripcion  = info.No_Descripcion;
                    Entity.Tipo            = info.Tipo;
                    Entity.GeneraMoviInven = info.GeneraMoviInven;

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

                    var lst = Context.fa_TipoNota_x_Empresa_x_Sucursal.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdTipoNota == info.IdTipoNota).ToList();
                    foreach (var item in lst)
                    {
                        Context.fa_TipoNota_x_Empresa_x_Sucursal.Remove(item);
                    }
                    foreach (var item in info.Lst_fa_TipoNota_x_Empresa_x_Sucursal)
                    {
                        fa_TipoNota_x_Empresa_x_Sucursal det = new fa_TipoNota_x_Empresa_x_Sucursal
                        {
                            IdEmpresa  = info.IdEmpresa,
                            IdSucursal = item.IdSucursal,
                            IdTipoNota = info.IdTipoNota,
                            IdCtaCble  = item.IdCtaCble
                        };
                        Context.fa_TipoNota_x_Empresa_x_Sucursal.Add(det);
                    }


                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception e)
            {
                throw;
            }
        }
예제 #3
0
        public bool guardarDB(fa_TipoNota_Info info)
        {
            try
            {
                using (Entities_facturacion Context = new Entities_facturacion())
                {
                    fa_TipoNota Entity = new fa_TipoNota
                    {
                        IdTipoNota      = info.IdTipoNota = get_id(),
                        CodTipoNota     = info.CodTipoNota,
                        No_Descripcion  = info.No_Descripcion,
                        Tipo            = info.Tipo,
                        Estado          = info.Estado = "A",
                        GeneraMoviInven = info.GeneraMoviInven,

                        IdUsuario     = info.IdUsuario,
                        Fecha_Transac = DateTime.Now
                    };
                    Context.fa_TipoNota.Add(Entity);
                    foreach (var item in info.Lst_fa_TipoNota_x_Empresa_x_Sucursal)
                    {
                        fa_TipoNota_x_Empresa_x_Sucursal det = new fa_TipoNota_x_Empresa_x_Sucursal
                        {
                            IdEmpresa  = info.IdEmpresa,
                            IdSucursal = item.IdSucursal,
                            IdTipoNota = info.IdTipoNota,
                            IdCtaCble  = item.IdCtaCble
                        };
                        Context.fa_TipoNota_x_Empresa_x_Sucursal.Add(det);
                    }
                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }