Exemple #1
0
        public static List <Condomino> get_Condominos(int IDPredio)
        {
            List <Condomino> condominos = new List <Condomino>();

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

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

            while (reader.Read())
            {
                Condomino c = new Condomino();

                // These values can't be null
                c.Nome = reader["Nome"].ToString();
                c.CC   = reader["CC"].ToString();
                c.NIF  = reader["NIF"].ToString();

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

                condominos.Add(c);
            }

            reader.Close();
            Database_Connection.cn.Close();
            return(condominos);
        }
Exemple #2
0
 public Compra(Fracao f, Condomino c, DateTime Data_Compra, DateTime Data_Venda)
 {
     this.f            = f;
     this.c            = c;
     this._Data_Compra = Data_Compra;
     this._Data_Venda  = Data_Venda;
 }
        public List <Compra> getAllCompras()
        {
            List <Compra> Compras = new List <Compra>();

            SqlCommand cmd = new SqlCommand(@"SELECT * FROM getAllComprasOfFraction(@ID) ORDER BY DATA_COMPRA;", Database_Connection.cn);

            cmd.Parameters.AddWithValue("@ID", ID);
            SqlDataReader reader = cmd.ExecuteReader();


            while (reader.Read())
            {
                string    CC     = reader["CC"].ToString();
                string    Nome   = reader["Nome"].ToString();
                string    e_mail = reader["e_mail"].ToString();
                string    NIF    = reader["NIF"].ToString();
                int       ID     = int.Parse(reader["ID"].ToString());
                Condomino c      = new Condomino(CC, Nome, NIF, e_mail);
                DateTime  compra = DateTime.Parse(reader["Data_Compra"].ToString());
                DateTime  venda;
                if (DBNull.Value != reader["Data_venda"])
                {
                    venda = DateTime.Parse(reader["Data_venda"].ToString());
                    Compras.Add(new Compra(ID, this, c, compra, venda));
                }
                else
                {
                    Compras.Add(new Compra(ID, this, c, compra));
                }
            }

            reader.Close();
            Database_Connection.cn.Close();
            return(Compras);
        }
 public CondominoQuotaView(Fracao f, Condomino c, bool pay, DateTime compra)
 {
     this.c      = c;
     this.pay    = pay;
     this.f      = f;
     this.compra = compra;
 }
Exemple #5
0
 public Compra(int ID, Fracao f, Condomino c, DateTime Data_Compra)
 {
     this.ID           = ID;
     this.f            = f;
     this.c            = c;
     this._Data_Compra = Data_Compra;
     this._Data_Venda  = DateTime.MaxValue;
 }
        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);
        }
        public Condomino getCurrentCondomino()
        {
            SqlCommand cmd = new SqlCommand(@"SELECT * FROM getCurrentCondomino(@ID);", Database_Connection.cn);

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

            Condomino C = null;

            while (reader.Read())
            {
                string CC     = reader["CC"].ToString();
                string Nome   = reader["Nome"].ToString();
                string e_mail = reader["e_mail"].ToString();
                string NIF    = reader["NIF"].ToString();
                C = new Condomino(CC, Nome, NIF, e_mail);
            }

            reader.Close();
            Database_Connection.cn.Close();
            return(C);
        }
 public void add_Condomino(Condomino c)
 {
     _condominos.Add(c);
 }
        public static List <CondominoQuotaView> get_All_Current_Condominos(int IDPredio)
        {
            DateTime dtstart = new DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month, 1);
            DateTime dtend   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 30);

            List <CondominoQuotaView> condominos = new List <CondominoQuotaView>();

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

            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@ID_Predio", IDPredio);
            cmd.Parameters.AddWithValue("@dtstart", dtstart);
            cmd.Parameters.AddWithValue("@dtend", dtend);
            SqlDataReader reader = cmd.ExecuteReader();

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

                compra = DateTime.Parse(reader["Data_Compra"].ToString());

                // 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());
                }

                Condomino c = new Condomino();

                // These values can't be null
                c.Nome = reader["Nome"].ToString();
                c.CC   = reader["CC"].ToString();
                c.NIF  = reader["NIF"].ToString();

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

                bool payed = !string.IsNullOrEmpty(reader["Mes"].ToString());


                condominos.Add(new CondominoQuotaView(F, c, payed, compra));
            }
            reader.Close();
            Database_Connection.cn.Close();
            return(condominos);
        }