Académique Documents
Professionnel Documents
Culture Documents
Because files on a computer can be stored in various places, Microsoft Windows provides various means of creating, locating, and managing files through objects named Windows Common Dialog Boxes. Indeed, these dialog boxes are part of the operating system and are equipped with all the necessary operations pertinent to their functionality. The common dialog boxes available in the MFC share a parent as the CCommonDialogclass. The CCommonDialog class is derived from CDialog:
The only member the CCommonDialog class has a constructor that takes a point toCWnd as argument.
C File Processing
Introduction
The C language provides very impressive support for file processing through a structure and many functions. The fundamental structure used to perform file processing in C is the FILE structure. In reality, to use this structure, you must call another function and get its return value.
11. Click Finish 12. On the dialog box, click TODO: and press Delete 13. Press the OK button and press Delete 14. Click the Cancel button to select it 15. In the Properties window, click Caption, type Close and press Enter 16. Design the dialog box as follows:
Control Static Text Edit Control Static Text Edit Control Static Text Static Text Edit Control Static Text
Caption Employee #:
ID
IDC_EMPLOYEENUMBER True Employee Name: IDC_EMPLOYEENAME ________________ Gross Pay: IDC_GROSSPAY Deductions True
Static Text Edit Control Static Text Edit Control Edit Control Static Text Static Text Edit Control Button Static Text Static Text Edit Control Static Text Static Text Edit Control Static Text Static Text Edit Control Button Button Button Button
Federal Income Tax: IDC_FEDERALTAX FICA Tax: IDC_FICATAX IDC_FICARATE % State Tax: IDC_STATETAX Calcuate _________________ Total Deductions: IDC_DEDUCTIONS _________________ Net Pay: IDC_NETPAY =============== File Name: IDC_FILENAME Open Reset Save Close IDC_OPEN IDC_RESET IDC_SAVE IDCANCEL True True IDC_CALCULATE True True True True
17. Right-click each edit control, click Add Variable, select the category as Value, set the options as follows and click Finish on each: Control ID IDC_EMPLOYEENAME IDC_GROSSPAY IDC_FEDERALTAX Category Variable Type Variable Name int CString double double m_EmployeeNumber m_EmployeeName m_GrossPay m_FederalIncomeTax Value Value Value
IDC_EMPLOYEENUMBER Value
18. Access the source file of the dialog box and change the initializations in the constructor as follows: 19. CPayrollPreparation1Dlg::CPayrollPreparation1Dlg(CWnd* pParent /*=NULL*/) 20. : CDialogEx(CPayrollPreparation1Dlg::IDD, pParent) 21. , m_EmployeeNumber(0) 22. , m_EmployeeName(_T("")) 23. , m_GrossPay(0) 24. , m_FederalIncomeTax(0) 25. , m_FICATax(_T("0.00")) 26. , m_StateTax(0) 27. , m_FICARate(7.65) 28. , m_TotalDeductions(_T("0.00")) 29. , m_NetPay(_T("0.00")) 30. , m_FileName(_T("")) 31. { 32. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } 33. Return to the dialog box 34. Double-click the Calculate button 35. Implement the event as follows: 36. void CPayrollPreparation1Dlg::OnBnClickedCalculate() 37. { 38. UpdateData(TRUE); 39. 40. double GrossPay = m_GrossPay; 41. double FederalIncomeTax = m_FederalIncomeTax; 42. double FICARate = m_FICARate; 43. double FICATax = m_GrossPay * FICARate / 100; 44. double StateTax = m_StateTax; 45. double TotalDeductions = FederalIncomeTax + FICATax + StateTax; 46. double NetPay = GrossPay - TotalDeductions; 47. 48. m_FICATax.Format(L"%.2f", FICATax); 49. m_TotalDeductions.Format(L"%.2f", TotalDeductions); 50. m_NetPay.Format(L"%.2f", NetPay); 51. 52. UpdateData(FALSE); } 53. Return to the dialog box 54. Double-click the Reset button 55. Implement the event as follows: 56. void CPayrollPreparation1Dlg::OnBnClickedReset() 57. { 58. m_EmployeeNumber = 0; 59. m_EmployeeName = L""; 60. m_GrossPay = 0.00;
m_FederalIncomeTax = 0.00; m_FICATax = _T("0.00"); m_FICARate = 7.65; m_StateTax = 0.00; m_TotalDeductions = _T("0.00"); m_NetPay = _T("0.00"); m_FileName = L""; UpdateData(FALSE);
Opening a File
The primary operation of file processing consists of opening one. In the strict sense, this means that you are initiating file processing. This can be done in C by calling one of the fopen-variant functions. Their syntax are: FILE *fopen(const char *filename, const char *mode); FILE *_wfopen(const wchar_t *filename, const wchar_t *mode); To support Unicode, you should use the _wfopen() version. In both cases, the first argument specifies the name of the file you want to work on. If you pass just the name of the file, the compiler will consider the directory of the current project. Otherwise, you can provide the complete path of the project. The second argument specifies the type of operation you want to perform. It is passed as a string. When this function has been called, if it succeeds in carrying its operation (we will see what types of operations are available), it returns a FILE object. If the function fails, it returns NULL.
Creating a File
To create a file, you can pass the second argument of fopen withe one the following values: "w": This specifies that you want to create a new file and write one or more values to it. If the file exists already, the compiler will replace it "w+": This means that you want to create a new file to read and write one or more values to it. If the file exists already, its contents will be replaced
To write other types of values to a file, you can call one of the following functions: size_t fwrite(const void *buffer, size_t size, size_t count, FILE *stream); To format a value before writting it to the file, you can call one of these functions: int fprintf(FILE *stream, const char *format [, argument ]...); int _fprintf_l(FILE *stream, const char *format, locale_t locale [, argument ]...); int fwprintf(FILE *stream, const wchar_t *format [, argument ]...); int _fwprintf_l(FILE *stream, const wchar_t *format, locale_t locale [, argument ]...);
Closing a Stream
After using a FILE object, you should close it to free the resources it was using. This is done by calling the fclose() or _fcloseall() function. Their syntaxes are: int fclose(FILE *stream); int _fcloseall(void);
31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. }
{ fwprintf(fstPayroll, fwprintf(fstPayroll, fwprintf(fstPayroll, fwprintf(fstPayroll, fwprintf(fstPayroll, fwprintf(fstPayroll, fwprintf(fstPayroll, fwprintf(fstPayroll, fwprintf(fstPayroll, fclose(fstPayroll); } OnBnClickedReset(); L"%d\n", m_EmployeeNumber); L"%s\n", m_EmployeeName); L"%.2f\n", m_GrossPay); L"%.2f\n", m_FederalIncomeTax); L"%s\n", m_FICATax); L"%.2f\n", m_FICARate); L"%.2f\n", m_StateTax); L"%s\n", m_TotalDeductions); L"%s\n", m_NetPay);
46. Execute the application to test 47. Enter the employee number as 281548 48. Enter the employee name as Paul Martin Sutters 49. In the Gross Pay, enter 428.79 50. In the Federal Income Tax, enter 71.46 51. In the State Tax, enter 28.86
54. Click Save 55. Close the dialog box and return to your programming environment
const char *format, locale_t locale [, argument ]...); fwscanf(FILE *stream, const wchar_t *format [, argument ]...); _fwscanf_l(FILE *stream, const wchar_t *format, locale_t locale [, argument ]...); fscanf_s(FILE *stream, const char *format [, argument ]...); _fscanf_s_l(FILE *stream, const char *format, locale_t locale [, argument ]... ); fwscanf_s(FILE *stream, const wchar_t *format [, argument ]...); _fwscanf_s_l(FILE *stream, const wchar_t *format, locale_t locale [, argument ]...);
40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. }
m_EmployeeNumber m_EmployeeName m_GrossPay m_FederalIncomeTax m_FICATax m_FICARate m_StateTax m_TotalDeductions m_NetPay UpdateData(FALSE); fclose(fstPayroll); }
53. Execute the application to test it 54. Enter the file name you had previously saved (pms) 55. Click Open 56. Close the dialog box and return to your programming environment
The MFC library provides it own version of C's file processing. This is done through a class named CStdioFile. The CStdioFile class is derived from CFile. As done for the FILE structure, to start normal file input/output operations, declare a variable of type CStdioFile. This class has five constructors whose syntaxes are: CStdioFile(); CStdioFile(CAtlTransactionManager* pTM); CStdioFile(FILE* pOpenStream); CStdioFile(LPCTSTR lpszFileName, UINT nOpenFlags); CStdioFile(LPCTSTR lpszFileName, UINT nOpenFlags, CAtlTransactionManager* pTM); The default constructor allows you to initiate file processing without giving much detail. If you use it, you can then call the Open() method that the CStdioFile class inherits fromCFile. Pass the same arguments you would for a CFile variable.
Control Static Text Edit Control Static Text Edit Control Static Text Static Text Edit Control Static Text Edit Control Static Text Static Text Edit Control Static Text Button
ID
IDC_CUSTOMERNAME Prepared For: IDC_EMPLOYEENAME ________________ Loan Amount: IDC_PRINCIPAL Interest Rate: IDC_INTERESTRATE % Paid In: IDC_PERIODS Months Evaluate IDC_EVALUATE True True True
Static Text Static Text Edit Control Static Text Edit Control Static Text Static Text Edit Control Button Static Text Edit Control Button Static Text Button Button
_________________ Future Value: IDC_FUTUREVALUE Monthly Payment: IDC_MONTHLYPAYMENT True _________________ Save As: IDC_FILESAVE Save File to Open: IDC_FILEOPEN Open File Name: Reset Close IDC_RESET_BTN IDCANCEL IDC_OPEN_BTN True IDC_SAVE_BTN True True
16. Right-click each edit control, click Add Variable, select the category as Value, set the options as follows and click Finish on each: Control ID IDC_CUSTOMERNAME IDC_EMPLOYEENAME IDC_PRINCIPAL IDC_INTERESTRATE IDC_PERIODS IDC_FUTUREVALUE IDC_FILESAVE IDC_FILEOPEN Category Variable Type Value Value Value Value Value Value Value Value CString CString CString CString CString CString CString CString CString Variable Name m_CustomerName m_EmployeeName m_Principal m_InterestRate m_Periods m_FutureValue m_MonthlyPayment m_FileSave m_FileOpen
IDC_MONTHLYPAYMENT Value
17. Access the source file of the dialog box and change the initializations in the constructor as follows: 18. CLoanPreparation1Dlg::CLoanPreparation1Dlg(CWnd* pParent /*=NULL*/) 19. : CDialogEx(CLoanPreparation1Dlg::IDD, pParent) 20. , m_CustomerName(_T("")) 21. , m_EmployeeName(_T("")) 22. , m_Principal(_T("0.00"))
, , , , , ,
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
31. Return to the dialog box 32. Double-click the Evaluate button 33. Implement the event as follows: 34. void CLoanPreparation1Dlg::OnBnClickedEvaluate() 35. { 36. UpdateData(TRUE); 37. 38. double Principal = _wtof(m_Principal); 39. double InterestRate = _wtof(m_InterestRate) / 100; 40. double Periods = _wtof(m_Periods) / 12; 41. double InterestAmount = Principal * InterestRate * Periods; 42. double FutureValue = Principal + InterestAmount; 43. double MonthlyPayment = FutureValue / _wtof(m_Periods); 44. 45. m_FutureValue.Format(L"%.2f", FutureValue); 46. m_MonthlyPayment.Format(L"%.2f", MonthlyPayment); 47. 48. UpdateData(FALSE); } 49. Return to the dialog box 50. Double-click the Reset button 51. Implement the event as follows: 52. void CLoanPreparation1Dlg::OnBnClickedResetBtn() 53. { 54. m_CustomerName = L""; 55. m_EmployeeName = L""; 56. m_Principal = L"0.00"; 57. m_InterestRate = L"0.00"; 58. m_Periods = L"0.00"; 59. m_FutureValue = L"0.00"; 60. m_MonthlyPayment = L"0.00"; 61. m_FileSave = L""; 62. m_FileOpen = L""; 63. 64. UpdateData(FALSE); }
50. Enter the Interest Rate as 12.25 51. Enter the Paid In value as 36
52. Click Evaluate 53. In the Save As edit control, type BG as the name of the file
54. Click Save 55. Close the dialog box and return to your programming environment
S No 1
Pre-requisites identified 8mouths\admin.letsface.com\sys tems\webapp\modules\admin\te mplates PHP time(), date(), $time_output=date("d-m-Y H:i:s",$time_input);
2 { user statistics, check-in correct for month and per day. (check-in includes registrations) user statistics, and registrations correct for month and per day. (registration is first time check-in, new user) }
How these values are calculated and which pages we deliver them How OpenPNE delivers them onto the page
Monthly Enrolment: (a=page_user_analysis_date_m onth) Daily Enrolment: (a=page_user_analysis_date_da y) Monthly check-in: (a=page_checkin_analysis_date _month) Monthly Returns: (a=page_monthlyReturns) $time_output=date("d-m-Y H:i:s",$time_input); Update c_member SET r_date=$time_output
3 statistics - registration per month - start 2010 June (not 1970) 4 { -- add function so when you click on day, from morning to evening as they checkedin/registered. -- name, time, picture, which club they registered/checked in at (display club logo), number, anything relevant on that user. (later depending on your authority different information will be displayed) } { think about auto refresh, so i can keep logged in on stat page and view users checking in } Modify MySQL database Database field to modify
AJAX
AJAX connection to monitor check-in time continuously with respect to current timestamp