Пример #1
0
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            /*
             * Obj
             * */
            Sindico obj = new Sindico();
            obj.Id_endereco = Convert.ToInt32(dlEndereco.SelectedValue);
            obj.Id_condominio = Convert.ToInt32(dlCondominio.SelectedValue);
            obj.Nome = Convert.ToString(txNome.Text);
            obj.Cpf = txCPF.Text;
            obj.Rg = txRg.Text;

            if (txId.Text.Equals(""))
            {
                obj.Id = obj.NextId();
                obj.Adicionar();
            }
            else
            {
                obj.Id = Convert.ToInt32(txId.Text);
                obj.Editar();
            }

            this.redirecionarMesmaPagina();
        }
Пример #2
0
        public bool Editar(Sindico sindico)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("UPDATE ");
            builder.Append(this.TableName + " ");
            builder.Append("SET ");
            
            builder.Append("id_endereco = ");
            builder.Append(sindico.Id_endereco + ", ");

            builder.Append("id_condominio = ");
            builder.Append(sindico.Id_condominio + ", ");

            builder.Append("nome = ");
            builder.Append("'" + sindico.Nome + "', ");

            builder.Append("cpf = "); 
            builder.Append("'" + sindico.Cpf + "', ");

            builder.Append("rg = ");
            builder.Append("'" + sindico.Rg + "' ");

            builder.Append("WHERE ");
            builder.Append("id = " + sindico.Id);
            builder.Append(";");

            return this.Update(builder.ToString());
        }
Пример #3
0
        public bool Adicionar(Sindico sindico)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("INSERT INTO ");
            builder.Append(this.TableName + " ");

            builder.Append("( ");

            builder.Append("id, ");
            builder.Append("id_endereco, ");
            builder.Append("id_condominio, ");
            builder.Append("nome, ");
            builder.Append("cpf, ");
            builder.Append("rg ");

            builder.Append(") ");

            builder.Append("VALUES ");

            builder.Append("(");

            builder.Append(sindico.Id + ", ");
            builder.Append(sindico.Id_endereco + ", ");
            builder.Append(sindico.Id_condominio + ", ");
            builder.Append("'" + sindico.Nome + "', ");
            builder.Append("'" + sindico.Cpf + "', ");
            builder.Append("'" + sindico.Rg + "' ");

            builder.Append(");");

            return this.Update(builder.ToString());
        }
Пример #4
0
 protected void DeleteRowButton_Click(Object sender, GridViewDeleteEventArgs e)
 {
     TableCell cell = gridView1.Rows[e.RowIndex].Cells[1];
     int id = Convert.ToInt32(cell.Text);
     Sindico sindico = new Sindico();
     sindico.Id = id;
     sindico.Excluir();
     this.redirecionarMesmaPagina();
 }
Пример #5
0
        protected void EditRowButton_Click(Object sender, GridViewEditEventArgs e)
        {
            TableCell cell = gridView1.Rows[e.NewEditIndex].Cells[1];
            int id = Convert.ToInt32(cell.Text);

            Sindico e1 = new Sindico();
            e1.Id = id;
            Sindico sindico = e1.GetPorId(e1.Id);

            txId.Text = Convert.ToString(sindico.Id);
            txIdEndereco.Text = Convert.ToString(sindico.Id_endereco);
            txIdCondominio.Text = Convert.ToString(sindico.Id_condominio);
            txNome.Text = sindico.Nome;
            txCPF.Text = sindico.Cpf;
            txRg.Text = sindico.Rg;
        }
Пример #6
0
        public Sindico GetPorId(int id)
        {
            NpgsqlDataReader dataReader = base.GetPorId(id);
            Sindico sindico = new Sindico();

            if (dataReader.HasRows && dataReader.Read())
            {
                sindico.Id = (int)dataReader[0];
                sindico.Id_endereco = (int)dataReader[1];
                sindico.Id_condominio = (int)dataReader[2];
                sindico.Nome = (String)dataReader[3];
                sindico.Cpf = (String)dataReader[4];
                sindico.Rg = (String)dataReader[5];
            }

            return sindico;
        }
