Beispiel #1
0
        public Outros_Pagamentos(DateTime dt, double balanco, Predio p, Sujeito_Fiscal sf, string desc = "", int ID = -1) : base(dt, balanco, ID, sf.nome, desc)
        {
            this.p  = p;
            this.sf = sf;

            if (!string.IsNullOrEmpty(desc))
            {
                this.descricao = desc;
            }
        }
Beispiel #2
0
        public Orcamento(string titulo, DateTime inicial, DateTime final, Predio p, string Descricao = "", int id = -1)
        {
            this.Titulo  = titulo;
            this.inicial = inicial;
            this.final   = final;
            this.p       = p;

            if (!string.IsNullOrEmpty(Descricao))
            {
                this.Descricao = Descricao;
            }

            if (id != -1)
            {
                this.ID = id;
            }
        }
Beispiel #3
0
        public static List <Predio> get_All_Buildings()
        {
            List <Predio> p = new List <Predio>();

            SqlCommand    cmd    = new SqlCommand("SELECT * FROM getAllBuildings();", Database_Connection.cn);
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                Predio P = new Predio();

                // These four values can't be null
                P.ID        = Int32.Parse(reader["ID"].ToString());
                P.Nome      = reader["Nome"].ToString();
                P.Latitude  = double.Parse(reader["Latitude"].ToString());
                P.Longitude = double.Parse(reader["Longitude"].ToString());

                // These four attributes can be null
                if (reader["Morada"] != DBNull.Value)
                {
                    P.Morada = reader["Morada"].ToString();
                }
                if (reader["Area"] != DBNull.Value)
                {
                    P.Area = double.Parse(reader["Area"].ToString());
                }
                if (reader["Cidade"] != DBNull.Value)
                {
                    P.Cidade = reader["Cidade"].ToString();
                }
                if (reader["Codigo_Postal"] != DBNull.Value)
                {
                    P.Codigo_Postal = reader["Codigo_Postal"].ToString();
                }

                p.Add(P);
            }

            reader.Close();
            Database_Connection.cn.Close();
            return(p);
        }
        public static List <Fracao> getFracoesOfCondomino(Condomino c, Predio p)
        {
            List <Fracao> fracoes = new List <Fracao>();

            SqlCommand cmd = new SqlCommand(@"SELECT * FROM getFractionsOfCondomino(@CC, @ID_Predio);", Database_Connection.cn);

            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@CC", c.CC);
            cmd.Parameters.AddWithValue("@ID_Predio", p.ID);
            SqlDataReader reader = cmd.ExecuteReader();


            while (reader.Read())
            {
                Fracao F = new Fracao();

                // These values can't be null
                F.ID       = int.Parse(reader["ID"].ToString());
                F.Area     = double.Parse(reader["Area"].ToString());
                F.Tipo     = reader["Tipo"].ToString();
                F.IDPredio = int.Parse(reader["ID_Predio"].ToString());
                F.Piso     = int.Parse(reader["Piso"].ToString());

                // These values can be null
                if (reader["Zona"] != DBNull.Value)
                {
                    F.Zona = reader["Zona"].ToString();
                }

                if (reader["Quota"] != DBNull.Value)
                {
                    F.Quota = double.Parse(reader["Quota"].ToString());
                }

                fracoes.Add(F);
            }

            reader.Close();
            Database_Connection.cn.Close();
            return(fracoes);
        }
