Académique Documents
Professionnel Documents
Culture Documents
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace miniProjeto
{
public partial class frmUsuario : Form
{
conn.Open();
conn.Close();
return;
}
public frmUsuario()
{
InitializeComponent();
}
if (txtNome.Text.Trim() == "")
{
MessageBox.Show("O campo Nome deve ser preenchido");
txtNome.Text = "";
txtNome.Focus();
return;
}
if (txtLogin.Text.Trim() == "")
{
MessageBox.Show("O campo Login deve ser preenchido");
txtLogin.Text = "";
txtLogin.Focus();
return;
}
if (txtSenha.Text.Trim() == "")
{
MessageBox.Show("O campo SENHA deve ser preenchido");
txtSenha.Text = "";
txtSenha.Focus();
return;
}
if (txtCPF.MaskFull == false)
{
MessageBox.Show("O campo CPF deve ser preenchido");
txtCPF.Text = "";
txtCPF.Focus();
return;
}
if (txtStatus.SelectedIndex == -1)
{
MessageBox.Show("O campo status deve ser preenchido");
txtCPF.Text = "";
txtCPF.Focus();
return;
}
conn.Open();
try
{
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
MessageBox.Show("Cadastro realizado com sucesso!");
}
else
{
MessageBox.Show("N�o foi possivel realizar o cadastro");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
finally
{
conn.Close();
}
}
int i;
try
{
leitura = cmd.ExecuteReader();
if (leitura.Read())
{
txtNome.Text = leitura[1].ToString();
txtLogin.Text = leitura[2].ToString();
txtSenha.Text = leitura[3].ToString();
txtCPF.Text = leitura[4].ToString();
txtStatus.SelectedItem = leitura[5].ToString();
txtObs.Text = leitura[6].ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
throw;
}
}
try
{
int i = cmd.ExecuteNonQuery();
if (i>0)
{
MessageBox.Show("Dados alterados com sucesso");
}
else
{
MessageBox.Show("N�o foi possivel fazer a altera��o.");
}
}
catch (Exception)
{
throw;
}
}
txtNome.Text = "";
txtLogin.Text = "";
txtSenha.Text = "";
txtCPF.Text = "";
txtStatus.SelectedIndex = -1;
txtObs.Text = "";
}
private void btnLimpar_Click(object sender, EventArgs e)
{
try
{
int i = cmd.ExecuteNonQuery();
if (i>0)
{
MessageBox.Show("Dados excluidos com sucesso");
Limpar();
txtCodigo.Text = "";
}
else
{
MessageBox.Show("N�o foi possivel fazer a altera��o.");
}
}
catch (Exception)
{
throw;
}
}
}
}