public string CarregarListagemDePecasMesAtualEmDBPromodaDash(DaoDashListagemDePecasMesAtualColecao daoDashListagemDePecasMesAtualColecao) { try { string retorno = "ok"; dalMySql.LimparParametros(); dalMySql.ExecutarManipulacao(CommandType.StoredProcedure, "uspDaoDashListagemDePecasMesAtualDeletar"); DataTable dataTabledaoDashListagemDePecasMesAtual = ConvertToDataTable(daoDashListagemDePecasMesAtualColecao); foreach (DataRow linha in dataTabledaoDashListagemDePecasMesAtual.Rows) { DaoDashListagemDePecasMesAtual daoDashListagemDePecasMesAtual = new DaoDashListagemDePecasMesAtual(); daoDashListagemDePecasMesAtual.Produto = linha["produto"].ToString(); daoDashListagemDePecasMesAtual.Pecas = Convert.ToDecimal(linha["pecas"]); daoDashListagemDePecasMesAtual.Metros = Convert.ToDecimal(linha["metros"]); daoDashListagemDePecasMesAtual.Batidas = Convert.ToDecimal(linha["batidas"]); daoDashListagemDePecasMesAtual.Pontos = Convert.ToDecimal(linha["pontos"]); dalMySql.LimparParametros(); dalMySql.AdicionaParametros("@produto", daoDashListagemDePecasMesAtual.Produto); dalMySql.AdicionaParametros("@pecas", daoDashListagemDePecasMesAtual.Pecas); dalMySql.AdicionaParametros("@metros", daoDashListagemDePecasMesAtual.Metros); dalMySql.AdicionaParametros("@batidas", daoDashListagemDePecasMesAtual.Batidas); dalMySql.AdicionaParametros("@pontos", daoDashListagemDePecasMesAtual.Pontos); dalMySql.ExecutarManipulacao(CommandType.StoredProcedure, "uspDaoDashListagemDePecasMesAtualInserir"); } return(retorno); } catch (Exception ex) { throw new Exception("Nao foi Possivel inserir dados no dash de mês atual. Detalhes: " + ex.Message); } }
public DaoDashListagemDePecasMesAtualColecao ConsultarListagemDePecasMesAtualEmDBPromoda(string codEmpresa, string codProduto, string codSituacao, string codCategoria, DateTime dataInicial, DateTime dataFinal) { try { //Criar coleçao nova de Funcionarios (vazia) DaoDashListagemDePecasMesAtualColecao daoDashListagemDePecasMesAtualColecao = new DaoDashListagemDePecasMesAtualColecao(); dalSqlServer.LimparParametros(); dalSqlServer.AdicionaParametros("@codEmpresa", codEmpresa); dalSqlServer.AdicionaParametros("@codProduto", codProduto); dalSqlServer.AdicionaParametros("@codSituacao", codSituacao); dalSqlServer.AdicionaParametros("@codCategoria", codCategoria); dalSqlServer.AdicionaParametros("@dataInicial", dataInicial); dalSqlServer.AdicionaParametros("@dataFinal", dataFinal); //Criando e populando a tabela de dados DataTable dataTableDaoDashListagemDePecasMesAtual = dalSqlServer.ExecutarConsulta(CommandType.StoredProcedure, "uspDashListagemDePecasMesAtual"); //Percorrer o DataTable e tranformar em coleçao de DaoDashListagemDePecasMesAtual //Cada linha do DataTable e um DaoDashListagemDePecasMesAtual //Data=Dados e Row=Linha //For=para e Each=Cada foreach (DataRow linha in dataTableDaoDashListagemDePecasMesAtual.Rows) { //Criar um Funcionario Vazio //Colocar os dados da linha nele //Adicionar ele na coleçao DaoDashListagemDePecasMesAtual daoDashListagemDePecasMesAtual = new DaoDashListagemDePecasMesAtual(); daoDashListagemDePecasMesAtual.Produto = linha["produto"].ToString(); daoDashListagemDePecasMesAtual.Pecas = Convert.ToDecimal(linha["pecas"]); daoDashListagemDePecasMesAtual.Metros = Convert.ToDecimal(linha["metros"]); daoDashListagemDePecasMesAtual.Batidas = Convert.ToDecimal(linha["batidas"]); daoDashListagemDePecasMesAtual.Pontos = Convert.ToDecimal(linha["pontos"]); daoDashListagemDePecasMesAtualColecao.Add(daoDashListagemDePecasMesAtual); } return(daoDashListagemDePecasMesAtualColecao); } catch (Exception ex) { throw new Exception("Nao foi Possivel consultar. Detalhes: " + ex.Message); } }