public void AtualizarGerar(int IdPedido) { try { con = ConnectionFactory.getConnection(); con.Open(); cmd = new SqlCommand("UPDATE Pedido SET Status = 'GERADO' WHERE IdPedido = @IdPedido ", con); cmd.Parameters.AddWithValue("@IdPedido", IdPedido); if (cmd.ExecuteNonQuery() == 1) { valor = 1; } else { valor = 0; } } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { try { if (con != null) { con.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (cmd != null) { cmd.Dispose(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } } }
public DataSet RetornarDataSet(int IdPedido) { try { con = ConnectionFactory.getConnection(); con.Open(); cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "dbo.RelatorioOrcamento"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@IDPEDIDO", SqlDbType.Int).Value = IdPedido; SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, "Orcamento"); return(ds); } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { try { if (con != null) { con.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (cmd != null) { cmd.Dispose(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } } }
public static ListaFornecedor RetornarFornecedor() { try { con = ConnectionFactory.getConnection(); con.Open(); comando = "SELECT Nome, CPF, CEP, Estado, Telefone, EMAIL FROM Fornecedor ORDER BY Nome;"; XmlSerializer ser = new XmlSerializer(typeof(ListaFornecedor)); list = new ListaFornecedor(); using (var cmd = con.CreateCommand()) { cmd.CommandText = comando.ToString(); using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) { list.Items.Add(new Fornecedor { Nome = rdr.GetString(0), CPF = rdr.GetString(1), CEP = rdr.GetString(2), Estado = rdr.GetString(3), Telefone = rdr.GetString(4), Email = rdr.GetString(5) }); } } cmd.Dispose(); } return(list); } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { try { if (con != null) { con.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (rdr != null) { rdr.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (cmd != null) { cmd.Dispose(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } } }
public static ListaFornecedorCombo RetornarComboFornecedor() { try { con = ConnectionFactory.getConnection(); con.Open(); comando = "SELECT IdFornecedor , Nome FROM Fornecedor ORDER BY Nome;"; XmlSerializer ser = new XmlSerializer(typeof(ListaFornecedorCombo)); list = new ListaFornecedorCombo(); using (var cmd = con.CreateCommand()) { cmd.CommandText = comando.ToString(); using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) { list.Items.Add(new FornecedorCombo { Id = rdr.GetInt32(0), Nome = rdr.GetString(1), }); } } cmd.Dispose(); } return(list); } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { try { if (con != null) { con.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (rdr != null) { rdr.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (cmd != null) { cmd.Dispose(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } } }
public void GravarFornecedor( string Nome , string CPF , string CEP , string Endereco , string Bairro , string Cidade , string Complemento , string Estado , string Complemento2 , string Numero , string Telefone , string Telefone2 , string EMAIL) { try { con = ConnectionFactory.getConnection(); con.Open(); cmd = new SqlCommand("INSERT INTO Fornecedor(Nome, CPF, CEP, Endereco, Bairro, Cidade, Complemento, Estado, Complemento2, Numero, Telefone, Telefone2, EMAIL) VALUES " + "(@Nome, @CPF, @CEP, @Endereco, @Bairro, @Cidade, @Complemento, @Estado, @Complemento2, @Numero, @Telefone, @Telefone2, @EMAIL );", con); cmd.Parameters.AddWithValue("@Nome", Nome); cmd.Parameters.AddWithValue("@CPF", CPF); cmd.Parameters.AddWithValue("@CEP", CEP); cmd.Parameters.AddWithValue("@Endereco", Endereco); cmd.Parameters.AddWithValue("@Bairro", Bairro); cmd.Parameters.AddWithValue("@Cidade", Cidade); cmd.Parameters.AddWithValue("@Complemento", Complemento); cmd.Parameters.AddWithValue("@Estado", Estado); cmd.Parameters.AddWithValue("@Complemento2", Complemento2); cmd.Parameters.AddWithValue("@Numero", Numero); cmd.Parameters.AddWithValue("@Telefone", Telefone); cmd.Parameters.AddWithValue("@Telefone2", Telefone2); cmd.Parameters.AddWithValue("@EMAIL", EMAIL); if (cmd.ExecuteNonQuery() == 1) { valor = 1; } else { valor = 0; } } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { try { if (con != null) { con.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (cmd != null) { cmd.Dispose(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } } }
public static ListaSolicitacaoItem RetornaSolicitacaoItem(int IdPedido) { con = ConnectionFactory.getConnection(); con.Open(); try { cmd = new SqlCommand("SELECT Cod, Nome, UnidadeMedida, QtdEstoque, QtdMinima, QtdMaxima, Solicitar FROM PedidoItem WHERE IdPedido = @IdPedido;", con); cmd.Parameters.AddWithValue("@IdPedido", IdPedido); XmlSerializer ser = new XmlSerializer(typeof(ListaSolicitacaoItem)); list = new ListaSolicitacaoItem(); using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) { list.Items.Add(new SolicitacaoItem { Cod = rdr.GetString(0), Nome = rdr.GetString(1), UnidadeMedida = rdr.GetString(2), QtdEstoque = rdr.GetDouble(3), QtdMinima = rdr.GetDouble(4), QtdMaxima = rdr.GetDouble(5), Solicitar = rdr.GetDouble(6), }); } } return(list); } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { try { if (con != null) { con.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (rdr != null) { rdr.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (cmd != null) { cmd.Dispose(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } } }
public static ListaSolicitacoes RetornaSolicitacoes() { try { con = ConnectionFactory.getConnection(); con.Open(); comando = "SELECT IdPedido, Solicitante, Urgencia, DataCriacao, Tipo, Status FROM Pedido WHERE Status = 'APROVADO' OR Status = 'GERADO' ORDER BY Status;"; XmlSerializer ser = new XmlSerializer(typeof(ListaSolicitacoes)); list = new ListaSolicitacoes(); using (var cmd = con.CreateCommand()) { cmd.CommandText = comando.ToString(); using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) { list.Items.Add(new Solicitacoes { IdPedido = rdr.GetInt32(0), Solicitante = rdr.GetString(1), Urgencia = rdr.GetString(2), DataCriacao = rdr.GetDateTime(3).ToString("dd/MM/yyyy"), Tipo = rdr.GetString(4), Status = rdr.GetString(5) }); } } } return(list); } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { try { if (con != null) { con.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (rdr != null) { rdr.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (cmd != null) { cmd.Dispose(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } } }
public void GravarOrcamento( int IdPedido , string Tipo , string DataEmissao , string Observacoes , string Vendedor , string PrazoEntrega , string CondicaoPag , double ValorAdicional , double Valor , int QtdItens) { try { con = ConnectionFactory.getConnection(); con.Open(); cmd = new SqlCommand("INSERT INTO Orcamento(IdPedido, Tipo, DataEmissao, Observacoes, Vendedor, PrazoEntrega, CondicaoPag, ValorAdicional, Valor, ValorSoma, QtdItens) VALUES " + "(@IdPedido, @Tipo, GETDATE(), @Observacoes, @Vendedor, @PrazoEntrega, @CondicaoPag, @ValorAdicional, @Valor, @ValorSoma, @QtdItens);", con); cmd.Parameters.AddWithValue("@IdPedido", IdPedido); cmd.Parameters.AddWithValue("@Tipo", Tipo); cmd.Parameters.AddWithValue("@DataEmissao", DataEmissao); cmd.Parameters.AddWithValue("@Observacoes", Observacoes); cmd.Parameters.AddWithValue("@Vendedor", Vendedor); cmd.Parameters.AddWithValue("@PrazoEntrega", PrazoEntrega); cmd.Parameters.AddWithValue("@CondicaoPag", CondicaoPag); cmd.Parameters.AddWithValue("@ValorAdicional", ValorAdicional); cmd.Parameters.AddWithValue("@Valor", Valor); cmd.Parameters.AddWithValue("@ValorSoma", Valor + ValorAdicional); cmd.Parameters.AddWithValue("@QtdItens", QtdItens); if (cmd.ExecuteNonQuery() == 1) { valor = 1; } else { valor = 0; } } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { try { if (con != null) { con.Close(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } try { if (cmd != null) { cmd.Dispose(); } } catch (Exception ex) { throw new Exception(ex.ToString()); } } }