示例#1
0
        public static Model.Reuniao BuscarPorId(int clienteId)
        {
            using (MySqlConnection conn = new MySqlConnection(strConection))
            {
                conn.Open();

                using (MySqlCommand cmd = new MySqlCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandText = @"SELECT * FROM reuniao WHERE id = ?id";
                    cmd.Parameters.AddWithValue("?id", clienteId);

                    MySqlDataReader reader = cmd.ExecuteReader();

                    Model.Reuniao retorno = new Model.Reuniao();

                    while (reader.Read())
                    {
                        retorno.Id           = (int)reader["Id"];
                        retorno.Assunto      = (string)reader["assunto"];
                        retorno.Situacao     = (SituacaoReuniao)reader["situacao"];
                        retorno.CondominioId = (int)reader["idCondominio"];
                        retorno.DataHora     = (DateTime)reader["dataHora"];
                        retorno.Local        = (string)reader["local"];
                    }

                    return(retorno);
                }
            }
        }
示例#2
0
 public ActionResult Create(Model.Reuniao reuniao)
 {
     try
     {
         Control.ReuniaoDAO.Salvar(reuniao);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#3
0
 public ActionResult Edit(int id, Model.Reuniao reuniao)
 {
     try
     {
         // TODO: Add update logic here
         Control.ReuniaoDAO.Salvar(reuniao);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#4
0
        public static void Salvar(Model.Reuniao reuniao)
        {
            using (MySqlConnection conn = new MySqlConnection(strConection))
            {
                conn.Open();

                using (MySqlCommand cmd = new MySqlCommand())
                {
                    cmd.Connection = conn;

                    if (reuniao.Id == 0)
                    {
                        cmd.CommandText = @"INSERT INTO reuniao
                                                (assunto, dataHora, local, situacao, idCondominio)
                                            VALUES
                                                (?assunto, ?dataHora, ?local, ?situacao, ?idCondominio);";
                    }
                    else
                    {
                        cmd.CommandText = @"UPDATE reuniao 
                                                SET assunto = ?assunto,
                                                    dataHora = ?dataHora,
                                                    local = ?local,
                                                    situacao = ?situacao,
                                                    idCondominio = ?idCondominio
                                            WHERE id = ?id;";
                    }

                    cmd.Parameters.AddWithValue("?assunto", reuniao.Assunto);
                    cmd.Parameters.AddWithValue("?dataHora", reuniao.DataHora);
                    cmd.Parameters.AddWithValue("?local", reuniao.Local);
                    cmd.Parameters.AddWithValue("?situacao", (int)reuniao.Situacao);
                    cmd.Parameters.AddWithValue("?idCondominio", reuniao.CondominioId);
                    cmd.Parameters.AddWithValue("?id", reuniao.Id);

                    cmd.ExecuteNonQuery();
                }
            }
        }