예제 #1
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                dataGridView1.Rows[i].DataGridView.Columns.Clear();
            }

            Obras   obras   = new Obras();
            ObrasBO obrasBO = new ObrasBO();

            try
            {
                obras.CodObras = Convert.ToInt16(lblCodObra.Text);
                obrasBO.Deletar(obras);

                MessageBox.Show("Obra excluída com sucesso");

                mskData.Clear();
                txtApto.Clear();
                txtBloco.Clear();;
                txtProprietario.Clear();

                txtBusca.Clear();
                panel1.Enabled     = false;
                btnAlterar.Enabled = false;
                btnExcluir.Enabled = false;
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
예제 #2
0
        public string[] nombresCuadrosGaleria(string Gal)
        {
            ObrasExposicion obras = null;

            obras = Obras.todosLosCuadrosPrestados();

            String[] nombresCuadrosGaleria = new String[obras.exposicion.Length];

            bool encontrado = false;
            int  x          = 0;

            foreach (var item in obras.exposicion)
            {
                encontrado = false;
                CuadroPrestado c = (CuadroPrestado)item;
                if (c != null)
                {
                    if (c.nombreGaleria == Gal)
                    {
                        while (x < nombresCuadrosGaleria.Length && encontrado == false)
                        {
                            if (nombresCuadrosGaleria[x] == null)
                            {
                                nombresCuadrosGaleria[x] = item.nombre;
                                encontrado = true;
                            }
                            x++;
                        }
                    }
                }
            }

            return(nombresCuadrosGaleria);
        }
예제 #3
0
        public void update(Obras obraInf)
        {
            obraInf.Cidade  = db.Cidades.Where(x => x.Id == obraInf.Cidade.Id).First();
            obraInf.Cliente = db.Clientes.Where(x => x.Id == obraInf.Cliente.Id).First();
            obraInf.Status  = db.Status.Where(x => x.Id == obraInf.Status.Id).First();
            try
            {
                obraInf.Responsavel = db.Responsavel.Where(x => x.Id == obraInf.Responsavel.Id).First();
            }
            catch
            {
            }

            Obras obraAlt = db.Obras.Where(x => x.Id == obraInf.Id).First();

            obraAlt.Cidade          = obraInf.Cidade;
            obraAlt.Cliente         = obraInf.Cliente;
            obraAlt.DataFim         = obraInf.DataFim;
            obraAlt.DataInicio      = obraInf.DataInicio;
            obraAlt.Endereco        = obraInf.Endereco;
            obraAlt.Excluido        = obraInf.Excluido;
            obraAlt.PrazoEstipulado = obraInf.PrazoEstipulado;
            obraAlt.Preco           = obraInf.Preco;
            obraAlt.Responsavel     = obraInf.Responsavel;
            obraAlt.Status          = obraInf.Status;
            db.SaveChanges();

            // Inserção de log de alteração de obra
            logsDAO.insert(15);
        }
예제 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Obras obras = db.Obras.Find(id);

            db.Obras.Remove(obras);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #5
0
파일: ObrasBO.cs 프로젝트: CarinaEtec/RIGOR
        public void Gravar(Obras obras)
        {
            ObrasDAO obrasDao = new ObrasDAO();

            if ((obras.BA.Ba_Cod != 0) && (obras.Moradores.CodMorador != 0) && (obras.DataHora != null))
            {
                obrasDao.Insert(obras);
            }
        }
 public void actualizarObra(Obras obra)
 {
     try
     {
         logica.ActualizarObra(obra);
     }
     catch (NegocioException ex) { throw ex; }
     catch (Exception ex) { throw ex; }
 }
 public void agregarObra(Obras obra)
 {
     try
     {
         logica.AgregarObra(obra);
     }
     catch (NegocioException ex) { throw ex; }
     catch (Exception ex) { throw ex; }
 }
예제 #8
0
파일: ObrasBO.cs 프로젝트: CarinaEtec/RIGOR
        public void Editar(Obras obras)
        {
            ObrasDAO obrasDao = new ObrasDAO();

            if (obras.CodObras != 0)
            {
                obrasDao.Update(obras);
            }
        }
예제 #9
0
파일: ObrasBO.cs 프로젝트: CarinaEtec/RIGOR
        public void Deletar(Obras obras)
        {
            ObrasDAO obrasDao = new ObrasDAO();

            if (obras.CodObras != 0)
            {
                obrasDao.Delete(obras);
            }
        }
예제 #10
0
        public void delete(int id)
        {
            Obras obraExc = db.Obras.Where(x => x.Id == id).First();

            obraExc.Excluido = true;
            db.SaveChanges();

            // Inserção de log de exclusão de obra
            logsDAO.insert(16);
        }
예제 #11
0
        //
        // GET: /Admincp/Obras/Details/5

        public ActionResult Details(int id = 0)
        {
            Obras obras = db.Obras.Find(id);

            if (obras == null)
            {
                return(HttpNotFound());
            }
            return(View(obras));
        }
 internal void ActualizarObra(Obras obra)
 {
     if (obra.IdObra <= 0)
     {
         throw new NegocioException("El Identificador de la Obra que se desea modificar no es válido. Verifique");
     }
     if (string.IsNullOrWhiteSpace(obra.ObraNombre) || string.IsNullOrWhiteSpace(obra.ACCU))
     {
         throw new NegocioException("La Obra y el ACCU deben ser requeridos.");
     }
     datos.ActualizarObra(obra);
 }
 internal void AgregarObra(Obras obra)
 {
     if (obra.IdObra != 0)
     {
         throw new NegocioException("El Identificador de la Obra no es válido. Verifique");
     }
     if (string.IsNullOrWhiteSpace(obra.ObraNombre) || string.IsNullOrWhiteSpace(obra.ACCU))
     {
         throw new NegocioException("La Obra y el ACCU deben ser ingresados.");
     }
     datos.AgregarObra(obra);
 }
예제 #14
0
        //
        // GET: /Admincp/Obras/Edit/5

        public ActionResult Edit(int id = 0)
        {
            Obras obras = db.Obras.Find(id);

            if (obras == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id_Artista   = new SelectList(db.Artistas, "id_Artista", "nombre", obras.id_Artista);
            ViewBag.id_Recepcion = new SelectList(db.Ubicacion, "id_Recepcion", "Ubicacion1", obras.id_Recepcion);
            return(View(obras));
        }
예제 #15
0
        public ActionResult Create(Obras obras)
        {
            if (ModelState.IsValid)
            {
                db.Obras.Add(obras);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_Artista   = new SelectList(db.Artistas, "id_Artista", "nombre", obras.id_Artista);
            ViewBag.id_Recepcion = new SelectList(db.Ubicacion, "id_Recepcion", "Ubicacion1", obras.id_Recepcion);
            return(View(obras));
        }
예제 #16
0
 public ActionResult Delete(Obras obras)
 {
     try
     {
         db.Delete(obras);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         Logger.Instance.LogException(ex);
         ViewBag.MessageDanger = ex.Message;
         return(View(obras));
     }
 }
예제 #17
0
 public ActionResult Edit(Obras obras)
 {
     if (ModelState.IsValid)
     {
         db.Entry(obras).State = EntityState.Modified;
         try
         {
             db.SaveChanges();
         }
         catch (Exception e) {
         }
         return(RedirectToAction("Index"));
     }
     ViewBag.id_Artista   = new SelectList(db.Artistas, "id_Artista", "nombre", obras.id_Artista);
     ViewBag.id_Recepcion = new SelectList(db.Ubicacion, "id_Recepcion", "Ubicacion1", obras.id_Recepcion);
     return(View(obras));
 }
예제 #18
0
        public void Delete(Obras obras)
        {
            try
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "Delete from Obras where CodObras=@CodObras";

                comando.Parameters.AddWithValue("@CodObras", obras.CodObras);

                ConexaoBanco.CRUD(comando);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível se conectar" + ex.Message);
            }
        }
예제 #19
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            Obras    obras    = new Obras();
            ObrasBO  obrasBO  = new ObrasBO();
            ObrasDAO obrasDAO = new ObrasDAO();

            this.dataGridView1.DefaultCellStyle.Font = new Font("Arial", 10);

            if (rbtApto.Checked)
            {
                try
                {
                    obras.BA.Apto = txtBusca.Text;

                    dataGridView1.DataSource = obrasDAO.BuscaApto(txtBusca.Text);
                    for (int i = 0; i == dataGridView1.RowCount; i++)
                    {
                        MessageBox.Show("Nenhuma obra encontrada");
                        txtBusca.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Preencha corretamente as informações");
                }
            }
            if (rbtBloco.Checked)
            {
                try
                {
                    obras.BA.Bloco = txtBusca.Text;

                    dataGridView1.DataSource = obrasDAO.BuscaBloco(txtBusca.Text);
                    for (int i = 0; i == dataGridView1.RowCount; i++)
                    {
                        MessageBox.Show("Nenhuma obra encontrada");
                        txtBusca.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Preencha corretamente as informações");
                }
            }
        }
예제 #20
0
        public void insert(Obras obraInf)
        {
            obraInf.Cidade  = db.Cidades.Where(x => x.Id == obraInf.Cidade.Id).First();
            obraInf.Cliente = db.Clientes.Where(x => x.Id == obraInf.Cliente.Id).First();
            obraInf.Status  = db.Status.Where(x => x.Id == obraInf.Status.Id).First();
            try
            {
                obraInf.Responsavel = db.Responsavel.Where(x => x.Id == obraInf.Responsavel.Id).First();
            }
            catch
            {
            }
            db.Obras.Add(obraInf);
            db.SaveChanges();

            // Inserção de log de inclusão de obra
            logsDAO.insert(14);
        }
예제 #21
0
        private void btAdicionar_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridTrab.Rows)
            {
                if (Convert.ToBoolean(row.Cells[3].Value))
                {
                    Obras obra = new Obras();
                    obra = obrasDAO.select().Where(x => x.Id == Convert.ToInt16(textId.Text)).First();
                    Trabalhadores trab = new Trabalhadores();
                    trab = trabalhadoresDAO.select().Where(x => x.Id == Convert.ToInt16(row.Cells[0].Value)).First();
                    ObrasTrabalhadores ot = new ObrasTrabalhadores();
                    ot.Obra        = obra;
                    ot.Trabalhador = trab;
                    otDAO.insert(ot);
                }
            }

            carregarOT();
        }
예제 #22
0
        public void Insert(Obras obras)
        {
            try
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "Insert into Obras(CodMorador,DataHora,BA_Cod) " +
                                      "values(@CodMorador,@DataHora,@BA_Cod)";

                comando.Parameters.AddWithValue("@DataHora", obras.DataHora);
                comando.Parameters.AddWithValue("@CodMorador", obras.Moradores.CodMorador);
                comando.Parameters.AddWithValue("@Ba_Cod", obras.BA.Ba_Cod);

                ConexaoBanco.CRUD(comando);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível se conectar" + ex.Message);
            }
        }
