private void button2_Click(object sender, EventArgs e) { if (arr.Count > 0) { if (MessageBox.Show("Você deseja realmente excluir este dentista ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { classDentista d = new classDentista(); int t = dataGridView1.CurrentRow.Index; string x = d.Deletar(((classDentista)arr[t]).Iddentista.ToString()); if (x == "1") { MessageBox.Show("Dentista excluido com sucesso."); atualiza_grid(); } else { MessageBox.Show("Não é possivel excluir este dentista\n. já existem dados gravados relativos a ele", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } else { MessageBox.Show("Não há nenhum dentista selecionado", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public frmExpediente(int id) { InitializeComponent(); classDentista d = new classDentista(); int x = d.bucarexpediente(id.ToString()); if (x == 0) { d.criar_exp(id.ToString()); } }
public frmCadastrardentista(string id) { ID = id; InitializeComponent(); aux = 1; classDentista de = new classDentista(); arr = de.bucareditar(id); txtNomeMedico.Text = ((classDentista)arr[0]).Nome; txtEnderecoMedico.Text = ((classDentista)arr[0]).Endereco; txtCro.Text = ((classDentista)arr[0]).Cro; txtRg.Text = ((classDentista)arr[0]).Rg.ToString(); txtOrg.Text = ((classDentista)arr[0]).Orgaoexpedidor; txtCpf.Text = ((classDentista)arr[0]).Cpf.ToString(); txtTelefoneMedico.Text = ((classDentista)arr[0]).Telefone.ToString(); txtLogin.Text = ((classDentista)arr[0]).Login; txtSenha.Text = ((classDentista)arr[0]).Senha; txtLogin.Enabled = false; txtCro.Enabled = false; }
public void atualiza_grid() { classDentista den = new classDentista(); dataGridView1.Rows.Clear(); arr.Clear(); try { arr = den.buscar(txtDentista.Text); for (int i = 0; i < arr.Count; i++) { dataGridView1.Rows.Add(); dataGridView1[0, i].Value = ((classDentista)arr[i]).Nome; dataGridView1[1, i].Value = ((classDentista)arr[i]).Cro; dataGridView1[2, i].Value = ((classDentista)arr[i]).Cpf; } } catch (Exception e) { throw e; } }
public string Deletar(string idd) { classDentista dent = new classDentista(); string sql = "DELETE FROM dentista WHERE iddentista = '" + idd + "';"; MySqlCommand commS = new MySqlCommand(sql, Conn.mConn); if (dent.bucarficha(idd) == 0 || dent.bucarconsulta(idd) == 0) { try { Conn.ExecuteNonQuery(commS); } catch (Exception e) { throw e; } return "1"; } else { return "0"; } }
public ArrayList buscar(string bus) { ArrayList arr = new ArrayList(); string sql = "SELECT * FROM dentista where nome like '%" + bus + "%' or cro like '%" + bus + "%';"; MySqlCommand commS = new MySqlCommand(sql, Conn.mConn); DataTable dt = Conn.ExecuteQuery(commS); if (dt != null) { int i = 0; while (i < dt.Rows.Count) { classDentista de = new classDentista(); de.login = dt.Rows[i][6].ToString(); de.senha = dt.Rows[i][7].ToString(); de.Iddentista = int.Parse(dt.Rows[i][0].ToString()); de.cpf = dt.Rows[i][1].ToString(); de.rg = dt.Rows[i][2].ToString(); de.orgaoexpedidor = dt.Rows[i][3].ToString(); de.nome = dt.Rows[i][4].ToString(); de.cro = dt.Rows[i][5].ToString(); de.tipo = int.Parse(dt.Rows[i][8].ToString()); de.endereco = dt.Rows[i][9].ToString(); de.telefone = int.Parse(dt.Rows[i][10].ToString()); arr.Add(de); i++; } } return arr; }
private void btnSalvar_Click(object sender, EventArgs e) { if (txtCro.Text != null || txtNomeMedico.Text != string.Empty || txtLogin.Text != string.Empty || txtSenha.Text != string.Empty) { classDentista d = new classDentista(); ArrayList arra = new ArrayList(); arra = d.bucaverificar(txtCro.Text, txtLogin.Text); if (aux == 1) { d.Nome = txtNomeMedico.Text; d.Endereco = txtEnderecoMedico.Text; d.Cro = txtCro.Text; d.Rg = txtRg.Text; d.Orgaoexpedidor = txtOrg.Text; d.Cpf = txtCpf.Text; d.Telefone = int.Parse(txtTelefoneMedico.Text); d.Login = txtLogin.Text; d.Senha = txtSenha.Text; try { d.Editar(ID); MessageBox.Show("Dados alterados com sucesso.\n", " ", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); } catch (Exception tt) { MessageBox.Show("erro!\n" + tt.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (arra.Count == 0) { d.Nome = txtNomeMedico.Text; d.Endereco = txtEnderecoMedico.Text; d.Cro = txtCro.Text; d.Rg = txtRg.Text; d.Orgaoexpedidor = txtOrg.Text; d.Cpf = txtCpf.Text; d.Telefone = int.Parse(txtTelefoneMedico.Text); d.Login = txtLogin.Text; d.Senha = txtSenha.Text; d.Tipo = 1; try { d.Salvar(); MessageBox.Show("Dentista salvo com sucesso.\n", " ", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); } catch (Exception tt) { MessageBox.Show("erro!\n" + tt.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Login ou Cro já estam sendo usados por outro dentista.\n", " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Os campos com * não podem ficar em branco \n", " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } }