public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values[1].ToString().Length < 4)
            {
                return(false);
            }

            QuotaView qv = (QuotaView)values[0];

            if (string.IsNullOrEmpty(qv.Nome))
            {
                return(false);
            }

            int year = int.Parse(values[1].ToString());

            if (qv.Janeiro == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }
            if (qv.Fevereiro == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }
            if (qv.Marco == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }
            if (qv.Abril == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }
            if (qv.Maio == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }
            if (qv.Junho == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }
            if (qv.Julho == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }
            if (qv.Agosto == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }
            if (qv.Setembro == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }
            if (qv.Outubro == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }
            if (qv.Novembro == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }
            if (qv.Dezembro == false && inBetweenDates(qv.DateCompra, qv.DateVenda, 1, year))
            {
                return(false);
            }


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