Exemple #1
0
 private void btn_add_Click(object sender, EventArgs e)
 {
     if (CheckGaps().Equals(true))
     {
         ProdutoDTO produto = new ProdutoDTO();
         produto = GeralRN.GetProductByCodeWithoutImage(this.txt_codigo.Text);
         int qtde = Convert.ToInt32(this.txt_quant.Text);
         if (CheckFornecedorProduto(produto))
         {
             if ((CheckProductIntoGrid(produto.codigo).Equals(-1)))
             {
                 this.dtgrid_venda.Rows.Add();
                 this.dtgrid_venda.Rows[count].Cells["code"].Value = produto.codigo.ToString();
                 this.dtgrid_venda.Rows[count].Cells["quatde"].Value = this.txt_quant.Text;
                 this.dtgrid_venda.Rows[count].Cells["codigo"].Value = produto.code_ref.ToString();
                 this.dtgrid_venda.Rows[count].Cells["precoInicial"].Value = produto.precoInicial.ToString();
                 this.dtgrid_venda.Rows[count].Cells["precototal"].Value = (produto.precoInicial * qtde).ToString();
                 this.lbl_total.Text = ("R$ ") + (total += (produto.precoInicial * qtde)).ToString();
                 count++;
             }
             else
                 MessageBox.Show("O produto já foi adicionado à venda!");
         }
         else
             MessageBox.Show("O produto não pertence ao fornecedor informado!");
     }
     else
         MessageBox.Show("Preencha os campos vazio!");
 }
        private void btn_add_Click(object sender, EventArgs e)
        {
            if(CheckGaps().Equals(true))
            {
                ProdutoDTO produto = new ProdutoDTO();
                produto = GeralRN.GetProductByCodeWithoutImage(this.txt_codigo.Text);
                int qtde = Convert.ToInt32(this.txt_quant.Text);

                if ((CheckProductIntoGrid(produto.codigo).Equals(-1)))
                {
                    if (produto.qtde >= qtde)
                    {
                        this.dtgrid_venda.Rows.Add();
                        this.dtgrid_venda.Rows[count].Cells["code"].Value = produto.codigo.ToString();
                        this.dtgrid_venda.Rows[count].Cells["quatde"].Value = this.txt_quant.Text;
                        this.dtgrid_venda.Rows[count].Cells["descri"].Value = produto.descricao.ToString();
                        this.dtgrid_venda.Rows[count].Cells["precoo"].Value = ("R$ ") + produto.precoFinal.ToString();
                        this.dtgrid_venda.Rows[count].Cells["totall"].Value = ("R$ ") + (produto.precoFinal * qtde).ToString();
                        this.lbl_total.Text = ("R$ ") + (total += (produto.precoFinal * qtde)).ToString();
                        count++;
                    }
                    else
                        MessageBox.Show("Quantidade do produto não confere com o estoque! ESTOQUE: " + produto.qtde);
                }
                else
                    MessageBox.Show("O produto já foi adicionado à venda!");

            }
            else
                MessageBox.Show("Preencha os campos vazio!");
        }
        private void btn_ok_Click(object sender, EventArgs e)
        {
            if(ChecarCampos())
            {
                ProdutoDTO produto = new ProdutoDTO();
                produto.codBarras = this.txt_codigo.Text;
                produto.code_ref = Convert.ToInt64(this.txt_code_ref.Text);
                produto.descricao = this.txt_descricao.Text;
                produto.precoInicial = Convert.ToDouble((this.txt_preco_inicial.Text = string.IsNullOrWhiteSpace(this.txt_preco_inicial.Text) ? "0" : this.txt_preco_inicial.Text));
                produto.precoFinal = Convert.ToDouble((this.txt_preco_final.Text = string.IsNullOrWhiteSpace(this.txt_preco_final.Text) ? "0" : this.txt_preco_final.Text));
                produto.tamanho = this.txt_tamanho.Text;
                produto.tipo.codigo = this.cbx_tipo.SelectedIndex;
                produto.fornecedor.codigo = Convert.ToInt32(cbx_fornecedor.SelectedValue);
                MemoryStream ms = new MemoryStream();
                imagem_box.Image.Save(ms, imagem_box.Image.RawFormat);
                byte[] imagem = ms.GetBuffer();

                try
                {
                    if (GeralRN.InsertProduct(produto,imagem))
                    {
                        MessageBox.Show("Produto cadastrado com sucesso!");
                        this.btn_limpar_Click(sender, e);
                    }

                }
                catch (Exception erro)
                {
                    throw erro;
                }

            }
        }
