Beispiel #1
0
 private void btnSalvar_Click(object sender, EventArgs e)
 {
     dataDisponivel   = new DataDisponivelM();
     dataIndisponivel = new DataIndisponivelM();
     if (cbxReservista.Text.Equals(String.Empty) || cbxAcao.Text.Equals(String.Empty) || txtData.Text.Equals(String.Empty))
     {
         MessageBox.Show("Existe Campos Imcompletos");
     }
     else
     {
         if (cbxAcao.SelectedIndex == 0)
         {
             MessageBox.Show("Selecione alguma ação");
         }
         else if (cbxAcao.SelectedIndex == 1)
         {
             //dataDisponivel.Reservista_IdReservista = cbxReservista.SelectedIndex();
             dataDisponivel.Data = txtData.Text;
             datasdao.SalvarPunicao(dataDisponivel);
         }
         else if (cbxAcao.SelectedIndex == 2)
         {
             //dataIndisponivel.Reservista_IdReservista = cbxReservista.SelectedIndex();
             dataIndisponivel.Data = txtData.Text;
             datasdao.SalvarDispensa(dataIndisponivel);
         }
     }
 }
Beispiel #2
0
        public int SalvarDispensa(DataIndisponivelM dataIndisp)
        {
            try
            {
                string          conn    = ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ToString();
                MySqlConnection conexao = new MySqlConnection(conn);
                conexao.Open();
                MySqlCommand comando = new MySqlCommand();
                comando             = conexao.CreateCommand();
                comando.CommandText = "insert into DataIndisponivel values(" +
                                      "@IdDataIndisponivel," +
                                      "@Reservista_IdReservista," +
                                      "@Data)";
                comando.Parameters.AddWithValue("@IdDataIndisponivel", null);
                comando.Parameters.AddWithValue("@Reservista_IdReservista", dataIndisp.Reservista_IdReservista);
                comando.Parameters.AddWithValue("@Data", dataIndisp.Data);
                int retorno = comando.ExecuteNonQuery();
                conexao.Close();

                return(retorno);
            }
            catch (SqlException)
            {
                return(0);
            }
        }