コード例 #1
0
        public int Alterar(CicloEvento cicloEvento)
        {
            SqlCommand cmd = new SqlCommand();

            using (cmd.Connection = _conexao.ObjetoDaConexao)
            {
                try
                {
                    _conexao.Conectar();
                    cmd.CommandText = @"UPDATE TB_CICLO_EVENTO SET
                                        TERMINO = @TERMINOCICLOEVENTO,
                                        COMPLETO = @COMPLETO
                                        WHERE ID = @ID";
                    cmd.Parameters.AddWithValue("@TERMINOCICLOEVENTO", cicloEvento.Termino);
                    cmd.Parameters.AddWithValue("@COMPLETO", cicloEvento.Completo);
                    cmd.Parameters.AddWithValue("@ID", cicloEvento.Id);

                    var resultado = cmd.ExecuteNonQuery();

                    return(resultado);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    _conexao.Desconectar();
                }
            }
        }
コード例 #2
0
ファイル: frmTimer.cs プロジェクト: TabataMora/MyLearnings
        private int InserirCicloEvento()
        {
            CicloEvento cicloEvento = new CicloEvento(IdCicloAtual, 1, DateTime.Now);

            if (chkTempoCiclo.Checked)
            {
                cicloEvento.IdEvento = 1;
            }
            if (chkDescCurto.Checked)
            {
                cicloEvento.IdEvento = 2;
            }
            if (chkDescLongo.Checked)
            {
                cicloEvento.IdEvento = 3;
            }
            if (chkResumo.Checked)
            {
                cicloEvento.IdEvento = 4;
            }

            CicloEventoRegrasDeNegocio cicloEventoRegras = new CicloEventoRegrasDeNegocio();

            retornoDoIdEvento = cicloEventoRegras.Incluir(cicloEvento);

            return(retornoDoIdEvento);
        }
コード例 #3
0
        public int Incluir(CicloEvento cicloEvento)
        {
            SqlCommand cmd = new SqlCommand();

            using (cmd.Connection = _conexao.ObjetoDaConexao)
            {
                try
                {
                    _conexao.Conectar();
                    cmd.CommandText = @"INSERT TB_CICLO_EVENTO(ID_CICLO, ID_EVENTO, 
                                          COMPLETO, INICIO) 
                                          VALUES (@IDCICLO, @IDEVENTO, 
                                           @COMPLETO, @INICIO);
                                          SELECT @@IDENTITY;";
                    cmd.Parameters.AddWithValue("@IDCICLO", cicloEvento.IdCiclo);
                    cmd.Parameters.AddWithValue("@IDEVENTO", cicloEvento.IdEvento);
                    cmd.Parameters.AddWithValue("@COMPLETO", cicloEvento.Completo);
                    cmd.Parameters.AddWithValue("@INICIO", cicloEvento.Inicio);
                    cicloEvento.Id = Convert.ToInt32(cmd.ExecuteScalar());
                    return(cicloEvento.Id);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    _conexao.Desconectar();
                }
            }
        }
コード例 #4
0
 public int Alterar(CicloEvento cicloEvento)
 {
     try
     {
         CicloEventoAcessoADados cicloAcessoADados = new CicloEventoAcessoADados();
         return(cicloAcessoADados.Alterar(cicloEvento));
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #5
0
ファイル: frmTimer.cs プロジェクト: TabataMora/MyLearnings
        public int AlterarCicloEventoNoBanco()
        {
            CicloEvento cicloEvento = new CicloEvento(DateTime.Now);

            cicloEvento.Id = retornoDoIdEvento;
            if (cicloEvento.Id != 0)
            {
                CicloEventoRegrasDeNegocio cicloEventoRegras = new CicloEventoRegrasDeNegocio();

                var retorno = cicloEventoRegras.Alterar(cicloEvento);
            }

            return(cicloEvento.Id);
        }