Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //User Manager 1.0 by Ilir "Skifter" Prenku
- #include "windows.h"
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- ///////////////////////////////////////////////Functions Used////////////////////////////////////////////////////
- int LoginAttempts(int value);
- void loadingBar(int);
- void addNewUser();
- void CreateUser(char * firstn, char * lastn, float balance, short iD);
- void DisplayOptions();
- void newUser();
- char tab = '\t';
- bool status = 1;
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- class CreateAcc
- {
- public:
- char *fName, *lName;
- short iD;
- float EditBalance(float currentBalance, float addRemove) { currentBalance = (addRemove + currentBalance); return currentBalance; };
- float AddBalance(float balance) { currentBalance = balance; return balance; };
- float dispBalance() {
- float myBalance = currentBalance; return myBalance;
- };
- private:
- float currentBalance;
- };
- int main()
- {
- system("title User Management SNC-SyS 1.0"); //Window Title - Programm Name
- system("color E");
- int input;
- if (!LoginAttempts(3))
- cout << "Program will Exit.\n";
- //else
- //cout << "we can continue with the programm\n.";
- else
- {
- do
- {
- DisplayOptions();
- cout << "\n\nType in Your Option: ";
- cin >> input;
- switch (input)
- {
- case 0: status = 0;
- break;
- case 1: cout << "Finding User";
- break;
- case 2: addNewUser();
- break;
- case 3: cout << "Add Remove Balance";
- break;
- default: cout << "Give an Option from above.";
- break;
- }
- } while (status);
- }
- system("cls");
- cout <<"\n\n\tThank you For Using SNC Softwares - Hope we'll see you soon...";
- Sleep(3000);
- exit(0);
- system("pause");
- return 0;
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void CreateUser(char * firstn, char * lastn, float balance, short iD)
- {
- ofstream dataB;
- system("cls");
- cout << ".:==============================SNC/SYS==================================:.\n\n";
- cout << " User Created ID: " << iD << " \n";
- cout << "===========================================================================\n";
- CreateAcc account;
- account.fName = firstn;
- account.lName = lastn;
- account.iD = iD;
- account.AddBalance(balance);
- cout << endl;
- cout << " First Name: " << account.fName << endl;
- cout << " Last Name: " << account.lName << endl;
- cout << " Balance: " << account.dispBalance()<< endl;
- cout << "===========================================================================\n";
- dataB.open("database.txt");
- dataB<< account.iD <<tab<<account.fName << tab << account.lName <<tab<< account.AddBalance(balance) << endl;
- dataB.close();
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- int LoginAttempts(int counter)
- {
- string usr, pass;
- int login = 0;
- cout << ".:==============================SNC/SYS==================================:.\n\n";
- while (counter != 0)
- {
- cout << "Username: ";
- cin >> usr;
- cout << "\nPassword: ";
- cin >> pass;
- if (usr == "admin" && pass == "skifteri")
- {
- counter = 0;
- system("cls");
- cout << "Connecting to License Server\n";
- loadingBar(50);
- cout << "\nLogged in Succesfully..\n";
- Sleep(3000);
- system("cls");
- login = 1;
- }
- else
- {
- counter--;
- system("cls");
- cout << ".:==============================SNC/SYS==================================:.\n\n";
- cout << "Attempts left : " << counter <<" !!\n\n";
- Beep(750, 300); Beep(750, 300); Beep(750, 300);
- if (counter == 0 && (usr != "admin" || pass != "skifteri"))
- {
- system("cls");
- system("color c");
- cout << "Wrong User or Password... \nContact your system administrator."; Sleep(3000); exit(0);
- login = 0;
- }
- }
- }
- return login;
- };
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void addNewUser()
- {
- system("cls");
- cout << "\t\t\t\tCreating New User to Database\n-----------------------------------------------------------------------------\n";
- char fname[15], lname[15]; float balance; int iD;
- cout << "Type the Firstname: ";
- cin >> fname;
- cout << endl;
- cout << "Type the Lastname: ";
- cin >> lname;
- cout << endl;
- cout << "Id Number: ";
- cin >> iD;
- cout << endl;
- cout << "Type Balance: ";
- cin >> balance;
- CreateUser(fname, lname, balance, iD);
- };
- void DisplayOptions()
- {
- cout << ".:==============================SNC/SYS==================================:.\n\n";
- cout << "1. Find Account" << endl;
- cout << "2. Create Account" << endl;
- cout << "3. Add/Remove Balance to Account" << endl;
- cout << "4. Edit Account" << endl;
- cout << "5. Exit System" << endl;
- }
- void loadingBar(int i)
- {
- char load = ':';
- cout << "STATUS: ";
- for (i; i<100; i++)
- {
- Sleep(100);
- cout << load;
- }
- cout<<" Loaded 100%" ; Sleep(1000);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement