public void Insert_Agendamento(Agendamento_Estetica c)
        {
            cf = new ConnectionFactory();

            StringBuilder query = new StringBuilder();

            query.AppendLine("INSERT INTO TB_AGENDAMENTO");
            query.AppendLine(" (CLIENTE_AGEN,DATA_AGEN,HORA_AGEN) ");
            query.AppendLine("VALUES (@CLIENTE_AGEN,@DATA_AGEN,@HORA_AGEN) ");
            query.AppendLine("SELECT SCOPE_IDENTITY();");

            cf.Comando = cf.Conexao.CreateCommand();

            cf.Comando.Parameters.AddWithValue("@CLIENTE_AGEN", c.NomeCliente);
            cf.Comando.Parameters.AddWithValue("@DATA_AGEN", c.Data);
            cf.Comando.Parameters.AddWithValue("@HORA_AGEN", c.Hora);

            cf.Comando.CommandType = CommandType.Text;
            cf.Comando.CommandText = query.ToString();

            cf.Conexao.Open();

            c.IdAgendmento = Convert.ToInt32(cf.Comando.ExecuteScalar());
            cf.Conexao.Close();
        }
        public List <Agendamento_Estetica> FindClienteAgen()
        {
            cf = new ConnectionFactory();

            string query = "SELECT ID_CLINTE, NM_CLIENTE FROM CLIENTE";

            cf.Comando = cf.Conexao.CreateCommand();

            cf.Comando.CommandType = CommandType.Text;

            cf.Comando.CommandText = query;

            cf.Conexao.Open();

            List <Agendamento_Estetica> lista = new List <Agendamento_Estetica>();

            SqlDataReader dr = cf.Comando.ExecuteReader();

            while (dr.Read())
            {
                Agendamento_Estetica c = new Agendamento_Estetica();
                c.IdCliente1  = Convert.ToInt32(dr["ID_CLINTE"]);
                c.NomeCliente = Convert.ToString(dr["NM_CLIENTE"]);
                lista.Add(c);
            }
            cf.Conexao.Close();

            return(lista);
        }
        public Agendamento_Estetica FindByIdAgendamento(int id)
        {
            string query = "SELECT ID_AGEN,CLIENTE_AGEN,DATA_AGEN,HORA_AGEN FROM TB_AGENDAMENTO WHERE ID_AGEN = @ID";
            //Cria um objeto do tipo Pessoa
            Agendamento_Estetica c = new Agendamento_Estetica();

            cf         = new ConnectionFactory();
            cf.Comando = cf.Conexao.CreateCommand();
            cf.Comando.Parameters.AddWithValue("@ID", id);
            cf.Comando.CommandType = CommandType.Text;
            cf.Comando.CommandText = query;

            cf.Conexao.Open();
            //Objeto SqlDataReader: Armazena um buffer dos resultados da consulta
            SqlDataReader reader = cf.Comando.ExecuteReader();

            //Se o buffer conter linhas, entrará no IF parar ler os dados da pessoa
            //e carregar o objeto que será devolvido pelo Método
            if (reader.Read())
            {
                c.IdAgendmento = Convert.ToInt32(reader["ID_AGEN"]);
                c.NomeCliente  = reader["CLIENTE_AGEN"].ToString();
                c.Data         = Convert.ToDateTime(reader["DATA_AGEN"]);
                c.Hora         = Convert.ToDateTime(reader["HORA_AGEN"]);
            }
            cf.Conexao.Close();
            return(c); //Retorna o objeto do tipo Pessoa
        }
        private void AtualizarFinalizado()
        {
            Agendamento_Estetica p = new Agendamento_Estetica();

            p.IdAgendmento = Convert.ToInt32(txtId.Text);

            aService.UpdateFina(p);
        }
        private void AtualizarCancelamento()
        {
            Agendamento_Estetica p = new Agendamento_Estetica();

            p.Data         = Convert.ToDateTime(txtData.Text);
            p.Hora         = Convert.ToDateTime(txtHora.Text);
            p.IdAgendmento = Convert.ToInt32(txtId.Text);

            aService.UpdateCancelamento(p);
        }
        private void adicionar()
        {
            Agendamento_Estetica c = new Agendamento_Estetica();

            c.IdCliente1  = Convert.ToInt32(ddlCliente.SelectedValue);
            c.NomeCliente = ddlCliente.Text;
            c.Data        = Convert.ToDateTime(txtData.Text);
            c.Hora        = Convert.ToDateTime(txtHora.Text);

            aService.Insert(c);
        }
        public bool Insert(Agendamento_Estetica c)
        {
            bool salvou = false;

            new AgendamentoDAL().Insert_Agendamento(c);

            if (c.IdAgendmento > 0)
            {
                salvou = true;
            }
            return(salvou);
        }
        protected void btnAdicionar_Click(object sender, EventArgs e)
        {
            try
            {
                string idcli = ddlCliente.SelectedValue;
                List <Agendamento_Estetica> listCliente = new List <Agendamento_Estetica>();

                //foreach (GridViewRow linha in gvAgendamento.Rows)
                //{

                //    Agendamento_Estetica aLinha = new Agendamento_Estetica();
                //    aLinha.IdCliente1 = Convert.ToInt32(linha.Cells[0].Text);
                //    aLinha.NomeCliente = linha.Cells[1].Text;
                //    aLinha.Data = Convert.ToDateTime(linha.Cells[2].Text);
                //    aLinha.Hora = Convert.ToDateTime(linha.Cells[3].Text);


                //    listCliente.Add(aLinha);

                //}



                Agendamento_Estetica c = new Agendamento_Estetica();

                c.IdCliente1  = Convert.ToInt32(idcli);
                c.NomeCliente = ddlCliente.SelectedItem.Text;
                c.Data        = Convert.ToDateTime(txtData.Text);
                c.Hora        = Convert.ToDateTime(txtHora.Text);

                listCliente.Add(c);

                gvAgendamento.DataSource = listCliente;
                gvAgendamento.DataBind();

                btnSalvarBanco.Visible = true;
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

            //try
            //{
            //    adicionar();
            //}
            //catch (Exception)
            //{

            //    throw;
            //}
        }
 private void EditarAgendamento()
 {
     if (!string.IsNullOrEmpty(Request.QueryString["AgendamentoId"]))
     {
         int ClienteID          = Convert.ToInt32(Request.QueryString["AgendamentoId"].ToString());
         Agendamento_Estetica a = aService.FindByIdAgendamento(ClienteID);
         txtId.Text      = a.IdAgendmento.ToString();
         ddlCliente.Text = a.NomeCliente.ToString();
         txtData.Text    = a.Data.ToString();
         txtHora.Text    = a.Hora.ToString();
     }
     //Metodo para desbloquear os botões de Cancelar e Reagendar
     DesbloquearButoes();
     BloquearCampos();
 }
Example #10
0
 private void AtualizarFinalizadoComMedida()
 {
     try
     {
         Agendamento_Estetica p = new Agendamento_Estetica();
         p.IdAgendmento = Convert.ToInt32(txtAgemdamento.Text);
         if (aService.UpdateFina(p))
         {
             InserirMedidas();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public bool UpdateFina(Agendamento_Estetica P)
        {
            bool           atualizou = false;
            AgendamentoDAL pDAL      = new AgendamentoDAL();

            //if (P.Id == 0)
            //{
            //    throw new Exception("Selecione uma pessoa para atualizar.");
            //}

            if (pDAL.UpdateFinalizado(P) > 0)
            {
                //Este IF verificará se o retorno do método será maior que 0,
                //ou seja, se a atualização foi feita pela classe que acessa o Banco
                //se sim vai mudar para TRUE a variável e retornar para quem chamou este método.
                atualizou = true;
            }
            return(atualizou);
        }
        public int UpdateFinalizadoComMedida(Agendamento_Estetica a)
        {
            cf = new ConnectionFactory();
            string query = "USP_TB_AGENDAMENTO_UPD_FIN";

            //Variável guardará a quantidade de linhas afetadas
            int linhasAfetadas = 0;

            //PARAMETROS
            cf.Comando = cf.Conexao.CreateCommand();
            cf.Comando.Parameters.AddWithValue("@ID_AGEN", a.IdAgendmento);//Necessário ID para saber que registro será atualizado

            cf.Comando.CommandType = CommandType.StoredProcedure;
            cf.Comando.CommandText = query;
            cf.Conexao.Open();
            //ExecuteNonQuery: Retorna o número de linhas afetadas no Banco de dados para a variável.
            linhasAfetadas = cf.Comando.ExecuteNonQuery();
            cf.Conexao.Close();

            //Este método retorna um número inteiro, conforme o que a assinatura pede.
            return(linhasAfetadas);
        }
        public void SalvarBAnco()
        {
            List <Agendamento_Estetica> listCliente1 = new List <Agendamento_Estetica>();
            bool salvou = false;

            foreach (GridViewRow linha in gvAgendamento.Rows)
            {
                Agendamento_Estetica c = new Agendamento_Estetica();
                c.NomeCliente = linha.Cells[1].Text;
                c.Data        = Convert.ToDateTime(linha.Cells[2].Text);
                c.Hora        = Convert.ToDateTime(linha.Cells[3].Text);

                listCliente1.Add(c);
            }
            foreach (Agendamento_Estetica c in listCliente1)
            {
                salvou = aService.Insert(c);
            }
            if (salvou)
            {
                //carregarClientes();
            }
        }
        public List <Agendamento_Estetica> FindAll()
        {
            //Consulta tebale de agendamento usando select
            StringBuilder query = new StringBuilder();

            query.AppendLine("SELECT ID_AGEN, CLIENTE_AGEN, DATA_AGEN, HORA_AGEN, AGEN_SITUACAO FROM TB_AGENDAMENTO ORDER BY  DATA_AGEN ASC");

            //Abrir conexão com o banco de dados
            cf                     = new ConnectionFactory();
            cf.Comando             = cf.Conexao.CreateCommand();
            cf.Comando.CommandType = CommandType.Text;
            cf.Comando.CommandText = query.ToString();

            //Cria uma lista, que armazenárá os resultados da consulta
            List <Agendamento_Estetica> listaAgendamento = new List <Agendamento_Estetica>();

            cf.Conexao.Open();                                 //Abre a conexão
            SqlDataReader reader = cf.Comando.ExecuteReader(); //Executando o comando

            while (reader.Read())
            {
                Agendamento_Estetica p = new Agendamento_Estetica();//Instanciando o objeto da iteração
                //Preenchimento das propriedades a partir do que retornou no banco.
                p.IdAgendmento = Convert.ToInt32(reader["ID_AGEN"]);
                p.NomeCliente  = reader["CLIENTE_AGEN"].ToString();
                p.Data         = Convert.ToDateTime(reader["DATA_AGEN"]);
                p.Hora         = Convert.ToDateTime(reader["HORA_AGEN"]);
                p.Status       = reader["AGEN_SITUACAO"].ToString();

                listaAgendamento.Add(p);//Adicionando o objeto para a lista
            }
            //Fechando a conexão
            cf.Conexao.Close();

            //Retornando a lista já carregada.
            return(listaAgendamento);
        }