Ejemplo n.º 1
0
        private bool Insert(ref DepTemporalEntidad item)
        {
            try
            {
                if (item.Instance == Infrastructure.Aspect.BusinessEntity.InstanceEntity.Added)
                {
                    DataAccessEnterpriseSQL.DAAsignarProcedure("DETESI_UnReg");
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintDETE_Codigo", item.DETE_Codigo, SqlDbType.Int, 4, ParameterDirection.InputOutput);
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintENTC_CodLNaviera", item.ENTC_CodLNaviera, SqlDbType.Int, 4, ParameterDirection.Input);
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintENTC_CodDepTemporal", item.ENTC_CodDepTemporal, SqlDbType.Int, 4, ParameterDirection.Input);


                    if (DataAccessEnterpriseSQL.DAExecuteNonQuery() > 0)
                    {
                        Int32 _DETE_Codigo;
                        if (Int32.TryParse(DataAccessEnterpriseSQL.DASqlCommand.Parameters["@pintDETE_Codigo"].Value.ToString(), out _DETE_Codigo))
                        {
                            item.DETE_Codigo = _DETE_Codigo;
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Ejemplo n.º 2
0
        private bool Delete(ref DepTemporalEntidad item)
        {
            try
            {
                if (item.Instance == Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted)
                {
                    DataAccessEnterpriseSQL.DAAsignarProcedure("DETESD_UnReg");
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintDETE_Codigo", item.DETE_Codigo, SqlDbType.Int, 4, ParameterDirection.Input);

                    if (DataAccessEnterpriseSQL.DAExecuteNonQuery() > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Ejemplo n.º 3
0
        public BLDepTemporalEntidad(IUnityContainer container)
        {
            this.ContainerService = container;
            Loader = new BusinessEntityLoader <DepTemporalEntidad>();
            DepTemporalEntidad item = new DepTemporalEntidad();

            Loader.EntityType = item.GetType();
        }
 public Boolean SaveDepTemporalEntidad(DepTemporalEntidad Item)
 {
    try
    {
       if (Item.Instance != Infrastructure.Aspect.BusinessEntity.InstanceEntity.Unchanged)
       {
          return BL_DepTemporalEntidad.Save(ref Item);
       }
       return true;
    }
    catch (Exception ex)
    { throw ex; }
 }
Ejemplo n.º 5
0
        public Boolean Save(ref DepTemporalEntidad Item)
        {
            try
            {
                Boolean m_isCorrect = true;
                if (Item.Transact)
                {
                    Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DABeginTransaction();
                    switch (Item.Instance)
                    {
                    case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Added:
                        m_isCorrect = Insert(ref Item); break;

                    case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Modified:
                        m_isCorrect = Update(ref Item); break;

                    case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted:
                        m_isCorrect = Delete(ref Item); break;
                    }
                    if (m_isCorrect)
                    {
                        Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DACommitTransaction();
                    }
                    else
                    {
                        Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction();
                    }
                }
                else
                {
                    switch (Item.Instance)
                    {
                    case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Added:
                        m_isCorrect = Insert(ref Item); break;

                    case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Modified:
                        m_isCorrect = Update(ref Item); break;

                    case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted:
                        m_isCorrect = Delete(ref Item); break;
                    }
                }
                return(m_isCorrect);
            }
            catch (Exception)
            { Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction(); throw; }
        }
Ejemplo n.º 6
0
 private ObservableCollection <DepTemporalEntidad> SelectAll(Int32?x_ENTC_Codigo)
 {
     try
     {
         ObservableCollection <DepTemporalEntidad> items = new ObservableCollection <DepTemporalEntidad>();
         DepTemporalEntidad item = new DepTemporalEntidad();
         DataAccessEnterpriseSQL.DAAsignarProcedure("DETESS_TodosDepTemporal");
         DataAccessEnterpriseSQL.DAAgregarParametro("@pintENTC_Codigo", x_ENTC_Codigo, SqlDbType.Int, 4, ParameterDirection.Input);
         using (IDataReader reader = DataAccessEnterpriseSQL.DAExecuteReader())
         {
             while (reader.Read())
             {
                 item = new DepTemporalEntidad();
                 Loader.LoadEntity(reader, item);
                 item.Instance = InstanceEntity.Unchanged;
                 items.Add(item);
             }
         }
         return(items);
     }
     catch (Exception ex)
     { throw ex; }
 }
Ejemplo n.º 7
0
 private DepTemporalEntidad SelectOne(Int32 DETE_Codigo)
 {
     try
     {
         DepTemporalEntidad item = new DepTemporalEntidad();
         DataAccessEnterpriseSQL.DAAsignarProcedure("DETESS_UnReg");
         DataAccessEnterpriseSQL.DAAgregarParametro("@pintDETE_Codigo", DETE_Codigo, SqlDbType.Int, 4, ParameterDirection.Input);
         using (IDataReader reader = DataAccessEnterpriseSQL.DAExecuteReader())
         {
             if (reader.Read())
             {
                 Loader.LoadEntity(reader, item);
                 item.Instance = InstanceEntity.Unchanged;
             }
             else
             {
                 throw new Exception("No se encontro el registro.");
             }
         }
         return(item);
     }
     catch (Exception ex)
     { throw ex; }
 }