Example #1
0
        private void buttonRegistarClube_Click(object sender, EventArgs e)
        {
            //Nome
            if (String.IsNullOrEmpty(textBoxNovoNome.Text) || textBoxNovoNome.Text == " ")
            {
                _FormInicio.EscreverNaConsola("Nome em falta!");
                return;
            }

            //Fotografia
            if (Foto == "nada")
            {
                _FormInicio.EscreverNaConsola("Foto em falta!");
                return;
            }

            try
            {
                //Verificar diretório  dos clubes
                if (!Directory.Exists("E:\\Rascal\\Clubes"))
                {
                    Directory.CreateDirectory("E:\\Rascal\\Clubes");
                }

                //Guardar Foto
                string[] parts    = Foto.Split('.');
                string   NovaFoto = "E:\\Rascal\\Clubes\\" + Funcionalidades.RemoveWhitespace(Funcionalidades.RemoveSpecialCharacters(textBoxNovoNome.Text)) + "." + parts[parts.Count() - 1];
                File.Move(Foto, NovaFoto);

                //Registar novo clube
                Funcionalidades.GuardarNovoClube(textBoxNovoNome.Text, Funcionalidades.RemoveWhitespace(Funcionalidades.RemoveSpecialCharacters(textBoxNovoNome.Text)) + "." + parts[parts.Count() - 1]);
            }
            catch (Exception ex)
            {
                _FormInicio.EscreverNaConsola("Erro ao registar o clube...");
                Console.WriteLine(ex.ToString());
                return;
            }

            _FormInicio.EscreverNaConsola(textBoxNovoNome.Text + " registado!");

            LimparFormNovoClube();

            //Refresh list view
            CarregarListaClubes();
        }