Tuesday, December 9, 2014

C++ Practice Exercise

Write a C++ program that will display the calculator menu.

The program will prompt the user to choose the operation choice (from 1 to 5). Then it should ask the user to input two integer values

for the calculation.

See the sample below.


MENU
  1. Add
  2. Subtract
  3. Multiply
  4. Divide
  5. Modulus

Enter your choice: 1

Enter your two numbers: 12 15

Result: 27
 
Continue? y




 
The program also asks the user to decide whether he/she wants to continue the operation. If he/she input ‘y’, the program will prompt

the user to choose the operation gain. Otherwise, the program will terminate.

Wednesday, November 26, 2014

COMPRO8 Activity #4

Things That Needs To Be Done Today
 
Study PHP Arrays in http://www.w3schools.com/php/php_arrays.asp

Activity #4

Problem:
Write a Web App to accept a string input (sentence) using a <textarea> element. During form submission, store each word of the sentence in an array named $words[].


Sample Output:

Web Interface

Enter a sentence: 

Result: Each word will be stored as element in the array.


words
Whatdidthefoxsay?Tingtingtingting...

Tuesday, September 30, 2014

Review - Activity #1

Sept 30, 2014
COMPRO2 - Excellence and Integrity

Problem #1
Write a program to compute the salary of an employee using the formula : salary=hours worked X hourly rate. Require an input for hours worked and hourly rate using the keyboard.

Sample output:
Enter hours worked: 20
Enter hourly rate: 70.50
Salary: 1410.0


Problem #2
Write a program to accept the gender of a person; 'M' for male and 'F' for female. Display an appropriate message based on gender.

Sample output:

Validation #1:
What is your gender? M
Good morning Sir!

Validation #2:
What is your gender? F
Good morning Ma'am!

Validation #3:
What is your gender? Male
Invalid gender!

SEND YOUR SOURCE CODE TO: adichosa@gmail.com
SUBJECT: <section>-COMPRO2-LACARLOTA-<fullname>


Monday, September 29, 2014

LOL

Watch the official trailer of "The Walking Dead" season 5. If you can!

Wednesday, September 24, 2014

Creating Printable Reports Using Data Environment and Data Report

Welcome to another tutorial! This time you will learn how to create simple printable reports in VB6 and MS Access using Data Environment and Data Report. Again, I would like to stress out that the approach that I am going to user is a simple one.

To start with, I will assume that you have the latest copy of our project, open it and add a Data Environment. How? Follow the steps below: 
  • Go to your project window and right click on Project1.
  • Select Add then Data Environment.
  • You will be prompted with a DataEnvironment window. Within it, by default, you will see DataEnvironment1 and Connection1 objects.
  • Right click on Connection1 and select Properties.


  • A Data Link Properties Window pops-up. Under Provider tab, select Microsoft Jet 4.0 OLE DB Provider and click Next button.

  • Right now, Connection tab is the default tab. From there, point the DataEnvironment to your database. In short, browse for your database.


  • Once done, click the Test Connection button to test the connection.
  • If executed properly, you will get a msgbox saying “Test connection succeeded”.
At this point, we have successfully established a connection to our database. The next series of steps is for the creation of Commands. We use Commands to execute SQL command via Data Environment. Follow the steps below:

  • ight click on Connection1 and select Add Command.
     
  • A new command will be created, if this is your first command, its default name is Command1.
  • Right click on the newly created command and select Properties.

  • Command1 Properties window will popup. Under General tab toggle Connection box and select our newly created connection Connection1.

  • Next, set the Database Object to Table and select an Object Name from the list (Student or Vendor).

  • Finally, click OK.
Now we have successfully setup the DataEnvironment (the source of data for our report). It is time to create the actual report page. 

  • Add a Data Report to your Project. How? Right click on Project1 in you Properties window and select Data Report.
  • A new Data Report form will be created. Set its DataSource property to 'Connection1' and  DataMember to 'Command1'.
  • If you are experiencing any problems related to the connection at this point, you might want to re-visit the steps above.
Considering you have flawlessly executed the instructions, you are now ready to add data fields to your report form. To do this, just simply drag and drop any fields that you want to appear to your report (Data Report) from the Commands in your Data Environment. Finally, format your report according to your requirements.


Here comes the coding part. Remember recently we have added Report menu to our MDIForm? We are going to invoke the report using Studentlist item. Go to the Click event procedure of Studentlist and paste the following source code:

       DataReport1.Show