Beispiel #5
0
        public static List <Outros_Pagamentos> get_OutrosPagamentos(Predio P, DateTime final, DateTime initial)
        {
            List <Outros_Pagamentos> Ts = new List <Outros_Pagamentos>();

            SqlCommand cmd = new SqlCommand(@"SELECT * FROM getOutrosPagamentos(@ID_Predio, @InitialDate, @FinalDate);", Database_Connection.cn);

            cmd.Parameters.AddWithValue("@ID_Predio", P.ID);
            cmd.Parameters.AddWithValue("@InitialDate", initial);
            cmd.Parameters.AddWithValue("@FinalDate", final);
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                string NIF    = reader["NIF"].ToString();
                string nome   = reader["Nome"].ToString();
                string e_mail = "";
                string morada = "";
                if (reader["E_mail"] != DBNull.Value)
                {
                    e_mail = reader["E_mail"].ToString();
                }
                if (reader["Morada"] != DBNull.Value)
                {
                    morada = reader["Morada"].ToString();
                }

                Sujeito_Fiscal suj = new Sujeito_Fiscal(NIF, nome, e_mail, morada);

                int      ID      = int.Parse(reader["OID"].ToString());
                DateTime dt      = DateTime.Parse(reader["Data"].ToString());
                double   Balanco = double.Parse(reader["Balanco"].ToString());
                string   desc    = reader["descricao"].ToString();
                Ts.Add(new Outros_Pagamentos(dt, Balanco, P, suj, desc, ID));
            }

            reader.Close();
            Database_Connection.cn.Close();
            return(Ts);
        }
 public Manutencao(Predio p, DateTime data, string titulo, string Descricao = "", int id = 0, string tipo = "", Outros_Pagamentos op = null) : base(p.ID, data, titulo, Descricao, id)
 {
     this.p    = p;
     this.tipo = tipo;
     this.op   = op;
 }
        public static List <Manutencao> get_Manutencoes(Predio p, DateTime final, DateTime initial)
        {
            List <Manutencao> Rs = new List <Manutencao>();

            SqlCommand cmd = new SqlCommand(@"SELECT * FROM getAllManutencoesAndPaymentsOfBuilding(@ID_Predio, @InitialDate, @FinalDate);", Database_Connection.cn);

            cmd.Parameters.AddWithValue("@ID_Predio", p.ID);
            cmd.Parameters.AddWithValue("@InitialDate", initial);
            cmd.Parameters.AddWithValue("@FinalDate", final);
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                Sujeito_Fiscal    sj;
                Outros_Pagamentos op = null;

                if (DBNull.Value != reader["Id_Outros_Pagamentos"])
                {
                    string Morada = "";
                    string Email  = "";

                    string NIF  = reader["NIF"].ToString();
                    string Nome = reader["Nome"].ToString();

                    if (reader["Morada"] != DBNull.Value)
                    {
                        Morada = reader["Morada"].ToString();
                    }
                    if (reader["e_mail"] != DBNull.Value)
                    {
                        Email = reader["e_mail"].ToString();
                    }
                    sj = new Sujeito_Fiscal(NIF, Nome, Email, Morada);

                    int      id_outros_pag = int.Parse(reader["Id_Outros_Pagamentos"].ToString());
                    DateTime OData         = DateTime.Parse(reader["OData"].ToString());
                    double   balanco       = double.Parse(reader["Balanco"].ToString());

                    string ODescricao = "";
                    if (DBNull.Value != reader["ODescricao"])
                    {
                        ODescricao = reader["ODescricao"].ToString();
                    }

                    op = new Outros_Pagamentos(OData, balanco, p, sj, ODescricao, id_outros_pag);
                }

                DateTime dt     = DateTime.Parse(reader["MData"].ToString());
                string   titulo = reader["Titulo"].ToString();
                string   desc   = "";
                string   tipo   = "";


                if (DBNull.Value != reader["MDescricao"])
                {
                    desc = reader["MDescricao"].ToString();
                }

                if (DBNull.Value != reader["Tipo"])
                {
                    tipo = reader["Tipo"].ToString();
                }

                int id = int.Parse(reader["MID"].ToString());

                Rs.Add(new Manutencao(p, dt, titulo, desc, id, tipo, op));
            }

            reader.Close();
            Database_Connection.cn.Close();
            return(Rs);
        }
