Guest User

Untitled

a guest
Feb 6th, 2016
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7.  
  8. namespace RegistrazioneLogin
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string username, password;
  15.             int scelta, numerouser;
  16.             Console.WriteLine("Sistema di Registrazione/Login. Powered by XXXXXXXXX. Vietata la ridistribuzione.");
  17.             Console.Write("Sei un nuovo utente (0 no/1 si)? ");
  18.             scelta = Convert.ToInt32(Console.ReadLine());
  19.             switch (scelta)
  20.             {
  21.                 case 0:
  22.                     Console.Write("Inserisci il tuo numero utente: ");
  23.                     numerouser = Convert.ToInt32(Console.ReadLine());
  24.                     Loginew.logga(username, password, numerouser);
  25.                     break;
  26.                 case 1:
  27.                     Console.Write("Inserisci il numero dell'utente: ");
  28.                     numerouser = Convert.ToInt32(Console.ReadLine());
  29.                     Registrazione.Registra(username, password, numerouser);
  30.                     Console.WriteLine("Ora eseguirai il login.");
  31.                     Loginew.logga(username, password, numerouser);
  32.                     break;
  33.                 default:
  34.                     Console.WriteLine("Numero inserito non valido, chiusura del programma...");
  35.                     break;
  36.             }
  37.         }
  38.     }
  39.     class Registrazione
  40.     {
  41.         public static void Registra(string nomeutente, string passparola, int numutente)
  42.         {
  43.             Console.Write("Inserisci il nome utente che vuoi utilizzare: ");
  44.             StreamWriter utente = new StreamWriter("C:\\Users\\Administrator\\Desktop\\RegistrazioneLogin\\user" + numutente + ".txt", false);
  45.             nomeutente = Convert.ToString(Console.ReadLine());
  46.             utente.WriteLine("Username:" + nomeutente);
  47.             Console.Write("Inserisci la password che vuoi utilizzare: ");
  48.             passparola = Convert.ToString(Console.ReadLine());
  49.             utente.WriteLine("Password: " + passparola);
  50.             utente.Close();
  51.             Console.WriteLine("Registrazione eseguita! Numero utente: " + numutente);
  52.         }
  53.     }
  54.     class Loginew
  55.     {
  56.         public static void logga(string nomeutente, string passparola, int numutente)
  57.         {
  58.             StreamReader utente = new StreamReader("C:\\Users\\Administrator\\Desktop\\RegistrazioneLogin\\user" + numutente + ".txt");
  59.             Console.Write("Inserisci il tuo nome utente: ");
  60.             nomeutente = Convert.ToString(Console.ReadLine());
  61.             if (nomeutente == Registrazione.nomeutente)
  62.             {
  63.                 Console.Write("Inserisci la password: ");
  64.                 passparola = Convert.ToString(Console.ReadLine());
  65.                 if (passparola = Registrazione.passparola)
  66.                 {
  67.                     Console.WriteLine("Sei entrato correttamente nel tuo account!");
  68.                 } else Console.WriteLine("Password errata, chiusura del programma...");
  69.             } else Console.WriteLine("Nome utente errato, chiusura del programma...");
  70.             utente.Close();
  71.         }
  72.     }
  73. }
Add Comment
Please, Sign In to add comment