protected void btnCadastrar_Click(object sender, EventArgs e)
 {
     Projeto p = new Projeto();
     p.titulo = txtTitulo.Value;
     p.emailResponsavel = listaResponsaveis.SelectedItem.Value;
     p.tipo = Convert.ToInt16(listaTipo.SelectedItem.Value);
     p.status = 0;
     if(checkTerceiro.Checked == true)
     {
         p.vaiTerceiro = 1;
         p.idTerceiro = Convert.ToInt16(listaTerceiros.SelectedItem.Value);
     }
     else
     {
         p.vaiTerceiro = 0;
         p.idTerceiro = 0;
     }
     p.dataInicio = DateTime.Now;
     ProjetoBL pbl = new ProjetoBL();
     bool cadastrou = pbl.cadastraProjeto(p);
     if (cadastrou)
     {
         Response.Write("<script>alert('Registro efetuado com sucesso!')</script>");
     }
     LogEventoBL lbl = new LogEventoBL();
     Log l = new Log();
     l.email = Session["email"].ToString();
     l.data = DateTime.Now;
     l.descricao = "Cadastradao Projeto Titulo: " + p.titulo + ", Responsável: " + p.emailResponsavel + " ";
     lbl.adicionaLog(l);
 }
Example #2
0
 public Projeto buscaProjeto(string titulo, int codigo)
 {
     Projeto p = new Projeto();
     ProjetoDA pda = new ProjetoDA();
     p = pda.buscaProjeto(titulo, codigo);
     return p;
 }
Example #3
0
 public Projeto buscaProjeto(string titulo, int codigo)
 {
     Projeto p = new Projeto();
     SqlConnection conexao = new SqlConnection();
     conexao.ConnectionString = StaticObjects.strConexao;
     SqlCommand comando = new SqlCommand();
     SqlDataReader leitor;
     string where;
     // mudar os titulos para LIKE
     if ((titulo != "") && (codigo != 0))
     {
         where = "WHERE titulo LIKE '%" + titulo + "%' AND id = " + codigo + " ";
     }
     else if (titulo != "")
     {
         where = "WHERE titulo LIKE '%" + titulo + "%' ";
     }
     else if (codigo != 0)
     {
         where = "WHERE id = " + codigo + " ";
     }
     else
     {
         where = "";
     }
     try
     {
         conexao.Open();
         comando.CommandText = @"SELECT id, emailResponsavel, titulo, idTipo, vaiterceiro, idTerceiro, dataInicio, status FROM Projeto " + where + " ";
         comando.Connection = conexao;
         leitor = comando.ExecuteReader();
         while (leitor.Read())
         {
             p.id = Convert.ToInt16(leitor["id"].ToString());
             p.titulo = leitor["titulo"].ToString();
             p.emailResponsavel = leitor["emailResponsavel"].ToString();
             p.vaiTerceiro = Convert.ToInt16(leitor["vaiTerceiro"].ToString());
             p.idTerceiro = Convert.ToInt16(leitor["idTerceiro"].ToString());
             p.status = Convert.ToInt16(leitor["status"].ToString());
             p.tipo = Convert.ToInt16(leitor["idTipo"].ToString());
             p.dataInicio = Convert.ToDateTime(leitor["dataInicio"].ToString());
         }
     }
     catch (Exception)
     {
         conexao.Close();
         return null;
     }
     conexao.Close();
     return p;
 }
Example #4
0
 public bool editaProjeto(Projeto p)
 {
     ProjetoDA pda = new ProjetoDA();
     bool editou = pda.editaProjeto(p);
     return editou;
 }
