示例#1
0
 public void LimpaDados()
 {
     TxtCodProduto.Clear();
     TxtDescri.Clear();
     TxtCodEan.Clear();
     CboCategoria.Text = "Selecione";
     TxtPrecoCompra.Clear();
     TxtLucro.Clear();
     TxtPrecoVenda.Clear();
     CboSubCat.Text = "Selecione";
     TxtEstoqueMin.Clear();
     TxtEstoqueMax.Clear();
     CboFabricante.Text = "Selecione";
     TxtICMS.Clear();
     TxtIPI.Clear();
     CboUnidade.Text   = "Selecione";
     CboCadPor.Text    = "Selecione";
     DataCad.Text      = "";
     CboCadPor.Enabled = true;
 }
示例#2
0
        private void BtnCadastrar_Click(object sender, EventArgs e)
        {
            if (TxtDescri.Text == "")
            {
                MessageBox.Show("Preencher Descrição do Produto!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtDescri.Focus();
            }
            else if (TxtCodEan.Text == "" || TxtCodEan.TextLength < 13)
            {
                MessageBox.Show("Preencher Código EAN!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtCodEan.Focus();
            }
            else if (CboFabricante.Text == "Selecione")
            {
                MessageBox.Show("Selecione Fabricante!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CboFabricante.Focus();
            }
            else if (CboCategoria.Text == "Selecione")
            {
                MessageBox.Show("Selecione Categoria!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CboCategoria.Focus();
            }
            else if (TxtPrecoCompra.Text == "")
            {
                MessageBox.Show("Preencher Preço Compra!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtPrecoCompra.Focus();
            }
            else if (TxtPrecoVenda.Text == "")
            {
                MessageBox.Show("Preencher Preço de Venda!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtPrecoVenda.Focus();
            }
            else if (CboSubCat.Text == "Selecione")
            {
                MessageBox.Show("Selecione Sub-Categoria!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CboSubCat.Focus();
            }

            else if (TxtEstoqueMin.Text == "")
            {
                MessageBox.Show("Preencher Estoque Mínimo!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtEstoqueMin.Focus();
            }
            else if (TxtEstoqueMax.Text == "")
            {
                MessageBox.Show("Preencher Estoque Máximo", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtEstoqueMax.Focus();
            }

            else if (CboUnidade.Text == "Selecione")
            {
                MessageBox.Show("Selecione Unidade!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CboUnidade.Focus();
            }

            else if (TxtICMS.Text == "")
            {
                MessageBox.Show("Preencher ICMS!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtICMS.Focus();
            }
            else if (TxtIPI.Text == "")
            {
                MessageBox.Show("Preencher IPI!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtIPI.Focus();
            }
            else if (TxtLucro.Text == "")
            {
                MessageBox.Show("Preencher Lucro!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtLucro.Focus();
            }
            else if (CboCadPor.Text == "Selecione")
            {
                MessageBox.Show("Selecione Usuário!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CboCadPor.Focus();
            }
            else
            {
                conn.Open();
                try
                {
                    SqlCommand comando = new SqlCommand
                    {
                        CommandType = CommandType.Text,
                        CommandText = "INSERT INTO Produto(Descricao,Qtd,EAN,Categoria,PrecoCompra,Lucro,PrecoVenda,SubCateg,EstoqueMin,EstoqueMax,Fabricante,ICMS,IPI,Unidade,DataCad,Id_Usuario) VALUES ('" + TxtDescri.Text + "','" + 0 + "','" + TxtCodEan.Text + "','" + CboCategoria.Text + "','" + TxtPrecoCompra.Text.Replace(',', '.') + "','" + TxtLucro.Text + "','" + TxtPrecoVenda.Text.Replace(',', '.') + "','" + CboSubCat.Text + "','" + TxtEstoqueMin.Text + "','" + TxtEstoqueMax.Text + "','" + CboFabricante.Text + "','" + TxtICMS.Text + "','" + TxtIPI.Text + "','" + CboUnidade.Text + "','" + DateTime.Now + "',(select id_usuario from usuario where usuario.usuario='" + CboCadPor.Text + "'))",
                        Connection  = conn
                    };
                    comando.ExecuteNonQuery();
                    MessageBox.Show("Produto Cadastrado com Sucesso!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch
                {
                    MessageBox.Show("Erro ao Cadastrar Produto! Tente Novamente.", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                conn.Close();
                LimpaDados();
                TxtDescri.Focus();
            }
        }