Run the application and test the report.

For Viral Stuff and Trending News, visit http://www.fooviral.com.

Wednesday, September 17, 2014

How To Implement A Simple System User Level In VB6 and MS Access (The Cool Dude Way)

In an organization or company, each employee has certain access level to company's sensitive information. The company keeps an organizational chart which enforce the hierarchy of employee and their current  position. This will enable us to determine which user has access to which part of the system. Since we already have our login facility added to our fancy Project, we will now implement the System User Level.

The login form will simply filter valid users to the system. But once valid users are in, we still need to implement further security check. The main purpose of the SUL is to limit the access of those valid users to the modules or elements of our system.

Note: "This tutorial will just introduce a simple (lame) approach on how to implement SUL. However, I encourage you to come up with your own method or approach, a kick-ass one. Once again, use some logic."

We will jump-start by expanding our menu list, follow the structure below:

Masterfiles
  • Manage Student
  • Manage Subject
 Transactions
  • Enroll
  • Grade Entry
Queries
  • Search Student
Reports
  • Student list
  • Student Grade
Help
  • About
Log-out


For this tutorial, we will assume that there are three types of user: Administrator, Teacher and Encoder.
Below are their user levels:

Administrator - Overall access
Teacher - Can only access Grade Entry, Search Student, Student list and Student Grade
Encoder - Can only Manage Student and Manage Subject

Now we are ready to edit the database. We need to add another field to the 'User' table, see illustration below:

Table: User
Field Name               Data Type         Attribute           Value
username                  Text                    Field Size          15
password                  Text                    Field Size           8
fullname                   Text                    Field Size          100
usrlevel                    Number             Field Size          Byte

The next step is not very impressive, but it will work for now. For the sake of simplicity (but lame) we will device a picture box and a label control to hold our user's user level variable. Add a picture box to your MDIForm. Inside the picturebox, draw a label and name it 'lblUserLevel'.

At this point, we are now ready to write some code. Copy and paste the snippet below to your login form. The exact place on where to put the code is for you to figure out. Use some logic lads.

        MDIForm1.lblUserLevel.Caption =Adodc1.Recordset.Fields("usrlevel")       
        Dim lvl As Integer   


        lvl = MDIForm1.lblUserLevel.Caption
    
        If lvl = 1 Then

            'The following block was written by Miss Mendoza
            MDIForm1.muTransGradeEntry.Enabled = True
            MDIForm1.mnuQSearchStud.Enabled = True
            MDIForm1.mnuRepStudlist.Enabled = True
           
            MDIForm1.mnuStudForm.Enabled = True
            MDIForm1.mnuSubjForm.Enabled = True
           
            MDIForm1.mnuTransEnroll.Enabled = True
            MDIForm1.mnuRepStudGrade.Enabled = True
            MDIForm1.mnuHelpAbout.Enabled = True
            'End of Miss Mendoza's code
        


       
        ElseIf lvl = 2 Then

           
            MDIForm1.muTransGradeEntry.Enabled = True
            MDIForm1.mnuQSearchStud.Enabled = True
            MDIForm1.mnuRepStudlist.Enabled = True
           
            MDIForm1.mnuStudForm.Enabled = False
            MDIForm1.mnuSubjForm.Enabled = False
           
            MDIForm1.mnuTransEnroll.Enabled = False
            MDIForm1.mnuRepStudGrade.Enabled = False
            MDIForm1.mnuHelpAbout.Enabled = False
        

       'Code of Miss Lito   
        ElseIf lvl = 3 Then
            MDIForm1.mnuStudForm.Enabled = True
            MDIForm1.mnuSubjForm.Enabled = True           
           
            MDIForm1.mnuTransEnroll.Enabled = False
            MDIForm1.muTransGradeEntry.Enabled = False
            MDIForm1.mnuQSearchStud.Enabled = False
            MDIForm1.mnuRepStudlist.Enabled = False
            MDIForm1.mnuRepStudGrade.Enabled = False
            MDIForm1.mnuHelpAbout.Enabled = False
                         
           
        End If

        'End of Miss Lito's code 

For the logout module:

        lblUserLevel.Caption = ""
        frmLogin.Show 1

Finally, we have one thing left to do and that is to test the  program. Run the application and login using our user accounts.




Tuesday, September 16, 2014

Terms to Remember

Tokens in C++ every programmer should know
  • Identifier
  • Keywords
  • Constant
  • Operators

Prepare for a quiz next meeting.