コード例 #1
0
ファイル: TarefaDA.cs プロジェクト: CPicinin/Repository_PDM
 public List<ItemTarefa> buscaItensTarefa(int id)
 {
     List<ItemTarefa> listaItens = new List<ItemTarefa>();
     SqlConnection conexao = new SqlConnection();
     conexao.ConnectionString = StaticObjects.strConexao;
     SqlCommand comando = new SqlCommand();
     SqlDataReader leitor;
     try
     {
         conexao.Open();
         comando.CommandText = @"SELECT id,idTarefa,data,descricao FROM dbo.ItensTarefa WHERE idTarefa = " + id + " ";
         comando.Connection = conexao;
         leitor = comando.ExecuteReader();
         while (leitor.Read())
         {
             ItemTarefa it = new ItemTarefa();
             it.id = Convert.ToInt16(leitor["id"]);
             it.idTarefa = Convert.ToInt16(leitor["idTarefa"]);
             it.data = Convert.ToDateTime(leitor["data"]);
             it.descricao = leitor["descricao"].ToString();
             listaItens.Add(it);
         }
         conexao.Close();
         return listaItens;
     }
     catch (Exception)
     {
         conexao.Close();
         return null;
     }
 }
コード例 #2
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if ((txtItem.Text != "") && txtItem.Text != null)
     {
         ItemTarefa i = new ItemTarefa();
         i.idTarefa = idTarefa;
         i.data = DateTime.Now;
         i.descricao = txtItem.Text;
         TarefaBL tbl = new TarefaBL();
         bool foi = tbl.adicionarItem(i);
         carregaTabela();
         LogEventoBL lbl = new LogEventoBL();
         Log l = new Log();
         l.email = Session["email"].ToString();
         l.data = DateTime.Now;
         l.descricao = "Adicionou um item <" + i.descricao + "> na Tarefa nº " + i.idTarefa + " ";
         lbl.adicionaLog(l);
         txtItem.Text = "";
     }
 }
コード例 #3
0
ファイル: TarefaDA.cs プロジェクト: CPicinin/Repository_PDM
        public bool adicionarItem(ItemTarefa i)
        {
            SqlConnection conexao = new SqlConnection();
            conexao.ConnectionString = StaticObjects.strConexao;
            SqlCommand comando = new SqlCommand();
            try
            {
                conexao.Open();
                comando.CommandText = @"INSERT INTO dbo.ItensTarefa (idTarefa,data,descricao) " +
                            " VALUES (" + i.idTarefa + ",'" + i.data.ToShortDateString() + "', '" + i.descricao + "')";
                comando.Connection = conexao;
                comando.ExecuteNonQuery();
                conexao.Close();
                return true;
            }

            catch (Exception)
            {
                conexao.Close();
                return false;
            }
        }
コード例 #4
0
ファイル: TarefaBL.cs プロジェクト: CPicinin/Repository_PDM
 public bool adicionarItem(ItemTarefa i)
 {
     bool foi = tda.adicionarItem(i);
     return foi;
 }