Example #5
0
 public bool cadastraProjeto(Projeto p)
 {
     ProjetoDA pda = new ProjetoDA();
     bool cadastrou = pda.cadastraProjeto(p);
     return cadastrou;
 }
        public void criaPDFPage(PdfPage page, Projeto pro)
        {
            XGraphics gfx = XGraphics.FromPdfPage(page);
            XTextFormatter tf = new XTextFormatter(gfx);
            XRect retangulo;
            int iLeftMargin = 15;
            int iTopMargin = 25;
            int conta = 0, iTempTopMargin;
            System.Drawing.Point point;
            point = new System.Drawing.Point(260, 15);
            System.Drawing.Image newImage = System.Drawing.Image.FromFile(StaticObjects.filepathImage);
            gfx.DrawImage(newImage, point);

            //MOntar header
            iLeftMargin = iLeftMargin + 15;
            iTopMargin = iTopMargin + 50;

            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            gfx.DrawString("Número do Projeto: " + pro.id.ToString(), font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 270, 15);
            point = new System.Drawing.Point(iLeftMargin + 3 + 270, iTopMargin + 10);
            string tipo = pda.buscaNomeTipoProjeto(pro.tipo);
            gfx.DrawString("Tipo de projeto: " + tipo, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin + 270, iTopMargin, 270, 15);

            iTopMargin = iTopMargin + 15;

            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            UsuarioBL uda = new UsuarioBL();
            string nome = uda.buscaNome(pro.emailResponsavel);
            gfx.DrawString("Responsável pelo Projeto: " + nome, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 270, 15);
            point = new System.Drawing.Point(iLeftMargin + 3 + 270, iTopMargin + 10);
            gfx.DrawString("E-mail do responsável: " + pro.emailResponsavel, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin + 270, iTopMargin, 270, 15);

            iTopMargin = iTopMargin + 15;

            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            gfx.DrawString("Data de Início: " + pro.dataInicio.ToShortDateString(), font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 270, 15);
            point = new System.Drawing.Point(iLeftMargin + 3 + 270, iTopMargin + 10);
            gfx.DrawString("Duração em dias até agora: " + DateTime.Now.Subtract(pro.dataInicio).Days, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin + 270, iTopMargin, 270, 15);

            iTopMargin = iTopMargin + 15;

            TarefaBL tda = new TarefaBL();
            int qntTotal = tda.contaTarefasProjeto(pro.id);
            int qntFinalizada = tda.contaTarefaFinalizadasProjeto(pro.id);
            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            gfx.DrawString("Quantidade Total de Tarefas: " + qntTotal, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 270, 15);
            point = new System.Drawing.Point(iLeftMargin + 3 + 270, iTopMargin + 10);
            gfx.DrawString("Percentual de Tarefas Concluídas): " + ((qntFinalizada * 100)/qntTotal) + "%", font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin + 270, iTopMargin, 270, 15);

            iTopMargin = iTopMargin + 15;

            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            gfx.DrawString("Título: " + pro.titulo, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 540, 15);

            iTopMargin = iTopMargin + 37;

            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            gfx.DrawString("TAREFAS", headersFont, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 540, 15);

            iTopMargin = iTopMargin + 15;

            rect = new RectangleF(iLeftMargin + 3, iTopMargin + 10, 540, 300);
            conta = 0;
            iTempTopMargin = iTopMargin;
            List<Tarefa> lista = new List<Tarefa>();
            lista = tda.buscaTarefasProjeto(pro.id, false, "");
            foreach (Tarefa t in lista)
            {
                StringBuilder frase = new StringBuilder();
                frase.Append(t.titulo);
                frase.Append(" (");
                string status;
                switch (t.status)
                {
                    case 0:
                        status = "Pendente";
                        break;
                    case 1:
                        status = "Em Andamento";
                        break;
                    case 2:
                        status = "Concluída";
                        break;
                    case 3:
                        status = "Cancelada";
                        break;
                    default:
                        status = "Não Iformado";
                        break;
                }
                frase.Append(status);
                frase.Append(")");
                point = new System.Drawing.Point(iLeftMargin + 3, iTempTopMargin + 10);
                gfx.DrawString(frase.ToString(), font, Brushes.Black, point);
                conta++;
                iTempTopMargin = iTempTopMargin + 15;
            }
            rect = new RectangleF(iLeftMargin, iTopMargin, 540, iTempTopMargin - iTopMargin);
            gfx.DrawRectangle(Pens.Black, Rectangle.Round(rect));
            iTopMargin = iTempTopMargin + 15;
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ProjetoBL pbl = new ProjetoBL();
                Dictionary<string, string> lista = new Dictionary<string, string>();
                lista = pbl.buscaTiposProjeto();
                listaTipo.DataSource = lista;
                listaTipo.DataBind();
                List<Usuario> listaU = new List<Usuario>();
                string teste = Session["empresa"].ToString();
                UsuarioBL ubl = new UsuarioBL();
                listaU = ubl.buscaUsuariosEmpresa(Convert.ToInt16(teste));
                foreach (Usuario u in listaU)
                {
                    listaResponsaveis.Items.Add(u.email);
                }
                listaResponsaveis.DataBind();
                Dictionary<string, string> listaTer = new Dictionary<string, string>();
                TerceiroBL tb = new TerceiroBL();
                List<Terceiro> listaT = new List<Terceiro>();
                listaT = tb.buscaTerceiros(Convert.ToInt16(Session["empresa"]));
                foreach (Terceiro t in listaT)
                {
                    string item = t.id.ToString();
                    string item2 = t.nome.ToString();
                    listaTer.Add(item, item2);
                }
                listaTerceiros.DataSource = listaTer;
                listaTerceiros.DataBind();

                if (Request["id_projeto"] != null)
                {
                    p = pbl.buscaProjeto("", Convert.ToInt16(Request["id_projeto"].ToString()));
                    txtTitulo.Value = p.titulo;
                    listaResponsaveis.Text = p.emailResponsavel;
                    listaTipo.SelectedIndex = p.tipo;
                    GridView grid = new GridView();
                    DataTable dt = new DataTable();
                    List<Tarefa> listaTarefas = new List<Tarefa>();
                    TarefaBL tbl = new TarefaBL();
                    listaTarefas = tbl.buscaTarefasProjeto(p.id, false, "");

                    DataColumn c1 = new DataColumn("Responsavel", Type.GetType("System.String"));
                    DataColumn c2 = new DataColumn("DataInicio", Type.GetType("System.String"));
                    DataColumn c3 = new DataColumn("Prazo", Type.GetType("System.String"));
                    DataColumn c4 = new DataColumn("Status", Type.GetType("System.String"));
                    DataColumn c5 = new DataColumn("Titulo", Type.GetType("System.String"));
                    DataColumn c6 = new DataColumn("editar", Type.GetType("System.String"));

                    dt.Columns.Add(c1);
                    dt.Columns.Add(c2);
                    dt.Columns.Add(c3);
                    dt.Columns.Add(c4);
                    dt.Columns.Add(c5);
                    dt.Columns.Add(c6);

                    foreach (Tarefa t in listaTarefas)
                    {
                        DataRow dr = dt.NewRow();
                        dr["Responsavel"] = t.emailResponsavel.ToString();
                        dr["DataInicio"] = t.dataInicio.ToShortDateString();
                        dr["Prazo"] = t.dataInicio.AddDays(t.prazoEstimado).ToShortDateString();
                        switch (t.status)
                        {
                            case 0:
                                dr["Status"] = "Pendente";
                                break;
                            case 1:
                                dr["Status"] = "Em Andamento";
                                break;
                            case 2:
                                dr["Status"] = "Concluída";
                                break;
                            case 3:
                                dr["Status"] = "Cancelada";
                                break;
                        }
                        dr["Titulo"] = t.titulo.ToString();
                        dr["editar"] = "~/EditaTarefa.aspx?id_tarefa=" + t.id.ToString();
                        dt.Rows.Add(dr);
                    }
                    gridTarefas.DataSource = dt.Copy();
                    gridTarefas.DataBind();
                }
                EtapaBL ebl = new EtapaBL();
                Dictionary<string, string> listaE = new Dictionary<string, string>();
                listaE = ebl.buscaDescricaoEtapas();
                lstEtapa.DataSource = listaE;
                lstEtapa.DataBind();
            }
        }
        protected void btnGeraRelatorio_Click(object sender, EventArgs e)
        {
            s_document = new PdfDocument();
            s_document.Info.Title = "`PDM - Projeto";
            s_document.Info.Author = "PDM Product Development Manager";
            s_document.Info.Subject = "Documento de Acompanhamento de Projeto";
            s_document.Info.Keywords = "Projeto, PDM";

            int idprojeto = Convert.ToInt16(Request["id_projeto"].ToString());
            p = new Projeto();
            ProjetoBL pbl = new ProjetoBL();
            p = pbl.buscaProjeto("", idprojeto);

            string filename = String.Format(@"{0}_projeto_{1}.pdf", Guid.NewGuid().ToString("D").ToUpper(), p.id);
            string filepath = StaticObjects.filepathPDF;

            criaPDFPage(s_document.AddPage(), p);
            s_document.Save(filepath + filename);
            Process.Start(filepath + filename);
        }
