Example #1
0
        private bool salaDisponivel(List <Reserva> reservas, Sala sala, Reserva reserva)
        {
            for (int j = 0; j < reservas.Count; j++)
            {
                if (reservas[j].sala.nome == sala.nome)
                {
                    //estão na mesma sala

                    if (conflitoData(reservas[j], reserva))
                    {
                        //marcaram na mesma data

                        if (conflitoHora(reservas[j], reserva))
                        {
                            //mesmo horário
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Example #2
0
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            Sala sala = new Sala();

            if (fuEntrada.FileName == "")
            {
                sala = buscaSala(calDataInicio.SelectedDate.Date, txtHoraInicio.Text, calDataFim.SelectedDate.Date, txtHoraFim.Text,
                                 Convert.ToInt32(txtNumPessoas.Text), cbComputador.Checked, cbTV.Checked, cbWebcam.Checked, cbWifi.Checked, txtMinInicio.Text, txtMinFim.Text);

                if (sala != null)
                {
                    adicionaReserva(sala);
                }
                else if (viabilidade)
                {
                    sugestaoData();
                }
            }
            else
            {
                string nome    = fuEntrada.FileName;
                string caminho = AppDomain.CurrentDomain.BaseDirectory;
                fuEntrada.PostedFile.SaveAs(caminho + nome);

                string textoEntrada = File.ReadAllText(caminho + nome);

                String[] texto = textoEntrada.Split(';');

                DateTime inicio     = DateTime.Parse(texto[0]);
                string   horaInicio = texto[1];

                String[] tempo1 = horaInicio.Split(':');
                horaInicio = tempo1[0];
                string minInicio = tempo1[1];

                DateTime fim     = DateTime.Parse(texto[2]);
                string   horaFim = texto[3];

                String[] tempo2 = horaFim.Split(':');
                horaFim = tempo2[0];
                string minFim = tempo2[1];

                int  pessoas  = Convert.ToInt32(texto[4]);
                bool internet = false;
                bool webcam   = false;
                if (texto[5] == "Sim")
                {
                    internet = true;
                }
                else
                {
                    internet = false;
                }
                if (texto[6] == "Sim")
                {
                    webcam = true;
                }
                else
                {
                    webcam = false;
                }

                sala = buscaSala(inicio, horaInicio, fim, horaFim, pessoas, false, false, webcam, internet, minInicio, minFim);

                if (sala != null)
                {
                    adicionaReserva(sala, inicio, fim, horaInicio, horaFim, minInicio, minFim);
                }
                else if (lblMotivo.Text == "" && viabilidade)
                {
                    sugestaoData();
                }
            }
        }