コード例 #1
0
        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;
                }
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                ImovelDAL imov = new ImovelDAL();

                GridView1.DataSource = imov.Disponivel(); //popular o grid
                GridView1.DataBind();                     //exibir o conteudo do grid
            }
            catch (Exception ex)
            {
                lblMensagem.Text = ex.Message;
            }
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            txtCodigo.Text   = Request.QueryString["codigoCliente"];
            txtNome.Text     = Request.QueryString["nomeCliente"];
            txtTelefone.Text = Request.QueryString["telefoneCliente"];
            txtCPF.Text      = Request.QueryString["cpfCliente"];
            txtLogin.Text    = Request.QueryString["loginCliente"];
            txtSenha.Text    = Request.QueryString["senhaCliente"];

            //txtCodigo5.Text = Request.QueryString["codigoImovel"];
            //txtBairro5.Text = Request.QueryString["nomeBairro"];
            //txtTipoImovel5.Text = Request.QueryString["tipo"];
            //txtTipoNegocio5.Text = Request.QueryString["negocio"];
            //txtQuarto5.Text = Request.QueryString["quarto"];
            //txtValor5.Text = Request.QueryString["valor"];

            //dataInicio.Text = Request.QueryString["dataInicio"];
            //dataFim.Text = Request.QueryString["dataFim"];


            //pegando dados da tabela aluguel atraves do codigo
            int        codigo = Convert.ToInt32(txtCodigo.Text);
            AluguelDAL d      = new AluguelDAL();
            Alugados   c      = d.PesquisarCodigoCliente(codigo);

            if (c != null)
            {
                txtCodigoImovel.Text        = Convert.ToString(c.codigoImovel);
                txtdataFim.Text             = Convert.ToString(c.dataFim);
                DropDownList1.SelectedValue = Convert.ToString(c.pagamento);
                DropDownList1.Enabled       = false;
            }


            //pegando valor da tabela imovel atraves do codigo
            int       codigoImovel = Convert.ToInt32(c.codigoImovel);
            ImovelDAL aludal       = new ImovelDAL();
            Imovel    alu          = aludal.PesquisarCodigoImovel(codigoImovel);

            if (alu != null)
            {
                txtBairro.Text  = Convert.ToString(alu.nomeBairro);
                txtNegocio.Text = Convert.ToString(alu.negocioNome);
                txtTipo.Text    = Convert.ToString(alu.nomeTipoImovel);
                txtQuarto.Text  = Convert.ToString(alu.quantidadeQuarto);
                txtValor.Text   = Convert.ToString(alu.valorImovel);
            }
        }
