private void filtrar() { try { PessoaBean pessoa = new PessoaBean(); pessoa.idPessoa = Uteis.stringToInt(txtId.Text); pessoa.nome = txtNome.Text; pessoa.apelido = txtApelido.Text; pessoa.logradouro = txtLogradouro.Text; pessoa.numDoc = txtDocumento.Text; GrupoPessoaBean grupo = new GrupoPessoaBean(); grupo.descr = txtGrupo.Text; pessoa.grupoPessoa = grupo; List <PessoaBean> list = PessoaDAO.getRecords(pessoa); dgvDados.DataSource = list; dgvDados.Select(); } catch (InvalidPropertyValueException e) { MessageBox.Show(e.Message); txtId.Select(); } }
private void setTextBoxIntoBean() { try { if (bean.idPessoa == 0) { bean.idPessoa = Uteis.stringToInt(txtIdPessoa.Text); } GrupoPessoaBean g = (GrupoPessoaBean)cmbGrupoPressoa.SelectedItem; bean.grupoPessoa = g; bean.nome = txtNome.Text; bean.apelido = txtApelido.Text; bean.numDoc = txtDocumento.Text; bean.tipoDoc = txtTipoDoc.Text; bean.tel1 = txtTel1.Text; bean.tel2 = txtTel2.Text; bean.tel3 = txtTel3.Text; bean.logradouro = txtLogradouro.Text; bean.numero = txtNumero.Text; bean.complemento = txtComplemento.Text; bean.bairro = txtBairro.Text; bean.cep = txtCep.Text; bean.pontoRef = txtPontoRefer.Text; bean.obs = txtObs.Text; } catch (Exception e) { MessageBox.Show(e.Message); } }
private static List <GrupoPessoaBean> SetInstance(OracleDataReader dr) { List <GrupoPessoaBean> list = new List <GrupoPessoaBean>(); try { while (dr.Read()) { GrupoPessoaBean obj = new GrupoPessoaBean(); obj.idGrupoPessoa = Convert.ToInt32(dr["id_grupo_pessoa"].ToString()); obj.descr = dr["descr"].ToString(); list.Add(obj); } } catch (Exception ex) { throw (ex); } finally { if (!dr.IsClosed) { dr.Close(); } } return(list); }
private static bool SetInstance(OracleDataReader dr, GrupoPessoaBean bean) { try { if (dr.Read()) { bean.idGrupoPessoa = Convert.ToInt32(dr["id_grupo_pessoa"].ToString()); bean.descr = dr["descr"].ToString(); return(true); } else { return(false); } } catch (Exception ex) { throw (ex); } finally { if (!dr.IsClosed) { dr.Close(); } } }
public static int insert(GrupoPessoaBean bean) { int qtdInsert = 0; using (OracleConnection conn = new OracleConnection(REFOracleDatabase.CONN_STRING)) { OracleParameter[] parms = GetParameters(true); SetParameters(parms, bean); conn.Open(); using (OracleTransaction trans = conn.BeginTransaction()) { try { OracleCommand cmd = REFOracleDatabase.ExecuteNonQueryCmd(trans, CommandType.Text, CMDINSERT, out qtdInsert, parms); bean.idGrupoPessoa = Convert.ToInt32(cmd.Parameters["id_grupo_pessoa_out"].Value.ToString()); cmd.Parameters.Clear(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw (ex); } } } return(qtdInsert); }
public static int update(GrupoPessoaBean bean) { int qtdUpdate = 0; using (OracleConnection conn = new OracleConnection(REFOracleDatabase.CONN_STRING)) { OracleParameter[] parms = GetParameters(false); SetParameters(parms, bean); conn.Open(); using (OracleTransaction trans = conn.BeginTransaction()) { try { OracleCommand cmd = REFOracleDatabase.ExecuteNonQueryCmd(trans, CommandType.Text, CMDUPDATE, out qtdUpdate, parms); cmd.Parameters.Clear(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw (ex); } } } return(qtdUpdate); }
protected override void setObgectValues(BaseModel beanObj) { GrupoPessoaBean bean = (GrupoPessoaBean)beanObj; txtIdGrupoPessoa.setText(bean.idGrupoPessoa.ToString()); txtDescr.setText(bean.descr); //concluir com o processamento da super classe base.setObgectValues(bean); }
public void init(GrupoPessoaBean grupoPessoaBean, TipoDMLForm tipoDMLForm) { bean = grupoPessoaBean; setBeanIntoTextBox(); tipoDML = tipoDMLForm; if (tipoDML == TipoDMLForm.DELETE) { pnlPrincipal.Enabled = false; } }
protected override object getObgectValues(BaseModel beanObj) { GrupoPessoaBean bean = (GrupoPessoaBean)beanObj; if (txtDescr.isAltered) { bean.descr = txtDescr.Text.Trim(); } return(bean); }
protected override void consultar() { GrupoPessoaBean filtro = new GrupoPessoaBean(); filtro.idGrupoPessoa = getNumberFromText(txtIdGrupoPessoa); filtro.descr = txtDescr.Text; List <GrupoPessoaBean> list = GrupoPessoaDAO.getRecords(filtro); this.beanDataSet = new ArrayList(list); finalizarConsulta(); }
protected override void alterar() { if (dgvDados.SelectedRows.Count > 0) { DMLGrupoPessoa form = new DMLGrupoPessoa(); GrupoPessoaBean bean = (dgvDados.DataSource as List <GrupoPessoaBean>)[dgvDados.SelectedRows[0].Index]; form.init(bean, TipoDMLForm.UPDATE); form.ShowDialog(this); } else { MessageBox.Show("Selecione um registro para alterá-lo."); } }
public static List <GrupoPessoaBean> getRecords(GrupoPessoaBean filter) { OracleDataReader dr = LoadDataReader(filter); List <GrupoPessoaBean> list = null; try { list = SetInstance(dr); } catch (Exception ex) { throw (ex); } return(list); }
private static OracleDataReader LoadDataReader(GrupoPessoaBean filtro) { String where = null; //montar o comando if (filtro.idGrupoPessoa > 0) { where = REFOracleDatabase.addAndWhere(where, " id_grupo_pessoa = " + filtro.idGrupoPessoa); } if (filtro.descr != null && filtro.descr.Trim() != "") { where = REFOracleDatabase.addAndWhere(where, " upper(descr) like '" + filtro.descr.Trim().ToUpper().Replace("'", "''") + "'"); } // return(REFOracleDatabase.ExecuteReader(CommandType.Text, CMDSELECT + where + ORDER_BY)); }
public static GrupoPessoaBean getRecord(int id) { GrupoPessoaBean bean = new GrupoPessoaBean(); OracleDataReader dr = LoadDataReader(id); try { SetInstance(dr, bean); } catch (Exception ex) { throw (ex); } return(bean); }
private void excluir() { try { int qtdregistros = GrupoPessoaDAO.delete(bean.idGrupoPessoa); pnlMessage.status = MessageStatus.SUCCESS; pnlMessage.textMessage = "Grupo de Pessoa excluido com sucesso."; pnlPrincipal.Enabled = false; isCommited = true; bean = null; } catch (Exception e) { MessageBox.Show(e.Message); pnlMessage.status = MessageStatus.ERROR; pnlMessage.textMessage = "Erro ao excluir o Grupo de Pessoa."; } }
protected override void filtrar() { try { GrupoPessoaBean grupoPessoa = new GrupoPessoaBean(); grupoPessoa.idGrupoPessoa = Uteis.stringToInt(txtId.Text); grupoPessoa.descr = txtDescr.Text; List <GrupoPessoaBean> list = GrupoPessoaDAO.getRecords(grupoPessoa); dgvDados.DataSource = list; dgvDados.Select(); } catch (InvalidPropertyValueException e) { MessageBox.Show(e.Message); txtId.Select(); } }
protected override void novo() { GrupoPessoaBean obj = new GrupoPessoaBean(); this.incluirRegistro(obj); }
private static void SetParameters(OracleParameter[] parms, GrupoPessoaBean bean) { parms[0].Value = bean.descr; parms[1].Value = bean.idGrupoPessoa; }
public DMLGrupoPessoa() { InitializeComponent(); bean = new GrupoPessoaBean(); tipoDML = TipoDMLForm.INSERT; }