コード例 #1
0
        /// <summary>
        /// Editando um projeto já existente.
        /// </summary>
        /// <param name="InformacoesProjeto"></param>
        /// <returns></returns>
        public static string Editar(Projeto InformacoesProjeto)
        {
            string Saida = "";
            StreamWriter sw = null;

            try
            {
                sw = new StreamWriter($"Projetos/{InformacoesProjeto.NomeProjeto}/{InformacoesProjeto.NomeProjeto}.sgp");

                sw.WriteLine(InformacoesProjeto.NomeProjeto);
                sw.WriteLine(InformacoesProjeto.DataInicial);
                sw.WriteLine(InformacoesProjeto.HorasDeTrabalho);

                Saida = "Projeto editado com sucesso.";
            }
            catch (Exception exc)
            {
                Arquivos.ArquivoLog ArquivoLog = new Arquivos.ArquivoLog();

                ArquivoLog.ArquivoExceptionLog(exc);

                Saida = $"Ocorreu um erro ao editar o projeto: {exc.Message}";
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
            }

            return Saida;
        }
コード例 #2
0
        private DateTime SomarTempo(Projeto InformacoesProjeto, DateTime TempoAdicional)
        {
            DateTime TempoResultante = InformacoesProjeto.HorasDeTrabalho;

            DateTime inicio = InformacoesProjeto.HorasDeTrabalho;
            DateTime final = TempoAdicional;

            Double Hora, Minuto, Segundo;
            string[] Linha = new string[3];
            string[] LinhaSeparada = new string[2];

            LinhaSeparada = final.ToString().Split(' '); //Separando a data do tempo

            Linha = LinhaSeparada[1].ToString().Split(':'); //Separando Hora/Minuto/Segundo

            Hora = Double.Parse(Linha[0]);
            Minuto = Double.Parse(Linha[1]);

            Segundo = Double.Parse(Linha[2]);

            TempoResultante = inicio.AddHours(Hora);
            TempoResultante = inicio.AddMinutes(Minuto);
            TempoResultante = inicio.AddSeconds(Segundo);

            return TempoResultante;
        }
コード例 #3
0
 public ActionResult NovoProjeto(string TipoProjeto, string Nome)
 {
     Data.DB _db = new Data.DB();
     Projeto model = new Projeto();
     model.Nome = Nome;
     model.IdTipoProjeto = Convert.ToInt32(TipoProjeto);
     model.IdProponente = Convert.ToInt32(Session["Proponente"]);
     _db.gravarProjeto(model);
     return RedirectToAction("Index");
 }
