Exemplo n.º 1
0
        public Boolean Save(ref DetRebate Item)
        {
            try
            {
                Boolean m_isCorrect = true;
                //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(); }
                return(m_isCorrect);
            }
            catch (Exception)
            {
                //Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction();
                throw;
            }
        }
Exemplo n.º 2
0
        private bool Delete(ref DetRebate item)
        {
            try
            {
                if (item.Instance == Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted)
                {
                    DataAccessEnterpriseSQL.DAAsignarProcedure("TCOM_SP_ELIMINAR_DetRebate");
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintDREB_Codigo", item.DREB_Codigo, SqlDbType.Int, 4, ParameterDirection.Input);

                    if (DataAccessEnterpriseSQL.DAExecuteNonQuery() > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Exemplo n.º 3
0
        private bool Update(ref DetRebate item)
        {
            try
            {
                if (item.Instance == Infrastructure.Aspect.BusinessEntity.InstanceEntity.Modified)
                {
                    DataAccessEnterpriseSQL.DAAsignarProcedure("TCOM_SP_ACTUALIZAR_DetRebate");
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintDREB_Codigo", item.DREB_Codigo, SqlDbType.Int, 4, ParameterDirection.Input);
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintPACK_Codigo", item.PACK_Codigo, SqlDbType.Int, 4, ParameterDirection.Input);
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintREBA_Codigo", item.REBA_Codigo, SqlDbType.Int, 4, ParameterDirection.Input);
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pdecDREB_Valor", item.DREB_Valor, SqlDbType.Decimal, 15, 2, ParameterDirection.Input);

                    DataAccessEnterpriseSQL.DAAgregarParametro("@pvchAUDI_UsrMod", item.AUDI_UsrMod, SqlDbType.VarChar, 20, ParameterDirection.Input);

                    if (DataAccessEnterpriseSQL.DAExecuteNonQuery() > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Exemplo n.º 4
0
 public Boolean SaveDetRebate(DetRebate Item)
 {
     try
     { return(base.Channel.SaveDetRebate(Item)); }
     catch (Exception ex)
     { throw ex; }
 }
Exemplo n.º 5
0
        public BLDetRebate(IUnityContainer container)
        {
            this.ContainerService = container;
            Loader = new BusinessEntityLoader <DetRebate>();
            DetRebate item = new DetRebate();

            Loader.EntityType = item.GetType();
        }
Exemplo n.º 6
0
        public Boolean Save(ref Rebate Item)
        {
            try
            {
                Boolean m_isCorrect = true;
                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)
                {
                    for (int i = 0; i < Item.ListDetRebate.Count; i++)
                    {
                        DetRebate ItemDetRebate = Item.ListDetRebate[i];
                        ItemDetRebate.REBA_Codigo = Item.REBA_Codigo;
                        if (ItemDetRebate.DREB_Valor <= 0)
                        {
                            ItemDetRebate.Instance = Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted;
                        }

                        m_isCorrect = BL_DetRebate.Save(ref ItemDetRebate);
                        if (!m_isCorrect && ItemDetRebate.Instance != Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted)
                        {
                            break;
                        }
                        else
                        {
                            m_isCorrect = true;
                        }
                    }

                    if (m_isCorrect)
                    {
                        Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DACommitTransaction();
                    }
                    else
                    {
                        Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction();
                    }
                }
                else
                {
                    Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction();
                }
                return(m_isCorrect);
            }
            catch (Exception)
            { Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction(); throw; }
        }
Exemplo n.º 7
0
 public Boolean SaveDetRebate(DetRebate Item)
 {
     try
     {
         if (Item.Instance != Infrastructure.Aspect.BusinessEntity.InstanceEntity.Unchanged)
         {
             return(BL_DetRebate.Save(ref Item));
         }
         return(true);
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemplo n.º 8
0
 private ObservableCollection <DetRebate> SelectAll()
 {
     try
     {
         ObservableCollection <DetRebate> items = new ObservableCollection <DetRebate>();
         DetRebate item = new DetRebate();
         DataAccessEnterpriseSQL.DAAsignarProcedure("TCOM_SP_CONSULTAR_DetRebate");
         using (IDataReader reader = DataAccessEnterpriseSQL.DAExecuteReader())
         {
             while (reader.Read())
             {
                 item = new DetRebate();
                 Loader.LoadEntity(reader, item);
                 item.Instance = InstanceEntity.Unchanged;
                 items.Add(item);
             }
         }
         return(items);
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemplo n.º 9
0
 private ObservableCollection <DetRebate> SelectAllByRebate(Int32 REBA_Codigo)
 {
     try
     {
         ObservableCollection <DetRebate> items = new ObservableCollection <DetRebate>();
         DetRebate item = new DetRebate();
         DataAccessEnterpriseSQL.DAAsignarProcedure("TCOM_SP_CONSULTAR_DetRebate");
         DataAccessEnterpriseSQL.DAAgregarParametro("@pintREBA_Codigo", REBA_Codigo, SqlDbType.Int, 4, ParameterDirection.Input);
         using (IDataReader reader = DataAccessEnterpriseSQL.DAExecuteReader())
         {
             while (reader.Read())
             {
                 item = new DetRebate();
                 Loader.LoadEntity(reader, item);
                 item.Instance = InstanceEntity.Unchanged;
                 items.Add(item);
             }
         }
         return(items);
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemplo n.º 10
0
        private bool Insert(ref DetRebate item)
        {
            try
            {
                if (item.Instance == Infrastructure.Aspect.BusinessEntity.InstanceEntity.Added)
                {
                    DataAccessEnterpriseSQL.DAAsignarProcedure("TCOM_SP_INSERTAR_DetRebate");
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintDREB_Codigo", item.DREB_Codigo, SqlDbType.Int, 4, ParameterDirection.InputOutput);
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintPACK_Codigo", item.PACK_Codigo, SqlDbType.Int, 4, ParameterDirection.Input);
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintREBA_Codigo", item.REBA_Codigo, SqlDbType.Int, 4, ParameterDirection.Input);
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pdecDREB_Valor", item.DREB_Valor, SqlDbType.Decimal, 15, 2, ParameterDirection.Input);

                    DataAccessEnterpriseSQL.DAAgregarParametro("@pvchAUDI_UsrCrea", item.AUDI_UsrCrea, SqlDbType.VarChar, 20, ParameterDirection.Input);

                    if (DataAccessEnterpriseSQL.DAExecuteNonQuery() > 0)
                    {
                        Int32 _DREB_Codigo;
                        if (Int32.TryParse(DataAccessEnterpriseSQL.DASqlCommand.Parameters["@pintDREB_Codigo"].Value.ToString(), out _DREB_Codigo))
                        {
                            item.DREB_Codigo = _DREB_Codigo;
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Exemplo n.º 11
0
 private DetRebate SelectOne(Int32 DREB_Codigo)
 {
     try
     {
         DetRebate item = new DetRebate();
         DataAccessEnterpriseSQL.DAAsignarProcedure("TCOM_SP_CONSULTAR_DetRebate");
         DataAccessEnterpriseSQL.DAAgregarParametro("@pintDREB_Codigo", DREB_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; }
 }