Пример #7
0
        public Sindico GetPorId(int id)
        {
            NpgsqlDataReader dataReader = base.GetPorId(id);
            Sindico obj = new Sindico();

            if (dataReader.HasRows && dataReader.Read())
            {
                obj = this.PreencherObjeto(dataReader);
            }

            /*
             * Fechando
             * */
            dataReader.Close();
            this.CloseCon();

            return obj;
        }
Пример #8
0
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            Sindico sindico = new Sindico();

            sindico.Id_endereco = Convert.ToInt32(txIdEndereco.Text);
            sindico.Id_condominio = Convert.ToInt32(txIdCondominio.Text);
            sindico.Nome = txNome.Text;
            sindico.Cpf = txCPF.Text;
            sindico.Rg = txRg.Text;

            if (txId.Text.Equals(""))
            {
                sindico.Id = listSindico.Count + 1;
                sindico.Adicionar();
            }
            else
            {
                sindico.Id = Convert.ToInt32(txId.Text);
                sindico.Editar();
            }

            this.redirecionarMesmaPagina();
        }
Пример #9
0
        public void ExclusaoSindico()
        {
            Sindico sindico = new Sindico();
            sindico.Id = 1;

            Assert.IsTrue(sindico.Excluir());
        }
Пример #10
0
        public void ListarSindico()
        {
            List<Sindico> listSindico = new Sindico().GetTodos();

            Assert.IsTrue(listSindico.Count == 1);
        }
Пример #11
0
        public void BuscaSindicoPorId()
        {
            Sindico sindico = new Sindico().GetPorId(1);

            Assert.AreEqual("5666", sindico.Rg);
        }
Пример #12
0
        public void EditarSindico()
        {
            Sindico sindico = new Sindico();
            sindico.Id = 1;
            sindico.Id_condominio = 1;
            sindico.Id_endereco = 1;
            sindico.Nome = "Fabricio Oliveira";
            sindico.Rg = "5666";
            sindico.Cpf = "657657";

            Assert.IsTrue(sindico.Editar());
        }
Пример #13
0
        public void AdicaoSindico()
        {
            Sindico sindico = new Sindico();
            sindico.Id = 1;
            sindico.Id_condominio = 1;
            sindico.Id_endereco = 1;
            sindico.Nome = "Marcela Freitas";
            sindico.Rg = "223344";
            sindico.Cpf = "3242456";

            Assert.IsTrue(sindico.Adicionar());
        }
Пример #14
0
        protected void EditRowButton_Click(Object sender, GridViewEditEventArgs e)
        {
            TableCell cell = gridView1.Rows[e.NewEditIndex].Cells[1];
            int id = Convert.ToInt32(cell.Text);

            /*
             * Obj
             * */
            Sindico obj = new Sindico().GetPorId(id);
            txId.Text = Convert.ToString(obj.Id);
            dlEndereco.DataValueField = Convert.ToString(obj.Id_endereco);
            txNome.Text = Convert.ToString(obj.Nome);
            txNome.Text = obj.Nome;
            txCPF.Text = obj.Cpf;
            txRg.Text = obj.Rg;
        }
Пример #15
0
        private Sindico PreencherObjeto(NpgsqlDataReader dataReader)
        {
            int i = 0;
            Sindico obj = new Sindico();
            obj.Id = dataReader.GetInt32(i++);
            obj.Id_endereco = dataReader.GetInt32(i++);
            obj.Id_condominio = dataReader.GetInt32(i++);
            obj.Nome = dataReader.GetString(i++);
            obj.Cpf = dataReader.GetString(i++);
            obj.Rg = dataReader.GetString(i++);

            return obj;
        }
Пример #16
0
        public List<Sindico> GetTodos()
        {
            List<Sindico> listSindico = new List<Sindico>();

            NpgsqlDataReader dataReader = base.GetTodos();
            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    Sindico sindico = new Sindico();
                    sindico.Id = (int)dataReader[0];
                    sindico.Id_endereco = (int)dataReader[1];
                    sindico.Id_condominio = (int)dataReader[2];
                    sindico.Nome = (String)dataReader[3];
                    sindico.Cpf = (String)dataReader[4];
                    sindico.Rg = (String)dataReader[5];

                    listSindico.Add(sindico);
                }
            }

            return listSindico;
        }