Exemple #1
0
 public void LimpaDados()
 {
     TxtCodCliente.Clear();
     TxtNome.Clear();
     CboSexo.Text = "Selecione";
     TxtEndereco.Clear();
     TxtBairro.Clear();
     TxtCidade.Clear();
     MktCep.Clear();
     CmbEstado.Text = "Selecione";
     MktFoneFixo.Clear();
     MkFoneComercial.Clear();
     MktCelular.Clear();
     TxtRG.Clear();
     TxtEmail.Clear();
     MktCPF.Clear();
     dataNasc.Text     = "";
     CboCadPor.Text    = "Selecione";
     CboCadPor.Enabled = true;
 }
 public void LimpaDados()
 {
     TxtCodFornecedor.Clear();
     TxtRazao.Clear();
     MktCNPJ.Clear();
     TxtNomeFan.Clear();
     MktIE.Clear();
     TxtEndereco.Clear();
     CboTipoPessoa.Text = "Selecione";
     TxtCidade.Clear();
     TxtBairro.Clear();
     CboEstado.Text = "Selecione";
     MktCep.Clear();
     MktFoneFixo.Clear();
     MktFoneComercial.Clear();
     MktCelular.Clear();
     TxtHomePage.Clear();
     CboCadPor.Text = "Selecione";
     TxtEmail.Clear();
     DataCad.Text      = "";
     CboCadPor.Enabled = true;
 }
        private void BtnCadastrar_Click(object sender, EventArgs e)
        {
            if (TxtRazao.Text == "")
            {
                MessageBox.Show("Preencher Razão Social!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtRazao.Focus();
            }
            else if (!MktCNPJ.MaskCompleted)
            {
                MessageBox.Show("Preencher CNPJ!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MktCNPJ.Focus();
            }
            else if (TxtNomeFan.Text == "")
            {
                MessageBox.Show("Preencher Nome Fantasia!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtNomeFan.Focus();
            }

            else if (!MktIE.MaskCompleted)
            {
                MessageBox.Show("Preencher Inscrição Estadual!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MktIE.Focus();
            }
            else if (TxtEndereco.Text == "")
            {
                MessageBox.Show("Preencher Endereço!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtEndereco.Focus();
            }
            else if (CboTipoPessoa.Text == "Selecione")
            {
                MessageBox.Show("Selecione Tipo Pessoa!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CboTipoPessoa.Focus();
            }
            else if (TxtCidade.Text == "")
            {
                MessageBox.Show("Preencher Cidade!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtCidade.Focus();
            }
            else if (TxtBairro.Text == "")
            {
                MessageBox.Show("Preencher Bairro!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtBairro.Focus();
            }
            else if (CboEstado.Text == "Selecione")
            {
                MessageBox.Show("Selecione o Estado!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CboEstado.Focus();
            }

            else if (!MktCep.MaskCompleted)
            {
                MessageBox.Show("Preencher Cep!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MktCep.Focus();
            }

            else if (!MktFoneFixo.MaskCompleted)
            {
                MessageBox.Show("Preencher Telefone Fixo!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MktFoneFixo.Focus();
            }
            else if (!MktFoneComercial.MaskCompleted)
            {
                MessageBox.Show("Preencher Telefone Comercial!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MktFoneComercial.Focus();
            }
            else if (!MktCelular.MaskCompleted)
            {
                MessageBox.Show("Preencher Telefone Celular!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MktCelular.Focus();
            }
            else if (TxtHomePage.Text == "")
            {
                MessageBox.Show("Preencher Site!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtHomePage.Focus();
            }
            else if (CboCadPor.Text == "Selecione")
            {
                MessageBox.Show("Selecione Cadastrado Por!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CboCadPor.Focus();
            }

            else if (TxtEmail.Text == "")
            {
                MessageBox.Show("Preencher E-mail!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtEmail.Focus();
            }
            else
            {
                conn.Open();
                try
                {
                    SqlCommand comando = new SqlCommand
                    {
                        CommandType = CommandType.Text,
                        CommandText = "INSERT INTO Fornecedor(RazaoSocial,CNPJ,NomeFantasia,IE,Endereco,TipoPessoa,Cidade,Bairro,Estado,Cep,FoneFixo,FoneComercial,Celular,Site,Email,DataCad,Id_Usuario) VALUES ('" + TxtRazao.Text + "','" + MktCNPJ.Text + "','" + TxtNomeFan.Text + "','" + MktIE.Text + "','" + TxtEndereco.Text + "','" + CboTipoPessoa.Text + "','" + TxtCidade.Text + "','" + TxtBairro.Text + "','" + CboEstado.Text + "','" + MktCep.Text + "','" + MktFoneFixo.Text + "','" + MktFoneComercial.Text + "','" + MktCelular.Text + "','" + TxtHomePage.Text + "','" + TxtEmail.Text + "','" + DateTime.Now + "',(select id_usuario from usuario where usuario.usuario='" + CboCadPor.Text + "'))",
                        Connection  = conn
                    };
                    comando.ExecuteNonQuery();
                    MessageBox.Show("Fornecedor Cadastrado com Sucesso!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch
                {
                    MessageBox.Show("Erro ao Cadastrar Fornecedor! Tente Novamente.", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                LimpaDados();
                TxtRazao.Focus();
                conn.Close();
            }
        }
Exemple #4
0
        private void BtnCadastrar_Click_1(object sender, EventArgs e)
        {
            if (TxtNome.Text == "")
            {
                MessageBox.Show("Preencher Nome!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtNome.Focus();
            }
            else if (TxtEndereco.Text == "")
            {
                MessageBox.Show("Preencher Endereço!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtEndereco.Focus();
            }
            else if (CboSexo.Text == "Selecione")
            {
                MessageBox.Show("Selecione Sexo!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CboSexo.Focus();
            }
            else if (TxtCidade.Text == "")
            {
                MessageBox.Show("Preencher Cidade!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtCidade.Focus();
            }

            else if (TxtBairro.Text == "")
            {
                MessageBox.Show("Preencher Bairro!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtBairro.Focus();
            }
            else if (CmbEstado.Text == "Selecione")
            {
                MessageBox.Show("Selecione Estado!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CmbEstado.Focus();
            }
            else if (!MktCep.MaskCompleted)
            {
                MessageBox.Show("Preencher Cep!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MktCep.Focus();
            }
            else if (!MktFoneFixo.MaskCompleted)
            {
                MessageBox.Show("Preencher Telefone Fixo!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MktFoneFixo.Focus();
            }
            else if (!MkFoneComercial.MaskCompleted)
            {
                MessageBox.Show("Preencher Telefone Comercial!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MkFoneComercial.Focus();
            }
            else if (!MktCelular.MaskCompleted)
            {
                MessageBox.Show("Preencher Telefone Celular!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MktCelular.Focus();
            }
            else if (TxtRG.Text == "")
            {
                MessageBox.Show("Preencher RG!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtRG.Focus();
            }

            else if (!MktCPF.MaskCompleted)
            {
                MessageBox.Show("Preencher CPF/CNPJ!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                MktCPF.Focus();
            }
            else if (TxtEmail.Text == "")
            {
                MessageBox.Show("Preencher E-mail!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TxtEmail.Focus();
            }
            else if (CboCadPor.Text == "Selecione")
            {
                MessageBox.Show("Selecione o Usuário!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CmbEstado.Focus();
            }
            else
            {
                conn.Open();
                try
                {
                    SqlCommand comando = new SqlCommand
                    {
                        CommandType = CommandType.Text,
                        CommandText = "INSERT INTO Clientes(Nome,Sexo,Endereco,Bairro,Cidade,Cep,Estado,FoneFixo,FoneComercial,Celular,RG,Email,CPF,DataNascimento,DataCad,Id_Usuario) VALUES ('" + TxtNome.Text + "','" + CboSexo.Text + "','" + TxtEndereco.Text + "','" + TxtBairro.Text + "','" + TxtCidade.Text + "','" + MktCep.Text + "','" + CmbEstado.Text + "','" + MktFoneFixo.Text + "','" + MkFoneComercial.Text + "','" + MktCelular.Text + "','" + TxtRG.Text + "','" + TxtEmail.Text + "','" + MktCPF.Text + "','" + dataNasc.Value.ToString("dd/MM/yyyy") + "','" + DateTime.Now + "',(select id_usuario from usuario where usuario.usuario='" + CboCadPor.Text + "'))",
                        Connection  = conn
                    };
                    comando.ExecuteNonQuery();
                    MessageBox.Show("Cliente Cadastrado com Sucesso!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch
                {
                    MessageBox.Show("Erro ao Cadastrar Cliente!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                /*
                 *
                 * VERIFICAR ERRO
                 *
                 *
                 * string sql = "INSERT INTO NotaFiscalItens(Id_Produto,Qtd,Descricao,PrecoUnitario,NFNumero,Id_NotaFiscal) VALUES (@Id_Produto,@Qtd,@Descricao,@PrecoUnitario,@NfNumero,@Id_NotaFiscal)";
                 *  UPDATEESTOQUE.CommandText = (@"Update Produto set produto.qtde=10 from produto");
                 *
                 *  SqlCommand comandos = new SqlCommand(sql, conn);
                 *  for (int i = 0; i < dataGridView1.Rows.Count; i++)
                 *  {
                 *      comandos.Parameters.Clear();
                 *      comandos.Parameters.AddWithValue("@Id_Produto",
                 *          dataGridView1.Rows[i].Cells[0].Value);
                 *      comandos.Parameters.AddWithValue("@Qtd",
                 *          dataGridView1.Rows[i].Cells[1].Value);
                 *      comandos.Parameters.AddWithValue("@Descricao",
                 *          dataGridView1.Rows[i].Cells[2].Value);
                 *      comandos.Parameters.AddWithValue("@PrecoUnitario",
                 *          dataGridView1.Rows[i].Cells[3].Value);
                 *      comandos.Parameters.AddWithValue("@NFNumero",
                 *          dataGridView1.Rows[i].Cells[4].Value);
                 *      comandos.Parameters.AddWithValue("@Id_NotaFiscal",
                 *          dataGridView1.Rows[i].Cells[5].Value);
                 *      comandos.ExecuteNonQuery();
                 *  }
                 *
                 *  UPDATEESTOQUE.ExecuteNonQuery();
                 *  comandos.ExecuteNonQuery();
                 */


                LimpaDados();
                TxtNome.Focus();
                conn.Close();
            }
        }