Beispiel #8
0
        public static List <Orcamento> get_Orcamentos(int IDPredio, DateTime final, DateTime initial, Predio p)
        {
            List <Orcamento> Orcamentos = new List <Orcamento>();

            SqlCommand cmd = new SqlCommand(@"SELECT * FROM getOrcamentoFromBuilding(@ID_Predio, @InitialDate, @FinalDate);", Database_Connection.cn);

            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@ID_Predio", IDPredio);
            cmd.Parameters.AddWithValue("@InitialDate", initial);
            cmd.Parameters.AddWithValue("@FinalDate", final);
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                DateTime dt_inicial = DateTime.Parse(reader["Data_Inicial"].ToString());
                DateTime dt_final   = DateTime.Parse(reader["Data_Final"].ToString());
                string   titulo     = reader["Titulo"].ToString();
                string   desc       = "";
                if (DBNull.Value != reader["Descricao"])
                {
                    desc = reader["Descricao"].ToString();
                }
                int id = int.Parse(reader["ID"].ToString());

                Orcamentos.Add(new Orcamento(titulo, dt_inicial, dt_final, p, desc, id));
            }

            reader.Close();
            Database_Connection.cn.Close();
            return(Orcamentos);
        }
        public static List <QuotaView> getAllQuotas(Predio p, int year)
        {
            List <QuotaView> Qvs = new List <QuotaView>();

            DateTime dtstart = new DateTime(year, 1, 1);
            DateTime dtend   = new DateTime(year, 12, 31);



            SqlCommand cmd = new SqlCommand(@"SELECT * FROM getAllQuotasWithinYear(@Predio_ID, @dtstart, @dtend);", Database_Connection.cn);

            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@Predio_ID", p.ID);
            cmd.Parameters.AddWithValue("@dtstart", dtstart);
            cmd.Parameters.AddWithValue("@dtend", dtend);

            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                // Check if it already exists. If not, create one.
                QuotaView search = Qvs.Find(Qv => Qv.Fracao_Id == int.Parse(reader["ID"].ToString()));
                if (search == null)
                {
                    Fracao F = new Fracao();
                    F.ID       = int.Parse(reader["ID"].ToString());
                    F.Area     = double.Parse(reader["Area"].ToString());
                    F.Tipo     = reader["Tipo"].ToString();
                    F.Zona     = reader["Zona"].ToString();
                    F.IDPredio = int.Parse(reader["ID_Predio"].ToString());
                    F.Piso     = int.Parse(reader["Piso"].ToString());

                    // These values can be null
                    if (reader["Zona"] != DBNull.Value)
                    {
                        F.Zona = reader["Zona"].ToString();
                    }

                    if (reader["Quota"] != DBNull.Value)
                    {
                        F.Quota = double.Parse(reader["Quota"].ToString());
                    }
                    search = new QuotaView("", F.ID, F.Piso, F.Zona, F.Tipo, F.Quota);

                    if (reader["Data_Compra"] != DBNull.Value)
                    {
                        search.DateCompra = DateTime.Parse(reader["Data_Compra"].ToString());
                    }

                    if (reader["Data_Venda"] != DBNull.Value)
                    {
                        search.DateVenda = DateTime.Parse(reader["Data_Venda"].ToString());
                    }
                }

                /* Set the month as payed */
                if (DBNull.Value != reader["Mes"])
                {
                    if (DateTime.Parse(reader["Mes"].ToString()).Month == 1)
                    {
                        search.Janeiro = true;
                    }
                    else if (DateTime.Parse(reader["Mes"].ToString()).Month == 2)
                    {
                        search.Fevereiro = true;
                    }
                    else if (DateTime.Parse(reader["Mes"].ToString()).Month == 3)
                    {
                        search.Marco = true;
                    }
                    else if (DateTime.Parse(reader["Mes"].ToString()).Month == 4)
                    {
                        search.Abril = true;
                    }
                    else if (DateTime.Parse(reader["Mes"].ToString()).Month == 5)
                    {
                        search.Maio = true;
                    }
                    else if (DateTime.Parse(reader["Mes"].ToString()).Month == 6)
                    {
                        search.Junho = true;
                    }
                    else if (DateTime.Parse(reader["Mes"].ToString()).Month == 7)
                    {
                        search.Julho = true;
                    }
                    else if (DateTime.Parse(reader["Mes"].ToString()).Month == 8)
                    {
                        search.Agosto = true;
                    }
                    else if (DateTime.Parse(reader["Mes"].ToString()).Month == 9)
                    {
                        search.Setembro = true;
                    }
                    else if (DateTime.Parse(reader["Mes"].ToString()).Month == 10)
                    {
                        search.Outubro = true;
                    }
                    else if (DateTime.Parse(reader["Mes"].ToString()).Month == 11)
                    {
                        search.Novembro = true;
                    }
                    else if (DateTime.Parse(reader["Mes"].ToString()).Month == 12)
                    {
                        search.Dezembro = true;
                    }
                }

                // Set Condomin to fraction if it exists.
                if (reader["Nome"] != DBNull.Value)
                {
                    if (!search.Nome.Contains(reader["Nome"].ToString()))
                    {
                        if (search.Nome == "")
                        {
                            search.Nome = reader["Nome"].ToString();
                        }
                        else
                        {
                            search.Nome += "/" + reader["Nome"].ToString();
                        }
                    }
                }

                if (Qvs.Find(Qv => Qv.Fracao_Id == int.Parse(reader["ID"].ToString())) == null)
                {
                    Qvs.Add(search);
                }
            }



            reader.Close();
            Database_Connection.cn.Close();

            return(Qvs);
        }