Exemplo n.º 1
0
        public bool guardarDB(imp_gasto_Info info)
        {
            try
            {
                using (Entities_importacion Context = new Entities_importacion())
                {
                    imp_gasto Entity = new imp_gasto
                    {
                        IdGasto_tipo   = info.IdGasto_tipo = get_id(),
                        gt_descripcion = info.gt_descripcion,
                        observacion    = info.observacion,
                        gt_orden       = info.gt_orden,
                        estado         = info.estado = true,
                    };
                    Context.imp_gasto.Add(Entity);

                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
 public imp_gasto_Info get_info(int IdGasto_tipo)
 {
     try
     {
         imp_gasto_Info info = new imp_gasto_Info();
         using (Entities_importacion Context = new Entities_importacion())
         {
             imp_gasto Entity = Context.imp_gasto.FirstOrDefault(q => q.IdGasto_tipo == IdGasto_tipo);
             if (Entity == null)
             {
                 return(null);
             }
             info = new imp_gasto_Info
             {
                 IdGasto_tipo   = Entity.IdGasto_tipo,
                 gt_descripcion = Entity.gt_descripcion,
                 observacion    = Entity.observacion,
                 gt_orden       = Entity.gt_orden,
                 estado         = Entity.estado
             };
         }
         return(info);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 3
0
 public bool modificarDB(imp_gasto_Info info)
 {
     try
     {
         using (Entities_importacion Context = new Entities_importacion())
         {
             //TRes el info del gasto - OK
             imp_gasto Entity = Context.imp_gasto.FirstOrDefault(q => q.IdGasto_tipo == info.IdGasto_tipo);
             if (Entity == null)
             {
                 return(false);
             }
             //Modificar los campos si encuentra un gasto - OK
             Entity.gt_descripcion = info.gt_descripcion;
             Entity.observacion    = info.observacion;
             Entity.gt_orden       = info.gt_orden;
             //aqui tienes que hacer la parte del detalle
             //Primero busco si este gasto tiene cuenta en esta empresa
             var Entity_cta = Context.imp_gasto_x_ct_plancta.Where(q => q.IdEmpresa == info.info_gasto_cta.IdEmpresa && q.IdGasto_tipo == info.IdGasto_tipo).FirstOrDefault();
             if (Entity_cta == null)
             {
                 //Si no tiene creo uno nuevo
                 Context.imp_gasto_x_ct_plancta.Add(new imp_gasto_x_ct_plancta
                 {
                     IdEmpresa    = info.info_gasto_cta.IdEmpresa,
                     IdCtaCble    = info.IdCtaCble,
                     IdGasto_tipo = info.IdGasto_tipo
                 });
             }
             else
             {
                 //Caso contrario le actualizo la cuenta contable
                 Entity_cta.IdCtaCble = info.IdCtaCble;
             }
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 4
0
        public bool anularDB(imp_gasto_Info info)
        {
            try
            {
                using (Entities_importacion Context = new Entities_importacion())
                {
                    imp_gasto Entity = Context.imp_gasto.FirstOrDefault(q => q.IdGasto_tipo == info.IdGasto_tipo);
                    if (Entity == null)
                    {
                        return(false);
                    }

                    Entity.estado = info.estado = false;

                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 5
0
        public bool guardarDB(imp_gasto_x_ct_plancta_Info info)
        {
            try
            {
                using (Entities_importacion Context = new Entities_importacion())
                {
                    if (info.info_gasto.IdGasto_tipo == 0)
                    {
                        imp_gasto Entity_gasto = new imp_gasto();
                        Entity_gasto.IdGasto_tipo   = info.info_gasto.IdGasto_tipo = info.IdGasto_tipo = get_id_gasto();
                        Entity_gasto.gt_descripcion = info.info_gasto.gt_descripcion;
                        Entity_gasto.estado         = info.info_gasto.estado = true;
                        Context.imp_gasto.Add(Entity_gasto);
                        Context.SaveChanges();

                        imp_gasto_x_ct_plancta Entity = new imp_gasto_x_ct_plancta();
                        Entity.IdEmpresa    = info.IdEmpresa;
                        Entity.IdGasto_tipo = info.IdGasto_tipo;
                        Entity.IdCtaCble    = info.IdCtaCble;
                        Context.imp_gasto_x_ct_plancta.Add(Entity);
                        Context.SaveChanges();
                    }
                    else
                    {
                        imp_gasto Entity_gasto = Context.imp_gasto.FirstOrDefault(q => q.IdGasto_tipo == info.IdGasto_tipo);
                        if (Entity_gasto == null)
                        {
                            return(false);
                        }

                        Entity_gasto.gt_descripcion = info.info_gasto.gt_descripcion;
                        Context.SaveChanges();

                        imp_gasto_x_ct_plancta Entity = Context.imp_gasto_x_ct_plancta.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdGasto_tipo == info.IdGasto_tipo);
                        if (Entity == null)
                        {
                            Entity              = new imp_gasto_x_ct_plancta();
                            Entity.IdEmpresa    = info.IdEmpresa;
                            Entity.IdGasto_tipo = info.IdGasto_tipo;
                            Entity.IdCtaCble    = info.IdCtaCble;
                            Context.imp_gasto_x_ct_plancta.Add(Entity);
                            Context.SaveChanges();
                        }
                        else
                        {
                            Entity.IdCtaCble = info.IdCtaCble;
                            Context.SaveChanges();
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                string mensaje = "";
                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());
            }
        }