コード例 #4
0
        protected void btnSeguinte_Click(object sender, EventArgs e)
        {
            string codigocli = txtCodigoCliente.Text;


            int    codigo      = Convert.ToInt32(txtCodigoCliente.Text);
            string nomeCliente = tbNome.Text;
            int    telefone    = Convert.ToInt32(tbTelefone.Text);
            int    cpf         = Convert.ToInt32(tbCPF.Text);
            string login       = tbLogin.Text;
            string senha       = tbSenha.Text;

            AluguelDAL          aludal = new AluguelDAL();
            Alugados            alu    = aludal.PesquisarCodigoCliente(codigo);
            DateTime            datIni = alu.dataInicio;
            Nullable <DateTime> datFim = alu.dataFim;

            DateTime di = Convert.ToDateTime(datIni);

            DateTime data = DateTime.Now.Date;

            if (di != null)
            {
                if (data > di)
                {
                    //alugado

                    try         //entra no try para conferir se tem uma reserva
                    {
                        //agendado

                        //DateTime data = DateTime.Now.Date;

                        AluguelDAL          aludaldata   = new AluguelDAL();
                        Alugados            aludata      = aludaldata.PesquisarAgendado(codigo, data);
                        int                 codigoclire  = aludata.codigoCliente;
                        int                 codigoImovre = aludata.codigoImovel;
                        int                 pagamentore  = aludata.pagamento;
                        DateTime            dataInire    = aludata.dataInicio;
                        Nullable <DateTime> dataFimre    = aludata.dataFim;

                        ImovelDAL imodal       = new ImovelDAL();
                        Imovel    imov         = imodal.PesquisarCodigoImovel(codigoImovre);
                        string    nomeBairrore = imov.nomeBairro;
                        string    negociore    = imov.negocioNome;
                        string    tipore       = imov.nomeTipoImovel;
                        int       quartore     = imov.quantidadeQuarto;
                        float     valorre      = imov.valorImovel;

                        string pagre = "";
                        switch (pagamentore)
                        {
                        case 0:
                            pagre = "Selecione:";
                            break;

                        case 1:
                            pagre = "À Vista";
                            break;

                        case 2:
                            pagre = "Boleto";
                            break;

                        case 3:
                            pagre = "Cartão";
                            break;
                        }

                        lblMensagem.Text = "cliente possui um aluguel e uma reserva";
                        //string url = null;
                        //url = "DadosGerais.aspx?codigoImovel=" + codigoImovre + "&nomeBairro=" + nomeBairrore + "&tipo=" + tipore + "&negocio=" + negociore + "&quarto=" + quartore + "&valor=" + valorre + "&dataInicio=" + dataInire + "&pagamento=" + pagre + "&dataFim=" + dataFimre + "&codigoCliente=" + codigo + "&nomeCliente=" + nomeCliente + "&telefoneCliente=" + telefone + "&cpfCliente=" + cpf + "&loginCliente=" + login + "&senhaCliente=" + senha;
                        //Response.Redirect(url);
                    }
                    catch (Exception)         //se nao tiver uma reserva entra no catch, vai mostrar só o alugado.
                    {
                        //throw;

                        AluguelDAL          aludaldata    = new AluguelDAL();
                        Alugados            aludata       = aludaldata.PesquisarAlugado(codigo, data);
                        int                 codigoclidata = aludata.codigoCliente;
                        int                 codigoImov    = aludata.codigoImovel;
                        int                 pagamento     = aludata.pagamento;
                        DateTime            dataIni       = aludata.dataInicio;
                        Nullable <DateTime> dataFim       = aludata.dataFim;

                        ImovelDAL imodal     = new ImovelDAL();
                        Imovel    imov       = imodal.PesquisarCodigoImovel(codigoImov);
                        string    nomeBairro = imov.nomeBairro;
                        string    negocio    = imov.negocioNome;
                        string    tipo       = imov.nomeTipoImovel;
                        int       quarto     = imov.quantidadeQuarto;
                        float     valor      = imov.valorImovel;

                        string pag = "";
                        switch (pagamento)
                        {
                        case 0:
                            pag = "Selecione:";
                            break;

                        case 1:
                            pag = "À Vista";
                            break;

                        case 2:
                            pag = "Boleto";
                            break;

                        case 3:
                            pag = "Cartão";
                            break;
                        }

                        lblMensagem.Text = "cliente possui só um aluguel";
                        //string url = null;
                        //url = "DadosGerais.aspx?codigoImovel=" + codigoImov + "&nomeBairro=" + nomeBairro + "&tipo=" + tipo + "&negocio=" + negocio + "&quarto=" + quarto + "&valor=" + valor + "&dataInicio=" + dataIni + "&pagamento=" + pag + "&dataFim=" + dataFim + "&codigoCliente=" + codigo + "&nomeCliente=" + nomeCliente + "&telefoneCliente=" + telefone + "&cpfCliente=" + cpf + "&loginCliente=" + login + "&senhaCliente=" + senha;
                        //Response.Redirect(url);
                    }
                }
                else
                {
                    //agendado

                    try
                    {
                        // conferir se tem um aluguel

                        AluguelDAL          aludaldata    = new AluguelDAL();
                        Alugados            aludata       = aludaldata.PesquisarAlugado(codigo, data);
                        int                 codigoclidata = aludata.codigoCliente;
                        int                 codigoImov    = aludata.codigoImovel;
                        int                 pagamento     = aludata.pagamento;
                        DateTime            dataIni       = aludata.dataInicio;
                        Nullable <DateTime> dataFim       = aludata.dataFim;

                        ImovelDAL imodal     = new ImovelDAL();
                        Imovel    imov       = imodal.PesquisarCodigoImovel(codigoImov);
                        string    nomeBairro = imov.nomeBairro;
                        string    negocio    = imov.negocioNome;
                        string    tipo       = imov.nomeTipoImovel;
                        int       quarto     = imov.quantidadeQuarto;
                        float     valor      = imov.valorImovel;

                        string pag = "";
                        switch (pagamento)
                        {
                        case 0:
                            pag = "Selecione:";
                            break;

                        case 1:
                            pag = "À Vista";
                            break;

                        case 2:
                            pag = "Boleto";
                            break;

                        case 3:
                            pag = "Cartão";
                            break;
                        }

                        lblMensagem.Text = "cliente possui uma reserva e um aluguel";
                        //string url = null;
                        //url = "DadosGerais.aspx?codigoImovel=" + codigoImov + "&nomeBairro=" + nomeBairro + "&tipo=" + tipo + "&negocio=" + negocio + "&quarto=" + quarto + "&valor=" + valor + "&dataInicio=" + dataIni + "&pagamento=" + pag + "&dataFim=" + dataFim + "&codigoCliente=" + codigo + "&nomeCliente=" + nomeCliente + "&telefoneCliente=" + telefone + "&cpfCliente=" + cpf + "&loginCliente=" + login + "&senhaCliente=" + senha;
                        //Response.Redirect(url);
                    }
                    catch (Exception)         //entra no catch se nao houver aluguel, mostra a reserva
                    {
                        //throw;

                        //agendado

                        //DateTime data = DateTime.Now.Date;

                        AluguelDAL          aludaldata   = new AluguelDAL();
                        Alugados            aludata      = aludaldata.PesquisarAgendado(codigo, data);
                        int                 codigoclire  = aludata.codigoCliente;
                        int                 codigoImovre = aludata.codigoImovel;
                        int                 pagamentore  = aludata.pagamento;
                        DateTime            dataInire    = aludata.dataInicio;
                        Nullable <DateTime> dataFimre    = aludata.dataFim;

                        ImovelDAL imodal       = new ImovelDAL();
                        Imovel    imov         = imodal.PesquisarCodigoImovel(codigoImovre);
                        string    nomeBairrore = imov.nomeBairro;
                        string    negociore    = imov.negocioNome;
                        string    tipore       = imov.nomeTipoImovel;
                        int       quartore     = imov.quantidadeQuarto;
                        float     valorre      = imov.valorImovel;

                        string pagre = "";
                        switch (pagamentore)
                        {
                        case 0:
                            pagre = "Selecione:";
                            break;

                        case 1:
                            pagre = "À Vista";
                            break;

                        case 2:
                            pagre = "Boleto";
                            break;

                        case 3:
                            pagre = "Cartão";
                            break;
                        }

                        lblMensagem.Text = "cliente possui só uma reserva";
                        //string url = null;
                        //url = "DadosGerais.aspx?codigoImovel=" + codigoImovre + "&nomeBairro=" + nomeBairrore + "&tipo=" + tipore + "&negocio=" + negociore + "&quarto=" + quartore + "&valor=" + valorre + "&dataInicio=" + dataInire + "&pagamento=" + pagre + "&dataFim=" + dataFimre + "&codigoCliente=" + codigo + "&nomeCliente=" + nomeCliente + "&telefoneCliente=" + telefone + "&cpfCliente=" + cpf + "&loginCliente=" + login + "&senhaCliente=" + senha;
                        //Response.Redirect(url);
                    }
                }
            }
            else
            {
                lblMensagem.Text    = "<br />Cliente não possui imóvel alugado!<br /><br />Clique em Alugar para escolher um imóvel";
                btnAlugar.Visible   = true;
                btnSeguinte.Visible = false;
            }


            //string url = null;

            //url = "Cliente3.aspx?codigoCliente=" + codigo + "&nomeCliente=" + nomeCliente + "&telefoneCliente=" + telefone + "&cpfCliente=" + cpf + "&loginCliente=" + login + "&senhaCliente=" + senha;

            //Response.Redirect(url);
        }
コード例 #5
0
        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;
            }
        }