示例#1
0
        public PlanningEntity FillDoneValue(PlanningEntity planning, int clientId)
        {
            base.Initialize();
            base.OpenConnection();
            try
            {
                using (var cmd = new SqlCommand(string.Empty, connection))
                {
                    cmd.CommandText = "spr_upd_preenchimento_clien_planejamento_mensal";
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@id", planning.Id);
                    cmd.Parameters.AddWithValue("@val_reali", planning.DoneValue);
                    cmd.Parameters.AddWithValue("@cod_usu_clien", clientId);
                    cmd.Parameters.AddWithValue("@des_cor_status", planning.StatusColor);

                    return(planning);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                base.CloseConnection();
            }
        }
示例#2
0
        public PlanningEntity ToEntity()
        {
            var entity = new PlanningEntity(0, DoneValue, PlannedValue,
                                            GreenFrom, GreenTo, RedFrom, RedTo, Budgeted, DateTime.Now,
                                            Month, Year);

            return(entity);
        }
示例#3
0
        public PlanningEntity FillDoneValue(PlanningEntity planning, int clientId)
        {
            //var planningExists = _planningService.GetById(planning.Id);
            //if(!planningExists)
            //  throw new Exception("invalid.planning.id");

            return(_planningService.FillDoneValue(planning, clientId));
        }
示例#4
0
        public IEnumerable <PlanningEntity> GetSubItemPlanning(int companyId, int itemId, int subItemId)
        {
            base.Initialize();
            base.OpenConnection();

            try
            {
                var collection = new List <PlanningEntity>();

                base.connection = new SqlConnection(connectionstring);
                this.OpenConnection();

                using (var cmd = new SqlCommand("spr_ler_plan_subitem", connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@id_empresa", companyId);
                    cmd.Parameters.AddWithValue("@id_item", itemId);
                    cmd.Parameters.AddWithValue("@id_subitem", subItemId);

                    var dataReader = cmd.ExecuteReader();
                    while (dataReader.Read())
                    {
                        var id           = dataReader["id"].ToInt32();
                        var year         = dataReader["num_ano"].ToInt32();
                        var month        = dataReader["cod_mes"].ToInt32();
                        var doneValue    = dataReader["val_reali"].ToDouble();
                        var plannedValue = dataReader["val_previ"].ToDouble();
                        var greenFrom    = dataReader["val_verde_ini"].ToDouble();
                        var greenTo      = dataReader["val_verde_fim"].ToDouble();
                        var redFrom      = dataReader["val_verme_ini"].ToDouble();
                        var redTo        = dataReader["val_verme_fim"].ToDouble();
                        var budgeted     = dataReader["val_orcad"].ToDouble();
                        var creationDate = dataReader["dat_criac"].ToDateTime();
                        var statusColor  = dataReader["des_cor_status"].ToString();

                        var planning = new PlanningEntity(id,
                                                          doneValue, plannedValue, greenFrom, greenTo, redFrom, redTo, budgeted,
                                                          creationDate, month, year, statusColor);

                        collection.Add(planning);
                    }
                }
                return(collection);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                base.CloseConnection();
            }
        }
示例#5
0
 public PlanningRead(PlanningEntity entity)
 {
     Id           = entity.Id;
     DoneValue    = entity.DoneValue;
     PlannedValue = entity.PlannedValue;
     GreenFrom    = entity.GreenFrom;
     GreenTo      = entity.GreenTo;
     RedFrom      = entity.RedFrom;
     RedTo        = entity.RedTo;
     Budgeted     = entity.Budgeted;
     StatusColor  = entity.StatusColor;
     Month        = entity.Month;
     Year         = entity.Year;
 }
示例#6
0
        public PlanningEntity CreateMonthPlanning(int companyId, int itemId, int?subItemId, PlanningEntity planning, int relationId, int userId)
        {
            base.Initialize();
            base.OpenConnection();
            try
            {
                using (var cmd = new SqlCommand(string.Empty, connection))
                {
                    //executar se ainda não houver vínculo
                    //var relationId = this.CreateEntityRelation(companyId, itemId, subItemId, userId, cmd);

                    cmd.CommandText = "spr_ins_planejamento_mensal";
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@id_empre_item_subitem", relationId);
                    cmd.Parameters.AddWithValue("@cod_mes", planning.Month);
                    cmd.Parameters.AddWithValue("@num_ano", planning.Year);
                    cmd.Parameters.AddWithValue("@val_reali", planning.DoneValue);
                    cmd.Parameters.AddWithValue("@val_previ", planning.PlannedValue);
                    cmd.Parameters.AddWithValue("@val_verde_ini", planning.GreenFrom);
                    cmd.Parameters.AddWithValue("@val_verde_fim", planning.GreenTo);
                    cmd.Parameters.AddWithValue("@val_verme_ini", planning.RedFrom);
                    cmd.Parameters.AddWithValue("@val_verme_fim", planning.RedTo);
                    cmd.Parameters.AddWithValue("@val_orcad", planning.Budgeted);
                    cmd.Parameters.AddWithValue("@dat_criac", planning.CreationDate);
                    cmd.Parameters.AddWithValue("@cod_usu_adm", userId);
                    cmd.Parameters.AddWithValue("@des_cor_status", planning.StatusColor);

                    var id = (int)cmd.ExecuteScalar();

                    var p = new PlanningEntity(id, planning.DoneValue, planning.PlannedValue,
                                               planning.GreenFrom, planning.GreenTo, planning.RedFrom,
                                               planning.RedTo, planning.Budgeted, planning.CreationDate, planning.Month, planning.Year);

                    return(p);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                base.CloseConnection();
            }
        }
 public void SetSubItemEntity(int id
                              , string name
                              , string description
                              , bool isActive
                              , DateTime creationDate
                              , DateTime?lastupdate
                              , List <PlanningEntity> monthPlanning
                              , PlanningEntity yearPlanning
                              )
 {
     Id            = id;
     Name          = name;
     Description   = description;
     IsActive      = isActive;
     CreationDate  = creationDate;
     LastUpdate    = lastupdate;
     MonthPlanning = monthPlanning;
     YearPlanning  = yearPlanning;
 }
示例#8
0
        public PlanningEntity Update(int PlanningId, PlanningEntity planning, int adminId)
        {
            base.Initialize();
            base.OpenConnection();
            try
            {
                using (var cmd = new SqlCommand(string.Empty, connection))
                {
                    cmd.CommandText = "spr_upd_planejamento_mensal";
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@id", PlanningId);
                    cmd.Parameters.AddWithValue("@cod_mes", planning.Month);
                    cmd.Parameters.AddWithValue("@num_ano", planning.Year);
                    cmd.Parameters.AddWithValue("@val_reali", planning.DoneValue);
                    cmd.Parameters.AddWithValue("@val_previ", planning.PlannedValue);
                    cmd.Parameters.AddWithValue("@val_verde_ini", planning.GreenFrom);
                    cmd.Parameters.AddWithValue("@val_verde_fim", planning.GreenTo);
                    cmd.Parameters.AddWithValue("@val_verme_ini", planning.RedFrom);
                    cmd.Parameters.AddWithValue("@val_verme_fim", planning.RedTo);
                    cmd.Parameters.AddWithValue("@val_orcad", planning.Budgeted);
                    cmd.Parameters.AddWithValue("@dat_criac", planning.CreationDate);
                    cmd.Parameters.AddWithValue("@cod_usu_adm", adminId);
                    cmd.Parameters.AddWithValue("@des_cor_status", planning.StatusColor);

                    cmd.ExecuteNonQuery();

                    return(planning);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                base.CloseConnection();
            }
        }
示例#9
0
 public PlanningReadCollectionDto(IDictionary <PlanningEntity, List <PlanningEntity> > dictionary)
 {
     YearPlanning    = dictionary.Keys.First();
     MonthlyPlanning = dictionary.Values.First();
 }
 public PlanningEntity Update(int idPlanning, PlanningEntity planning, int adminId)
 {
     return(_repository.Update(idPlanning, planning, adminId));
 }
 public PlanningEntity FillDoneValue(PlanningEntity planning, int clientId)
 {
     return(_repository.FillDoneValue(planning, clientId));
 }
 public PlanningEntity CreateYearPlanning(int companyId, int itemId, int?subItemId, PlanningEntity planning, int relationId, int userId)
 {
     return(_repository.CreateYearPlanning(companyId, itemId, subItemId, planning, relationId, userId));
 }
示例#13
0
        public IDictionary <PlanningEntity, List <PlanningEntity> > Create(int companyId, int itemId, int?subItemId, List <PlanningEntity> montlyPlanning, PlanningEntity yearPlanning, int userId)
        {
            this.ValidateRelation(companyId, itemId, subItemId);

            var relationId = GetRelationId(companyId, itemId, subItemId);


            using (var transaction = new TransactionScope())
            {
                var monthPlanningCollection = new List <PlanningEntity>();
                foreach (var p in montlyPlanning)
                {
                    var monthPlanning = _planningService.CreateMonthPlanning(companyId, itemId, subItemId, p, relationId, userId);
                    monthPlanningCollection.Add(monthPlanning);
                }

                var yearPlanningEntity = _planningService.CreateYearPlanning(companyId, itemId, subItemId, yearPlanning, relationId, userId);

                var dictionaryEntity = new Dictionary <PlanningEntity, List <PlanningEntity> >();
                dictionaryEntity.Add(yearPlanningEntity, monthPlanningCollection);

                transaction.Complete();

                // Notificate client;

                return(dictionaryEntity);
            }
        }
示例#14
0
 public PlanningEntity Update(int PlanningId, PlanningEntity planning, int adminId)
 {
     return(_planningService.Update(PlanningId, planning, adminId));
 }