public imp_gasto_x_ct_plancta_Info get_info(int IdEmpresa, string IdCtaCble)
 {
     try
     {
         imp_gasto_x_ct_plancta_Info info = new imp_gasto_x_ct_plancta_Info();
         using (Entities_importacion Context = new Entities_importacion())
         {
             imp_gasto_x_ct_plancta Entity = Context.imp_gasto_x_ct_plancta.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdCtaCble == IdCtaCble);
             if (Entity == null)
             {
                 return(null);
             }
             info = new imp_gasto_x_ct_plancta_Info
             {
                 IdEmpresa    = Entity.IdEmpresa,
                 IdGasto_tipo = Entity.IdGasto_tipo,
                 IdCtaCble    = Entity.IdCtaCble
             };
         }
         return(info);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public bool guardarDB(imp_gasto_x_ct_plancta_Info info)
 {
     try
     {
         using (Entities_importacion Context = new Entities_importacion())
         {
             imp_gasto_x_ct_plancta Entity = new imp_gasto_x_ct_plancta
             {
                 IdEmpresa    = info.IdEmpresa,
                 IdGasto_tipo = info.IdGasto_tipo,
                 IdCtaCble    = info.IdCtaCble
             };
             Context.imp_gasto_x_ct_plancta.Add(Entity);
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#3
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());
            }
        }