Beispiel #1
0
        public ProjetoModel RetornarProjeto(int?id)
        {
            ProjetoModel item;
            DAL          objDAL = new DAL();
            string       sql    = "select p.id, u.nome as usuario, p.nome, p.descricao, p.total, p.data, e.nome as etapa from projeto p " +
                                  "inner join etapa e on e.id = p.id_etapa " +
                                  "inner join cliente c on c.id = p.id_cliente " +
                                  "inner join usuario u on u.id = c.id_usuario " +
                                  $"where p.id = '{id}'" +
                                  "order by p.nome asc";
            DataTable dt          = objDAL.RetDataTable(sql);
            var       dataProjeto = DateTime.Parse(dt.Rows[0]["data"].ToString());

            DateTime dataHoje = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            var diferencaDatas = (int)dataHoje.Subtract(dataProjeto).TotalDays;

            item = new ProjetoModel
            {
                Id         = dt.Rows[0]["Id"].ToString(),
                Cliente_Id = dt.Rows[0]["Usuario"].ToString(),
                Nome       = dt.Rows[0]["Nome"].ToString(),
                Descricao  = dt.Rows[0]["Descricao"].ToString(),
                Etapa_Id   = dt.Rows[0]["Etapa"].ToString(),
                Data       = diferencaDatas,
                //Data = DateTime.Parse(dt.Rows[0]["data"].ToString()).ToString("dd/MM/yyyy"),
                Total = double.Parse(dt.Rows[0]["total"].ToString())
            };

            return(item);
        }
Beispiel #2
0
        public List <ProjetoModel> ListarTodosProjetos()
        {
            List <ProjetoModel> lista = new List <ProjetoModel>();
            ProjetoModel        item;
            DAL    objDAL = new DAL();
            string sql    = "select p.id, u.nome as usuario, p.nome, p.descricao, p.total, p.data, e.nome as etapa from projeto p " +
                            "inner join etapa e on e.id = p.id_etapa " +
                            "inner join cliente c on c.id = p.id_cliente " +
                            "inner join usuario u on u.id = c.id_usuario " +
                            "order by p.nome asc";
            DataTable dt          = objDAL.RetDataTable(sql);
            var       dataProjeto = DateTime.Parse(dt.Rows[0]["data"].ToString());

            DateTime dataHoje = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            var diferencaDatas = (int)dataHoje.Subtract(dataProjeto).TotalDays;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                item = new ProjetoModel
                {
                    Id         = dt.Rows[i]["Id"].ToString(),
                    Cliente_Id = dt.Rows[i]["Usuario"].ToString(),
                    Nome       = dt.Rows[i]["Nome"].ToString(),
                    Descricao  = dt.Rows[i]["Descricao"].ToString(),
                    Etapa_Id   = dt.Rows[i]["Etapa"].ToString(),
                    Data       = diferencaDatas,
                    Total      = double.Parse(dt.Rows[i]["total"].ToString())
                };
                lista.Add(item);
            }

            return(lista);
        }