예제 #23
0
        private void btAdicionar_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridForn.Rows)
            {
                if (Convert.ToBoolean(row.Cells[2].Value))
                {
                    Obras obra = new Obras();
                    obra = obrasDAO.select().Where(x => x.Id == Convert.ToInt16(textId.Text)).First();
                    Fornecedores forn = new Fornecedores();
                    forn = fornecedoresDAO.select().Where(x => x.Id == Convert.ToInt16(row.Cells[0].Value)).First();
                    ObrasFornecedores of = new ObrasFornecedores();
                    of.Obra       = obra;
                    of.Fornecedor = forn;
                    of.Observacao = textObs.Text;
                    ofDAO.insert(of);
                }
            }

            carregarOF();
        }
예제 #24
0
        public void Update(Obras obras)
        {
            try
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "Update obras set CodMorador=@CodMorador, DataHora=@DataHora, " +
                                      "Ba_Cod=@Ba_Cod where CodObras=@CodObras";

                comando.Parameters.AddWithValue("@codObras", obras.CodObras);
                comando.Parameters.AddWithValue("@CodMorador", obras.Moradores.CodMorador);
                comando.Parameters.AddWithValue("@DataHora", obras.DataHora);
                comando.Parameters.AddWithValue("@Ba_Cod", obras.BA.Ba_Cod);

                ConexaoBanco.CRUD(comando);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível se conectar" + ex.Message);
            }
        }
