public static bool registerUser(string login, string password, string cpf) { bool result = false; string sql = "INSERT INTO `ROS_PERSON`(`PER_NAME`,`PER_CPF`, `PER_RG_CTPS`) " + "VALUES(\"" + login + "\", \"" + cpf + "\", NULL);"; try { using (DatabaseROS db = new DatabaseROS()) { long personId = db.executeScalarSQL(sql); if (personId == -1) { throw new ArgumentException("Problema ao cadastrar usuário com este CPF"); } else { string userSql = "INSERT INTO `ROS_USER`(`USR_LOGIN`,`USR_PASSWORD`, `USR_PER_ID`, `USR_PRO_ID`) " + "VALUES(\"" + login + "\", \"" + password + "\", " + personId + ", \"1\");"; db.executeCommandSQL(userSql); } } result = true; } catch (Exception ex) { throw ex; } return(result); }
private void btnSalvar_Click(object sender, EventArgs e) { string sql = "INSERT INTO `CERTIFICACOES`(`CERT_NOME`) " + "VALUES(\"" + tbNome.Text + "\");"; try { using (DatabaseROS db = new DatabaseROS()) { db.executeCommandSQL(sql); } if (DialogResult.OK == MessageBox.Show("Grau de instrução cadastrado com sucesso!", "Sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Information)) { Close(); } } catch (Exception ex) { MessageBox.Show("Erro :" + ex.Message); } }