Buscar

PIM Final

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes
Você viu 3, do total de 192 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes
Você viu 6, do total de 192 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes
Você viu 9, do total de 192 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

Prévia do material em texto

1 
 
UNIVERSIDADE PAULISTA 
 
Amanda Cristina da Silva 
Daniel Felipe Oliveira Soares da Cunha 
Gabriel Correia Amorim 
Jhonatan Santos Gomes 
Keslander Antunes Santana 
Lyvia Ravenna Dias Cruz 
 
 
 
 
 
 
 
 
 
Sistemas de Gerenciamento para Hotelaria 
 
 
 
 
 
 
 
 
 
 
 
 
 
São Paulo 
2021 
 
 
2 
 
Amanda Cristina da Silva 
Daniel Felipe Oliveira Soares da Cunha 
Gabriel Correia Amorim 
Jhonatan Santos Gomes 
Keslander Antunes Santana 
Lyvia Ravenna Dias Cruz 
 
 
 
 
 
 
 
 
Sistemas de Gerenciamento para Hotelaria 
 
 
 
 
 
 
Projeto Integrado Multidisciplinar do Curso da 
Universidade Paulista. 
 
Orientador: Mestre Sandra Bozolan 
 
 
 
 
 
 
São Paulo 
2021
 
 
3 
 
RESUMO 
 
 
Em nosso projeto abordamos o tema sobre hotelaria, dentro do mesmo tivemos 
diversas fases de aprimoramento. Começamos por etapas, desde a recepção à 
finalização do pedido, também criamos todo o processo tecnológico que ajudará o 
bom andamento dos serviços prestados pelo hotel. 
O software desenvolvido irá fazer o controle do sistema da hotelaria, como, cadastro 
de hospedes, quartos, reservas, funcionários, serviços e hospedagem. 
 
Palavras chaves: hotel, software, tecnologia, serviços. 
 
 
4 
 
LISTA DE FIGURAS 
 
Figura 1 - Modelo Conceitual 12 
Figura 2 - Modelo Logico 13 
Figuras 3 a 6 – Telas Mobile 14 
a 18 
Figura 7 a 11 – Telas Web 19 
a 21 
Figura 12 a 16 – Telas Desktop 22 a 
25 
Figura 17 e 18 – Diagramas de Casos de Uso 26 
Figura 19 – Diagrama de Classes 27 
Figura 20 – Diagrama de Sequência 28 
Figura 21 – Diagrama de Implantação 29 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5 
 
LISTA DE TABELAS 
 
Tabela 1 – Planilha de Banco de Dados 32 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6 
 
LISTA DE ABREVIATURAS E SIGLAS 
 
 LGPD - Lei geral Proteção de Dados 
 
 SQL - Structured Query Language 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7 
 
SUMÁRIO 
 
 
INTRODUÇÃO 8 
OBJETIVOS 9 
JUSTIFICATIVA 10 
ESTRUTURA DO TRABALHO 122 
DESENVOLVIMENTO 31 
MANUAL DE USO DO SISTEMA 189 
CONCLUSÃO 191 
REFERÊNCIAS BIBLIOGRAFICAS 192 
 
 
 
 
 
8 
 
INTRODUÇÃO 
 
 Numa era globalizada, prestadores de serviços, especialmente as 
organizações hoteleiras, convivem em um ambiente de alta competitividade. A 
necessidade de conquista do cliente não consiste só em atender, mas inclui 
inovar, encantar e surpreender e isso pressupõe conhecer as expectativas dos 
clientes para executar ações que permitam não apenas atendê-las, mas acima 
de tudo, superá-las. (MINCIOTTI; SANTOLIA; KASPAR, 2008). 
 A indústria hoteleira, do setor de serviços, tem se mostrado um 
importante segmento da economia em termos de movimentação de recursos, 
geração de empregos e principalmente atração de capital. Portanto, há a necessidade 
de estar sempre se inovando, buscando o melhor para seus clientes, preparar seus 
funcionários para atender bem e acima de tudo está atento à necessidade de cada 
cliente em especial. (SOUZA, 2006). 
 Segundo Silva (2004), a qualidade e excelência nos serviços, e tem sempre 
como foco a sua satisfação, e diante disso tem-se constatado que as empresas estão 
cada vez mais buscando recursos para encantar e conquistar cada um de seus 
clientes. 
 A hotelaria é parte da infraestrutura da atividade turística e possui lugar 
de destaque no cenário turístico. Castelli (2003) considera essa como uma 
14 indústria de serviços com características próprias e que tem por finalidade 
oferecer hospedagem, alimentação e segurança aos clientes. A hospedagem é 
um somatório de bens e serviços que atendem às necessidades e preferências 
dos hóspedes. Este setor busca satisfazer as expectativas de acomodação das 
pessoas que por algum motivo estão fora de seus domicílios e por isso, 
necessitam de um local para se abrigar, algo que proporcione conforto e bem 
estar, independentemente do tipo de turismo que as pessoas pratiquem. 
 A hotelaria é uma reunião de diversos serviços e amenidades prestadas a um 
grande público. Podemos destacar, como seus três pilares principais, a hospedagem, 
a alimentação e os eventos. A hotelaria possui uma missão crítica: diz que “o hotel 
não tem chave” para significar sua operação durante as 24 horas do dia, 7 dias por 
semana e 365 dias por ano. (Gomes, 2014). 
 
 
9 
 
OBJETIVOS 
 
Objetivo Geral 
Nosso objetivo é ter um sistema eficaz e de fácil entendimento, que atenda ao usuário 
e seja simples de manusear e usar. 
 
Objetivos Específicos 
● Desenvolver e aplicar conhecimentos adquiridos; 
● Efetuação de cadastro e reservas; 
● Desenvolver menus de fácil aprendizagem e interação; 
● Sistema de acordo com as normas LGPD; 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10 
 
JUSTIFICATIVA 
O presente trabalho irá ter uma contribuição no projeto onde abrangerá três sistemas 
integrados (Desk, web, Mobile), servindo de auxílio no dia a dia para o gerenciamento 
de hotéis. O sistema poderá ser expandido conforme o crescimento da rede do hotel. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11 
 
Regras de negócio 
 
Cadastro de reserva 
 
❖ Só poderá acessar o aplicativo mediante a cadastro! 
❖ Para reservar um hotel é necessário especificar a quantidade de diárias e as 
datas das mesmas! 
❖ Informar os dados corretamente para realizar a reserva! 
 
Vendas 
 
❖ Poderá ser reservado o quarto mediante a todos os dados inseridos, completos 
e corretamente. 
❖ Poderá ser cancelada a reserva com até 10 dias de antecedência, caso 
contrário será cobrado multa de meia diária por não cumprir o requisito. 
❖ Obrigatório a confirmação de dados ao adentrar ao hotel antes do check-in. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12 
 
ESTRUTURA DO TRABALHO 
 
DIAGRAMAS ENTIDADE RELACIONAL 
 
MODELO CONCEITUAL 
 
 
 
 
 
 
 
 
 
 
 
 
 
13 
 
MODELO LÓGICO 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14 
 
Telas do Sistema 
 As telas foram projetadas em Figma e Pencil 
 
Projeto Mobile 
 
Tela Login 
 
 
 
 
 
 
 
 
 
 
 
 
 
15 
 
Tela de Quartos para Reserva 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16 
 
 
Tela de Informação do Quarto 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17 
 
Tela de Escolha de Data para Hospedagem 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18 
 
Tela de Reserva Efetuadas pelo Usuário ! 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19 
 
Projeto Web 
 
Tela Principal de Login 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20 
 
Tela Reserva 
 
 
Tela desobre nos 
 
 
 
 
 
 
 
 
 
 
21 
 
Tela Cadastro de Cliente 
 
 
 
 
Tela de acomodações! 
 
 
 
 
 
 
 
 
22 
 
Projeto Desktop 
 
Tela de Login 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23 
 
Tela de Cadastro Funcionário 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24 
 
Tela de Reserva 
 
 
 
 
 
 
Tela Serviços de Quarto 
 
 
 
 
 
 
 
 
 
25 
 
Tela Cadastro de Cliente 
 
 
 
 
 
 
 
 
 
26 
 
Diagrama de Caso de Uso 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28 
 
Diagrama de Classe 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29 
 
Diagrama de Sequência 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30 
 
Diagrama de Implantação 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31 
 
 
DESENVOLVIMENTO 
Desk tabela login: 
 
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
using System.Data.SqlClient; 
 
 
namespace hotel 
{ 
 
 public partial class login : Form 
 { 
 SqlConnection conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 
 //Referencia da conexão 
 
 public login() 
 { 
 InitializeComponent(); 
 txtUsuario.Select();//cursor começa no campo 
 } 
 
 private void label1_Click(object sender, EventArgs e) 
 
 
32 
 
 { 
 
 
 } 
 
 private void label2_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 private void btnclose_Click(object sender, EventArgs e) 
 { 
 Application.Exit(); 
 
 } 
 
 private void textBox1_TextChanged(object sender, EventArgs e) 
 { 
 txtUsuario.BackColor = Color.White; 
 panel3.BackColor = Color.White; 
 panel4.BackColor = SystemColors.Control; 
 txtPassword.BackColor = SystemColors.Control; 
 } 
 
 private void panel2_Paint(object sender, PaintEventArgs e) 
 { 
 
 } 
 
 private void label9_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 
 
33 
 
 private void textBox2_TextChanged(object sender, EventArgs e) 
 { 
 txtPassword.BackColor = Color.White; 
 panel4.BackColor = Color.White; 
 panel3.BackColor = SystemColors.Control; 
 txtUsuario.BackColor = SystemColors.Control; 
 } 
 //verificação de campos txtusuario e txtPassword estão preenchidos 
 void verificar() 
 { 
 if (txtUsuario.Text =="" && txtPassword.Text == "") 
 { 
 MessageBox.Show("Preencha todos os campos!!", "Erro", 
MessageBoxButtons.OK, MessageBoxIcon.Error); 
 txtUsuario.Select(); 
 } 
 } 
 
 private void label8_Click(object sender, EventArgs e) 
 { 
 //textBox2.UseSystemPasswordChar = false; 
 // textBox2.UseSystemPasswordChar = true; 
 } 
 
 private void label8_Click(object sender, MouseEventArgs e) 
 { 
 
 } 
 //botão entrar/login 
 private void btnLogin_Click(object sender, EventArgs e) 
 { 
 conexao.Open(); //abrir a conexão 
 verificar(); 
 
 
34 
 
 string query = "select * from loginUser Where Username = '" + txtUsuario.Text 
+ "' and Password = '" + txtPassword.Text + "'"; 
 SqlDataAdapter dp = new SqlDataAdapter(query,conexao); 
 DataTable dt = new DataTable(); 
 dp.Fill(dt); 
 
 
 
 if (dt.Rows.Count == 1) 
 { 
 FrmPrincipal principal = new FrmPrincipal(); 
 this.Hide(); 
 principal.Show(); 
 
 } 
 else 
 { 
 MessageBox.Show("User ou Senha Incorreta!!", "Erro", 
MessageBoxButtons.OK, MessageBoxIcon.Error); 
 txtUsuario.Text = "";//vai zerar o campo user 
 txtPassword.Text = "";//vai zerar o campo senha 
 txtUsuario.Select(); //cursor volta para o campo 
 } 
 conexao.Close();// se tudo der certo ele fecha a conexão 
 } 
 
 private void panel2_Paint_1(object sender, PaintEventArgs e) 
 { 
 
 } 
 
 private void label11_Click(object sender, EventArgs e) 
 { 
 
 
 
35 
 
 } 
 } 
} 
 
 
 
código do FrmPrincipal: 
 
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
 
namespace hotel 
{ 
 public partial class FrmPrincipal : Form 
 { 
 private Form _objForm; 
 public FrmPrincipal() 
 { 
 InitializeComponent(); 
 } 
 
 private void btnTerminar_Click(object sender, EventArgs e) 
 { 
 login Login = new login(); 
 this.Hide(); 
 Login.Show(); 
 } 
 
 
36 
 
 public void OpenChildForm(Form childform, object sender) 
 { 
 
 } 
 
 private void btnFun_Click(object sender, EventArgs e) 
 { 
 _objForm?.Close(); 
 
 _objForm = new FrmFunc 
 { 
 TopLevel = false,//vai Desrespeitar a Hieraquia das classes 
 FormBorderStyle = FormBorderStyle.None, 
 Dock = DockStyle.Fill 
 
 }; 
 pnlBaseForm.Controls.Add(_objForm); 
 _objForm.Show(); 
 
 } 
 
 private void btnCliente_Click(object sender, EventArgs e) 
 { 
 _objForm?.Close(); 
 
 _objForm = new FrmCliente 
 { 
 TopLevel = false,//vai Desrespeitar a Hieraquia das classes 
 FormBorderStyle = FormBorderStyle.None, 
 Dock = DockStyle.Fill 
 
 }; 
 pnlBaseForm.Controls.Add(_objForm); 
 _objForm.Show(); 
 
 
37 
 
 
 } 
 
 private void btnReserva_Click(object sender, EventArgs e) 
 { 
 _objForm?.Close(); 
 
 _objForm = new FrmReserva 
 { 
 TopLevel = false,//vai Desrespeitar a Hieraquia das classes 
 FormBorderStyle = FormBorderStyle.None, 
 Dock = DockStyle.Fill 
 
 }; 
 pnlBaseForm.Controls.Add(_objForm); 
 _objForm.Show(); 
 
 } 
 
 private void btnServico_Click(object sender, EventArgs e) 
 { 
 
 _objForm?.Close(); 
 
 _objForm = new FrmServico 
 { 
 TopLevel = false,//vai Desrespeitar a Hieraquia das classes 
 FormBorderStyle = FormBorderStyle.None, 
 Dock = DockStyle.Fill 
 
 }; 
 pnlBaseForm.Controls.Add(_objForm); 
 _objForm.Show(); 
 
 
 
38 
 
 } 
 
 private void btnFinal_Click(object sender, EventArgs e) 
 { 
 
 _objForm?.Close(); 
 
 _objForm = new FrmVendas 
 { 
 TopLevel = false,//vai Desrespeitar a Hieraquia das classes 
 FormBorderStyle = FormBorderStyle.None, 
 Dock = DockStyle.Fill}; 
 pnlBaseForm.Controls.Add(_objForm); 
 _objForm.Show(); 
 
 
 } 
 } 
} 
 
FrmCliente 
 
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
using Newtonsoft.Json; 
 
 
39 
 
using System.Net.Http; 
using System.Data.SqlClient; 
 
namespace hotel 
{ 
 public partial class FrmCliente : Form 
 { 
 SqlConnection conexao; 
 SqlCommand comando; 
 SqlDataAdapter da; 
 SqlDataReader dr; 
 
 string strSQL; 
 public FrmCliente() 
 { 
 InitializeComponent(); 
 } 
 
 private void FrmCliente_Load(object sender, EventArgs e) 
 { 
 
 } 
 
 private void label1_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 private void dataGridView1_CellContentClick(object sender, 
DataGridViewCellEventArgs e) 
 { 
 
 } 
 
 
 
40 
 
