コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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();
                }
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 public void init(GrupoPessoaBean grupoPessoaBean, TipoDMLForm tipoDMLForm)
 {
     bean = grupoPessoaBean;
     setBeanIntoTextBox();
     tipoDML = tipoDMLForm;
     if (tipoDML == TipoDMLForm.DELETE)
     {
         pnlPrincipal.Enabled = false;
     }
 }
コード例 #9
0
        protected override object getObgectValues(BaseModel beanObj)
        {
            GrupoPessoaBean bean = (GrupoPessoaBean)beanObj;

            if (txtDescr.isAltered)
            {
                bean.descr = txtDescr.Text.Trim();
            }

            return(bean);
        }
コード例 #10
0
        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();
        }
コード例 #11
0
 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.");
     }
 }
コード例 #12
0
        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);
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        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);
        }
コード例 #15
0
 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.";
     }
 }
コード例 #16
0
        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();
            }
        }
コード例 #17
0
        protected override void novo()
        {
            GrupoPessoaBean obj = new GrupoPessoaBean();

            this.incluirRegistro(obj);
        }
コード例 #18
0
 private static void SetParameters(OracleParameter[] parms, GrupoPessoaBean bean)
 {
     parms[0].Value = bean.descr;
     parms[1].Value = bean.idGrupoPessoa;
 }
コード例 #19
0
 public DMLGrupoPessoa()
 {
     InitializeComponent();
     bean    = new GrupoPessoaBean();
     tipoDML = TipoDMLForm.INSERT;
 }