コード例 #4
0
        private void Btm_Criar_Click(object sender, EventArgs e)
        {
            Projeto ProjetoBase = new Projeto();

            ProjetoBase.NomeProjeto = Txt_Nome.Text;
            ProjetoBase.HorasDeTrabalho = Convert.ToDateTime("00:00:00");
            ProjetoBase.DataInicial = DateTime.Now.ToString();

            if (!string.IsNullOrWhiteSpace(Txt_Nome.Text))
            {
               string Resultado = ControllerProjeto.Criar(ProjetoBase);

                MessageBox.Show(Resultado, "informação", MessageBoxButtons.OK, MessageBoxIcon.Information);

                MessageBox.Show("O software sera reiniciado", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);

                Application.Restart();
            }
            else
            {
                MessageBox.Show("Digite um nome para o projeto","informação",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
            }
        }
コード例 #5
0
        /// <summary>
        /// Carregando todas as infromações do projeto.
        /// </summary>
        /// <param name="NomeProjeto"></param>
        /// <returns></returns>
        public static Projeto Carregar(String NomeProjeto)
        {
            Projeto ProjetoBase = new Projeto();
            StreamReader sr = null;

            if (!string.IsNullOrEmpty(NomeProjeto)) //Verifica se o nome do projeto é em branco ou nulo para não háver erros na hora da criação.
            {
                try
                {
                    sr = new StreamReader($"Projetos/{NomeProjeto}/{NomeProjeto}.sgp");

                    ProjetoBase.NomeProjeto = sr.ReadLine();
                    ProjetoBase.DataInicial = sr.ReadLine();
                    ProjetoBase.HorasDeTrabalho = DateTime.Parse(sr.ReadLine());

                }
                catch (Exception exc)
                {
                    Arquivos.ArquivoLog ArquivoLog = new Arquivos.ArquivoLog();

                    ArquivoLog.ArquivoExceptionLog(exc);
                }
                finally
                {
                    if (sr != null)
                    {
                        sr.Close();
                    }
                }
            }
            return ProjetoBase;
        }
コード例 #6
0
        /// <summary>
        /// Adicionando horas de trabalho
        /// </summary>
        /// <param name="Horas"></param>
        /// /// <param name="NomeProjeto"></param>
        /// <returns></returns>
        public static string AdicionarHoras(string Horas, string NomeDoProjeto)
        {
            string Saida = "";
            Projeto ProjetoBase = new Projeto(); ;
            StreamWriter sw = null;

            try
            {
                ProjetoBase = Carregar(NomeDoProjeto);
            }
            catch (Exception exc)
            {

                Arquivos.ArquivoLog ArquivoLog = new Arquivos.ArquivoLog();

                ArquivoLog.ArquivoExceptionLog(exc);

                Saida = $"Ocorreu um erro ao tentar adicionar horas ao projeto: {exc.Message}";
            }
            try
            {
                sw = new StreamWriter($"Projetos/{NomeDoProjeto}/{NomeDoProjeto}.sgp");

                sw.WriteLine(ProjetoBase.NomeProjeto);
                sw.WriteLine(ProjetoBase.DataInicial);
                sw.WriteLine(Horas);//O valor das horas já vem calculado pelo parametro da função.

                Saida = "O numero de horas foi modificado com sucesso.";

            }
            catch (Exception exc)
            {
                Arquivos.ArquivoLog ArquivoLog = new Arquivos.ArquivoLog();

                ArquivoLog.ArquivoExceptionLog(exc);

                Saida = $"Ocorreu um erro ao criar um novo projeto: {exc.Message}";
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
            }
            return Saida;
        } //Ateção: Enviar o valor das horas já calculado
コード例 #7
0
ファイル: DB.cs プロジェクト: Marksys/FormDynamicPOC
        public Projeto getProjeto(int id)
        {
            Projeto item = new Projeto(); ;
            using (SqlConnection cn = new SqlConnection(helper.ConnectionString))
            {
                string sql = "select * from PC_Projeto_PRJ where PRJ_ID = @PRJ_ID";
                SqlParameter[] param = {
                                       new SqlParameter("@PRJ_ID", id)
                                   };
                cn.Open();
                try
                {
                    SqlDataReader reader = helper.ExecuteReader(CommandType.Text, sql, param);
                    if (reader.Read())
                    {
                        item.Id = Convert.ToInt32(reader["PRJ_ID"]);
                        item.Nome = reader["PRJ_NOME"].ToString();
                        item.IdProponente = Convert.ToInt32(reader["PRJ_PRP_ID"]);
                        item.IdTipoProjeto = Convert.ToInt32(reader["PRJ_TPJ_ID"]);
                        item.DtCriacao = Convert.ToDateTime(reader["PRJ_DATA_CRIACAO"]);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    cn.Close();
                }

                return item;
            }
        }
コード例 #8
0
ファイル: DB.cs プロジェクト: Marksys/FormDynamicPOC
        public void gravarProjeto(Projeto model)
        {
            using (SqlConnection cn = new SqlConnection(helper.ConnectionString))
            {
                cn.Open();

                //Drop
                try
                {
                    string sql = "insert into PC_Projeto_PRJ values (@PRJ_NOME, GETDATE(), @PRJ_TPJ_ID, @PRJ_PRP_ID)";
                    SqlParameter[] param = {
                                       new SqlParameter("@PRJ_NOME", model.Nome),
                                       new SqlParameter("@PRJ_TPJ_ID", model.IdTipoProjeto),
                                       new SqlParameter("@PRJ_PRP_ID", model.IdProponente)
                                   };
                    helper.ExecuteNonQuery(CommandType.Text, sql, param);
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
                finally
                {
                    cn.Close();
                }
            }
        }
コード例 #9
0
ファイル: DB.cs プロジェクト: Marksys/FormDynamicPOC
        public List<Projeto> getProjetos(int? idProponente, int? idTipoProjeto)
        {
            List<Projeto> lista = new List<Projeto>();
            Projeto item;
            using (SqlConnection cn = new SqlConnection(helper.ConnectionString))
            {
                string sql = "select * from PC_Projeto_PRJ where (PRJ_PRP_ID = @PRJ_PRP_ID OR @PRJ_PRP_ID IS NULL) AND (PRJ_TPJ_ID = @PRJ_TPJ_ID OR @PRJ_TPJ_ID IS NULL)";
                SqlParameter[] param = {
                                       new SqlParameter("@PRJ_PRP_ID", idProponente == null ? DBNull.Value : (object)idProponente.Value),
                                       new SqlParameter("@PRJ_TPJ_ID", idTipoProjeto == null ? DBNull.Value : (object)idTipoProjeto.Value)
                                   };
                cn.Open();
                try
                {
                    SqlDataReader reader = helper.ExecuteReader(CommandType.Text, sql, param);
                    while (reader.Read())
                    {
                        item = new Projeto();
                        item.Id = Convert.ToInt32(reader["PRJ_ID"]);
                        item.Nome = reader["PRJ_NOME"].ToString();
                        item.IdProponente = Convert.ToInt32(reader["PRJ_PRP_ID"]);
                        item.IdTipoProjeto = Convert.ToInt32(reader["PRJ_TPJ_ID"]);
                        lista.Add(item);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    cn.Close();
                }

                return lista;
            }
        }
コード例 #10
0
        public Frm_NovaTarefa(Projeto InformacoesProjeto)
        {
            InitializeComponent();

            InfoProjeto = InformacoesProjeto;
        }
コード例 #11
0
        private void Btm_Abrir_Click(object sender, EventArgs e)
        {
            if (ControllerProjeto.Verificar(Txt_Lista.Text))
            {
                try
                {
                    ProjetoBase = ControllerProjeto.Carregar(Txt_Lista.Text);

                    Lbl_NomeProjeto.Text = $"Nome: {ProjetoBase.NomeProjeto}";
                    Lbl_DataInicial.Text = $"Data de criação: {ProjetoBase.DataInicial}";
                    Lbl_NumeroTarefas.Text = $"Tarefas: {ControllerTarefa.Listar(ProjetoBase.NomeProjeto).Count.ToString()}"; //Pega a lista de tarefas e retira o numero de tarefas da lista
                    Lbl_HorasTrabalho.Text = $"Horas de Trabalho: {ProjetoBase.HorasDeTrabalho.ToLongTimeString()}";

                    AtualizarTarefas();

                    this.Text = $"Projeto - {ProjetoBase.NomeProjeto}";
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Digite um nome de Projeto válido", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #12
0
        private void AtualizarHoras()
        {
            ProjetoBase = ControllerProjeto.Carregar(ProjetoBase.NomeProjeto);

            Lbl_HorasTrabalho.Text = $"Horas de trabalho {ProjetoBase.HorasDeTrabalho.ToLongTimeString()}";
        }
コード例 #13
0
        private void AtualizarNumeroDeTarefas()
        {
            ProjetoBase = ControllerProjeto.Carregar(ProjetoBase.NomeProjeto);

            Lbl_NumeroTarefas.Text = "Não esquecer de calcular tarefas";
        }