private void btn_comprarProduto_Click(object sender, EventArgs e) { string historico; if (MessageBox.Show("Deseja comprar esse produto?", "Atenção", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { //n esta efetuando a compra quando comprasse um produto que tenha ".". //Erro var precoCerto = float.Parse(String.Format("{0:#.00}", listView_consumables.SelectedItems[0].SubItems[4].Text.Replace("R$", ""))); if (string.IsNullOrEmpty(guest.gue_historico)) { historico = ""; } else { historico = guest.gue_historico; } historico += listView_consumables.SelectedItems[0].SubItems[1].Text + "/" + listView_consumables.SelectedItems[0].SubItems[4].Text + "/"; guest.gue_historico = historico; guest.gue_precoTotal += precoCerto; guestController.alterarGuestPreco(guest); if (Application.OpenForms.OfType <ReadGuestScreen>().Count() > 0) { ReadGuestScreen form = Application.OpenForms["ReadGuestScreen"] as ReadGuestScreen; form.listar(0); } btn_comprarProduto.Enabled = false; MessageBox.Show(listView_consumables.SelectedItems[0].SubItems[1].Text, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btn_cadastrar_Click(object sender, EventArgs e) { Guest guest = new Guest(); string dataNascimento; int verificaSeRetornou = 0; string cpfParaCadastrar = service.preparaCPFparaBD(txtb_cpf.Text); var listGuest = controller.retornaGuest(0); for (int i = 0; i < listGuest.Count; i++) { if (cpfParaCadastrar == listGuest[i].gue_cpf) { MessageBox.Show("Não é possível cadastrar esse hóspede, pois já há uma hóspede com esse CPF!!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); verificaSeRetornou = 1; } else if ((!service.verificaIntOrFloat(txtb_dia.Text.Trim())) || (!service.verificaIntOrFloat(txtb_mes.Text.Trim())) || (!service.verificaIntOrFloat(txtb_ano.Text.Trim()))) { MessageBox.Show("Não é possível cadastrar esse hóspede, pois a sua data de nascimento não está no formato correto!!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); verificaSeRetornou = 1; } } if (verificaSeRetornou == 0) { dataNascimento = txtb_ano.Text + "/" + txtb_mes.Text + "/" + txtb_dia.Text; guest.gue_nome = txtb_nome.Text; guest.gue_cpf = cpfParaCadastrar; guest.gue_dataNascimento = dataNascimento; if (MessageBox.Show("Deseja cadastrar esse Hóspede?", "Atenção", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { if (controller.cadastrarGuest(guest)) { txtb_nome.Clear(); txtb_cpf.Clear(); txtb_dia.Clear(); txtb_mes.Clear(); txtb_ano.Clear(); if (Application.OpenForms.OfType <ReadGuestScreen>().Count() > 0) { ReadGuestScreen form = Application.OpenForms["ReadGuestScreen"] as ReadGuestScreen; form.listar(0); } MessageBox.Show("Hóspede cadastrado com sucesso!!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Não foi possível cadastrar o hóspede!!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
private void btn_alterar_Click(object sender, EventArgs e) { int verificaSeRetornou = 0; int tipoSelect = 0; if (cbox_opcoes.SelectedIndex == 0) { guest.gue_nome = txtb_novoAlterar.Text; tipoSelect = 0; } else if (cbox_opcoes.SelectedIndex == 1) { guest.gue_cpf = txtb_novoAlterar.Text; tipoSelect = 0; if (!service.verificaIntOrFloat(guest.gue_cpf)) { verificaSeRetornou = 1; } var listGuest = controller.retornaGuest(0); for (int i = 0; i < listGuest.Count; i++) { if (guest.gue_cpf == listGuest[i].gue_cpf) { verificaSeRetornou = 1; } } } else if (cbox_opcoes.SelectedIndex == 2) { guest.gue_dataNascimento = txtb_ano.Text + "/" + txtb_mes.Text + "/" + txtb_dia.Text; tipoSelect = 1; if ((!service.verificaIntOrFloat(txtb_dia.Text.Trim())) || (!service.verificaIntOrFloat(txtb_mes.Text.Trim())) || (!service.verificaIntOrFloat(txtb_ano.Text.Trim()))) { verificaSeRetornou = 1; } } if (verificaSeRetornou == 0) { if (MessageBox.Show("Deseja alterar esse funcionario?", "Atenção", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { controller.alteraGuest(guest, tipoSelect); if (Application.OpenForms.OfType <ReadGuestScreen>().Count() > 0) { ReadGuestScreen form = Application.OpenForms["ReadGuestScreen"] as ReadGuestScreen; form.listar(0); } limpaCampoForm(); MessageBox.Show("Funcionario alterado com sucesso!!!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Não é possível alterar esse hóspede, pois já há um funcionário com esse CPF ou o mesmo é inválido!!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } }