Exemplo n.º 1
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                string nome = txtNomeFornecedor.Text;
                nome = nome.Trim();
                int qtdNome = nome.Count();

                if (qtdNome > 50)
                {
                    throw new Exception("O campo 'Nome' não pode conter mais de 50 caracteres.");
                }
                else if (qtdNome == 0)
                {
                    throw new Exception("Nome inválido");
                }


                string cidade = txtCidade.Text;
                cidade = cidade.Trim();
                int qtdCidade = cidade.Count();

                if (qtdCidade > 45)
                {
                    throw new Exception("O campo 'Cidade' não pode conter mais de 45 caracteres.");
                }
                else if (qtdCidade == 0)
                {
                    throw new Exception("Cidade inválida.");
                }

                dto.Nome      = txtNomeFornecedor.Text;
                dto.Cidade    = txtCidade.Text;
                dto.Estado    = mkbEstado.Text;
                dto.Discricao = txtCPF_CNPJ.Text;

                Classes.ClassesFornecedor.FornecedorBusiness business = new Classes.ClassesFornecedor.FornecedorBusiness();
                business.Alterar(dto);

                MessageBox.Show("Cliente alterado com sucesso!", "SIGMA", MessageBoxButtons.OK);

                frmListarFornecedores tela = new frmListarFornecedores();
                tela.AutoCarregar();
            }
            catch (MySqlException ex)
            {
                if (ex.Number == 1062)
                {
                    MessageBox.Show("Este fornecedor já esta cadastrado. Verifique se o CNPJ está corretamente preenchido ou se ele já está no sistema.",
                                    "SIGMA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "SIGMA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void fornecedoresToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmListarFornecedores tela = new frmListarFornecedores();

            OpenScreen(tela);
        }
Exemplo n.º 3
0
 private void btnFornecedores_Click(object sender, EventArgs e)
 {
     Telas.frmListarFornecedores tela = new frmListarFornecedores();
     OpenScreen(tela);
 }