예제 #25
0
        public ActionResult Create(Obras obras)
        {
            this.CheckAuditPattern(obras, true);
            var list = db.ValidateModel(obras);

            if (ModelIsValid(list))
            {
                return(View(obras));
            }
            try
            {
                db.Create(obras);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                Logger.Instance.LogException(ex);
                ViewBag.MessageDanger = ex.Message;
                return(View(obras));
            }
        }
예제 #26
0
        internal Obras TraerObra(int obraId)
        {
            Obras obra = null;

            using (var cnn = ObtenerConexion())
            {
                SqlCommand cmd = ObtenerComando(cnn, "sp_obra_traer", CommandType.StoredProcedure);

                cmd.Parameters.Add(new SqlParameter("@IdObra", obraId));

                cnn.Open();

                SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                if (dr.HasRows)
                {
                    dr.Read();
                    obra = ObtenerObraMapping(dr);
                }
            }

            return(obra);
        }
예제 #27
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                //puxar codigo do ba
                BA   ba   = new BA();
                BABO babo = new BABO();

                ba.Apto  = txtApto.Text;
                ba.Bloco = txtBloco.Text;

                babo.BuscaCodBA(ba);

                if ((ba.Bloco == "") || (ba.Apto == ""))
                {
                    MessageBox.Show("Bloco/Apartamento não encontrado");
                    txtBloco.Clear();
                    txtApto.Clear();
                }

                else
                {
                    lblBACod.Text = Convert.ToString(ba.Ba_Cod);
                    //ouxar codigo do morador
                    try
                    {
                        Moradores   mor   = new Moradores();
                        MoradoresBO morBO = new MoradoresBO();


                        mor.Nome = txtProprietario.Text;
                        morBO.Buscar(mor);

                        if (mor.Nome == "")
                        {
                            MessageBox.Show("Proprietário não encontrado");
                            txtProprietario.Clear();
                        }

                        else
                        {
                            lblMoradorCod.Text = Convert.ToString(mor.CodMorador);

                            try
                            {
                                //add obras
                                Obras   obras   = new Obras();
                                ObrasBO obrasBO = new ObrasBO();


                                obras.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                obras.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                obras.DataHora             = Convert.ToDateTime(mskData.Text);


                                obrasBO.Gravar(obras);
                                MessageBox.Show("Obra cadastrada com sucesso");

                                txtProprietario.Clear();
                                txtApto.Clear();
                                txtBloco.Clear();
                                mskData.Clear();
                            }
                            catch
                            {
                                MessageBox.Show("Verifique os dados e tente novamente");
                            }
                        }
                    }

                    catch
                    {
                        MessageBox.Show("Verifique os dados e tente novamente");
                    }
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
예제 #28
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                dataGridView1.Rows[i].DataGridView.Columns.Clear();
            }


            try
            {
                //pega codigo bloco apartamento
                BA   ba   = new BA();
                BABO babo = new BABO();

                ba.Apto  = txtApto.Text;
                ba.Bloco = txtBloco.Text;

                babo.BuscaCodBA(ba);

                if ((ba.Bloco == "") || (ba.Apto == ""))
                {
                    MessageBox.Show("Bloco/Apartamento não encontrado");
                    txtApto.Clear();
                    txtBloco.Clear();
                }

                else
                {
                    lblBACod.Text = Convert.ToString(ba.Ba_Cod);


                    try
                    {   //pega codigo morador
                        Moradores   mor   = new Moradores();
                        MoradoresBO morBO = new MoradoresBO();


                        mor.Nome = txtProprietario.Text;
                        morBO.Buscar(mor);

                        if (mor.Nome == "")
                        {
                            MessageBox.Show("Proprietário não encontrado");
                            txtProprietario.Clear();
                        }

                        else
                        {
                            lblMoradorCod.Text = Convert.ToString(mor.CodMorador);
                            //altera o pet
                            try
                            {
                                Obras   obras   = new Obras();
                                ObrasBO obrasBO = new ObrasBO();


                                obras.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                obras.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                obras.DataHora             = Convert.ToDateTime(mskData.Text);
                                obras.CodObras             = Convert.ToInt16(lblCodObra.Text);

                                obrasBO.Editar(obras);
                                MessageBox.Show("Obra editada com sucesso");

                                txtProprietario.Clear();
                                txtApto.Clear();
                                txtBloco.Clear();
                                mskData.Clear();

                                txtBusca.Clear();
                                panel1.Enabled     = false;
                                btnAlterar.Enabled = false;
                                btnExcluir.Enabled = false;
                            }
                            catch
                            {
                                MessageBox.Show("Verifique os dados e tente novamente");
                            }
                        }
                    }

                    catch
                    {
                        MessageBox.Show("Verifique os dados e tente novamente");
                    }
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
예제 #29
0
        private void gerarRel(int tipo)
        {
            StreamWriter wr;

            switch (tipo)
            {
            case 1:
                #region Gerar relatório da última última foto cadastrada para as obras
                wr = new StreamWriter(path + "relFotos.html");

                wr.WriteLine("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"/>");
                wr.WriteLine("<html>");
                wr.WriteLine("<head>");
                wr.WriteLine("<meta name='viewport' content='width=device-width, initial-scale=1'>");
                wr.WriteLine("<meta charset='utf-8'>");
                wr.WriteLine("<link rel='stylesheet' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>");
                wr.WriteLine("<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js'></script>");
                wr.WriteLine("<script src='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js'></script>");
                wr.WriteLine("<div class='container'>");
                wr.WriteLine("<h2>Relatório da Última Foto Cadastrada para as Obras</h2>");

                wr.WriteLine("<div class='table-responsive'>");
                wr.WriteLine("<table class='table table-hover'>");
                wr.WriteLine("<thead>");
                wr.WriteLine("<tr>");
                wr.WriteLine("<th>Código Obra</th>");
                wr.WriteLine("<th>Cliente</th>");
                wr.WriteLine("<th>Endereço</th>");
                wr.WriteLine("<th>Data Última Foto</th>");
                wr.WriteLine("<th>Foto</th>");
                wr.WriteLine("</tr>");
                wr.WriteLine("</thead>");
                wr.WriteLine("</tbody>");

                try
                {
                    foreach (Obras obra in obrasDAO.select())
                    {
                        wr.WriteLine("<tr><td>" + obra.Id + "</td>");
                        wr.WriteLine("<td>" + obra.Cliente.Nome + "</td>");
                        wr.WriteLine("<td>" + obra.Endereco + "</td>");

                        try
                        {
                            Fotos foto = fotosDAO.select().Where(x => x.Obra.Id == obra.Id).Last();
                            wr.WriteLine("<td>" + foto.Data.ToString("dd/MM/yyyy") + "</td>");
                            wr.WriteLine("<td><img src='" + @"C:\xampp\htdocs\fotos\" + foto.Id + "." + foto.Tipo + "' width=100 height=80></td></tr>");
                        }
                        catch
                        {
                            wr.WriteLine("<td>" + "-" + "</td>");
                            wr.WriteLine("<td>" + "Não possui foto cadastrada" + "</td></tr>");
                        }
                    }
                }
                catch
                {
                }

                wr.WriteLine("</tbody>");
                wr.WriteLine("</table>");
                wr.WriteLine("</div>");
                wr.WriteLine("</div>");
                wr.WriteLine("</body>");
                wr.WriteLine("</html>");

                wr.Close();
                #endregion
                break;

            case 2:
                #region Gerar relatório dos agendamentos das obras que estão por vir
                wr = new StreamWriter(path + "relAgendObras.html");

                wr.WriteLine("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"/>");
                wr.WriteLine("<html>");
                wr.WriteLine("<head>");
                wr.WriteLine("<meta name='viewport' content='width=device-width, initial-scale=1'>");
                wr.WriteLine("<meta charset='utf-8'>");
                wr.WriteLine("<link rel='stylesheet' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>");
                wr.WriteLine("<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js'></script>");
                wr.WriteLine("<script src='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js'></script>");
                wr.WriteLine("<div class='container'>");
                wr.WriteLine("<h2>Relatório dos Agendamentos Futuros das Obras</h2>");

                wr.WriteLine("<div class='table-responsive'>");
                wr.WriteLine("<table class='table table-hover'>");
                wr.WriteLine("<thead>");
                wr.WriteLine("<tr>");
                wr.WriteLine("<th>Código Obra</th>");
                wr.WriteLine("<th>Cliente</th>");
                wr.WriteLine("<th>Endereço</th>");
                wr.WriteLine("<th>Data Agendamento</th>");
                wr.WriteLine("<th>Assunto Agendamento</th>");
                wr.WriteLine("<th>Observação Agendamento</th>");
                wr.WriteLine("</tr>");
                wr.WriteLine("</thead>");
                wr.WriteLine("</tbody>");

                try
                {
                    foreach (Agendamentos agend in agendDAO.select().Where(x => x.Data >= DateTime.Today && x.Obra != null))
                    {
                        wr.WriteLine("<tr><td>" + agend.Obra.Id + "</td>");

                        try
                        {
                            Obras obras = obrasDAO.select().Where(x => x.Id == agend.Obra.Id).First();
                            wr.WriteLine("<td>" + obras.Cliente.Nome + "</td>");
                        }
                        catch
                        {
                        }

                        wr.WriteLine("<td>" + agend.Obra.Endereco + "</td>");
                        wr.WriteLine("<td>" + agend.Data.ToString("dd/MM/yyyy") + "</td>");
                        wr.WriteLine("<td>" + agend.Assunto + "</td>");
                        wr.WriteLine("<td>" + agend.Observacao + "</td>");
                    }
                }
                catch
                {
                }

                wr.WriteLine("</tbody>");
                wr.WriteLine("</table>");
                wr.WriteLine("</div>");
                wr.WriteLine("</div>");
                wr.WriteLine("</body>");
                wr.WriteLine("</html>");

                wr.Close();
                #endregion
                break;

            case 3:
                #region Gerar relatório dos agendamentos dos projetos que estão por vir
                wr = new StreamWriter(path + "relAgendProj.html");

                wr.WriteLine("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"/>");
                wr.WriteLine("<html>");
                wr.WriteLine("<head>");
                wr.WriteLine("<meta name='viewport' content='width=device-width, initial-scale=1'>");
                wr.WriteLine("<meta charset='utf-8'>");
                wr.WriteLine("<link rel='stylesheet' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>");
                wr.WriteLine("<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js'></script>");
                wr.WriteLine("<script src='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js'></script>");
                wr.WriteLine("<div class='container'>");
                wr.WriteLine("<h2>Relatório dos Agendamentos Futuros dos Projetos</h2>");

                wr.WriteLine("<div class='table-responsive'>");
                wr.WriteLine("<table class='table table-hover'>");
                wr.WriteLine("<thead>");
                wr.WriteLine("<tr>");
                wr.WriteLine("<th>Código Projeto</th>");
                wr.WriteLine("<th>Cliente</th>");
                wr.WriteLine("<th>Endereço</th>");
                wr.WriteLine("<th>Data Agendamento</th>");
                wr.WriteLine("<th>Assunto Agendamento</th>");
                wr.WriteLine("<th>Observação Agendamento</th>");
                wr.WriteLine("</tr>");
                wr.WriteLine("</thead>");
                wr.WriteLine("</tbody>");

                try
                {
                    foreach (Agendamentos agend in agendDAO.select().Where(x => x.Data >= DateTime.Today && x.Projeto != null))
                    {
                        wr.WriteLine("<tr><td>" + agend.Projeto.Id + "</td>");

                        try
                        {
                            Projetos projetos = projDAO.select().Where(x => x.Id == agend.Projeto.Id).First();
                            wr.WriteLine("<td>" + projetos.Cliente.Nome + "</td>");
                        }
                        catch
                        {
                        }

                        wr.WriteLine("<td>" + agend.Projeto.Endereco + "</td>");
                        wr.WriteLine("<td>" + agend.Data.ToString("dd/MM/yyyy") + "</td>");
                        wr.WriteLine("<td>" + agend.Assunto + "</td>");
                        wr.WriteLine("<td>" + agend.Observacao + "</td>");
                    }
                }
                catch
                {
                }

                wr.WriteLine("</tbody>");
                wr.WriteLine("</table>");
                wr.WriteLine("</div>");
                wr.WriteLine("</div>");
                wr.WriteLine("</body>");
                wr.WriteLine("</html>");

                wr.Close();
                #endregion
                break;
            }
        }
예제 #30
0
        private void btAdicionar_Click(object sender, EventArgs e)
        {
            #region Validação de dados
            errorProvider.SetError(label2, string.Empty);
            errorProvider.SetError(textDesc, string.Empty);

            int verif = 0;

            if (openFileDialog.FileName == "")
            {
                errorProvider.SetError(label2, "Selecione uma foto");
                verif++;
            }

            if (textDesc.Text.Trim().Length < 5)
            {
                errorProvider.SetError(textDesc, "Informe uma descrição válida para a foto");
                return;
            }

            if (verif > 0)
            {
                return;
            }
            #endregion

            #region Colocar dados em um objeto
            try
            {
                fotos           = new Fotos();
                fotos.Descricao = textDesc.Text.Trim();
                fotos.Data      = DateTime.Today;
                fotos.Obra      = obrasDAO.select(Convert.ToInt16(textId.Text));
                fotos.Tipo      = openFileDialog.FileName.Substring(openFileDialog.FileName.LastIndexOf('.') + 1);
                fotosDAO.insert(fotos);
            }
            catch
            {
            }
            #endregion

            #region Copiar imagem para a pasta de fotos
            fotos = fotosDAO.select().Last();
            File.Copy(openFileDialog.FileName, path + fotos.Id + "." + fotos.Tipo, true);

            textDesc.Text           = "";
            openFileDialog.FileName = "";
            pictureBoxFoto.Image    = null;
            #endregion

            // GET:
            try
            {
                Obras obra           = obrasDAO.select().Where(x => x.Id == fotos.Obra.Id).First();
                var   httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost/fotos/wsAndroid/insertFotos.php?id="
                                                                         + obra.Cliente.Id + "&tipo=" + fotos.Tipo + "&data=" + String.Format("{0:yyyy-MM-dd/}", fotos.Data) +
                                                                         "&desc=" + fotos.Descricao);
                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                }
            }
            catch
            {
            }
        }