Jump to content
fynaz

Tolong Saye Please..anyone..=(

Recommended Posts

what's wrong ngan coding ni ek?coding ni tk full...nk display data customer baru tk appear pon... sad.gif pening arrr...pastu,camane nk add function delete record ek??anyone please help me a.s.a.p!! Please..i'm helpless........ sad.gif

using namespace std;

static int p = 0;

class a

{

char movieTitle[15],

cast[10],

date[5],

time[5],

theatre[10],

numOfshow[10],

seat[8][4][10];

char name[20];

char ic[15];

char telno[12];

public:

//set functions

void addMovie();

void getcustomerdata();

void showdata();

void displaySeat();

void empty();

void display();

void movieDetails();

void position(int i);

char *getdate()

{

return date;

}

char *getic()

{

return ic;

}

}

movie[10];

void vline(char ch)

{

for (int i=80;i>0;i--)

cout<<ch;

}

void a::addMovie()

{

cout<<"\t\t\t:: Add Movie ::\n";

cout<<"\t\t\t---------------\n\n";

cout<<"\t\t\tEnter movie title : ";

cin>>movie[p].movieTitle;

cout<<"\t\t\tEnter cast's name : ";

cin>>movie[p].cast;

cout<<"\t\t\tDate : ";

cin>>movie[p].date;

cout<<"\t\t\tTime : ";

cin>>movie[p].time;

cout<<"\t\t\tTheatre : ";

cin>>movie[p].theatre;

cout<<"\t\t\tNumber of show : ";

cin>>movie[p].numOfshow;

movie[p].empty();

p++;

}

void a :: getcustomerdata(){

cout<<"\t\t\t:: New Customer Entry ::\n";

cout<<"\t\t\t------------------------\n\n";

cout<<"\t\t\tEnter Name :";

cin>>movie[p].name;

cout<<"\t\t\tEnter NRIC :";

cin>>movie[p].ic;

cout<<"\t\t\tEnter TelNo :";

cin>>movie[p].telno;

movie[p].empty();

p++;

}

void a :: showdata(){

cout<<"\t\t\t:: Customer Record ::"<<endl;

cout<<"\t\t\t---------------------\n";

cout<<"\t\t\tName :"<<movie[p].name<<endl;

cout<<"\t\t\tNRIC :"<<movie[p].ic<<endl;

cout<<"\t\t\tTelNo :"<<movie[p].telno<<endl;

movie[p].empty();

p++;

}

Share this post


Link to post
Share on other sites

mesti awak copy paste jer ni.. sebab aku tak nampak pulak function utk store record tu dalam file seperti .dat or anything

btw, utk tidak menghampakan dan agar tak cluecless lagi, ni code aku buat utk project bagi subject c programming dulu2

BOOL LoadFile(HWND hwnd, LPCTSTR pszFileName)
{
    HANDLE hFile;
	BOOL bSuccess;
     
    hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
        OPEN_EXISTING, 0, NULL);
    if(hFile != INVALID_HANDLE_VALUE)
    {
        DWORD dwFileSize;
    
  
        dwFileSize = GetFileSize(hFile, NULL);
        if(dwFileSize != 0xFFFFFFFF)
        {

            if(p_array != NULL)
            {
                DWORD dwRead;

                if(ReadFile(hFile, p_array, dwFileSize, &dwRead, NULL))
                {

    	total_acc = p_array[0].last_read;

/*    	wsprintf(pszFileText, "%d", dwOldUnit);
    	SetDlgItemText(hwnd, IDC_OLD, pszFileText);

    	sprintf(pszFileText, "%.2f", Debt);
    	SetDlgItemText(hwnd, IDC_DEBT, pszFileText);
*/    	//dwTempValue = atol (pszFileText);
                    
                }
              
            }
        }
        CloseHandle(hFile);
  bSuccess = TRUE;
    }
    
	else
  bSuccess = FALSE;

	return bSuccess;
}

// Save current data to file
BOOL SaveFile(HWND hwnd, LPCTSTR pszFileName)
{
    HANDLE hFile;

	//DWORD FileArray[4];


	BOOL bSuccess = FALSE;
    hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, NULL,
        CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if(hFile != INVALID_HANDLE_VALUE)
    {

        if(p_array != NULL)
        {	
        
  	DWORD dwWritten;
  	p_array[0].last_read = total_acc;

  	WriteFile(hFile, p_array, sizeof(p_array), &dwWritten, NULL);
            
            
        }
        CloseHandle(hFile);
  bSuccess = TRUE;	
    }

	return bSuccess;
}

edited:

additional info,

aku tak guna generic C functions utk write/load file.. but functions from win32 API

Edited by zeph

Share this post


Link to post
Share on other sites

tak..mmg copy paste je..sebenarrnye panjang lagi ni.. tongue.gif oh,ye..lupe lak actually tktau gak camane nk save data dlm file..lom wat lagi..humm..ni pakai c++..sowi..tk phm sgtla kalau pakai c..sad.gif

mesti awak copy paste jer ni.. sebab aku tak nampak pulak function utk store record tu dalam file seperti .dat or anything

btw, utk tidak menghampakan dan agar tak cluecless lagi, ni code aku buat utk project bagi subject c programming dulu2

BOOL LoadFile(HWND hwnd, LPCTSTR pszFileName)
{
    HANDLE hFile;
	BOOL bSuccess;
     
    hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
        OPEN_EXISTING, 0, NULL);
    if(hFile != INVALID_HANDLE_VALUE)
    {
        DWORD dwFileSize;
    
  
        dwFileSize = GetFileSize(hFile, NULL);
        if(dwFileSize != 0xFFFFFFFF)
        {

            if(p_array != NULL)
            {
                DWORD dwRead;

                if(ReadFile(hFile, p_array, dwFileSize, &dwRead, NULL))
                {

    	total_acc = p_array[0].last_read;

/*    	wsprintf(pszFileText, "%d", dwOldUnit);
    	SetDlgItemText(hwnd, IDC_OLD, pszFileText);

    	sprintf(pszFileText, "%.2f", Debt);
    	SetDlgItemText(hwnd, IDC_DEBT, pszFileText);
*/    	//dwTempValue = atol (pszFileText);
                    
                }
              
            }
        }
        CloseHandle(hFile);
  bSuccess = TRUE;
    }
    
	else
  bSuccess = FALSE;

	return bSuccess;
}

// Save current data to file
BOOL SaveFile(HWND hwnd, LPCTSTR pszFileName)
{
    HANDLE hFile;

	//DWORD FileArray[4];


	BOOL bSuccess = FALSE;
    hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, NULL,
        CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if(hFile != INVALID_HANDLE_VALUE)
    {

        if(p_array != NULL)
        {	
        
  	DWORD dwWritten;
  	p_array[0].last_read = total_acc;

  	WriteFile(hFile, p_array, sizeof(p_array), &dwWritten, NULL);
            
            
        }
        CloseHandle(hFile);
  bSuccess = TRUE;	
    }

	return bSuccess;
}

edited:

additional info,

aku tak guna generic C functions utk write/load file.. but functions from win32 API

sad.gifsad.gif

Share this post


Link to post
Share on other sites

wah..tolong..tk phm la...huargh..sad.gif ANYONE yg sudi tlg please..........

tak..mmg copy paste je..sebenarrnye panjang lagi ni.. tongue.gif oh,ye..lupe lak actually tktau gak camane nk save data dlm file..lom wat lagi..humm..ni pakai c++..sowi..tk phm sgtla kalau pakai c..sad.gif

sad.gifsad.gif

Share this post


Link to post
Share on other sites

http://www.codedb.org/submit/view.php?id=161

It doesn't do exactly what you want. but the general idea and functionality is the same. Hope this helps.

emm..is it??i try to modify it by using the filing system..but..it seems doesn't work though..*sigh* dry.gif ..nway,thankz 4 ur help..btw,i alreay submitted my paperwork...hehe..it can run properly but the only problem was i'm not using the filing system..ekeke...humm..it's gonna be a long journey to learn the "files management".. cool.gif

Share this post


Link to post
Share on other sites

rasanya mmg jln code aku tu. apa yg kau ubah? well if you have problems on file i/o just ask here. i would have replied earlier, but been real bz with work. srry

Edited by da^hype

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...