Exemple #4
0
 public static bool EditProductName(ProdutoDTO produto)
 {
     try
     {
         return ProdutoDAO.UpdateProduct(produto);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public void PreencherProduto()
 {
     ProdutoDTO produto = new ProdutoDTO();
     produto = GeralRN.GetProductByCode((string)SessionRN.getInstance().get(Constantes.COD_PRODUTO));
     this.txt_codigo.Text = produto.codBarras;
     this.txt_code_ref.Text = produto.code_ref.ToString();
     this.txt_descricao.Text = produto.descricao;
     this.cbx_fornecedor.SelectedValue = produto.fornecedor.codigo;
     this.cbx_tipo.SelectedIndex = produto.tipo.codigo;
     this.txt_preco_inicial.Text = produto.precoInicial.ToString();
     this.txt_preco_final.Text = produto.precoFinal.ToString();
     this.txt_qtde.Text = produto.qtde.ToString();
     this.txt_tamanho.Text = produto.tamanho;
     //FOTO
     MemoryStream ms = new MemoryStream(produto.imagem);
     imagem_box.Image = Image.FromStream(ms);
     imagem_box.SizeMode = PictureBoxSizeMode.StretchImage;
     imagem_box.BorderStyle = BorderStyle.Fixed3D;
 }
Exemple #6
0
        public static void DeleteProduct(ProdutoDTO produto)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.Append(@" DELETE FROM Produto WHERE codigo = @CODIGO");

            try
            {
                using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Mendes_varejo"].ConnectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand(SQL.ToString(), connection);
                    command.Parameters.AddWithValue("@CODIGO", produto.codigo);
                    command.ExecuteNonQuery();
                    command.Dispose();
                }
            }
            catch (Exception Erro)
            {
                throw Erro;
            }
        }
Exemple #7
0
        private void AdcionarProduto()
        {
            ProdutoDTO produto = new ProdutoDTO();

            int qtde = 0;
            if (!(GetQuantify(txt_produto.Text).Equals(1)))
            {
                qtde = GetQuantify(txt_produto.Text);
                produto = GeralRN.GetProductByCodeWithoutImage(txt_produto.Text.Remove(0, txt_produto.Text.IndexOf('*')+1));
            }
            else
            {
                qtde = GetQuantify(txt_produto.Text);
                produto = GeralRN.GetProductByCodeWithoutImage(txt_produto.Text.Remove(0, txt_produto.Text.IndexOf('*') +1));
            }

            CheckProductIntoGrid(produto.codBarras);

            if (produto.qtde >= qtde)
            {
                this.dt_produtos.Rows.Add();
                this.dt_produtos.Rows[count].Cells["CODIGO"].Value = produto.codigo;
                this.dt_produtos.Rows[count].Cells["ITEM"].Value = produto.codBarras.ToString();
                this.dt_produtos.Rows[count].Cells["QUANT"].Value = qtde.ToString();
                this.dt_produtos.Rows[count].Cells["DESCRICAO"].Value = produto.descricao.ToString();
                this.dt_produtos.Rows[count].Cells["DESCONTO"].Value = produto.desconto.ToString();
                this.dt_produtos.Rows[count].Cells["PRECO"].Value = produto.precoFinal.ToString("0.00");
                this.dt_produtos.Rows[count].Cells["TOTALL"].Value = (produto.precoFinal * qtde).ToString("0.00");
                this.lbl_total.Text = (total += (produto.precoFinal * qtde)).ToString("0.00");
                this.lbl_total_pagar.Text = (produto.precoFinal * qtde).ToString("0.00");
                this.txt_produto.Clear();
                count++;
            }
            else
            {
                MessageBox.Show("Quantidade do produto não confere com o estoque! ESTOQUE: " + produto.qtde);
                txt_produto.Clear();
            }
        }
Exemple #8
0
 private bool CheckFornecedorProduto(ProdutoDTO produto)
 {
     if (GeralRN.CheckFornecedorProduto(produto.code_ref, produto.fornecedor.codigo).Equals(true))
         return true;
     else
         return false;
 }