 private void btnLimpar_Click(object sender, EventArgs e) 
 { 
 txtCEPC.Text = string.Empty; 
 txtUF.Text = string.Empty; 
 txtLog.Text = string.Empty; 
 txtCid.Text = string.Empty; 
 txtBairro.Text = string.Empty; 
 } 
 
 private void panel1_Paint(object sender, PaintEventArgs e) 
 { 
 
 } 
 
 private void btnBuscarF_Click(object sender, EventArgs e) 
 { 
 if (string.IsNullOrWhiteSpace(txtCEPC.Text))// se o espaço estiver em branco 
 { 
 MessageBox.Show("Informe um CEP valido", this.Text, 
MessageBoxButtons.OK, MessageBoxIcon.Error); 
 } 
 else 
 { 
 string strUrl = string.Format("https://viacep.com.br/ws/{0}/json/", 
txtCEPC.Text.Trim()); 
 
 try 
 { 
 using (HttpClient client = new HttpClient()) 
 { 
 var response = client.GetAsync(strUrl).Result; 
 if (response.IsSuccessStatusCode) 
 { 
 var result = response.Content.ReadAsStringAsync().Result; 
 
 
41 
 
 Resultado res = JsonConvert.DeserializeObject<Resultado>(result); 
 
 txtUF.Text = res.UF; 
 txtCid.Text = res.Localidade; 
 txtBairro.Text = res.Bairro; 
 txtLog.Text = res.Logradouro; 
 
 } 
 
 } 
 
 } 
 catch (Exception ex) 
 { 
 MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, 
MessageBoxIcon.Error); 
 } 
 } 
 } 
 
 private void btnCadC_Click(object sender, EventArgs e) 
 { 
 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "INSERT INTO Cliente(Nome, CPF, Telefone, DataNasc, CEP, 
Logradouro, Bairro, Cidade, UF) VALUES (@Nome, @CPF, @Telefone, @DataNasc, 
@CEP, @Logradouro, @Bairro, @Cidade, @UF)"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@Nome", txtNomeC.Text); 
 
 
42 
 
 comando.Parameters.AddWithValue("@CPF", txtCPFC.Text); 
 comando.Parameters.AddWithValue("@Telefone", txtTelC.Text); 
 comando.Parameters.AddWithValue("@DataNasc", txtDataNascC.Text); 
 comando.Parameters.AddWithValue("@CEP", txtCEPC.Text); 
 comando.Parameters.AddWithValue("@Logradouro", txtLog.Text); 
 comando.Parameters.AddWithValue("@Bairro", txtBairro.Text); 
 comando.Parameters.AddWithValue("@Cidade", txtCid.Text); 
 comando.Parameters.AddWithValue("@UF", txtUF.Text); 
 
 conexao.Open(); 
 comando.ExecuteNonQuery(); 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 comando.Clone(); 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void btnExibirC_Click(object sender, EventArgs e) 
 { 
 try 
 { 
 
 
43 
 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "Select * From Cliente"; 
 
 
 DataSet ds = new DataSet(); 
 
 da = new SqlDataAdapter(strSQL, conexao); 
 
 
 conexao.Open(); 
 da.Fill(ds); 
 dgvC.DataSource = ds.Tables[0]; 
 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void btnConsultaC_Click(object sender, EventArgs e) 
 { 
 
 
44 
 
 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "Select * From Cliente Where CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@CPF", txtCPFC.Text); 
 
 conexao.Open(); 
 dr = comando.ExecuteReader(); 
 
 while (dr.Read()) 
 { 
 txtNomeC.Text = (string)dr["Nome"]; 
 txtTelC.Text = Convert.ToString(dr["Telefone"]); 
 txtDataNascC.Text = Convert.ToString(dr["DataNasc"]); 
 txtCEPC.Text = (string)dr["CEP"]; 
 txtLog.Text = (string)dr["Logradouro"]; 
 txtBairro.Text = (string)dr["Bairro"]; 
 txtCid.Text = (string)dr["Cidade"]; 
 txtUF.Text = (string)dr["UF"]; 
 } 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 
 
45 
 
 conexao.Close(); 
 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void btnAlterarF_Click(object sender, EventArgs e) 
 { 
 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "UPDATE Cliente set Nome = @Nome, Telefone = @Telefone, 
DataNasc = @DataNasc, CEP = @CEP, Logradouro = @Logradouro, Bairro = 
@Bairro, Cidade = @Cidade, UF = @UF Where CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@Nome", txtNomeC.Text); 
 comando.Parameters.AddWithValue("@CPF", txtCPFC.Text); 
 comando.Parameters.AddWithValue("@Telefone", txtTelC.Text); 
 comando.Parameters.AddWithValue("@DataNasc", txtDataNascC.Text); 
 comando.Parameters.AddWithValue("@CEP", txtCEPC.Text);comando.Parameters.AddWithValue("@Logradouro", txtLog.Text); 
 comando.Parameters.AddWithValue("@Bairro", txtBairro.Text); 
 comando.Parameters.AddWithValue("@Cidade", txtCid.Text); 
 comando.Parameters.AddWithValue("@UF", txtUF.Text); 
 
 conexao.Open(); 
 comando.ExecuteNonQuery(); 
 
 
46 
 
 
 MessageBox.Show("Cliente Cadastrado com Sucesso"); 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 comando.Clone(); 
 conexao = null; 
 comando = null; 
 
 
 } 
 
 } 
 
 private void btnExcluir_Click(object sender, EventArgs e) 
 { 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "DELETE Cliente WHERE CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 
 comando.Parameters.AddWithValue("@CPF", txtCPFC.Text); 
 
 
 
47 
 
 conexao.Open(); 
 comando.ExecuteNonQuery(); 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 comando.Clone(); 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void label10_Click(object sender, EventArgs e) 
 { 
 
 } 
 } 
} 
 
Frm Funcionario 
 
using Newtonsoft.Json; 
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
 
 
48 
 
using System.Drawing; 
using System.Linq; 
using System.Net.Http; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
using System.Data.SqlClient; 
 
namespace hotel 
{ 
 public partial class FrmFunc : Form 
 { 
 SqlConnection conexao; 
 SqlCommand comando; 
 SqlDataAdapter da; 
 SqlDataReader dr; 
 
 string strSQL; 
 public FrmFunc() 
 { 
 InitializeComponent(); 
 
 
 } 
 
 private void FrmFunc_Load(object sender, EventArgs e) 
 { 
 
 } 
 
 private void label4_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 
49 
 
 
 private void label4_Click_1(object sender, EventArgs e) 
 { 
 
 } 
 
 private void label6_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 private void label10_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 private void button1_Click(object sender, EventArgs e) 
 { 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "INSERT INTO Funcionario(Nome, CPF, Telefone, DataNasc, 
CEP, Logradouro, Bairro, Cidade, UF) VALUES (@Nome, @CPF, @Telefone, 
@DataNasc, @CEP, @Logradouro, @Bairro, @Cidade, @UF)"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@Nome", txtNomeF.Text); 
 comando.Parameters.AddWithValue("@CPF", txtCPF.Text); 
 comando.Parameters.AddWithValue("@Telefone", txtTelF.Text); 
 comando.Parameters.AddWithValue("@DataNasc", txtDataNasc.Text); 
 comando.Parameters.AddWithValue("@CEP", txtCEPF.Text); 
 comando.Parameters.AddWithValue("@Logradouro", txtLog.Text); 
 
 
50 
 
 comando.Parameters.AddWithValue("@Bairro", txtBairro.Text); 
 comando.Parameters.AddWithValue("@Cidade", txtCid.Text); 
 comando.Parameters.AddWithValue("@UF", txtUF.Text); 
 
