//duvida
 /// <summary>
 /// Initializes a new instance of the <see cref="Empresa"/> class.
 /// </summary>
 public Empresa()
 {
     pais            = String.Empty;
     nome            = String.Empty;
     localidade      = String.Empty;
     empregados      = new List <Apicultor>();
     nif             = long.MinValue;
     morada          = String.Empty;
     areaComercio    = String.Empty;
     calendarioAcoes = new Ano();
     empregados      = new List <Apicultor>();
 }
        /// <summary>
        /// Limpa
        /// </summary>
        /// <param name="a">a.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public static bool LimpaAccoesAno(Empresa.Ano a)
        {
            try
            {
                Empresa.Ano.LimpaCalendario(a);

                return(true);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Пример #3
0
        /// <summary>
        /// Limpas the calendario.
        /// </summary>
        /// <param name="a">a.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        /// <exception cref="Exception.AnoException"></exception>
        /// <exception cref="System.Exception"></exception>
        public static bool LimpaCalendario(Ano a)
        {
            try
            {
                a.acoes.Clear();

                return(true);
            }
            catch (Exception.AnoException)
            {
                throw new Exception.AnoException();
            }
            catch (System.Exception)
            {
                throw new System.Exception();
            }
        }
        //esta
        /// <summary>
        /// Dispenses the work.
        /// </summary>
        /// <param name="e">The e.</param>
        /// <param name="ap">The ap.</param>
        /// <param name="a">apiario</param>
        /// <param name="c">The c.</param>
        /// <param name="ac">The ac.</param>
        /// <returns>False error | True good</returns>
        /// <exception cref="Exception.ColmeiaException"></exception>
        /// <exception cref="System.Exception"></exception>
        public static bool DipensesAcao(Objecto.FichaTecnicaEmpresa e, Objecto.FichaTecnicaApicultor ap, Objecto.FichaTecnicaApiario a, Objecto.FichaTecnicaColmeia c, Objecto.Acao ac)
        {
            if (e == null || a == null || ap == null || ac == null || c == null)
            {
                return(false);
            }

            else
            {
                try
                {
                    if (!Multinacional.ExisteAccao(e, ap, a, c, ac))
                    {
                        Empresa   fe        = new Empresa(e);
                        Apicultor apicultor = new Apicultor(ap);
                        Apiario   apiario   = new Apiario(a);
                        Colmeia   colmeia   = new Colmeia(c);

                        foreach (List <Empresa> lista in Multinacional.multinacionais.Values)
                        {
                            foreach (Empresa empresa in lista)
                            {
                                if (fe == empresa)
                                {
                                    foreach (Apicultor item in empresa.empregados)
                                    {
                                        if (apicultor == item)
                                        {
                                            foreach (Apiario value in item.apiarios)
                                            {
                                                if (value == apiario)
                                                {
                                                    foreach (Colmeia cc in value.colmeias)
                                                    {
                                                        if (cc == colmeia)
                                                        {
                                                            cc.acoes.Remove(ac);
                                                            cc.totAcoes--;
                                                            if (Ano.ApagaEvento(empresa, ac))
                                                            {
                                                                return(true);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        return(false);
                    }

                    else
                    {
                        return(false);
                    }
                }
                catch (Exception.ColmeiaException)
                {
                    throw new Exception.ColmeiaException();
                }
                catch (System.Exception)
                {
                    throw new System.Exception();
                }
            }
        }
        // tá
        /// <summary>
        /// Agendars the acao.
        /// </summary>
        /// <param name="e">The e.</param>
        /// <param name="ap">The ap.</param>
        /// <param name="a">a.</param>
        /// <param name="c">The c.</param>
        /// <param name="ac">The ac.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        /// <exception cref="Exception.EmpresaException"></exception>
        /// <exception cref="System.Exception"></exception>
        public static bool AgendarAcao(Objecto.FichaTecnicaEmpresa e, Objecto.FichaTecnicaApicultor ap, Objecto.FichaTecnicaApiario a, Objecto.FichaTecnicaColmeia c, Objecto.Acao ac)
        {
            int dia = ac.Data.DayOfYear - 1;
            int k   = 0;

            if (e == null || ap == null || c == null || a == null || ac == null)
            {
                return(false);
            }

            else
            {
                try
                {
                    if (!Multinacional.ExisteAccao(e, ap, a, c, ac))
                    {
                        Empresa fe = new Empresa(e);

                        if (Ano.TemEventosNumDia(fe, ac))
                        {
                            return(false);
                        }

                        else
                        {
                            foreach (List <Empresa> lista in Multinacional.multinacionais.Values)
                            {
                                foreach (Empresa empresa in lista)
                                {
                                    if (fe == empresa)
                                    {
                                        Ano.InsereAcaoAno(empresa, ac);
                                    }
                                }
                            }
                        }

                        if (Colmeia.Intervention(e, ap, a, c, ac) && k == 1)
                        {
                            return(true);
                        }

                        return(false);
                    }

                    else
                    {
                        return(false);
                    }
                }

                catch (Exception.EmpresaException)
                {
                    throw new Exception.EmpresaException();
                }
                catch (System.Exception)
                {
                    throw new System.Exception();
                }
            }
        }