Exemplo n.º 1
0
        public List <Model.Agenda> select()
        {
            string sql = "SELECT * FROM agenda";
            List <Model.Agenda> lstAgenda = new List <Model.Agenda>();
            Conexao             conexao   = new Bll.Conexao();
            SqlCommand          command   = new SqlCommand(sql, conexao.getConexao());

            try
            {
                SqlDataReader reader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                while (reader.Read())
                {
                    Model.Agenda agenda = new Model.Agenda();
                    agenda.id            = Convert.ToInt32(reader["id"]);
                    agenda.duracao       = Convert.ToString(reader["duracao"]);
                    agenda.horarioInicio = Convert.ToString(reader["horarioInicio"]);

                    agenda.data          = Convert.ToDateTime(reader["data"]);
                    agenda.encaixe       = Convert.ToBoolean(reader["encaixe"]);
                    agenda.clienteID     = Convert.ToInt32(reader["clienteID"]);
                    agenda.funcionarioID = Convert.ToInt32(reader["funcionarioID"]);
                    lstAgenda.Add(agenda);
                }
            }
            catch
            {
                Console.WriteLine("Erro na seleção de Agenda");
            }
            finally
            {
                conexao.Dispose();
            }
            return(lstAgenda);
        }
Exemplo n.º 2
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Model.Agenda agenda = getAgenda();
     if (agenda != null)
     {
         Dal.AgendaDAL.insert(agenda);
     }
 }
Exemplo n.º 3
0
 public void addParameters(SqlCommand command, Model.Agenda agenda)
 {
     command.Parameters.AddWithValue("horarioInicio", agenda.horarioInicio);
     command.Parameters.AddWithValue("duracao", agenda.duracao);
     command.Parameters.AddWithValue("data", agenda.data.Date);
     command.Parameters.AddWithValue("encaixe", agenda.encaixe);
     command.Parameters.AddWithValue("clienteID", agenda.clienteID);
     command.Parameters.AddWithValue("funcionarioID", agenda.funcionarioID);
 }
Exemplo n.º 4
0
 protected void btnAdicionar_Click(object sender, EventArgs e)
 {
     Model.Agenda agenda = getAgenda();
     if (agenda != null)
     {
         Dal.AgendaDAL.insert(agenda);
     }
     limparCampos();
 }
Exemplo n.º 5
0
 private Model.Agenda getAgenda()
 {
     Model.Agenda agenda = new Model.Agenda();
     agenda.data          = Convert.ToDateTime(txtData.Text);
     agenda.horarioInicio = txtHorario.Text;
     agenda.duracao       = txtDuracao.Text;
     agenda.encaixe       = ckbEncaixe.Checked;
     agenda.funcionarioID = Convert.ToInt32(ddlFuncionario.SelectedValue);
     agenda.clienteID     = Convert.ToInt32(ddlCliente.SelectedValue);
     return(agenda);
 }
Exemplo n.º 6
0
        public void insert(Model.Agenda agenda)
        {
            string     sql     = "INSERT INTO agenda Values(@horarioInicio, @duracao, @data, @encaixe, @clienteID, @funcionarioID)";
            Conexao    conexao = new Bll.Conexao();
            SqlCommand command = new SqlCommand(sql, conexao.getConexao());

            addParameters(command, agenda);
            try
            {
                command.ExecuteNonQuery();
            }
            catch
            {
                Console.WriteLine("Erro de inserção na agenda");
            }
            finally
            {
                conexao.Dispose();
            }
        }
Exemplo n.º 7
0
 public static void insert(Model.Agenda agenda)
 {
     Bll.Agenda bllAgenda = new Bll.Agenda();
     bllAgenda.insert(agenda);
 }