protected void btnCadastrar_Click(object sender, EventArgs e) { string pagamento = DropDownList1.SelectedValue.ToString(); if (pagamento == "Selecione:") { lblMensagem.Text = txtNome.Text + " não escolheu forma de pagamento!"; } else { try { Alugados alu = new Alugados(); alu.codigoImovel = Convert.ToInt32(txtCodigo5.Text); alu.codigoCliente = Convert.ToInt32(txtCodigo.Text); alu.dataInicio = Convert.ToDateTime(dataInicio.Text); alu.dataFim = Convert.ToDateTime(dataFim.Text); alu.pagamento = Convert.ToInt32(DropDownList1.SelectedValue); AluguelDAL aludal = new AluguelDAL(); aludal.Gravar(alu); //gravando aluguel int codigo5 = Convert.ToInt32(txtCodigo5.Text); //Imovel2 i = new Imovel2(); ImovelDAL imovdal = new ImovelDAL(); imovdal.Atualizar(codigo5); txtCodigo.Text = ""; txtNome.Text = ""; txtTelefone.Text = ""; txtCPF.Text = ""; txtLogin.Text = ""; txtSenha.Text = ""; txtCodigo5.Text = ""; txtBairro5.Text = ""; txtTipoImovel5.Text = ""; txtTipoNegocio5.Text = ""; txtQuarto5.Text = ""; txtValor5.Text = ""; dataInicio.Text = ""; dataFim.Text = ""; pagamento = "Selecione:"; DropDownList1.Enabled = false; btnCadastrar.Enabled = false; lblMensagem.Text = "Aluguel registrado com sucesso!"; } catch (Exception ex) { lblMensagem.Text = ex.Message; } } }
protected void btnGravar_Click(object sender, EventArgs e) { //int codicli = Convert.ToInt32(txtCodigo.Text); try { if (txtDataFim.Text == "") { Alugados alu = new Alugados(); alu.codigoImovel = Convert.ToInt32(txtCodigo5.Text); alu.codigoCliente = Convert.ToInt32(txtCodigo.Text); alu.dataInicio = Convert.ToDateTime(txtDataInicial.Text); alu.pagamento = Convert.ToInt32(Request.QueryString["pagamento"]); AluguelDAL aludal = new AluguelDAL(); aludal.Gravar2(alu); //gravando aluguel int codigo5 = Convert.ToInt32(txtCodigo5.Text); //Imovel2 i = new Imovel2(); ImovelDAL imovdal = new ImovelDAL(); imovdal.Atualizar(codigo5);//aqui é passado o id do imovel para mudar a situação do imovel para alugado. btnVoltar.Visible = false; btnGravar.Visible = false; btnImprimir.Visible = true; lblMensagem.Text = "Aluguel registrado com sucesso!"; } else { Alugados alu = new Alugados(); alu.codigoImovel = Convert.ToInt32(txtCodigo5.Text); alu.codigoCliente = Convert.ToInt32(txtCodigo.Text); alu.dataInicio = Convert.ToDateTime(txtDataInicial.Text); alu.dataFim = Convert.ToDateTime(txtDataFim.Text); alu.pagamento = Convert.ToInt32(Request.QueryString["pagamento"]); AluguelDAL aludal = new AluguelDAL(); aludal.Gravar(alu); //gravando aluguel int codigo5 = Convert.ToInt32(txtCodigo5.Text); //Imovel2 i = new Imovel2(); ImovelDAL imovdal = new ImovelDAL(); imovdal.Atualizar(codigo5);//aqui é passado o id do imovel para mudar a situação do imovel para alugado. btnVoltar.Visible = false; btnGravar.Visible = false; btnImprimir.Visible = true; lblMensagem.Text = "Aluguel registrado com sucesso!"; } } catch (Exception ex) { lblMensagem.Text = ex.Message; } }