Jump to content

Marcar datas no calendário


N3lson

Recommended Posts

Boas estou a tentar colocar as datas (recolhidas de uma base de dados) no calendário a negrito, se colocar apenas um registo funciona bem mas se colocar mais que 1 registo retorna-me no calendário apenas o mais recente.

Podem me ajudar ?

  string _query = "SELECT * FROM calendario WHERE estado=1 AND utilizador=@user;";

            using (MySqlConnection con  = new MySqlConnection(ConSql))
            {
                using (MySqlCommand cmd = new MySqlCommand(_query, con))
                {
                    con.Open();
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@user", Sessao.Id);

                    MySqlDataReader reader = cmd.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            DateTime data = (DateTime)reader["dataAviso"];

                            int ano = data.Year;
                            int dia = data.Day;
                            int mes = data.Month;

                            monthCalendar1.BoldedDates = new System.DateTime[] { new System.DateTime(ano, mes, dia) };
                        }
                        reader.Close();
                    }
                }
                con.Close();
            }

Obrigado

You can't do it, kid. But don't worry, my boy. You're not the only one. No one else can do it.

Link to comment
Share on other sites

Já resolvi

string _query = "SELECT * FROM calendario WHERE estado=1 AND utilizador=@user;";

            using (MySqlConnection con  = new MySqlConnection(ConSql))
            {
                using (MySqlCommand cmd = new MySqlCommand(_query, con))
                {
                    con.Open();
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@user", Sessao.Id);

                    MySqlDataReader reader = cmd.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            		monthCalendar1.AddBoldedDate(DateTime.Parse(funcao.OutHoras(reader["dataAviso"].ToString())));

                        }
                        reader.Close();
                    }
                }
                con.Close();
            }

You can't do it, kid. But don't worry, my boy. You're not the only one. No one else can do it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.