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();
            }
        }
Beispiel #2
0
 private void BtnCadastrar_Click(object sender, EventArgs e)
 {
     if (TxtNome.Text == "")
     {
         MessageBox.Show("Preencher Nome Completo!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         TxtNome.Focus();
     }
     else if (TxtEmail.Text == "")
     {
         MessageBox.Show("Preencher E-mail!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         TxtEmail.Focus();
     }
     else if (TxtUsuario.Text == "")
     {
         MessageBox.Show("Preencher Usuário!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         TxtUsuario.Focus();
     }
     else if (TxtSenha.Text == "")
     {
         MessageBox.Show("Preencher Senha!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         TxtSenha.Focus();
     }
     else if (TxtRepeteSenha.Text == "")
     {
         MessageBox.Show("Repita a Senha!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         TxtRepeteSenha.Focus();
     }
     else if (CboTipoUsuario.Text == "Selecione")
     {
         MessageBox.Show("Selecione o Tipo de Usuário!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         CboTipoUsuario.Focus();
     }
     else if (CboCadPor.Text == "Selecione")
     {
         MessageBox.Show("Selecione Usuário que está realizando a Operação!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         CboCadPor.Focus();
     }
     else if (TxtSenha.Text != TxtRepeteSenha.Text)
     {
         MessageBox.Show("Senhas Não Conferem! Digite Novamente", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         TxtSenha.Text       = "";
         TxtRepeteSenha.Text = "";
         TxtSenha.Focus();
     }
     else
     {
         conn.Open();
         try
         {
             SqlCommand comando = new SqlCommand
             {
                 CommandType = CommandType.Text,
                 CommandText = "INSERT INTO Usuario(Nome,Email,Usuario,Senha,Tipo,Id_User,DataCad) VALUES ('" + TxtNome.Text + "','" + TxtEmail.Text + "','" + TxtUsuario.Text + "','" + TxtSenha.Text + "','" + CboTipoUsuario.Text + "',(select id_usuario from usuario where usuario.usuario='" + CboCadPor.Text + "'),'" + DateTime.Now + "')",
                 Connection  = conn
             };
             comando.ExecuteNonQuery();
             MessageBox.Show("Usuário Cadastrado com Sucesso!!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch
         {
             MessageBox.Show("Erro ao Cadastrar Usuário! Tente Novamente.", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         conn.Close();
         LimpaDados();
     }
 }
Beispiel #3
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();
            }
        }