public int getMinimoByBandeira(FormaPagamento.Bandeiras bandeira, int clienteID, string sessionID) { try { int parcelas = 0; string strSQL = "sp_getParcelas1 " + clienteID + ", '" + sessionID + "', '" + bandeira + "'"; IDataReader dr = oDAL.SelectToIDataReader(strSQL); if (dr.Read()) { parcelas = Convert.ToInt32(dr["Parcelas"]); } return(parcelas); } catch (Exception ex) { throw ex; } finally { oDAL.ConnClose(); } }
public int ParcelaMaxima(FormaPagamento.Bandeiras bandeira, int clienteID, string sessionID) { try { int Eventos = 0, Cotas = 0, Series = 0; int ParcelasEvento = 0, ParcelasCotas = 0, ParcelasSeries = 0; using (IDataReader dr = oDAL.SelectToIDataReader("EXEC FormasDePagamentoParcela @ClienteID = " + clienteID + ", @SessionID = '" + sessionID + "', @Bandeira = '" + bandeira + "'")) { //Qtd Só de Eventos if (dr.Read()) { Eventos = dr["QuantidadeEventos"].ToInt32(); } //Qtd só de Cotas, Sendo PA ou Avulso if (dr.NextResult() && dr.Read()) { Cotas = dr["QuantidadeCotas"].ToInt32(); } //Qtd só de Séries if (dr.NextResult() && dr.Read()) { Series = dr["QuantidadeSeries"].ToInt32(); } if (dr.NextResult() && dr.Read()) { ParcelasCotas = dr["Parcelas"].ToInt32(); } if (dr.NextResult() && dr.Read()) { ParcelasEvento = dr["Parcelas"].ToInt32(); } if (dr.NextResult() && dr.Read()) { ParcelasSeries = dr["Parcelas"].ToInt32(); } } if (Cotas > 0 && ParcelasCotas == 0) { string strQuery = @"SELECT IsNull(MAX(Parcelas), 0) AS Parcelas FROM (SELECT Parcelas FROM Carrinho c (NOLOCK) INNER JOIN FormaPagamentoEvento fpe (NOLOCK) ON fpe.EventoID = c.EventoID INNER JOIN FormaPagamento fp (NOLOCK) ON fp.IR_FormaPagamentoID = fpe.FormaPagamentoID WHERE c.ClienteID = " + clienteID + @" AND c.SessionID = '" + sessionID + @"' AND status = 'R' AND (c.CotaItemID > 0 OR c.CotaItemIDAPS > 0) AND fp.Nome = '" + bandeira + @"' GROUP BY Parcelas HAVING COUNT(DISTINCT c.CotaItemID) = " + Cotas + @") AS TB" ; using (IDataReader dr = oDAL.SelectToIDataReader(strQuery)) { if (dr.Read()) { ParcelasCotas = dr["Parcelas"].ToInt32(); } } } //Só cota if (Cotas > 0 && Eventos == 0 && Series == 0) { return(ParcelasCotas); } //Só eventos else if (Eventos > 0 && Cotas == 0 && Series == 0) { return(ParcelasEvento); } //Só Série else if (Series > 0 && Cotas == 0 && Eventos == 0) { return(ParcelasSeries); } //Os tipos else if (Cotas > 0 && Eventos > 0 && Series > 0) { return (Math.Min(Math.Min(ParcelasCotas, ParcelasEvento), ParcelasSeries)); } //Cota e Evento else if (Cotas > 0 && Eventos > 0) { return (Math.Min(ParcelasCotas, ParcelasEvento)); } //Cota e Serie else if (Cotas > 0 && Series > 0) { return (Math.Min(ParcelasCotas, ParcelasSeries)); } //Serie e Evento else { return (Math.Min(ParcelasSeries, ParcelasEvento)); } } finally { oDAL.ConnClose(); } }