Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace ConsoleApplication1
- {
- class Program
- {
- public struct Login
- {
- public string username;
- public string nome;
- public int tipo;
- public string password;
- public int id;
- }
- public struct Data
- {
- public int dia;
- public int mes;
- public int ano;
- public int hora;
- public int minutos;
- public int fimhora;
- public int fimminutos;
- }
- public struct Sala
- {
- public int capacidade;
- public int numsala;
- public int tipo;
- }
- public struct Sessao
- {
- public string nome;
- public Data data;
- public string local;
- public int idsessao;
- public Sala sala;
- }
- public struct Conferencia
- {
- public string nome;
- public Data data;
- public string local;
- public int idsessao;
- public Sala sala;
- public string artigo;
- public Login login;
- }
- public struct BilheteSessao
- {
- public Login login;
- public Sessao sessao;
- public Data data;
- public Sala sala;
- public int quantidade;
- }
- public struct BilheteConferencia
- {
- public Conferencia conferencia;
- public Data data;
- public Login login;
- public Sala sala;
- public int quantidade;
- }
- static int TestarInt(string pergunta)
- {
- int num = 0;
- lol:
- try
- {
- Console.WriteLine(pergunta);
- num = Convert.ToInt32(Console.ReadLine());
- }
- catch (Exception)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Dados introduzidos inválidos");
- Console.ForegroundColor = ConsoleColor.White;
- goto lol;
- }
- return num;
- }
- static void CarregarClientes(List<Login> a)
- {
- Login b = new Login();
- b.nome = "Jose";
- b.tipo = 1;
- b.id = 1;
- b.password = "12345";
- b.username = "Jose";
- a.Add(b);
- Login d = new Login();
- d.nome = "Rui";
- d.tipo = 1;
- d.id = 2;
- d.password = "12345";
- d.username = "Rui";
- a.Add(d);
- Login c = new Login();
- c.nome = "Antonio";
- c.id = 3;
- c.tipo = 1;
- c.password = "12345";
- c.username = "Antonio";
- a.Add(c);
- }
- static void CarregarSalas(List<Sala> b)
- {
- Sala s = new Sala();
- s.numsala = 1;
- s.capacidade = 50;
- s.tipo = 1;
- b.Add(s);
- Sala a = new Sala();
- a.numsala = 2;
- a.capacidade = 75;
- a.tipo = 1;
- b.Add(a);
- Sala c = new Sala();
- c.numsala = 3;
- c.capacidade = 300;
- c.tipo = 2;
- b.Add(c);
- }
- static void CarregarOrganizadores(List<Login> a)
- {
- Login e = new Login();
- e.username = "Jose1";
- e.nome = "Jose";
- e.id = 4;
- e.tipo = 2;
- e.password = "12345";
- a.Add(e);
- }
- static void CarregarAutor(List<Login> a)
- {
- Login e = new Login();
- e.id = 5;
- e.username = "Jorge";
- e.nome = "Jorge";
- e.tipo = 3;
- e.password = "12345";
- a.Add(e);
- }
- static void CarregarAdmin(List<Login> a)
- {
- Login e = new Login();
- e.id = 6;
- e.username = "admin";
- e.nome = "admin";
- e.tipo = 4;
- e.password = "admin";
- a.Add(e);
- }
- static void CarregarSessao(List<Sessao> c)
- {
- /* Sessao s = new Sessao();
- s.nome = "Os 3 Mosqueteiros";
- s.local = "Teatro Gil Vicente";
- s.data.ano = 2016;
- s.data.mes = 3;
- s.data.dia = 21;
- s.data.hora = 15;
- s.data.minutos = 30;
- s.data.fimhora = 18;
- s.data.fimminutos = 30;
- s.idsessao = 1;
- s.sala.numsala = 1;
- s.sala.capacidade = 50;
- c.Add(s);
- string nome = "Teste";
- string local = "Teste";
- int ano =2016;
- int mes = 7;
- int dia = 23;
- int hora= 18;
- int minutos=45;
- int fimhora=20;
- int fimminutos=30;
- int idsessao=3;
- int numsala=2;
- int capacidade=75;
- FileStream fs = new FileStream("Espetaculos.txt", FileMode.Append, FileAccess.Write);
- StreamWriter sw = new StreamWriter(fs);
- sw.WriteLine("{0, -4}{1, -40}{2, -30}{3, -4}{4, -2}{5, -2}{6, -2}{7, -2}{8, -2}{9, -2}{10, -3}{11, -4}", idsessao, nome, local, ano, mes, dia, hora, minutos, fimhora, fimminutos, numsala, capacidade);
- sw.Close();
- fs.Close();
- */
- string line;
- StreamReader sr = new StreamReader("Espetaculos.txt");
- while((line = sr.ReadLine()) != null)
- {
- int idsessao1 = Convert.ToInt32(line.Substring(0,4).Trim());
- string nome1 = line.Substring(4,40).Trim();
- string local1 = line.Substring(44,30).Trim();
- int ano1 = Convert.ToInt32(line.Substring(74, 4).Trim());
- int mes1 = Convert.ToInt32(line.Substring(78, 2).Trim());
- int dia1 = Convert.ToInt32(line.Substring(80, 2).Trim());
- int hora1 = Convert.ToInt32(line.Substring(82, 2).Trim());
- int minutos1 = Convert.ToInt32(line.Substring(84, 2).Trim());
- int fimhora1 = Convert.ToInt32(line.Substring(86, 2).Trim());
- int fimminutos1 = Convert.ToInt32(line.Substring(88, 2).Trim());
- int numsala1 = Convert.ToInt32(line.Substring(90, 3).Trim());
- int capacidade1 = Convert.ToInt32(line.Substring(93, 4).Trim());
- Sessao f = new Sessao();
- f.idsessao = idsessao1;
- f.nome = nome1;
- f.local = local1;
- f.data.ano = ano1;
- f.data.mes = mes1;
- f.data.dia = dia1;
- f.data.hora = hora1;
- f.data.minutos = minutos1;
- f.data.fimhora = fimhora1;
- f.data.fimminutos = fimminutos1;
- f.sala.numsala = numsala1;
- f.sala.capacidade = capacidade1;
- c.Add(f);
- }
- /*
- Sessao b = new Sessao();
- b.nome = "Os 3 Vilões";
- b.sala.capacidade = 75;
- b.sala.numsala = 2;
- b.local = "Teatro Gil Vicente";
- b.data.ano = 2016;
- b.data.mes = 3;
- b.data.dia = 21;
- b.data.hora = 15;
- b.data.minutos = 30;
- b.data.fimhora = 18;
- b.data.fimminutos = 30;
- b.idsessao = 2;
- c.Add(b);
- */
- }
- static void CarregarConferencias(List<Conferencia> d)
- {
- Conferencia b = new Conferencia();
- b.sala.capacidade = 300;
- b.sala.numsala = 3;
- b.local = "Teatro Gil Vicente";
- b.nome = "Afinal a Terra gira";
- b.idsessao = 1;
- b.login.id = 5;
- b.data.dia = 15;
- b.data.mes = 08;
- b.data.ano = 2016;
- b.data.hora = 15;
- b.data.minutos = 00;
- b.data.fimhora = 17;
- b.data.fimminutos = 00;
- b.artigo = "Terra Redonda";
- b.login.nome = "Jorge";
- b.login.username = "Jorge";
- d.Add(b);
- }
- static Login CriarCliente(List<Login> a)
- {
- Login c = new Login();
- int contador = 0;
- string username;
- Console.WriteLine("Nome?");
- c.nome = Console.ReadLine();
- do
- {
- Console.WriteLine("Username?");
- username = Console.ReadLine();
- for (int i = 0; i < a.Count; i++)
- {
- contador++;
- if (username == a[i].username)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Username já existe.");
- Console.ForegroundColor = ConsoleColor.White;
- contador--;
- }
- }
- } while (contador == a.Count - 1);
- c.username = username;
- Console.WriteLine("Password?");
- c.password = Console.ReadLine();
- c.tipo = 1;
- c.id = c.id + 1;
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Utilizador criado com sucesso.");
- Console.ForegroundColor = ConsoleColor.White;
- return c;
- }
- static void Ver(Sessao c)
- {
- Console.WriteLine();
- Console.WriteLine("Espectáculo");
- Console.WriteLine("--------------------------------------------------");
- Console.WriteLine("{10} - {0}\nLocal: {2} Sala: {11}\nLugares Disponíves: {1} \nDia: {3:D2}/{4:D2}/{5} Duração: {6:D2}:{7:D2} - {8:D2}:{9:D2}", c.nome, c.sala.capacidade, c.local, c.data.dia, c.data.mes, c.data.ano, c.data.hora, c.data.minutos, c.data.fimhora, c.data.fimminutos, c.idsessao, c.sala.numsala);
- Console.WriteLine("--------------------------------------------------");
- }
- static void VerSessao(List<Sessao> c)
- {
- if (c.Count == 0)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Não existem Sessões");
- Console.ForegroundColor = ConsoleColor.White;
- }
- else
- {
- for (int i = 0; i < c.Count; i++)
- {
- Ver(c[i]);
- }
- }
- }
- static void MostrarConferencia(Conferencia d)
- {
- Console.WriteLine();
- Console.WriteLine("Conferência Científica");
- Console.WriteLine("--------------------------------------------------");
- Console.WriteLine("{0} - {1}\nAutor: {12} Artigo: {13} \nLocal: {2} Sala: {3}\nLugares Disponíveis {4}\nDia: {5:D2}/{6:D2}/{7} Duração: {8:D2}:{9:D2} - {10:D2}:{11:D2}", d.idsessao, d.nome, d.local, d.sala.numsala, d.sala.capacidade, d.data.dia, d.data.mes, d.data.ano, d.data.hora, d.data.minutos, d.data.fimhora, d.data.fimminutos, d.login.nome, d.artigo);
- Console.WriteLine("--------------------------------------------------");
- }
- static void VerConferencia(List<Conferencia> d)
- {
- if (d.Count == 0)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Não existem Conferências");
- Console.ForegroundColor = ConsoleColor.White;
- }
- else
- {
- for (int i = 0; i < d.Count; i++)
- {
- MostrarConferencia(d[i]);
- }
- }
- }
- static void Apagar(List<Login> a, List<Sala> b, List<Sessao> c, List<Conferencia> d)
- {
- string pergunta;
- pergunta = ("Apagar (1 - Espectáculo --- 2 - Conferência --- 0 - Sair)");
- int num = TestarInt(pergunta);
- if (num == 1)
- {
- VerSessao(c);
- pergunta = ("Qual deseja apagar? (Use os números para escolher)");
- int num3 = TestarInt(pergunta);
- for (int i = 0; i < c.Count; i++)
- {
- if (num3 == c[i].idsessao)
- {
- c.RemoveAt(i);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Apagado com sucesso");
- Console.ForegroundColor = ConsoleColor.White;
- break;
- }
- }
- }
- if (num == 2)
- {
- VerConferencia(d);
- pergunta = ("Qual deseja apagar? (Use os números para escolher)");
- int num3 = TestarInt(pergunta);
- for (int i = 0; i < d.Count; i++)
- {
- if (num3 == d[i].idsessao)
- {
- d.RemoveAt(i);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Apagado com sucesso");
- Console.ForegroundColor = ConsoleColor.White;
- break;
- }
- }
- }
- }
- static void VerConferenciaAutor(List<Conferencia> d, ref int id)
- {
- for (int i = 0; i < d.Count; i++)
- {
- if (id == d[i].login.id)
- {
- VerConferencia(d);
- }
- }
- }
- static void InserirConferenciaAutor(List<Conferencia> d, ref int id)
- {
- string pergunta;
- VerConferenciaAutor(d, ref id);
- pergunta = ("Escolha a conferencia onde deseja por um artigo");
- int num = TestarInt(pergunta);
- for (int i = 0; i < d.Count; i++)
- {
- if (num == d[i].idsessao)
- {
- Console.WriteLine("Artigo a introduzir");
- string artigo = Console.ReadLine();
- Conferencia conferencia = d[i];
- conferencia.artigo = artigo;
- d[i] = conferencia;
- }
- }
- }
- static Login CriarOrganizador(List<Login> a)
- {
- Login c = new Login();
- int contador = 0;
- string username;
- Console.WriteLine("Nome?");
- c.nome = Console.ReadLine();
- do
- {
- Console.WriteLine("Username?");
- username = Console.ReadLine();
- for (int i = 0; i < a.Count; i++)
- {
- contador++;
- if (username == a[i].username)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Username já existe.");
- Console.ForegroundColor = ConsoleColor.White;
- contador--;
- }
- }
- } while (contador == a.Count - 1);
- c.username = username;
- Console.WriteLine("Password?");
- c.password = Console.ReadLine();
- c.tipo = 2;
- c.id = c.id + 1;
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Organizador criado com sucesso.");
- Console.ForegroundColor = ConsoleColor.White;
- return c;
- }
- static Login CriarAutor(List<Login> a)
- {
- Login c = new Login();
- int contador = 0;
- string username;
- Console.WriteLine("Nome?");
- c.nome = Console.ReadLine();
- do
- {
- Console.WriteLine("Username?");
- username = Console.ReadLine();
- for (int i = 0; i < a.Count; i++)
- {
- contador++;
- if (username == a[i].username)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Username já existe.");
- Console.ForegroundColor = ConsoleColor.White;
- contador--;
- }
- }
- } while (contador == a.Count - 1);
- c.username = username;
- Console.WriteLine("Password?");
- c.password = Console.ReadLine();
- c.tipo = 3;
- c.id = c.id + 1;
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Autor criado com sucesso.");
- Console.ForegroundColor = ConsoleColor.White;
- return c;
- }
- static void CriarSalas(List<Sala> b)
- {
- Sala s = new Sala();
- string pergunta;
- chu:
- pergunta = "Tamanho da sala?";
- int num = TestarInt(pergunta);
- if (num >= 50)
- {
- s.capacidade = num;
- chu2:
- pergunta = ("Tipo de sala? (1 - Espectáculos / 2 - Conferencias");
- int num2 = TestarInt(pergunta);
- if (num2 == 1 || num2 == 2)
- {
- s.tipo = num2;
- for (int p = 0; p < b.Count; p++)
- {
- if (p == b.Count - 1)
- {
- s.numsala = b[p].numsala + 1;
- }
- }
- b.Add(s);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Sala criada com sucesso.");
- Console.ForegroundColor = ConsoleColor.White;
- }
- else {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Tipo de sala não existe");
- Console.ForegroundColor = ConsoleColor.White;
- goto chu2;
- }
- }
- if (num < 50)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("A sala tem que ter pelo menos 50 lugares");
- Console.ForegroundColor = ConsoleColor.White;
- goto chu;
- }
- }
- static void MenuAdmin(List<Login> a, List<Sala> b, List<Sessao> c, List<Conferencia> d, List<BilheteConferencia> e, List<BilheteSessao> f, ref int[] fa)
- {
- int num;
- string pergunta;
- do
- {
- Console.WriteLine("//////////////////////////////////");
- Console.WriteLine("/ 1 - Criar Organizador /");
- Console.WriteLine("/ 2 - Criar Autor /");
- Console.WriteLine("/ 3 - Adicionar Sala /");
- Console.WriteLine("/ 4 - Ver Salas /");
- Console.WriteLine("/ 9 - Logout /");
- Console.WriteLine("//////////////////////////////////");
- pergunta = ("");
- num = TestarInt(pergunta);
- switch (num)
- {
- case 1:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- a.Add(CriarOrganizador(a));
- break;
- case 2:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- a.Add(CriarAutor(a));
- break;
- case 3:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- CriarSalas(b);
- break;
- case 4:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- MostrarSalas(b);
- Console.WriteLine();
- Console.WriteLine();
- break;
- case 9:
- Console.Clear();
- Log(a, b, c, d, ref fa, e, f);
- break;
- default:
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Introduza um valor válido");
- Console.ForegroundColor = ConsoleColor.White;
- break;
- }
- } while (num != 9);
- }
- static void MenuAutor(List<Login> a, List<Sala> b, List<Sessao> c, List<Conferencia> d, List<BilheteConferencia> e, List<BilheteSessao> f, ref int id, ref int[] fa)
- {
- int num;
- string pergunta;
- do
- {
- Console.WriteLine("//////////////////////////////////");
- Console.WriteLine("/ 1 - Ver as suas Conferencias /");
- Console.WriteLine("/ 2 - Inserir Artigo /");
- Console.WriteLine("/ 9 - Logout /");
- Console.WriteLine("//////////////////////////////////");
- pergunta = ("");
- num = TestarInt(pergunta);
- switch (num)
- {
- case 1:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- VerConferenciaAutor(d, ref id);
- break;
- case 2:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- InserirConferenciaAutor(d, ref id);
- break;
- case 9:
- Console.Clear();
- Log(a, b, c, d, ref fa, e, f);
- break;
- default:
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Introduza um valor válido");
- Console.ForegroundColor = ConsoleColor.White;
- break;
- }
- } while (num != 9);
- }
- static void ComprarSessao(List<Login> a, List<Sala> b, List<Sessao> c, List<Conferencia> d, List<BilheteConferencia> e, List<BilheteSessao> f, ref int id)
- {
- string pergunta;
- VerSessao(c);
- pergunta = ("Qual a Sessão que gostaria de assistir?(Use os números para escolher)");
- int num1 = TestarInt(pergunta);
- for (int i = 0; i < c.Count; i++)
- {
- if (num1 == c[i].idsessao)
- {
- for (int n = 0; n < c.Count; n++)
- {
- if (num1 == c[n].idsessao)
- {
- bilh:
- Console.WriteLine("Escolheu a Conferencia " + c[n].nome);
- pergunta = ("Quantos bilhetes deseja comprar?");
- int num2 = TestarInt(pergunta);
- if (num2 > 10)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Só pode comprar 10 bilhetes no máximo");
- Console.ForegroundColor = ConsoleColor.White;
- goto bilh;
- }
- if (num2 > c[n].sala.capacidade)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Só existem " + c[n].sala.capacidade + " bilhetes disponíveis, para o espectáculo: " + c[n].nome);
- Console.ForegroundColor = ConsoleColor.White;
- goto bilh;
- }
- int total = c[n].sala.capacidade - num2;
- Sessao sessao = c[n];
- sessao.sala.capacidade = total;
- c[n] = sessao;
- BilheteSessao h = new BilheteSessao();
- h.login.id = id;
- h.quantidade = num2;
- h.sessao.idsessao = c[n].idsessao;
- h.sessao.nome = c[n].nome;
- h.sala.numsala = c[n].sala.numsala;
- h.data.hora = c[n].data.hora;
- h.data.minutos = c[n].data.minutos;
- h.data.fimhora = c[n].data.fimhora;
- h.data.fimminutos = c[n].data.fimminutos;
- h.data.ano = c[n].data.ano;
- h.data.mes = c[n].data.mes;
- h.data.dia = c[n].data.dia;
- f.Add(h);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine(num2 + " bilhetes comprados com sucesso");
- Console.ForegroundColor = ConsoleColor.White;
- break;
- }
- }
- }
- if (num1 != c[i].idsessao && i == c.Count)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Sessão não existe");
- Console.ForegroundColor = ConsoleColor.White;
- }
- }
- }
- static void Comprar(List<Login> a, List<Sala> b, List<Sessao> c, List<Conferencia> d, List<BilheteConferencia> e, List<BilheteSessao> f, ref int id)
- {
- int resposta;
- string pergunta;
- bili:
- pergunta = ("Tipo de Bilhete a comprar (1 - Espéctaculo normal 2 - Conferencia 0 - Sair)");
- resposta = TestarInt(pergunta);
- if (resposta == 2)
- {
- VerConferencia(d);
- pergunta = ("Qual a Sessão que gostaria de assistir?(Use os números para escolher)");
- int num1 = TestarInt(pergunta);
- for (int n = 0; n < d.Count; n++)
- {
- if (num1 == d[n].idsessao)
- {
- bilh:
- Console.WriteLine("Escolheu a Conferencia " + d[n].nome);
- pergunta = ("Quantos bilhetes deseja comprar?");
- int num2 = TestarInt(pergunta);
- if (num2 < 0)
- {
- Console.WriteLine("Tem que comprar pelo menos 1 bilhete.");
- goto bilh;
- }
- if (num2 > 10)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Só pode comprar 10 bilhetes no máximo");
- Console.ForegroundColor = ConsoleColor.White;
- goto bilh;
- }
- if (num2 > d[n].sala.capacidade)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Só existem " + d[n].sala.capacidade + " bilhetes disponíveis");
- Console.ForegroundColor = ConsoleColor.White;
- goto bilh;
- }
- int total = d[n].sala.capacidade - num2;
- Conferencia sessao = d[n];
- sessao.sala.capacidade = total;
- d[n] = sessao;
- BilheteConferencia y = new BilheteConferencia();
- y.login.id = id;
- y.quantidade = num2;
- y.conferencia.idsessao = d[n].idsessao;
- y.conferencia.nome = d[n].nome;
- y.sala.numsala = d[n].sala.numsala;
- y.data.hora = d[n].data.hora;
- y.data.minutos = d[n].data.minutos;
- y.data.fimhora = d[n].data.fimhora;
- y.data.fimminutos = d[n].data.fimminutos;
- y.data.ano = c[n].data.ano;
- y.data.mes = c[n].data.mes;
- y.data.dia = c[n].data.dia;
- e.Add(y);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine(num2 + " bilhetes comprados com sucesso");
- Console.ForegroundColor = ConsoleColor.White;
- break;
- }
- if (num1 != d[n].idsessao && n == d.Count)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Conferência não existe");
- Console.ForegroundColor = ConsoleColor.White;
- }
- }
- }
- if (resposta == 1)
- {
- ComprarSessao(a, b, c, d, e, f, ref id);
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Opção não existe");
- Console.ForegroundColor = ConsoleColor.White;
- goto bili;
- }
- }
- static void MostrarBilheteConferencia(BilheteConferencia e)
- {
- Console.WriteLine("Nome: {0} Quantidade:{1} Sala:{2} \nData: {3:D2}/{4:D2}/{5} Horário: {6:D2}:{7:D2} - {8:D2}:{9:D2}", e.conferencia.nome, e.quantidade, e.sala.numsala, e.data.dia, e.data.mes, e.data.ano, e.data.hora, e.data.minutos, e.data.fimhora, e.data.fimminutos);
- Console.WriteLine();
- }
- static void MostrarBilheteSessao(BilheteSessao f)
- {
- Console.WriteLine("Nome: {0} Quantidade: {1} Sala:{2} \nData: {3:D2}/{4:D2}/{5} Horário: {6:D2}:{7:D2} - {8:D2}:{9:D2}", f.sessao.nome, f.quantidade, f.sala.numsala, f.data.dia, f.data.mes, f.data.ano, f.data.hora, f.data.minutos, f.data.fimhora, f.data.fimminutos);
- Console.WriteLine();
- }
- static void VerBilhetesCliente(List<Login> a, List<Sala> b, List<Sessao> c, List<Conferencia> d, List<BilheteConferencia> e, List<BilheteSessao> f, ref int id)
- {
- int contar = 0;
- for (int i = 0; i < a.Count; i++)
- {
- if (id == a[i].id)
- {
- for (int k = 0; k < e.Count-1; k++)
- {
- if (e[k].login.id == id)
- {
- MostrarBilheteConferencia(e[k]);
- contar++;
- }
- }
- for (int p = 0; p < f.Count-1; p++)
- {
- if (f[p].login.id == id)
- {
- MostrarBilheteSessao(f[p]);
- contar++;
- }
- }
- }
- if (contar == 0 && i == a.Count - 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Não comprou bilhetes");
- Console.ForegroundColor = ConsoleColor.White;
- }
- }
- }
- static void MenuCliente(List<Login> a, List<Sala> b, List<Sessao> c, List<Conferencia> d, List<BilheteConferencia> e, List<BilheteSessao> f, ref int id, ref int[] fa)
- {
- int num;
- string pergunta;
- do
- {
- Console.WriteLine();
- Console.WriteLine("//////////////////////////////////");
- Console.WriteLine("/ 1 - Ver Espectáculos /");
- Console.WriteLine("/ 2 - Ver Conferencia /");
- Console.WriteLine("/ 3 - Comprar bilhete /");
- Console.WriteLine("/ 4 - Ver bilhetes comprados /");
- Console.WriteLine("/ 9 - Logout /");
- Console.WriteLine("//////////////////////////////////");
- pergunta = ("");
- num = TestarInt(pergunta);
- switch (num)
- {
- case 1:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- VerSessao(c);
- break;
- case 2:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- VerConferencia(d);
- break;
- case 3:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- Comprar(a, b, c, d, e, f, ref id);
- break;
- case 4:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- VerBilhetesCliente(a, b, c, d, e, f, ref id);
- break;
- case 9:
- Console.Clear();
- Log(a, b, c, d, ref fa, e, f);
- break;
- default:
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Introduza um valor válido");
- Console.ForegroundColor = ConsoleColor.White;
- break;
- }
- } while (num != 9);
- }
- static void Log(List<Login> a, List<Sala> b, List<Sessao> c, List<Conferencia> d, ref int[] fa, List<BilheteConferencia> e, List<BilheteSessao> f)
- {
- string pergunta;
- int num;
- int i;
- string user, pass;
- int id;
- do
- {
- pergunta = ("");
- Console.WriteLine();
- Console.WriteLine("//////////////////////////////////");
- Console.WriteLine("/ BEM VINDO! /");
- Console.WriteLine("//////////////////////////////////");
- Console.WriteLine("/ 1 - Registar-se /");
- Console.WriteLine("/ 2 - Login /");
- Console.WriteLine("/ 9 - Sair /");
- Console.WriteLine("//////////////////////////////////");
- num = TestarInt(pergunta);
- switch (num)
- {
- case 1:
- a.Add(CriarCliente(a));
- break;
- case 2:
- Console.Clear();
- do
- {
- Console.WriteLine("//////////////////////////////////");
- Console.WriteLine("/ LOGIN /");
- Console.WriteLine("//////////////////////////////////");
- Console.WriteLine("/ 0 - SAIR /");
- Console.WriteLine("//////////////////////////////////");
- tua:
- Console.Write("Username: ");
- user = Console.ReadLine();
- int tipo;
- for (i = 0; i < a.Count; i++)
- {
- if (user != a[i].username && i == a.Count - 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Username não existe");
- Console.ForegroundColor = ConsoleColor.White;
- }
- if (user == a[i].username)
- {
- Console.WriteLine();
- tipo = a[i].tipo;
- Console.Write("Password: ");
- pass = Console.ReadLine();
- if (pass != a[i].password)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Password Errada. Tente de novo.");
- Console.ForegroundColor = ConsoleColor.White;
- goto tua;
- }
- else
- {
- if (tipo == 1)
- {
- id = a[i].id;
- Console.Clear();
- MenuCliente(a, b, c, d, e, f, ref id, ref fa);
- }
- if (tipo == 2)
- {
- Console.Clear();
- MenuOrganizador(a, b, c, d, e, f, ref fa);
- }
- if (tipo == 3)
- {
- id = a[i].id;
- Console.Clear();
- MenuAutor(a, b, c, d, e, f, ref id, ref fa);
- }
- if (tipo == 4)
- {
- Console.Clear();
- MenuAdmin(a, b, c, d, e, f, ref fa);
- }
- }
- }
- }
- } while (user != "0");
- break;
- case 9:
- System.Environment.Exit(1);
- break;
- default:
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Opção não existe");
- Console.ForegroundColor = ConsoleColor.White;
- break;
- }
- } while (num != 9);
- }
- static void MenuOrganizador(List<Login> a, List<Sala> b, List<Sessao> c, List<Conferencia> d, List<BilheteConferencia> e, List<BilheteSessao> f, ref int[] fa)
- {
- int num;
- string pergunta;
- do
- {
- Console.WriteLine();
- Console.WriteLine("///////////////////////////////////////////");
- Console.WriteLine("/ 1 - Ver Espectáculos /");
- Console.WriteLine("/ 2 - Ver Conferencias /");
- Console.WriteLine("/ 3 - Criar Espectáculos / Conferencias /");
- Console.WriteLine("/ 4 - Apagar Espectáculos / Conferências /");
- Console.WriteLine("/ 9 - Logout /");
- Console.WriteLine("///////////////////////////////////////////");
- pergunta = ("");
- num = TestarInt(pergunta);
- switch (num)
- {
- case 1:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- VerSessao(c);
- break;
- case 2:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- VerConferencia(d);
- break;
- case 3:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- CriarEspectaculo(a, b, c, d, e, f, ref fa);
- break;
- case 4:
- Console.Clear();
- Console.WriteLine();
- Console.WriteLine();
- Apagar(a, b, c, d);
- break;
- case 9:
- Console.Clear();
- Log(a, b, c, d, ref fa, e, f);
- break;
- default:
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Introduza um valor válido");
- Console.ForegroundColor = ConsoleColor.White;
- break;
- }
- } while (num != 9);
- }
- static void VerSalas(Sala b)
- {
- Console.Write("Sala - {0} Lugares: {1} ", b.numsala, b.capacidade);
- }
- static void MostrarSalas(List<Sala> b)
- {
- for (int i = 0; i < b.Count; i++)
- {
- VerSalas(b[i]);
- }
- }
- static void VerAutor(Login a)
- {
- Console.Write("{1} - {0}", a.nome, a.id);
- }
- static void MostrarAutor(List<Login> a)
- {
- for (int i = 0; i < a.Count; i++)
- {
- if (a[i].tipo == 3)
- {
- VerAutor(a[i]);
- }
- }
- }
- static void VerificarHoras(ref int[] fa, int contare, int hora1, int hora2, int min1, int min2, int tipo, List<Sessao> c, ref int ok)
- {
- int contar = 0;
- int conta = 0;
- ok = 0;
- if (contare == 1)
- {
- for (int k = 0; k < c.Count; k++)
- {
- if (fa[0] == c[k].idsessao)
- {
- if (c[k].data.fimhora < hora1)
- {
- conta++;
- }
- if (c[k].data.hora > hora1)
- {
- if (c[k].data.hora > hora2)
- {
- conta++;
- }
- }
- else
- {
- contar++;
- }
- }
- }
- }
- if (conta == contare)
- {
- ok = 1;
- }
- conta = 0;
- if (contare > 1)
- {
- for (int i = 0; i < fa.Length; i++)
- {
- for (int k = 0; k < c.Count; k++)
- {
- if (fa[i] == c[k].idsessao)
- {
- if (c[k].data.hora > hora1 && c[k].data.hora > hora2)
- {
- if (c[k].data.hora > hora2)
- {
- conta++;
- }
- else
- {
- break;
- }
- }
- if (c[k].data.fimhora < hora1)
- {
- conta++;
- }
- else
- {
- break;
- }
- }
- }
- }
- if (conta == contare)
- {
- ok = 1;
- }
- }
- }
- static void VerificaHorasConferencia(ref int[] fa, int contare, int hora1, int hora2, int min1, int min2, int tipo, List<Conferencia> d, ref int ok)
- {
- int contar = 0;
- int conta = 0;
- ok = 0;
- if (contare == 1)
- {
- for (int k = 0; k < d.Count; k++)
- {
- if (fa[0] == d[k].idsessao)
- {
- if (d[k].data.fimhora < hora1)
- {
- conta++;
- }
- if (d[k].data.hora > hora1)
- {
- if (d[k].data.hora > hora2)
- {
- conta++;
- }
- }
- else
- {
- contar++;
- }
- }
- }
- }
- if (conta == contare)
- {
- ok = 1;
- }
- conta = 0;
- if (contare > 1)
- {
- for (int i = 0; i < fa.Length; i++)
- {
- for (int k = 0; k < d.Count; k++)
- {
- if (fa[i] == d[k].idsessao)
- {
- if (d[k].data.hora > hora1 && d[k].data.hora > hora2)
- {
- if (d[k].data.hora > hora2)
- {
- conta++;
- }
- else
- {
- break;
- }
- }
- if (d[k].data.fimhora < hora1)
- {
- conta++;
- }
- else
- {
- break;
- }
- }
- }
- }
- if (conta == contare)
- {
- ok = 1;
- }
- }
- }
- static void CriarConferencia(List<Login> a, List<Sala> b, List<Sessao> c, List<Conferencia> d, List<BilheteConferencia> e, List<BilheteSessao> f, ref int[] fa)
- {
- string pergunta;
- int ano, mes, dia;
- int contador = 0;
- pergunta = ("Sessões a criar?");
- int num = TestarInt(pergunta);
- for (int i = 0; i < num; i++)
- {
- for (int o = 0; o < b.Count; o++)
- {
- if (b[o].tipo == 2)
- VerSalas(b[o]);
- }
- Conferencia s = new Conferencia();
- sui:
- pergunta = ("\nSala a ocupar");
- int num2 = TestarInt(pergunta);
- // Ver se sala introduzida existe
- for (int u = 0; u < b.Count; u++)
- {
- if (num2 != b[u].numsala)
- {
- contador++;
- }
- if (num2 != b[u].numsala && contador == b.Count)
- {
- contador = 0;
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Sala não existe.");
- Console.ForegroundColor = ConsoleColor.White;
- goto sui;
- }
- if (num2 == b[u].numsala)
- {
- if (b[u].tipo == 2)
- {
- s.sala.numsala = num2;
- s.sala.capacidade = b[u].capacidade;
- }
- else
- {
- contador = 0;
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Sala escolhida não serve.");
- Console.ForegroundColor = ConsoleColor.White;
- goto sui;
- }
- lol:
- Console.WriteLine("Dia do Espectáculo? (dd-mm-AAAA ou dd/mm/AAAA)");
- string[] dataa = Console.ReadLine().Split('-', '/');
- ano = Convert.ToInt32(dataa[2]);
- if (ano < 2016)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("Só pode marcar espectáculos no ano de 2016 ou mais\n");
- Console.ForegroundColor = ConsoleColor.White;
- goto lol;
- }
- mes = Convert.ToInt32(dataa[1]);
- if (mes > 12 || mes < 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Só existem 12 meses");
- Console.ForegroundColor = ConsoleColor.White;
- goto lol;
- }
- dia = Convert.ToInt32(dataa[0]);
- if (mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12)
- {
- if (dia > 31 || dia < 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("O mês escolhido tem apenas 31 dias.");
- Console.ForegroundColor = ConsoleColor.White;
- goto lol;
- }
- }
- if (mes == 4 || mes == 6 || mes == 9 || mes == 11)
- {
- if (dia > 30 || dia < 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("O mês escolhido tem apenas 30 dias.");
- Console.ForegroundColor = ConsoleColor.White;
- goto lol;
- }
- }
- if (mes == 2)
- {
- if (dia > 28 || dia < 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("O mês escolhido tem apenas 28 dias.");
- Console.ForegroundColor = ConsoleColor.White;
- goto lol;
- }
- }
- s.data.dia = dia;
- s.data.mes = mes;
- s.data.ano = ano;
- tui:
- int ok = 0;
- int contar = 0;
- int contare = 0;
- int o;
- int tipo = 0;
- Console.WriteLine("Hora de começo? (hh:mm)");
- string[] horaa = Console.ReadLine().Split(':');
- int hora1 = Convert.ToInt32(horaa[0]);
- int min1 = Convert.ToInt32(horaa[1]);
- Console.WriteLine("Hora de finalização? (hh:mm)");
- string[] horaa2 = Console.ReadLine().Split(':');
- int hora2 = Convert.ToInt32(horaa2[0]);
- int min2 = Convert.ToInt32(horaa2[1]);
- if (min2 < 0 || min2 > 59 || min1 < 0 || min1 > 59)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Minutos mal introduzidos");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- if (hora1 < 9 || hora2 < 9 || hora1 > 24 || hora2 > 24)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Os espéctaculos só podem durar até às 24:00 e começar às 9:00");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- if (hora1 == 24 || hora2 == 24)
- {
- if (min1 > 0 || min2 > 0)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("O establecimento fecha às 24.00");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- }
- if (hora1 + 1 > hora2)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Os espectáculos têm que durar pelo menos uma hora");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- if (hora1 > hora2)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("A hora de início tem que ser menor que a hora final");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- //show de uma hora
- if (hora1 + 1 == hora2)
- {
- if (min1 > min2)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Os espectáculos têm de durar pelo menos uma hora");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- if (min1 <= min2)
- {
- tipo = 1;
- }
- }
- if (fa.Length >= 1)
- {
- Array.Clear(fa, 0, fa.Length);
- }
- for (o = 0; o < d.Count; o++)
- {
- if (d[o].data.mes != s.data.mes && s.data.ano != d[o].data.ano && d[o].data.dia != s.data.dia)
- {
- contar++;
- }
- if (mes == d[o].data.mes && dia == d[o].data.dia && ano == d[o].data.ano && d[o].sala.numsala == s.sala.numsala)
- {
- Array.Resize(ref fa, fa.Length + 1);
- fa[contare] = d[o].idsessao;
- contare++;
- }
- }
- if (contare >= 1)
- {
- VerificaHorasConferencia(ref fa, contare, hora1, hora2, min1, min2, tipo, d, ref ok);
- if (ok == 1)
- {
- s.data.hora = hora1;
- s.data.minutos = min1;
- s.data.fimhora = hora2;
- s.data.fimminutos = min2;
- }
- if (ok != 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Hora indisponível.");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- Console.WriteLine("Nome");
- s.nome = Console.ReadLine();
- for (int p = 0; p < d.Count; p++)
- {
- if (p == d.Count - 1)
- {
- s.idsessao = d[p].idsessao + 1;
- }
- }
- s.local = "Teatro Gil Vicente";
- d.Add(s);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Conferência criada com sucesso.");
- Console.ForegroundColor = ConsoleColor.White;
- MenuOrganizador(a, b, c, d, e, f, ref fa);
- }
- //////////////////////////////////////////////////////////////////////////////NÃO HÁ DATAS REPETIDAS/////////////////////////////////////////////////////////////////////////////////////////////////////
- if (contare < 1)
- {
- s.data.hora = hora1;
- s.data.minutos = min1;
- s.data.fimhora = hora2;
- s.data.fimminutos = min2;
- Console.WriteLine("Nome");
- s.nome = Console.ReadLine();
- for (int p = 0; p < d.Count; p++)
- {
- if (p == d.Count - 1)
- {
- s.idsessao = d[p].idsessao + 1;
- }
- }
- s.local = "Teatro Gil Vicente";
- d.Add(s);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Conferência criada com sucesso.");
- Console.ForegroundColor = ConsoleColor.White;
- MenuOrganizador(a, b, c, d, e, f, ref fa);
- }
- }
- }
- }
- }
- static void CriarEspectaculo(List<Login> a, List<Sala> b, List<Sessao> c, List<Conferencia> d, List<BilheteConferencia> e, List<BilheteSessao> f, ref int[] fa)
- {
- string pergunta;
- int resposta;
- int ano, mes, dia;
- int contador = 0;
- sar:
- pergunta = ("Tipo de espectáculo (1 - Espéctaculo normal 2 - Conferencia 0 - Sair");
- resposta = TestarInt(pergunta);
- if (resposta == 1)
- {
- pergunta = ("Sessões a criar?");
- int num = TestarInt(pergunta);
- for (int i = 0; i < num; i++)
- {
- for (int o = 0; o < b.Count; o++)
- {
- if (b[o].tipo == 1)
- VerSalas(b[o]);
- }
- Sessao s = new Sessao();
- sui:
- pergunta = ("\nSala a ocupar");
- int num2 = TestarInt(pergunta);
- // Ver se sala introduzida existe
- for (int u = 0; u < b.Count; u++)
- {
- if (num2 != b[u].numsala)
- {
- contador++;
- }
- if (num2 != b[u].numsala && contador == b.Count)
- {
- contador = 0;
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Sala não existe.");
- Console.ForegroundColor = ConsoleColor.White;
- goto sui;
- }
- if (num2 == b[u].numsala)
- {
- if (b[u].tipo == 1)
- {
- s.sala.numsala = num2;
- s.sala.capacidade = b[u].capacidade;
- }
- else
- {
- contador = 0;
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Sala escolhida não serve.");
- Console.ForegroundColor = ConsoleColor.White;
- goto sui;
- }
- lol:
- Console.WriteLine("Dia do Espectáculo? (dd-mm-AAAA ou dd/mm/AAAA)");
- string[] dataa = Console.ReadLine().Split('-', '/');
- ano = Convert.ToInt32(dataa[2]);
- if (ano < 2016)
- {
- Console.Write("Só pode marcar espectáculos no ano de 2016 ou mais\n");
- goto lol;
- }
- mes = Convert.ToInt32(dataa[1]);
- if (mes > 12 || mes < 1)
- {
- Console.WriteLine("Só existem 12 meses");
- goto lol;
- }
- dia = Convert.ToInt32(dataa[0]);
- if (mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12)
- {
- if (dia > 31 || dia < 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("O mês escolhido tem apenas 31 dias.");
- Console.ForegroundColor = ConsoleColor.White;
- goto lol;
- }
- }
- if (mes == 4 || mes == 6 || mes == 9 || mes == 11)
- {
- if (dia > 30 || dia < 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("O mês escolhido tem apenas 30 dias.");
- Console.ForegroundColor = ConsoleColor.White;
- goto lol;
- }
- }
- if (mes == 2)
- {
- if (dia > 28 || dia < 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("O mês escolhido tem apenas 2 dias.");
- Console.ForegroundColor = ConsoleColor.White;
- goto lol;
- }
- }
- s.data.dia = dia;
- s.data.mes = mes;
- s.data.ano = ano;
- tui:
- int ok = 0;
- int contar = 0;
- int contare = 0;
- int o;
- int tipo = 0;
- Console.WriteLine("Hora de começo? (hh:mm)");
- string[] horaa = Console.ReadLine().Split(':');
- int hora1 = Convert.ToInt32(horaa[0]);
- int min1 = Convert.ToInt32(horaa[1]);
- Console.WriteLine("Hora de finalização? (hh:mm)");
- string[] horaa2 = Console.ReadLine().Split(':');
- int hora2 = Convert.ToInt32(horaa2[0]);
- int min2 = Convert.ToInt32(horaa2[1]);
- if (min2 < 0 || min2 > 59 || min1 < 0 || min1 > 59)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Minutos mal introduzidos");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- if (hora1 < 9 || hora2 < 9 || hora1 > 24 || hora2 > 24)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Os espéctaculos só podem durar até às 24:00 e começar às 9:00");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- if (hora1 == 24 || hora2 == 24)
- {
- if (min1 > 0 || min2 > 0)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("O establecimento fecha às 24.00");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- }
- if (hora1 + 1 > hora2)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Os espectáculos têm que durar pelo menos uma hora");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- if (hora1 > hora2)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("A hora de início tem que ser menor que a hora final");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- //show de uma hora
- if (hora1 + 1 == hora2)
- {
- if (min1 > min2)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Os espectáculos têm de durar pelo menos uma hora");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- if (min1 <= min2)
- {
- tipo = 1;
- }
- }
- if (fa.Length >= 1)
- {
- Array.Clear(fa, 0, fa.Length);
- }
- for (o = 0; o < c.Count; o++)
- {
- if (c[o].data.mes != s.data.mes && s.data.ano != c[o].data.ano && c[o].data.dia != s.data.dia)
- {
- contar++;
- }
- if (mes == c[o].data.mes && dia == c[o].data.dia && ano == c[o].data.ano && c[o].sala.numsala == s.sala.numsala)
- {
- Array.Resize(ref fa, fa.Length + 1);
- fa[contare] = c[o].idsessao;
- contare++;
- }
- }
- if (contare >= 1)
- {
- VerificarHoras(ref fa, contare, hora1, hora2, min1, min2, tipo, c, ref ok);
- if (ok == 1)
- {
- s.data.hora = hora1;
- s.data.minutos = min1;
- s.data.fimhora = hora2;
- s.data.fimminutos = min2;
- }
- if (ok != 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Hora indisponível.");
- Console.ForegroundColor = ConsoleColor.White;
- goto tui;
- }
- Console.WriteLine("Nome");
- s.nome = Console.ReadLine();
- for (int p = 0; p < c.Count; p++)
- {
- if (p == c.Count - 1)
- {
- s.idsessao = c[p].idsessao + 1;
- }
- }
- s.local = "Teatro Gil Vicente";
- c.Add(s);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Espectáculo criado com sucesso.");
- Console.ForegroundColor = ConsoleColor.White;
- MenuOrganizador(a, b, c, d, e, f, ref fa);
- }
- //////////////////////////////////////////////////////////////////////////////NÃO HÁ DATAS REPETIDAS/////////////////////////////////////////////////////////////////////////////////////////////////////
- if (contare < 1)
- {
- s.data.hora = hora1;
- s.data.minutos = min1;
- s.data.fimhora = hora2;
- s.data.fimminutos = min2;
- Console.WriteLine("Nome");
- s.nome = Console.ReadLine();
- for (int p = 0; p < c.Count; p++)
- {
- if (p == c.Count - 1)
- {
- s.idsessao = c[p].idsessao + 1;
- }
- }
- s.local = "Teatro Gil Vicente";
- c.Add(s);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Espectáculo criado com sucesso.");
- Console.ForegroundColor = ConsoleColor.White;
- MenuOrganizador(a, b, c, d, e, f, ref fa);
- }
- }
- }
- }
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //Criar Conferencia
- if (resposta == 2)
- {
- CriarConferencia(a, b, c, d, e, f, ref fa);
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Opção escolhida não é válida");
- Console.ForegroundColor = ConsoleColor.White;
- goto sar;
- }
- }
- static void Main(string[] args)
- {
- int[] fa = new int[0] { };
- List<Login> a = new List<Login>();
- List<Sala> b = new List<Sala>();
- List<Sessao> c = new List<Sessao>();
- List<Conferencia> d = new List<Conferencia>();
- List<BilheteConferencia> e = new List<BilheteConferencia>();
- List<BilheteSessao> f = new List<BilheteSessao>();
- CarregarClientes(a);
- CarregarOrganizadores(a);
- CarregarAutor(a);
- CarregarAdmin(a);
- CarregarSalas(b);
- CarregarSessao(c);
- CarregarConferencias(d);
- Log(a, b, c, d, ref fa, e, f);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement