Пример #1
0
        public bool ValidaCotaItemPrecoIniciaCom(EstruturaCotaItem cotaItem, int cotaID)
        {
            try
            {
                string strSQL = @"Select * from tCotaItem(NOLOCK) 
                                  where CotaID = " + cotaID + " AND ID <> " + cotaItem.ID + " AND " +
                                "(PrecoIniciaCom LIKE '" + cotaItem.precoIniciaCom + "%' OR '" + cotaItem.precoIniciaCom + "' LIKE PrecoIniciaCom + '%')";
                bd.Consulta(strSQL);

                if (bd.Consulta().Read())
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                bd.Fechar();
            }
        }
Пример #2
0
        public List <EstruturaCotaItem> ItensParaReplicar(int cotaID, bool apresentacao)
        {
            BD bd2 = new BD();

            try
            {
                List <EstruturaCotaItem> lstCotaItem         = new List <EstruturaCotaItem>();
                List <EstruturaCotaItem> lstCotaItemRetornar = new List <EstruturaCotaItem>();
                EstruturaCotaItem        item;
                string strSQL = "Select ID, PrecoIniciaCom FROM tCotaItem (NOLOCK) WHERE CotaID = " + cotaID + " ORDER BY PrecoIniciaCom ";

                bd2.Consulta(strSQL);
                while (bd2.Consulta().Read())
                {
                    item                = new EstruturaCotaItem();
                    item.ID             = bd2.LerInt("ID");
                    item.precoIniciaCom = bd2.LerString("PrecoIniciaCom");
                    lstCotaItem.Add(item);
                }
                bd2.FecharConsulta();
                foreach (EstruturaCotaItem itemNovo in lstCotaItem)
                {
                    item = new EstruturaCotaItem();
                    if (apresentacao)
                    {
                        item.quantidade = this.VerificaQuantidadeCotaPrecoApresentacao(bd2, itemNovo.ID);
                    }
                    else
                    {
                        item.quantidade = this.getQuantidadeJaVendidaAPS(bd2, itemNovo.precoIniciaCom);
                    }
                    item.precoIniciaCom = itemNovo.precoIniciaCom;
                    item.ID             = itemNovo.ID;
                    item.alterado       = true;
                    lstCotaItemRetornar.Add(item);
                }
                return(lstCotaItemRetornar);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                bd2.Fechar();
            }
        }