Example #1
0
 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;
 }
Example #2
0
        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();
            }
        }