Exemple #1
0
        private void btnEntrar_Click(object sender, EventArgs e)
        {
            try
            {
                byte[]       imageBt = null;
                FileStream   fstream = new FileStream(txtImg.Text, FileMode.Open, FileAccess.Read);
                BinaryReader br      = new BinaryReader(fstream);
                imageBt = br.ReadBytes((int)fstream.Length);
                //botao cadastrar
                Produto         produto = new Produto();
                ValidarNumerico validar = new ValidarNumerico();
                if (validar.ValidarNumeros(txtId.Text, txtId.Name))
                {
                    produto.ID = int.Parse(txtId.Text);
                }



                if (validar.ValidarDecimal(txtValor.Text, txtValor.Name))
                {
                    produto.Preco = float.Parse(txtValor.Text);
                }
                produto.Quantidade = int.Parse(mkdQTD.Text);
                produto.Descricao  = rtbDesc.Text;
                produto.Data       = DateTime.Parse(dtpData.Text);
                produto.Imagem     = imageBt;

                ProdutoBLL cadastrarProd = new ProdutoBLL();
                cadastrarProd.NovoProdutoEntrada(produto);
            }
            catch (Exception erro)
            {
                MessageBox.Show("Selecione uma imagem");
            }
        }
Exemple #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            Produto         produto  = new Produto();
            ProdutoBLL      prod     = new ProdutoBLL();
            ValidarNumerico validaId = new ValidarNumerico();

            if (validaId.ValidarNumeros(txtIdProd.Text, "Campo ID") && validaId.ValidarDecimal(txtPreco.Text, "Campo Preço"))
            {
                int   id    = int.Parse(txtIdProd.Text);
                int   qtd   = int.Parse(mkdQt.Text);
                float valor = float.Parse(txtPreco.Text);
                float tot   = float.Parse(lblValor.Text);

                produto.ID         = id;
                produto.Preco      = valor;
                produto.Quantidade = qtd;
                produto.Total      = tot;
                produto.Data       = DateTime.Parse(dtpSaida.Text);

                prod.NovoProdutoSaida(produto);
            }
        }
Exemple #3
0
        private void mkdQt_TextChanged(object sender, EventArgs e)
        {
            ValidarNumerico validarCampo = new ValidarNumerico();


            if (txtPreco.Text != "" && mkdQt.Text != "")
            {
                if (validarCampo.ValidarDecimal(txtPreco.Text, txtPreco.Name))
                {
                    preco = float.Parse(txtPreco.Text);
                    qtde  = int.Parse(mkdQt.Text);
                    total = qtde * preco;
                    string x = (qtde * preco).ToString();

                    lblValor.Text = x;
                }
                else
                {
                    MessageBox.Show("Digite apenas números", "Erro");
                }
            }
        }