Пример #1
0
        public frmReserva(List <string> list, string acao)
        {
            InitializeComponent();
            action = acao;
            if (action == "nova")
            {
                //List é um livro
                reservaDTO livro = new reservaDTO();
                livro.idLivro   = list[0];
                livro.nomeLivro = list[1];
                livros.Add(livro);
                cboLivroReserva.Items.Add(livros[0].nomeLivro);
                cboStatusReserva.SelectedIndex = 0;
                cboLivroReserva.SelectedIndex  = 0;
                reservaDTO.idLivroBusca        = list[0];
                cboStatusReserva.SelectedIndex = 0;
                cboStatusReserva.Enabled       = false;
            }
            else if (action == "editar")
            {
                //List é uma reserva
                ucSelecionarEmprestimoReserva1.Visible = false;
                reserva.idReserva         = list[0].ToString();
                cboLivroReserva.Text      = list[1].ToString();
                cboClienteReserva.Text    = list[2].ToString();
                cboLivroReserva.Enabled   = false;
                cboClienteReserva.Enabled = false;
                txtCodigoEmprestimo.Text  = list[6].ToString();

                DateTime retiradaPrevista = Convert.ToDateTime(list[4]);
                dtpHoraRetiradaPrevista.Value = Convert.ToDateTime(retiradaPrevista.ToString());
                dtpRetiradaPrevista.Value     = Convert.ToDateTime(retiradaPrevista.Date);
            }
        }
        public string reservaXsalaEvents(reservaDTO reserva)
        {
            var result = "";
            List <elReserva> lelReserva = new List <elReserva>();
            blReserva        oblReserva = new blReserva();

            lelReserva = oblReserva.reservaXsalaEvents(reserva.idSala, reserva.fhinicio, reserva.fhfin);
            result     = JsonConvert.SerializeObject(lelReserva);
            return(result);
        }
Пример #3
0
        private void ucSelecionarEmprestimoReserva_Load(object sender, EventArgs e)
        {
            if (reservaDTO.idLivroBusca != "")
            {
                try
                {
                    if (Conexao.con.State.ToString() == "Open")
                    {
                        Conexao.con.Close();
                    }
                    Conexao.con.Open();
                    MySqlCommand msc = Conexao.con.CreateCommand();
                    msc.CommandType = CommandType.Text;
                    msc.CommandText = "call selecionar_emprestimos_disponiveis(@idLivro)";
                    msc.Parameters.AddWithValue("@idLivro", reservaDTO.idLivroBusca);
                    MySqlDataReader msdr = msc.ExecuteReader();

                    if (msdr.HasRows)
                    {
                        Conexao.con.Close();
                        DataTable        dt = new DataTable();
                        MySqlDataAdapter da = new MySqlDataAdapter(msc);
                        da.Fill(dt);

                        foreach (DataRow row in dt.Rows)
                        {
                            reservaDTO res = new reservaDTO();
                            res.idEmprestimo     = row[0].ToString();
                            res.stringEmprestimo = "# ID: " + row[0].ToString() + " - Entrega prevista: " + row[1].ToString();

                            var dataHora = Convert.ToDateTime(row[1]);
                            res.dataDevolucaoEmprestimo = dataHora.Date.ToString();
                            res.horaDevolucaoEmprestimo = dataHora.TimeOfDay.ToString();
                            emprestimos.Add(res);
                            lstEmprestimosDisponiveis.Items.Add(res.stringEmprestimo);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Não foi possível carregar os empréstimos. " + ex.Message);
                    Conexao.con.Close();
                }
            }
        }
Пример #4
0
        private void cboClienteReserva_KeyPress(object sender, KeyPressEventArgs e)
        {
            cboClienteReserva.Items.Clear();
            cboClienteReserva.SelectionStart = cboClienteReserva.Text.Length;

            if (clientes.Count != 0)
            {
                clientes.Clear();
            }

            MySqlDataAdapter msa = new MySqlDataAdapter();
            DataTable        dt  = new DataTable();

            try
            {
                if (cboClienteReserva.Text != "")
                {
                    if (Conexao.con.State.ToString() == "Open")
                    {
                        Conexao.con.Close();
                    }
                    Conexao.con.Open();

                    MySqlCommand msc = Conexao.con.CreateCommand();
                    msc.CommandType = CommandType.Text;
                    msc.CommandText = "call pesquisar_cliente_regularizado(@texto)";
                    msc.Parameters.AddWithValue("@texto", cboClienteReserva.Text);
                    MySqlDataReader msdr = msc.ExecuteReader();

                    if (msdr.HasRows)
                    {
                        lblErroBuscaCliente.Text = "";
                        Conexao.con.Close();
                        MySqlDataAdapter da = new MySqlDataAdapter(msc);
                        da.Fill(dt);

                        foreach (DataRow dr in dt.Rows)
                        {
                            reservaDTO reserva = new reservaDTO();
                            reserva.idCliente   = dr[0].ToString();
                            reserva.nomeCliente = dr[1].ToString();
                            clientes.Add(reserva);
                            cboClienteReserva.Items.Add(dr[1].ToString());
                        }
                    }
                    else
                    {
                        if (cboClienteReserva.Text.Length >= 2)
                        {
                            lblErroBuscaCliente.Text = String.Format("Não foi encontrado nenhum cliente regulariado com \'{0}\'", cboClienteReserva.Text);
                        }
                    }

                    Conexao.con.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Não foi possível realizar a consulta dos livros" + ex.Message);
            }
        }