 conexao.Open(); 
 comando.ExecuteNonQuery(); 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 comando.Clone(); 
 conexao = null; 
 comando = null; 
 
 
 } 
 
 
 
 } 
 
 private void FrmFunc_Load_1(object sender, EventArgs e) 
 { 
 
 } 
 
 private void button2_Click(object sender, EventArgs e) 
 { 
 
 
51 
 
 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "Select * From Funcionario Where CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@CPF", txtCPF.Text); 
 
 conexao.Open(); 
 dr = comando.ExecuteReader(); 
 
 while (dr.Read()) 
 { 
 txtNomeF.Text = (string)dr["Nome"]; 
 txtTelF.Text = Convert.ToString(dr["Telefone"]); 
 txtDataNasc.Text = Convert.ToString(dr["DataNasc"]); 
 txtCEPF.Text = (string)dr["CEP"]; 
 txtLog.Text = (string)dr["Logradouro"]; 
 txtBairro.Text = (string)dr["Bairro"]; 
 txtCid.Text = (string)dr["Cidade"]; 
 txtUF.Text = (string)dr["UF"]; 
 } 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 
 
52 
 
 conexao.Close(); 
 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void btnBuscarF_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 private void btnLimpar_Click(object sender, EventArgs e) 
 { 
 txtCEPF.Text = string.Empty; 
 txtUF.Text = string.Empty; 
 txtLog.Text = string.Empty; 
 txtCid.Text = string.Empty; 
 txtBairro.Text = string.Empty; 
 
 } 
 
 private void btnConsultar_Click(object sender, EventArgs e) 
 { 
 if (string.IsNullOrWhiteSpace(txtCEPF.Text))// se o espaço estiver em branco 
 { 
 MessageBox.Show("Informe um CEP valido", this.Text, 
MessageBoxButtons.OK, MessageBoxIcon.Error); 
 } 
 else 
 { 
 
 
53 
 
 string strUrl = string.Format("https://viacep.com.br/ws/{0}/json/", 
txtCEPF.Text.Trim()); 
 
 try 
 { 
 using (HttpClient client = new HttpClient()) 
 { 
 var response = client.GetAsync(strUrl).Result; 
 if (response.IsSuccessStatusCode) 
 { 
 var result = response.Content.ReadAsStringAsync().Result; 
 Resultado res = JsonConvert.DeserializeObject<Resultado>(result); 
 
 txtUF.Text = res.UF; 
 txtCid.Text = res.Localidade; 
 txtBairro.Text = res.Bairro; 
 txtLog.Text = res.Logradouro;} 
 
 } 
 
 } 
 catch (Exception ex) 
 { 
 MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, 
MessageBoxIcon.Error); 
 } 
 } 
 } 
 
 private void label1_Click(object sender, EventArgs e) 
 { 
 
 
 
54 
 
 } 
 
 private void txtCPF_TextChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 private void btnExibir_Click(object sender, EventArgs e) 
 { 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "Select * From Funcionario"; 
 
 
 DataSet ds = new DataSet(); 
 
 da = new SqlDataAdapter(strSQL, conexao); 
 
 
 conexao.Open(); 
 da.Fill(ds); 
 dgvFunc.DataSource = ds.Tables[0]; 
 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 
 
55 
 
 conexao.Close(); 
 
 conexao = null; 
 comando = null; 
 
 
 } 
 
 } 
 
 private void btnAlterarF_Click(object sender, EventArgs e) 
 { 
 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "UPDATE Funcionario set Nome = @Nome, Telefone = 
@Telefone, DataNasc = @DataNasc, CEP = @CEP, Logradouro = @Logradouro, 
Bairro = @Bairro, Cidade = @Cidade, UF = @UF Where CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@Nome", txtNomeF.Text); 
 comando.Parameters.AddWithValue("@CPF", txtCPF.Text); 
 comando.Parameters.AddWithValue("@Telefone", txtTelF.Text); 
 comando.Parameters.AddWithValue("@DataNasc", txtDataNasc.Text); 
 comando.Parameters.AddWithValue("@CEP", txtCEPF.Text); 
 comando.Parameters.AddWithValue("@Logradouro", txtLog.Text); 
 comando.Parameters.AddWithValue("@Bairro", txtBairro.Text); 
 comando.Parameters.AddWithValue("@Cidade", txtCid.Text); 
 comando.Parameters.AddWithValue("@UF", txtUF.Text); 
 
 conexao.Open(); 
 
 
56 
 
 comando.ExecuteNonQuery(); 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 comando.Clone(); 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void label5_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 private void txtTelF_TextChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 private void btnExcluir_Click(object sender, EventArgs e) 
 { 
 try 
 { 
 
 
57 
 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "DELETE Funcionario WHERE CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 
 comando.Parameters.AddWithValue("@CPF", txtCPF.Text); 
 
 conexao.Open(); 
 comando.ExecuteNonQuery(); 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 comando.Clone(); 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 } 
 } 
 
Frm Reserva 
 
using System; 
 
 
58 
 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
using System.Data.SqlClient; 
 
namespace hotel 
{ 
 public partial class FrmReserva : Form 
 { 
 
 SqlConnection conexao; 
 SqlCommand comando; 
 SqlDataAdapter da; 
 SqlDataReader dr; 
 
 string strSQL; 
 public FrmReserva() 
 { 
 InitializeComponent(); 
 } 
 
 private void btnPegardata_Click(object sender, EventArgs e) 
 { 
 txtEntrada.Text = monthCalendar1.SelectionStart.ToShortDateString(); 
 txtSaida.Text = monthCalendar1.SelectionEnd.ToShortDateString(); 
 
 } 
 
 private void FrmReserva_Load(object sender, EventArgs e) 
 
 
59 
 
 { 
 
 } 
 
 private void label3_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 private void txtcpfR_TextChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 private void button1_Click(object sender, EventArgs e) 
 { 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "INSERT INTO Reserva (Nome, CPF, Quarto, ValorDiaria, 
ValorTotal, dataEntrada, dataSaida ) VALUES (@Nome, @CPF, @Quarto, 
@ValorDiaria, @ValorTotal, @dataEntrada, @dataSaida)"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@Nome", txtNomeR.Text); 
 comando.Parameters.AddWithValue("@CPF", txtcpfR.Text); 
 comando.Parameters.AddWithValue("@Quarto", txtQuatos.Text); 
 comando.Parameters.AddWithValue("@ValorDiaria", txtValorDia.Text); 
 comando.Parameters.AddWithValue("@ValorTotal", txtDiariaTotal.Text); 
 comando.Parameters.AddWithValue("@dataEntrada", txtEntrada.Text); 
 comando.Parameters.AddWithValue("@dataSaida", txtSaida.Text); 
 
 
 
60 
 
 
 conexao.Open(); 
 comando.ExecuteNonQuery(); 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 comando.Clone(); 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void button1_Click_1(object sender, EventArgs e) 
 { 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "Select * From Reserva Where CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@CPF", txtcpfR.Text); 
 
 conexao.Open(); 
 
 
61 
 
 dr = comando.ExecuteReader(); 
 
 while (dr.Read()) 
 { 
 txtNomeR.Text = (string)dr["Nome"]; 
 txtQuatos.Text = (string)dr["Quarto"]; 
 txtValorDia.Text = (string)dr["ValorDiaria"]; 
 txtDiariaTotal.Text = (string)dr["ValorTotal"]; 
 txtEntrada.Text = Convert.ToString(dr["dataEntrada"]); 
 txtSaida.Text = Convert.ToString(dr["dataSaida"]);} 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void button1_Click_2(object sender, EventArgs e) 
 { 
 try 
 { 
 
 
62 
 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "Select * From Reserva"; 
 
 
 DataSet ds = new DataSet(); 
 
 da = new SqlDataAdapter(strSQL, conexao); 
 
 
 conexao.Open(); 
 da.Fill(ds); 
 dgvR.DataSource = ds.Tables[0]; 
 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void btnExcluirR_Click(object sender, EventArgs e) 
 { 
 
 
63 
 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "DELETE Reserva WHERE CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 
 comando.Parameters.AddWithValue("@CPF", txtcpfR.Text); 
 
 conexao.Open(); 
 comando.ExecuteNonQuery(); 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 comando.Clone(); 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void btnAlterarR_Click(object sender, EventArgs e) 
 { 
 
 
 
64 
 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "UPDATE Reserva set Nome = @Nome, Quarto = @Quarto, 
dataSaida = @dataSaida Where CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@Nome", txtNomeR.Text); 
 comando.Parameters.AddWithValue("@CPF", txtcpfR.Text); 
 comando.Parameters.AddWithValue("@Quarto", txtQuatos.Text); 
 comando.Parameters.AddWithValue ("@dataSaida", txtSaida.Text); 
 
 conexao.Open(); 
 comando.ExecuteNonQuery(); 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 comando.Clone(); 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 
 
65 
 
 private void txtDiariaTotal_TextChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 private void monthCalendar1_DateChanged(object sender, 
DateRangeEventArgs e) 
 { 
 
 } 
 
 private void txtCalcular_Click(object sender, EventArgs e) 
 { 
 float valorFinal; 
 float valorDiaria = float.Parse(txtValorDia.Text); 
 float Dias = float.Parse(txtDias.Text); 
 valorFinal = valorDiaria * Dias; 
 string ValorDia = valorFinal + ""; 
 txtDiariaTotal.Text = ValorDia; 
 } 
 } 
} 
 
FrmServiço 
 
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
 
 
66 
 
using System.Data.SqlClient; 
 
namespace hotel 
{ 
 public partial class FrmServico : Form 
 { 
 SqlConnection conexao; 
 SqlCommand comando; 
 SqlDataAdapter da; 
 SqlDataReader dr; 
 
 string strSQL; 
 public FrmServico() 
 { 
 InitializeComponent(); 
 } 
 
 private void label2_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 private void label3_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 private void txtcpfR_TextChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 private void label4_Click(object sender, EventArgs e) 
 { 
 
 
67 
 
 } 
 
 private void txtNomeR_TextChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 private void FrmServico_Load(object sender, EventArgs e) 
 { 
 
 } 
 
 private void textBox1_TextChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 private void label2_Click_1(object sender, EventArgs e) 
 { 
 
 } 
 
 private void btnConSer_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 private void dataGridView1_CellContentClick(object sender, 
DataGridViewCellEventArgs e) 
 { 
 
 } 
 
 private void btnBuscarS_Click(object sender, EventArgs e) 
 
 
68 
 
 { 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "Select * From Reserva Where CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@CPF", txtcpfS.Text); 
 
 conexao.Open(); 
 dr = comando.ExecuteReader(); 
 
 while (dr.Read()) 
 { 
 txtNomeS.Text = (string)dr["Nome"]; 
 txtQuaS.Text = (string)dr["Quarto"]; 
 
 
 
 } 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 
 conexao = null; 
 
 
69 
 
 comando = null; 
 
 
 } 
 
 } 
 
 private void btnNovoSer_Click(object sender, EventArgs e) 
 { 
 
 txtcpfS.Text = string.Empty; 
 txtNomeS.Text = string.Empty; 
 txtQuaS.Text = string.Empty; 
 txtValorSer.Text = string.Empty; 
 
 } 
 
 private void CbxSer_SelectedIndexChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 private void btnCadSer_Click(object sender, EventArgs e) 
 { 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "INSERT INTO Servico (Nome, CPF, Quarto, Servico, 
valorServicos) VALUES (@Nome, @CPF, @Quarto, @Servico, @valorServicos )"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@Nome", txtNomeS.Text); 
 
 
70 
 
 comando.Parameters.AddWithValue("@CPF", txtcpfS.Text); 
 comando.Parameters.AddWithValue("@Quarto", txtQuaS.Text); 
 comando.Parameters.AddWithValue("@valorServicos", txtValorSer.Text);comando.Parameters.AddWithValue("@Servico", CbxSer.Text); 
 
 
 
 
 conexao.Open(); 
 comando.ExecuteNonQuery(); 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 comando.Clone(); 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void btnExibirS_Click(object sender, EventArgs e) 
 { 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 
 
71 
 
 strSQL = "Select * From Servico"; 
 
 
 DataSet ds = new DataSet(); 
 
 da = new SqlDataAdapter(strSQL, conexao); 
 
 
 conexao.Open(); 
 da.Fill(ds); 
 dgvSer.DataSource = ds.Tables[0]; 
 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 /* private void btnCancSer_Click(object sender, EventArgs e) 
 { 
 
 try 
 
 
72 
 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "Select * From Reserva Where CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@CPF", txtcpfS.Text); 
 
 conexao.Open(); 
 dr = comando.ExecuteReader(); 
 
 while (dr.Read()) 
 { 
 txtNomeS.Text = (string)dr["Nome"]; 
 txtQuaS.Text = (string)dr["Quarto"]; 
 
 } 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 
 conexao = null; 
 comando = null; 
 
 
 } 
 
 
73 
 
 }*/ 
 
 private void button1_Click(object sender, EventArgs e) 
 { 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "DELETE Servico WHERE CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 
 comando.Parameters.AddWithValue("@CPF", txtcpfS.Text); 
 
 conexao.Open(); 
 comando.ExecuteNonQuery(); 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 comando.Clone(); 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 
74 
 
 
 private void txtValorSer_TextChanged(object sender, EventArgs e) 
 { 
 
 } 
 } 
} 
 
FrmVendar 
 
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
using System.Data.SqlClient; 
namespace hotel 
{ 
 public partial class FrmVendas : Form 
 { 
 SqlConnection conexao; 
 SqlCommand comando; 
 SqlDataAdapter da; 
 SqlDataReader dr; 
 
 string strSQL; 
 public FrmVendas() 
 { 
 InitializeComponent(); 
 } 
 
 
75 
 
 
 private void FrmVendas_Load(object sender, EventArgs e) 
 { 
 
 } 
 
 private void dataGridView1_CellContentClick(object sender, 
DataGridViewCellEventArgs e) 
 { 
 
 } 
 
 private void btnConsVenda_Click(object sender, EventArgs e) 
 { 
 
 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "Select * From Reserva Where CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@CPF", txtcpfV.Text); 
 
 conexao.Open(); 
 dr = comando.ExecuteReader(); 
 
 while (dr.Read()) 
 { 
 txtNomeV.Text = (string)dr["Nome"]; 
 txtQuaV.Text = (string)dr["Quarto"]; 
 txtValReserva.Text = (string)dr["valorTotal"]; 
 
 
76 
 
 
 
 
 } 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 
 conexao = null; 
 comando = null; 
 
 
 } 
 
 
 
 } 
 
 private void txtValVenda_TextChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 private void btnSerV_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 
77 
 
 
 private void cmbParce_SelectedIndexChanged(object sender, EventArgs e) 
 { 
 
 
 } 
 
 private void txtVendaTotal_TextChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 
 
 private void cbCartao_CheckedChanged(object sender, EventArgs e) 
 { 
 if (cbCartao.Checked == true) 
 { 
 txtParc.Visible = true; 
 
 lblParcelas.Visible = true; 
 cbNaoPago.Checked = false; 
 cbDinheiro.Checked = false; 
 
 
 } 
 else 
 { 
 
 
 
78 
 
 lblParcelas.Visible = false; 
 
 
 } 
 } 
 
 private void cbDinheiro_CheckedChanged(object sender, EventArgs e) 
 { 
 if (cbDinheiro.Checked == true) 
 { 
 
 cbNaoPago.Checked = false; 
 cbCartao.Checked = false; 
 
 
 
 } 
 
 } 
 
 private void cbNaoPago_CheckedChanged(object sender, EventArgs e) 
 { 
 
 
 if (cbNaoPago.Checked == true) 
 { 
 
 cbDinheiro.Checked = false; 
 cbCartao.Checked = false; 
 
 } 
 } 
 
 private void button1_Click(object sender, EventArgs e) 
 
 
79 
 
 { 
 } 
 
 private void txtParcelas_TextChanged(object sender, EventArgs e) 
 { 
 
 } 
 
 private void btnServicoTotal_Click(object sender, EventArgs e) 
 { 
 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "Select * From Servico Where CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL,conexao); 
 
 comando.Parameters.AddWithValue("@CPF", txtcpfV.Text); 
 
 conexao.Open(); 
 dr = comando.ExecuteReader(); 
 
 while (dr.Read()) 
 { 
 txtValReserva.Text = (string)dr["valorServicos"]; 
 
 } 
 
 } 
 catch (Exception ex) 
 { 
 
 
 
80 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 
 conexao = null; 
 comando = null; 
 
 
 } 
 } 
 
 private void btnValServico_Click(object sender, EventArgs e) 
 { 
 
 
 
 try 
 { 
 conexao = new SqlConnection(@"Data Source=DESKTOP-
TIGCP3C\SQLEXPRESS;Initial Catalog=hotelLaghetto;Integrated Security=True"); 
 strSQL = "Select * From Servico Where CPF = @CPF"; 
 
 comando = new SqlCommand(strSQL, conexao); 
 
 comando.Parameters.AddWithValue("@CPF", txtcpfV.Text); 
 
 conexao.Open(); 
 dr = comando.ExecuteReader(); 
 
 while (dr.Read()) 
 { 
 
 
 
81 
 
 txtServicosV.Text = (string)dr["valorServicos"]; 
 
 
 } 
 
 } 
 catch (Exception ex) 
 { 
 
 MessageBox.Show(ex.Message); 
 } 
 finally 
 { 
 conexao.Close(); 
 
 conexao = null; 
 comando = null; 
 
 
 } 
 
 } 
 
 private void btnCalcVenda_Click(object sender, EventArgs e) 
 { 
 
 
 
 if (cbDinheiro.Checked == true) 
 { 
 
 
 float valorFinal; 
 float valorReserva = float.Parse(txtValReserva.Text); 
 
 
82 
 
 float Servicos = float.Parse(txtServicosV.Text); 
 valorFinal = valorReserva + Servicos; 
 string ValorDia = valorFinal + ""; 
 txtVendaTotal.Text = ValorDia; 
 
 
 
 } 
 if (cbCartao.Checked == true) 
 { 
 
 
 float valorFinal; 
 float valorReserva = float.Parse(txtValReserva.Text); 
 float Servicos = float.Parse(txtServicosV.Text); 
 valorFinal = valorReserva + Servicos; 
 
 float ValParcelas = float.Parse(txtParc.Text); 
 valorFinal = valorFinal / ValParcelas; 
 string ValorDia = valorFinal + ""; 
 txtVendaTotal.Text = ValorDia; 
 
 
 
 
 } 
 
 
 
 } 
 
 private void btnCalcPar_Click(object sender, EventArgs e) 
 { 
 
 
 
83 
 
 
 } 
 
 private void lblValParcelas_Click(object sender, EventArgs e) 
 { 
 
 } 
 
 private void btnFinalVen_Click(object sender, EventArgs e) 
 { 
 if (cbNaoPago.Checked == true) 
 { 
 MessageBox.Show("Venda não finalizada"); 
 
 } 
 if (cbDinheiro.Checked || cbCartao.Checked == true) 
 { 
 MessageBox.Show("venda Realizada com sucesso"); 
 
 } 
 } 
 } 
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
84 
 
Códigos da aplicação mobile: 
 
MainActivity.kt ---------------------------------------------------------------------------------------------
--------------------------------------------------------- 
 
class MainActivity : AppCompatActivity(), Serializable { 
 
 override fun onCreate(savedInstanceState: Bundle?) { 
 super.onCreate(savedInstanceState) 
 setContentView(R.layout.activity_main) 
 
 findViewById<Toolbar>(R.id.toolBar).also { 
 setSupportActionBar(it) 
 } 
 
 supportActionBar!!.setDisplayShowTitleEnabled(true) 
 
 val viewPager = findViewById<ViewPager>(R.id.viewpager) 
 
 setupViewPager(viewPager) 
 findViewById<TabLayout>(R.id.tabs).setupWithViewPager(viewPager) 
 } 
 
 private fun setupViewPager(viewPager: ViewPager) { 
 val adapter = ViewPagerAdapter(supportFragmentManager) 
 adapter.addFrag(HomeFragment(), "Home") 
 adapter.addFrag(ReservationFragment(), "Reservas") 
 
 viewPager.addOnPageChangeListener(object : OnPageChangeListener { 
 override fun onPageScrolled( 
 position: Int, 
 positionOffset: Float, 
 positionOffsetPixels: Int 
 ) {} 
 
 
85 
 
 
 override fun onPageSelected(position: Int) { 
 if (position == 1) { 
 (adapter.getItem(position) as ReservationFragment).updateList() 
 } else { 
 (adapter.getItem(position) as HomeFragment).updateList() 
 } 
 } 
 
 override fun onPageScrollStateChanged(state: Int) {} 
 }) 
 
 viewPager.adapter = adapter 
 } 
} 
 
class ViewPagerAdapter(manager: FragmentManager?) : 
 FragmentPagerAdapter(manager!!, 
BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { 
 fun addFrag(fragment: Fragment, title: String) { 
 mFragmentList.add(fragment) 
 mFragmentTitleList.add(title) 
 } 
 
 override fun getItem(position: Int): Fragment { 
 return mFragmentList[position] 
 } 
 
 override fun getCount(): Int { 
 return mFragmentList.size 
 } 
 
 override fun getPageTitle(position: Int): CharSequence { 
 return mFragmentTitleList[position] 
 
 
86 
 
 } 
 
 companion object { 
 private val mFragmentList: MutableList<Fragment> = ArrayList() 
 private val mFragmentTitleList: MutableList<String> = ArrayList() 
 } 
} 
 
LoginActivity.kt --------------------------------------------------------------------------------------------
---------------------------------------------------------- 
 
class LoginActivity : AppCompatActivity(), View.OnClickListener { 
 private val usernameInput: TextInputLayout by lazy { findViewById(R.id.username) 
} 
 private val passwordInput: TextInputLayout by lazy { findViewById(R.id.password) } 
 
 override fun onCreate(savedInstanceState: Bundle?) { 
 super.onCreate(savedInstanceState) 
 setContentView(R.layout.activity_login) 
 
 findViewById<Button>(R.id.loginBtn).setOnClickListener(this) 
 } 
 
 @SuppressLint("CommitPrefEdits") 
 override fun onClick(view: View) { 
 if (view.id == R.id.loginBtn) { 
 val username = usernameInput.editText!!.text.toString() 
 val password = passwordInput.editText!!.text.toString() 
 
 if (username == "") { 
 usernameInput.error = "Forneça seu usuário para se autenticar" 
 } else if (password == "") { 
 passwordInput.error = "Forneça sua senha para se autenticar" 
 } else if (username != "admin" || password != "123456") { 
 
 
87 
 
 passwordInput.error = "Dados incorretos" 
 } else { 
 val sharedPreferences = getSharedPreferences(username, 
MODE_PRIVATE) 
 
 if (sharedPreferences.getString("active", "in") == "in") { 
 getSharedPreferences("cur", MODE_PRIVATE) 
 .edit() 
 .putString("user", username) 
 } 
 
 newActivity(this@LoginActivity, MainActivity::class.java)} 
 } 
 } 
} 
 
HotelInfo.kt -------------------------------------------------------------------------------------------------
----------------------------------------------------- 
 
class HotelInfo : AppCompatActivity() { 
 private val toolbar: Toolbar by lazy { findViewById(R.id.toolbarInfo) } 
 private val hotelImage: ImageView by lazy { findViewById(R.id.hotelImage) } 
 private val hotelDesc: TextView by lazy { findViewById(R.id.hotelDesc) } 
 private val book: Button by lazy { findViewById(R.id.confirmBooking) } 
 private val startAt: TextView by lazy { findViewById(R.id.startAt) } 
 private val endAt: TextView by lazy { findViewById(R.id.endAt) } 
 private val buttonStartAt: TextView by lazy { findViewById(R.id.buttonStartAt) } 
 private val buttonEndAt: TextView by lazy { findViewById(R.id.buttonEndAt) } 
 
 override fun onCreate(savedInstanceState: Bundle?) { 
 super.onCreate(savedInstanceState) 
 setContentView(R.layout.activity_hotel_info) 
 } 
 
 
88 
 
 
 override fun onResume() { 
 super.onResume() 
 
 intent.also { 
 it.getSerializableExtra("data")?.let { data -> hotel = data as Hotel } 
 startAt.text = it.getStringExtra("startAt") ?: "" 
 endAt.text = it.getStringExtra("endAt") ?: "" 
 } 
 
 hotelResult = gson.fromJson(getHotels(), HotelResult::class.java) 
 toolbar.title = hotel.name 
 
 setSupportActionBar(toolbar) 
 
 Picasso 
 .with(this@HotelInfo) 
 .load(Uri.parse(hotel.imageUrl)) 
 .into(hotelImage) 
 
 hotelDesc.text = hotel.description 
 
 setupComponents() 
 } 
 
 private fun setupComponents() { 
 val calendar = Calendar.getInstance() 
 val year = calendar.get(Calendar.YEAR) 
 val month = calendar.get(Calendar.MONTH) + 1 
 val day = calendar.get(Calendar.DAY_OF_MONTH) 
 
 buttonStartAt.setOnClickListener { 
 DatePickerDialog(this, { _, year, month, day -> 
 startAt.text = "$day/$month/$year" 
 
 
89 
 
 }, year, month, day).show() 
 } 
 
 buttonEndAt.setOnClickListener { 
 DatePickerDialog(this, { _, year, month, day -> 
 endAt.text = "$day/$month/$year" 
 }, year, month, day).show() 
 } 
 
 book.setOnClickListener { 
 setBooking(this@HotelInfo) 
 } 
 } 
 
 private fun setBooking(context: Context) { 
 try { 
 val startDate = startAt.text!!.toString() 
 val endDate = endAt.text!!.toString() 
 
 DateUtils.validateDates(context, startDate, endDate) 
 } catch (e: Exception) { 
 return 
 } 
 
 AlertDialog.Builder(context) 
 .setCancelable(false) 
 .setTitle("Confirmar reserva") 
 .setMessage("Deseja reservar o quarto \"${hotel.name}\"?") 
 .setPositiveButton("Confirmar") { _, _ -> 
 ReservationFragment.reservations.apply { createOrUpdate(this) } 
 
 storeUpdates(hotelResult) 
 finish() 
 } 
 
 
90 
 
 .setNegativeButton("Cancelar") { dialog, _ -> dialog.dismiss() } 
 .create() 
 .show() 
 } 
 
 private fun createOrUpdate(reservations: MutableList<Reservation>) { 
 val filtered = reservations.filter { it.hotel.id == hotel.id } 
 
 if (filtered.isNotEmpty()) { 
 filtered.map { 
 it.startsAt = startAt.text.toString() 
 it.endsAt = endAt.text.toString() 
 } 
 } else { 
 reservations.add( 
 Reservation( 
 id = UUID.randomUUID().toString(), 
 hotel = hotel, 
 startsAt = startAt.text.toString(), 
 endsAt = endAt.text.toString() 
 ) 
 ) 
 } 
 } 
 
 private fun getHotels() = getSharedPreferences("hotel", MODE_PRIVATE).let { 
 if (it.contains("data")) it.getString("data", null) else null 
 } 
 
 private fun storeUpdates(hotelResult: HotelResult) { 
 getSharedPreferences("hotel", MODE_PRIVATE).edit().also { 
 it.putString("data", gson.toJson(hotelResult)) 
 it.apply() 
 } 
 
 
91 
 
 } 
 
 companion object { 
 private lateinit var hotel: Hotel 
 private lateinit var hotelResult: HotelResult 
 private val gson = Gson() 
 } 
} 
 
HotelAdapter.kt --------------------------------------------------------------------------------------------
---------------------------------------------------------- 
 
class HotelAdapter(private val context: Context): 
 RecyclerView.Adapter<HotelAdapter.HotelViewHolder>() { 
 
 private val inflater: LayoutInflater = LayoutInflater.from(context) 
 private lateinit var view: View 
 private lateinit var hotelViewHolder: HotelViewHolder 
 
 override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): 
HotelViewHolder { 
 view = inflater.inflate(R.layout.hotelcard, parent, false) 
 hotelViewHolder = HotelViewHolder(view) 
 
 return hotelViewHolder 
 } 
 
 override fun onBindViewHolder(holder: HotelViewHolder, position: Int) { 
 Picasso 
 .with(context) 
 .load(Uri.parse(hotels[position].imageUrl)) 
 .into(holder.hotelImage) 
 
 holder.hotelRatings.text = hotels[position].ratings 
 
 
92 
 
 holder.tags.text = hotels[position].tags 
 holder.hotelName.text = hotels[position].name 
 
 holder.bookButton.setOnClickListener { 
 setHotels(hotels) 
 
 Intent(context, HotelInfo::class.java).let { 
 it.putExtra("hotels", hotelResult) 
 it.putExtra("pos", position) 
 it.putExtra("data", hotels[position]) 
 context.startActivity(it) 
 } 
 } 
 } 
 
 override fun getItemCount() = hotels.size 
 
 @SuppressLint("NotifyDataSetChanged") 
 fun setHotels(lists: List<Hotel>) { 
 hotels = lists 
 hotelResult.hotels = hotels 
 
 storeUpdates(HotelResult(hotels = hotels)) 
 
 notifyDataSetChanged() 
 } 
 
 private fun storeUpdates(hotelResult: HotelResult) { 
 context.getSharedPreferences("hotel", Context.MODE_PRIVATE).edit().also { 
 it.putString("data", gson.toJson(hotelResult)) 
 it.apply() 
 } 
 } 
 
 
 
93 
 
 inner class HotelViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) 
{ 
 var hotelImage: ImageView = itemView.findViewById(R.id.hotelImage) 
 var hotelRatings: TextView = itemView.findViewById(R.id.ratings) 
 var hotelName: TextView = itemView.findViewById(R.id.hotelName) 
 var tags: TextView = itemView.findViewById(R.id.tagsList) 
 var bookButton: Button = itemView.findViewById(R.id.hotelBookButton) 
 } 
 
 companion object { 
 private var hotels = emptyList<Hotel>() 
 private val hotelResult = HotelResult() 
 private val gson = Gson() 
 } 
} 
 
ReservationAdapter.kt -----------------------------------------------------------------------------------
------------------------------------------------------------- 
 
class ReservationAdapter(private val context: Context): 
 RecyclerView.Adapter<ReservationAdapter.ReservationViewHolder>(), 
Serializable { 
 
 private val inflater: LayoutInflater = LayoutInflater.from(context) 
 private lateinit var view: View 
 private lateinit var viewHolder: ReservationViewHolder 
 
 override fun onCreateViewHolder(parent:ViewGroup, viewType: Int): 
ReservationViewHolder { 
 view = inflater.inflate(R.layout.reservation_card, parent, false) 
 viewHolder = ReservationViewHolder(view) 
 
 return viewHolder 
 } 
 
 
94 
 
 
 override fun onBindViewHolder(holder: ReservationViewHolder, position: Int) { 
 val reservation = reservations[position] 
 
 Picasso 
 .with(context) 
 .load(Uri.parse(reservation.hotel.imageUrl)) 
 .into(holder.hotelImage) 
 
 holder.startDate.text = reservation.startsAt 
 holder.endDate.text = reservation.endsAt 
 
 holder.delete.setOnClickListener { 
 AlertDialog.Builder(context) 
 .setCancelable(false) 
 .setTitle("Confirmar exclusão") 
 .setMessage("Deseja realmente excluir sua reserva do quarto 
\"${reservation.hotel.name}\"?") 
 .setPositiveButton("Sim") { _, _ -> 
 reservations.remove(reservation) 
 setReservations(reservations) 
 } 
 .setNegativeButton("Não") { dialog, _ -> dialog.dismiss() } 
 .create() 
 .show() 
 } 
 
 holder.edit.setOnClickListener { 
 Intent(context, HotelInfo::class.java).let { 
 it.putExtra("data", reservation.hotel) 
 it.putExtra("startAt", reservation.startsAt) 
 it.putExtra("endAt", reservation.endsAt) 
 
 context.startActivity(it) 
 
 
95 
 
 } 
 } 
 } 
 
 override fun getItemCount() = reservations.size 
 
 @SuppressLint("NotifyDataSetChanged") 
 fun setReservations(lists: MutableList<Reservation>) { 
 reservations = lists 
 
 notifyDataSetChanged() 
 } 
 
 inner class ReservationViewHolder(itemView: View): 
 RecyclerView.ViewHolder(itemView), UpdateListener, Serializable { 
 
 var hotelImage: ImageView = itemView.findViewById(R.id.hotelImage) 
 var startDate: TextView = itemView.findViewById(R.id.startDate) 
 var endDate: TextView = itemView.findViewById(R.id.endDate) 
 var edit: TextView = itemView.findViewById(R.id.editReservation) 
 var delete: TextView = itemView.findViewById(R.id.deleteReservation) 
 
 override fun update() { 
 notifyItemChanged(adapterPosition) 
 } 
 } 
 
 companion object { 
 private lateinit var reservations: MutableList<Reservation> 
 } 
} 
 
interface UpdateListener : Serializable { 
 fun update() 
 
 
96 
 
} 
 
HomeFragment.kt ----------------------------------------------------------------------------------------
-------------------------------------------------------------- 
 
class HomeFragment : Fragment() { 
 
 private lateinit var recyclerView: RecyclerView 
 private var hotelAdapter: HotelAdapter? = null 
 
 override fun onCreateView( 
 inflater: LayoutInflater, 
 container: ViewGroup?, 
 savedInstanceState: Bundle? 
 ): View = inflater.inflate(R.layout.fragment_home, container, false).let { 
 recyclerView = it.findViewById(R.id.hotelList) 
 it 
 } 
 
 override fun onPause() { 
 super.onPause() 
 
 lastPos = (recyclerView.layoutManager as LinearLayoutManager) 
 .findFirstCompletelyVisibleItemPosition() 
 } 
 
 override fun onResume() { 
 super.onResume() 
 val hotelAdapter = HotelAdapter(context!!) 
 
 if (getHotels() == null) { 
 lateinit var br: BufferedReader 
 
 try { 
 
 
97 
 
 br = 
BufferedReader(InputStreamReader(context!!.assets.open("hotels.json"))) 
 } catch (e: IOException) { 
 e.printStackTrace() 
 } 
 
 hotelResult = gson.fromJson(br, HotelResult::class.java) 
 } else { 
 hotelResult = gson.fromJson(getHotels(), HotelResult::class.java) 
 } 
 
 hotelAdapter.setHotels(hotelResult.hotels) 
 recyclerView.layoutManager = LinearLayoutManager(context) 
 recyclerView.adapter = hotelAdapter 
 recyclerView.layoutManager!!.scrollToPosition(lastPos) 
 } 
 
 fun updateList() { 
 hotelAdapter?.setHotels(hotelResult.hotels) 
 } 
 
 private fun getHotels() = activity!!.getSharedPreferences("hotel", 
Context.MODE_PRIVATE).let { 
 if (it.contains("data")) it.getString("data", null) else null 
 } 
 
 companion object { 
 private lateinit var hotelResult: HotelResult 
 private val gson = Gson() 
 
 private var lastPos = 0 
 } 
} 
 
 
 
98 
 
ReservationFragment.kt --------------------------------------------------------------------------------
--------------------------------------------------------------- 
 
class ReservationFragment : Fragment() { 
 private lateinit var adapter: ReservationAdapter 
 private lateinit var placeholderEmpty: TextView 
 
 override fun onCreateView( 
 inflater: LayoutInflater, 
 container: ViewGroup?, 
 savedInstanceState: Bundle? 
 ): View = inflater.inflate(R.layout.fragment_reservation, container, false).let { 
 placeholderEmpty = it.findViewById(R.id.emptyReservationPlaceHolder) 
 adapter = ReservationAdapter(context!!) 
 
 updateList() 
 
 val recyclerView: RecyclerView = it.findViewById(R.id.hotelList) 
 recyclerView.layoutManager = LinearLayoutManager(context) 
 recyclerView.adapter = adapter 
 
 it 
 } 
 
 override fun onResume() { 
 super.onResume() 
 
 placeholderEmpty.visibility = if (adapter.itemCount == 0) { 
 View.VISIBLE 
 } else View.INVISIBLE 
 } 
 
 fun updateList() { 
 adapter.setReservations(reservations) 
 
 
99 
 
 } 
 
 companion object { 
 var reservations: MutableList<Reservation> = mutableListOf() 
 } 
} 
 
HotelModels.kt ---------------------------------------------------------------------------------------------
---------------------------------------------------------- 
 
data class Hotel( 
 @Expose val id: String, 
 @Expose val name: String, 
 @Expose val ratings: String = "", 
 @Expose val tags: String = "", 
 @Expose val description: String, 
 @Expose val imageUrl: String? = null, 
) : Serializable 
 
data class HotelResult( 
 @Expose var hotels: List<Hotel> = emptyList() 
) : Serializable 
 
data class Reservation ( 
 @Expose val id: String, 
 @Expose val hotel: Hotel, 
 @Expose var startsAt: String, 
 @Expose var endsAt: String 
) 
 
DateUtils.kt -------------------------------------------------------------------------------------------------
-------------------------------------------------------- 
 
object DateUtils { 
 
 
100 
 
 fun validateDates(context: Context, startDate: String, endDate: String) { 
 validateEmptyBookingDate(startDate, endDate, context) 
 
 val format = SimpleDateFormat("dd/MM/yyyy", Locale.getDefault()) 
 
 val startAsCalendar = Calendar.getInstance().also { startingDate -> 
 startingDate.time = format.parse(startDate)!! 
 startingDate.validateBookingDate(context) 
 } 
 
 Calendar.getInstance().also { endingDate -> 
 endingDate.time = format.parse(endDate)!! 
 endingDate.validateBookingDate(context) 
 endingDate.validateEndingBookingDate(startAsCalendar, context) 
 } 
 } 
 
 private fun Calendar.validateBookingDate(context: Context) { 
 val today = Calendar.getInstance() 
 
 if (this.before(today)) { 
 showErrorDialog(context, "A data preenchida

Continue navegando