Exemple #9
0
        public static List<ProdutoDTO> GetAllProducts()
        {
            List<ProdutoDTO> retorno = new List<ProdutoDTO>();
            StringBuilder SQL = new StringBuilder();
            SQL.Append(@" SELECT codBarras, produto_nome, qtde, preco FROM Produto");

            try
            {
                using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Mendes_varejo"].ConnectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand(SQL.ToString(), connection);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ProdutoDTO produto = new ProdutoDTO();
                            produto.codBarras = (reader["codBarras"]).ToString();
                            produto.descricao = Convert.ToString(reader["produto_nome"]);
                            produto.qtde = (Convert.ToInt32(reader["qtde"]));
                            produto.precoInicial = ((float)(reader["precoInicial"]));
                            produto.precoFinal = ((float)(reader["precoFinal"])); ;
                            retorno.Add(produto);
                        }
                    }
                }

            }
            catch (Exception Erro)
            {
                throw Erro;
            }
            return retorno;
        }
Exemple #10
0
        public static bool UpdateProduct(ProdutoDTO produto, byte[] imagem)
        {
            try
            {
                StringBuilder SQL = new StringBuilder();
                SQL.Append(@"UPDATE Produto SET produto_nome=@DESCRICAO, fornecedor_id=@FORNECEDOR_ID, qtde=@QTDE,precoFinal=@PRECOFINAL,precoInicial=@PRECOINICIAL,tamanho=@TAMANHO,tipo_id=@TIPO_ID, imagem=@IMAGEM ");
                SQL.Append(@"WHERE codBarras=@CODIGO ");

                using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Mendes_varejo"].ConnectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand(SQL.ToString(), connection);
                    command.Parameters.AddWithValue("@CODIGO", produto.codBarras);
                    command.Parameters.AddWithValue("@DESCRICAO", produto.descricao);
                    command.Parameters.AddWithValue("@FORNECEDOR_ID", produto.fornecedor.codigo);
                    command.Parameters.AddWithValue("@QTDE", produto.qtde);
                    command.Parameters.AddWithValue("@PRECOFINAL", produto.precoFinal);
                    command.Parameters.AddWithValue("@PRECOINICIAL", produto.precoInicial);
                    command.Parameters.AddWithValue("@TAMANHO", produto.tamanho);
                    command.Parameters.AddWithValue("@TIPO_ID", produto.tipo.codigo);
                    command.Parameters.AddWithValue("@IMAGEM", imagem);
                    command.ExecuteNonQuery();
                    command.Dispose();

                }
                return true;
            }
            catch (Exception erro)
            {
                throw erro;
            }
        }
Exemple #11
0
        public static bool UpdateProduct(ProdutoDTO produto)
        {
            try
            {
                StringBuilder SQL = new StringBuilder();
                SQL.Append(@"UPDATE Produto SET produto_nome = @DESCRICAO");
                SQL.Append(@"WHERE codigo = @CODIGO");

                using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Mendes_varejo"].ConnectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand(SQL.ToString(), connection);
                    command.Parameters.AddWithValue("@DESCRICAO", produto.descricao);
                    command.Parameters.AddWithValue("@CODIGO", produto.codigo);
                    command.ExecuteNonQuery();
                    command.Dispose();
                }
            }
            catch (Exception erro)
            {
                throw erro;
            }

            return true;
        }