Example #9
0
 public List<Projeto> buscaProjetos(string email)
 {
     List<Projeto> lista = new List<Projeto>();
     SqlConnection conexao = new SqlConnection();
     conexao.ConnectionString = StaticObjects.strConexao;
     SqlCommand comando = new SqlCommand();
     SqlDataReader leitor;
     try
     {
         conexao.Open();
         comando.CommandText = @"SELECT id, emailResponsavel, titulo, idTipo, dataInicio, vaiTerceiro, idTerceiro, status FROM Projeto WHERE emailResponsavel = '" + email + "' ";
         comando.Connection = conexao;
         leitor = comando.ExecuteReader();
         while (leitor.Read())
         {
             Projeto p = new Projeto();
             p.id = Convert.ToInt16(leitor["id"].ToString());
             p.titulo = leitor["titulo"].ToString();
             p.emailResponsavel = leitor["emailResponsavel"].ToString();
             p.vaiTerceiro = Convert.ToInt16(leitor["vaiTerceiro"].ToString());
             p.idTerceiro = Convert.ToInt16(leitor["idTerceiro"].ToString());
             p.status = Convert.ToInt16(leitor["status"].ToString());
             p.tipo = Convert.ToInt16(leitor["idTipo"].ToString());
             p.dataInicio = Convert.ToDateTime(leitor["dataInicio"].ToString());
             lista.Add(p);
         }
         conexao.Close();
         return lista;
     }
     catch (Exception)
     {
         conexao.Close();
         return null;
     }
 }
Example #10
0
 public bool editaProjeto(Projeto p)
 {
     SqlConnection conexao = new SqlConnection();
     conexao.ConnectionString = StaticObjects.strConexao;
     SqlCommand comando = new SqlCommand();
     try
     {
         conexao.Open();
         comando.CommandText = @"UPDATE Projeto SET emailResponsavel = '" + p.emailResponsavel +"', titulo = '" + p.titulo + "', " +
             " vaiTerceiro = " + p.vaiTerceiro + ", idTerceiro = " + p.idTerceiro + ", " +
             " idTipo = " + p.tipo + ", dataInicio = '" + p.dataInicio + "', status = " + p.status + " WHERE id = " + p.id + " ";
         comando.Connection = conexao;
         comando.ExecuteNonQuery();
         conexao.Close();
         return true;
     }
     catch (Exception)
     {
         conexao.Close();
         return false;
     }
 }
Example #11
0
 public bool cadastraProjeto(Projeto p)
 {
     SqlConnection conexao = new SqlConnection();
     conexao.ConnectionString = StaticObjects.strConexao;
     SqlCommand comando = new SqlCommand();
     try
     {
         conexao.Open();
         comando.CommandText = @"INSERT INTO Projeto(emailResponsavel, vaiTerceiro, idTerceiro, titulo, idTipo, dataInicio, status) VALUES " +
         " ('" + p.emailResponsavel +"', " + p.vaiTerceiro + ", " + p.idTerceiro + ", '" + p.titulo + "', " + p.tipo + ", '" + p.dataInicio + "', " + p.status + ")";
         comando.Connection = conexao;
         comando.ExecuteNonQuery();
         conexao.Close();
         return true;
     }
     catch (Exception)
     {
         conexao.Close();
         return false;
     }
 }