Esempio n. 1
0
        public void Reprovar(int IdPedido)
        {
            try
            {
                con = ConnectionFactory.getConnection();
                con.Open();

                cmd = new SqlCommand("UPDATE Pedido SET Status = 'REPROVADO' 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());
                }
            }
        }
Esempio n. 2
0
            public static ListaOrcamento RetornaOrcamento()
            {
                try
                {
                    con = ConnectionFactory.getConnection();
                    con.Open();

                    comando = "SELECT Orcamento.IdPedido, Orcamento.Tipo, DataEmissao,Observacoes, Vendedor, PrazoEntrega, CondicaoPag, Orcamento.ValorSoma, QtdItens FROM Orcamento INNER JOIN Pedido on Pedido.IdPedido = Orcamento.IdPedido WHERE Pedido.Status = 'ORCAMENTO' ORDER BY DataEmissao;";

                    XmlSerializer ser = new XmlSerializer(typeof(ListaOrcamento));
                    list = new ListaOrcamento();

                    using (var cmd = con.CreateCommand())
                    {
                        cmd.CommandText = comando.ToString();
                        using (var rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                list.Items.Add(new Orcamento
                                {
                                    Pedido       = rdr.GetInt32(0),
                                    Tipo         = rdr.GetString(1),
                                    DataEmissao  = rdr.GetDateTime(2).ToString("dd/MM/yyyy"),
                                    Observacoes  = rdr.GetString(3),
                                    Vendedor     = rdr.GetString(4),
                                    PrazoEntrega = rdr.GetString(5),
                                    CondicaoPag  = rdr.GetString(6),
                                    ValorTotal   = rdr.GetDouble(7),
                                    QtdItens     = rdr.GetInt32(8)
                                });
                            }
                        }
                    }

                    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());
                    }
                }
            }
Esempio n. 3
0
            public static ListaOrcamentoDados RetornaOrcamentoDados(int IdPedido)
            {
                try
                {
                    con = ConnectionFactory.getConnection();
                    con.Open();

                    cmd = new SqlCommand("SELECT Cod, Nome, UnidadeMedida, Solicitar FROM PedidoItem WHERE IdPedido = @IdPedido;", con);
                    cmd.Parameters.AddWithValue("@IdPedido", IdPedido);

                    XmlSerializer ser = new XmlSerializer(typeof(ListaOrcamentoDados));
                    list = new ListaOrcamentoDados();


                    using (var rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            list.Items.Add(new OrcamentoDados
                            {
                                Cod           = rdr.GetString(0),
                                Nome          = rdr.GetString(1),
                                UnidadeMedida = rdr.GetString(2),
                                Solicitar     = rdr.GetDouble(3),
                            });
                        }
                    }
                    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());
                    }
                }
            }
Esempio n. 4
0
        public string Vendedor(int IdVendedor)
        {
            try
            {
                con = ConnectionFactory.getConnection();
                con.Open();

                cmd = new SqlCommand("SELECT Nome FROM Fornecedor WHERE IdFornecedor = @IdVendedor;", con);

                cmd.Parameters.AddWithValue("@IdVendedor", IdVendedor);


                rdr = cmd.ExecuteReader();

                if (rdr.Read())
                {
                    VendedorStr = rdr["Nome"].ToString();
                }

                return(VendedorStr);
            }

            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());
                }
            }
        }