Exemple #12
0
        public static bool InsertProduct(ProdutoDTO produto, byte[] imagem)
        {
            try
            {
                StringBuilder SQL = new StringBuilder();
                SQL.Append(@"INSERT INTO Produto (codigo,codBarras,cod_ref, produto_nome, fornecedor_id, qtde,precoFinal,precoInicial, tamanho,tipo_id, imagem) ");
                SQL.Append(@"VALUES (NEXT VALUE FOR dbo.Sequence_Produto_interno,NEXT VALUE FOR dbo.Sequence_Produto,@COD_REF,@DESCRICAO,@FORNECEDOR_ID,@QTDE,@PRECOFINAL,@PRECOINICIAL,@TAMANHO,@TIPO_ID, @IMAGEM) ");

                using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Mendes_varejo"].ConnectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand(SQL.ToString(), connection);
                    command.Parameters.AddWithValue("@COD_REF", produto.code_ref);
                    command.Parameters.AddWithValue("@DESCRICAO", produto.descricao);
                    command.Parameters.AddWithValue("@FORNECEDOR_ID", produto.fornecedor.codigo);
                    command.Parameters.AddWithValue("@QTDE", produto.qtde);
                    command.Parameters.AddWithValue("@PRECOFINAL", produto.precoFinal);
                    command.Parameters.AddWithValue("@PRECOINICIAL", produto.precoInicial);
                    command.Parameters.AddWithValue("@TAMANHO", produto.tamanho);
                    command.Parameters.AddWithValue("@TIPO_ID", produto.tipo.codigo);
                    command.Parameters.AddWithValue("@IMAGEM", imagem);
                    command.ExecuteNonQuery();
                    command.Dispose();

                }
                return true;
            }
            catch(Exception erro)
            {
                throw erro;
            }
        }
Exemple #13
0
        public static ProdutoDTO GetProductByCodeWithoutImage(string code)
        {
            ProdutoDTO produto = new ProdutoDTO();
            StringBuilder SQL = new StringBuilder();
            SQL.Append(@" SELECT codigo,cod_ref,codBarras,produto_nome,fornecedor_id,qtde,precoFinal,precoInicial,tamanho,tipo_id FROM Produto");
            SQL.Append(@" WHERE codBarras = @CODIGO");

            try
            {
                using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Mendes_varejo"].ConnectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand(SQL.ToString(), connection);
                    command.Parameters.AddWithValue("@CODIGO", code);
                    command.ExecuteNonQuery();
                    command.Dispose();

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            produto.codBarras = (reader["codBarras"]).ToString();
                            produto.codigo = (reader["codigo"]).ToString();
                            produto.code_ref = Convert.ToInt64(reader["cod_ref"]);
                            produto.descricao = (reader["produto_nome"]).ToString();
                            produto.qtde = Convert.ToInt32(reader["qtde"]);
                            produto.fornecedor.codigo = Convert.ToInt32(reader["fornecedor_id"]);
                            produto.precoFinal = Convert.ToDouble(reader["precoFinal"]);
                            produto.precoInicial = Convert.ToDouble(reader["precoInicial"]);
                            produto.tamanho = (reader["tamanho"]).ToString();
                            produto.tipo.codigo = Convert.ToInt32(reader["tipo_id"]);
                        }
                    }
                }
                return produto;
            }
            catch (Exception Erro)
            {
                throw Erro;
            }
        }
Exemple #14
0
        public static List<ProdutoDTO> GetAllProductsCodeRef(string value)
        {
            List<ProdutoDTO> produtos = new List<ProdutoDTO>();
            StringBuilder SQL = new StringBuilder();
            SQL.Append(@"SELECT cod_ref FROM Produto WHERE fornecedor_id = @FORNECEDOR");

            try
            {
                using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Mendes_varejo"].ConnectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand(SQL.ToString(), connection);
                    command.Parameters.AddWithValue("@FORNECEDOR", value);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ProdutoDTO produto = new ProdutoDTO();
                            produto.code_ref = Convert.ToInt64(reader["cod_ref"]);
                            produtos.Add(produto);
                        }
                    }
                }
                return produtos;
            }
            catch (Exception Erro)
            {
                throw Erro;
            }
        }
Exemple #15
0
        public static List<ProdutoDTO> GetAllProductsCode()
        {
            List<ProdutoDTO> produtos = new List<ProdutoDTO>();
            StringBuilder SQL = new StringBuilder();
            SQL.Append(@"SELECT codBarras FROM Produto");

            try
            {
                using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Mendes_varejo"].ConnectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand(SQL.ToString(), connection);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ProdutoDTO produto = new ProdutoDTO();
                            produto.codBarras = ((reader["codBarras"]).ToString());
                            produtos.Add(produto);
                        }
                    }
                }
                return produtos;
            }
            catch (Exception Erro)
            {
                throw Erro;
            }
        }
Exemple #16
0
 public static bool UpdateProduct(ProdutoDTO produto, byte[] imagem)
 {
     try
     {
         return ProdutoDAO.UpdateProduct(produto, imagem);
     }
     catch (Exception e)
     {
         throw e;
     }
 }