public bool AtualizarMvtoBMFContrato(ClientLimitContractBMFInfo contractLimit) { try { _abrirConexao(_strConnectionStringDefault); _sqlCommand = new SqlCommand("prc_lmt_atualiza_limite_bmf_contrato", _sqlConn); _sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; _sqlCommand.Parameters.Add(new SqlParameter("@idClienteParametroBMF", contractLimit.IdClienteParametroBMF)); _sqlCommand.Parameters.Add(new SqlParameter("@qtDisponivel", contractLimit.QuantidadeDisponivel)); _sqlCommand.Parameters.Add(new SqlParameter("@dtMovimento", contractLimit.DataMovimento)); int rows = _sqlCommand.ExecuteNonQuery(); _fecharConexao(); if (rows > 0) { return(true); } return(false); } catch (Exception ex) { logger.Error("Problemas na atualizacao de movimentacao de limite de contrato BMF: " + ex.Message, ex); return(false); } }
public ClientLimitBMFInfo CarregarLimitesBMF(int account) { try { ClientLimitBMFInfo ret = null; SqlDataAdapter lAdapter; _abrirConexao(_strConnectionStringDefault); DataSet lDataSet = new DataSet(); _sqlCommand = new SqlCommand("prc_lmt_sel_limites_bmf", _sqlConn); _sqlCommand.Parameters.Add(new SqlParameter("@account", account)); _sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; lAdapter = new SqlDataAdapter(_sqlCommand); lAdapter.Fill(lDataSet); if (lDataSet.Tables.Count > 0) { if (lDataSet.Tables[0].Rows.Count > 0 || lDataSet.Tables[0].Rows.Count > 0) { ret = new ClientLimitBMFInfo(); } foreach (DataRow lRow in lDataSet.Tables[0].Rows) { ClientLimitContractBMFInfo ret1 = new ClientLimitContractBMFInfo(); ret1.Account = (lRow["account"]).DBToInt32(); ret1.IdClienteParametroBMF = (lRow["idClienteParametroBMF"]).DBToInt32(); ret1.Contrato = (lRow["Contrato"]).DBToString(); string sentido = lRow["sentido"].DBToString(); ret1.Sentido = string.IsNullOrEmpty(sentido) ? string.Empty : sentido; ret1.QuantidadeTotal = (lRow["qtTotal"]).DBToInt32(); ret1.QuantidadeDisponivel = (lRow["qtDisponivel"]).DBToInt32(); ret1.DataValidade = (lRow["dtValidade"]).DBToDateTime(); ret1.DataMovimento = (lRow["dtMovimento"]).DBToDateTime(); ret1.QuantidadeMaximaOferta = (lRow["qtMaxOferta"]).DBToInt32(); ret.Account = ret1.Account; ret.ContractLimit.Add(ret1); } foreach (DataRow lRow in lDataSet.Tables[1].Rows) { ClientLimitInstrumentBMFInfo ret2 = new ClientLimitInstrumentBMFInfo(); ret2.Account = ret.Account; ret2.IdClienteParametroBMF = (lRow["IdClienteParametroBMF"]).DBToInt32(); ret2.IdClienteParametroInstrumento = (lRow["IdClienteParametroInstrumento"]).DBToInt32(); ret2.Instrumento = (lRow["Instrumento"]).DBToString(); ret2.dtMovimento = (lRow["dtMovimento"]).DBToDateTime(); ret2.QtTotalContratoPai = (lRow["QtTotalContratoPai"]).DBToInt32(); ret2.QtTotalInstrumento = (lRow["QtTotalInstrumento"]).DBToInt32(); ret2.QtDisponivel = (lRow["QtDisponivel"]).DBToInt32(); ret2.ContratoBase = (lRow["contrato"]).DBToString(); ret2.QuantidadeMaximaOferta = (lRow["qtMaxOferta"]).DBToInt32(); string sentido = lRow["sentido"].DBToString(); ret2.Sentido = string.IsNullOrEmpty(sentido)? string.Empty : sentido; ret.InstrumentLimit.Add(ret2); } } _fecharConexao(); lAdapter.Dispose(); lDataSet.Dispose(); _sqlCommand.Dispose(); return(ret); } catch (Exception ex) { logger.Error("Erro ao obter limite de bmf do cliente: " + ex.Message, ex); return(null); } }