-
کد برنامه ویرایش شد :
[code]#include <iostream>
#include <string.h>
#include <fstream>
#include <conio.h>
#include <windows.h>
#include "Borders.h"
using namespace std;
const int NameSize=40;
char Name[NameSize];
string FirstName;
string LastName;
string Telephone;
string Mobile;
string Address;
string FirstName2;
string LastName2;
string Telephone2;
string Mobile2;
string Address2;
void QuestionForm (int);
void SaveDataBase();
void ImportDataBase(char DBName[]);
void AboutDisplayMassage();
void gotoxy(int x,int y)
{
COORD pos;
HANDLE hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
if (INVALID_HANDLE_VALUE != hConsole)
{
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition( hConsole, pos );
}
}
int main () {
int ResumeProgram=true;
while (ResumeProgram) {
SetConsoleTitle("Phone Book Classic");
char answer;
HANDLE hOut;
hOut = GetStdHandle (STD_OUTPUT_HANDLE);
system("cls");
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
cout<<"\n\n\n\n\n\n";
cout<<" ____________________________ "<<endl;
cout<<" | |"<<endl;
cout<<" | ++ Welcome ++ |"<<endl;
cout<<" | |"<<endl;
cout<<" | ++ Select a modify ++ |"<<endl;
cout<<" | |"<<endl;
cout<<" | 1.Enter Data |"<<endl;
cout<<" | |"<<endl;
cout<<" | 2.Import Data |"<<endl;
cout<<" | |"<<endl;
cout<<" | 3.About |"<<endl;
cout<<" | |"<<endl;
cout<<" | 4.Quit |"<<endl;
cout<<" |____________________________|"<<endl;
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_BLUE|FOREGROUND_INTENSITY);
cout<<"\n\n Answer :";
At (39,22,(unsigned char)186);
At (41,22,(unsigned char)186);
At (40,21,(unsigned char)205);
At (40,23,(unsigned char)205);
At (41,21,(unsigned char)187);
At (41,23,(unsigned char)188);
At (39,21,(unsigned char)201);
At (39,23,(unsigned char)200);
gotoxy(40,22);
SetConsoleTextAttribute(hOut,FOREGROUND_RED|FOREGR OUND_BLUE|FOREGROUND_INTENSITY);
cin>>answer;
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_BLUE);
switch (answer) {
case '1' :
QuestionForm(1);
break;
case '2' :
QuestionForm(2);
break;
case '3' :
AboutDisplayMassage();
break;
case '4' :
ResumeProgram=false;
break;
default :
break;}}
return 0;}
void QuestionForm (int modify){
HANDLE hOut;
hOut = GetStdHandle (STD_OUTPUT_HANDLE);
if (modify==1){
SetConsoleTitle("Phone Book Classic > Save Data");
system("cls");
cout<<"\n\n\n\n\n\n";
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
cout<<" Enter DataBase Name : ";
cin>>Name;
system("cls");
cout<<"\n";
cout<<"\n First Name : ";
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_INTENSITY);
At(18,2,(unsigned char)179);
At(50,2,(unsigned char)179);
At(18,1,(unsigned char)218);
At(50,1,(unsigned char)191);
At(18,3,(unsigned char)192);
At(50,3,(unsigned char)217);
for (int body=19;body<=49;body++) {
At(body,1,(unsigned char)196);}
for (int bottom=19;bottom<=49;bottom++) {
At(bottom,3,(unsigned char)196);}
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
cout<<"\n\n Last Name : ";
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_INTENSITY);
At(18,5,(unsigned char)179);
At(50,5,(unsigned char)179);
At(18,4,(unsigned char)218);
At(50,4,(unsigned char)191);
At(18,6,(unsigned char)192);
At(50,6,(unsigned char)217);
for (int body2=19;body2<=49;body2++) {
At(body2,4,(unsigned char)196);}
for (int bottom2=19;bottom2<=49;bottom2++) {
At(bottom2,6,(unsigned char)196);}
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
cout<<"\n\nTelephone Number : ";
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_INTENSITY);
At(18,8,(unsigned char)179);
At(50,8,(unsigned char)179);
At(18,7,(unsigned char)218);
At(50,7,(unsigned char)191);
At(18,9,(unsigned char)192);
At(50,9,(unsigned char)217);
for (int body3=19;body3<=49;body3++) {
At(body3,7,(unsigned char)196);}
for (int bottom3=19;bottom3<=49;bottom3++) {
At(bottom3,9,(unsigned char)196);}
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
cout<<"\n\n Moblie Number : ";
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_INTENSITY);
At(18,11,(unsigned char)179);
At(50,11,(unsigned char)179);
At(18,10,(unsigned char)218);
At(50,10,(unsigned char)191);
At(18,12,(unsigned char)192);
At(50,12,(unsigned char)217);
for (int body4=19;body4<=49;body4++) {
At(body4,10,(unsigned char)196);}
for (int bottom4=19;bottom4<=49;bottom4++) {
At(bottom4,12,(unsigned char)196);}
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
cout<<"\n\n Address : ";
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_INTENSITY);
At(18,14,(unsigned char)179);
At(50,14,(unsigned char)179);
At(18,13,(unsigned char)218);
At(50,13,(unsigned char)191);
At(18,15,(unsigned char)192);
At(50,15,(unsigned char)217);
for (int body5=19;body5<=49;body5++) {
At(body5,13,(unsigned char)196);}
for (int bottom5=19;bottom5<=49;bottom5++) {
At(bottom5,15,(unsigned char)196);}
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
cin.sync();
gotoxy(19,2);
getline(cin,FirstName2);
gotoxy(19,5);
getline(cin,LastName2);
gotoxy(19,8);
getline(cin,Telephone2);
gotoxy(19,11);
getline(cin,Mobile2);
gotoxy(19,14);
getline(cin,Address2);
FirstName=" FirstName : "+FirstName2;
LastName= " LastName : "+LastName2;
Telephone=" Telephone Number : "+Telephone2;
Mobile= " Mobile Number : "+Mobile2;
Address= " Address : "+Address2;
SaveDataBase();}
else {
SetConsoleTitle("Phone Book Classic > Load Data");
system("cls");
cout<<"\n\n\n\n\n\n";
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
cout<<" Enter DataBase Name : ";
cin>>Name;
system("cls");
ImportDataBase(Name);}
}
void SaveDataBase(){
ofstream DB;
DB.open(Name);
DB<<FirstName<<"\n\n"<<LastName<<"\n\n"<<Telephone <<"\n\n"<<Mobile<<"\n\n"<<Address;
DB.close();
cout<<"\n\nThe Datas has been saved !...";
getch();}
void ImportDataBase(char DBName[]){
HANDLE hOut;
hOut = GetStdHandle (STD_OUTPUT_HANDLE);
string Buffer;
ifstream myDB (DBName);
if (myDB.is_open())
{
while (! myDB.eof() )
{
getline (myDB,Buffer);
SetConsoleTextAttribute(hOut,FOREGROUND_GREEN|FORE GROUND_INTENSITY);
cout << Buffer<<endl;
}
myDB.close();
}
else cout << "Unable to open file";
getch();}
void AboutDisplayMassage() {
SetConsoleTitle("Phone Book Classic > About");
system("cls");
cout<<"\n\n\n\n";
cout<<" ____________________________ "<<endl;
cout<<" | |"<<endl;
cout<<" | This Program |"<<endl;
cout<<" | |"<<endl;
cout<<" | Writed by C++ in |"<<endl;
cout<<" | |"<<endl;
cout<<" | Agust 2008 - 1387 H.SH |"<<endl;
cout<<" | |"<<endl;
cout<<" | If you find a bug in this |"<<endl;
cout<<" | Call with this E-Mail : |"<<endl;
cout<<" | Hosein1986@Hotmail.com |"<<endl;
cout<<" |____________________________|"<<endl;
getch();}
[code]
-
پس فارسي چطور ؟ اخه من برنامه ي بانك كه تحت داس هست رو ديدم كه كاملا فارسي بود (چه ورودي چه خروجي) ؟
در عين حال امضاي صاحبحساب رو هم بصورت عكس نشون ميداد .