Thursday, July 3, 2014

An Application Package on Hospital Management System (HMS) ~~ VisualBasic Code Snippet + GUI Design"

NOTE :- This application isn't developed for General Hospital Lagos. General Hospital's logo is only used for design purpose.
 Need more info about this application ? feel free to reach me.

Appointment Module

Doctor's Module

Patient Module

Report Screen

Emergency Module

Source Code

Imports System.Data
Imports System.Data.OleDb

Public Class HomePage   ' Class Begins

    Dim conn As New OleDbConnection
    Dim connmand As New OleDbCommand
    Dim connword = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\hms_db.mdb"
   

    Private Sub HomePage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'TODO: This line of code loads data into the 'Hms_dbDataSet11.Emergency_Record' table. You can move, or remove it, as needed.
        Me.Emergency_RecordTableAdapter.Fill(Me.Hms_dbDataSet11.Emergency_Record)
        'TODO: This line of code loads data into the 'Hms_dbDataSet10.Report' table. You can move, or remove it, as needed.
        Me.ReportTableAdapter.Fill(Me.Hms_dbDataSet10.Report)
        'TODO: This line of code loads data into the 'Hms_dbDataSet9.Patient_Record' table. You can move, or remove it, as needed.
        Me.Patient_RecordTableAdapter.Fill(Me.Hms_dbDataSet9.Patient_Record)
        'TODO: This line of code loads data into the 'Hms_dbDataSet8.Doctor_Record' table. You can move, or remove it, as needed.
        Me.Doctor_RecordTableAdapter.Fill(Me.Hms_dbDataSet8.Doctor_Record)
        'TODO: This line of code loads data into the 'Hms_dbDataSet7.Appointment_Record' table. You can move, or remove it, as needed.
    Me.Appointment_RecordTableAdapter.Fill(Me.Hms_dbDataSet7.Appointment_Record)

        conn.ConnectionString = connword
        conn.Open()

    End Sub


    Private Sub cmdsub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        connmand.CommandText = "insert into Report (Patient_Id, Report) values ('" & txtppiidd.Text & " ', '" & txtrr.Text & " ')"
        connmand.CommandType = CommandType.Text
        connmand.Connection = conn
        connmand.ExecuteNonQuery()

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        connmand.CommandText = "insert into Appointment_Record (Token_No, Patient_Id, Name, Phone_No, Appointment_Date) values ('" & txttno.Text & " ', '" & txtpatientid.Text & " ', '" & txtpatientname.Text & " ', '" & txtphoneno.Text & " ', '" & txtadate.Text & " ')"
        connmand.CommandType = CommandType.Text
        connmand.Connection = conn
        connmand.ExecuteNonQuery()

    End Sub

    Private Sub pateint_update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        connmand.CommandText = "insert into Patient_Record (Patient_Code, Name, Gender, DOB, Address, Phone_No, Email, Occupation, Marital_Status, Spouse_Name, Children, Blood_Group, Allergies) values ('" & txtpcode.Text & " ', '" & txtpname.Text & " ', '" & txtgender.Text & " ', '" & txtdob.Text & " ', '" & txtaddress.Text & " ', '" & txtpno.Text & " ', '" & txteid.Text & " ', '" & txtoccupation.Text & " ', '" & txtmstatus.Text & " ', '" & txtsname.Text & " ', '" & txtchildren.Text & " ', '" & txtbgroup.Text & " ', '" & txtallergies.Text & " ')"
        connmand.CommandType = CommandType.Text
        connmand.Connection = conn
        connmand.ExecuteNonQuery()

    End Sub

    Private Sub cmdup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        connmand.CommandText = "insert into Emergency_Record (Patient_Code, Name, Gender, DOB, Address, Blood_Group, Emergency_Report) values ('" & txtppcode.Text & " ', '" & txtppname.Text & " ', '" & txtpgender.Text & " ', '" & txtpdob.Text & " ', '" & txtpadd.Text & " ', '" & txtpblood.Text & " ', '" & txtereport.Text & " ')"
        connmand.CommandType = CommandType.Text
        connmand.Connection = conn
        connmand.ExecuteNonQuery()

    End Sub

    Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

        txtdob.Text = DateTimePicker1.Text

    End Sub

    Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

        txtadate.Text = DateTimePicker2.Text

    End Sub

    Private Sub DateTimePicker3_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

        txtpdob.Text = DateTimePicker3.Text

    End Sub

    Private Sub btnhome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhome.Click

        ' TabControl1.SelectedTab() = TabPage1

    End Sub

    Private Sub btnapp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnapp.Click

        TabControl1.SelectedTab() = TabPage2

    End Sub

    Private Sub btndoc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndoc.Click

        TabControl1.SelectedTab() = TabPage3

    End Sub

    Private Sub btnPatient_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPatient.Click

        TabControl1.SelectedTab() = TabPage4

    End Sub

    Private Sub btnreport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnreport.Click

        TabControl1.SelectedTab() = TabPage5

    End Sub

    Private Sub btnemergency_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnemergency.Click

        TabControl1.SelectedTab() = TabPage6

    End Sub

    Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        'TODO: This line of code loads data into the 'Hms_dbDataSet7.Appointment_Record' table. You can move, or remove it, as needed.
        Me.Appointment_RecordTableAdapter.Fill(Me.Hms_dbDataSet7.Appointment_Record)

        txttno.Text = ""
        txtpatientid.Text = ""
        txtpatientname.Text = ""
        txtphoneno.Text = ""
        txtadate.Text = ""

    End Sub

    Private Sub pateint_update_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pateint_update.Click

        Me.Patient_RecordTableAdapter.Fill(Me.Hms_dbDataSet9.Patient_Record)

        txtpcode.Text = ""
        txtpname.Text = ""
        txtgender.Text = ""

        txtdob.Text = ""
        txtaddress.Text = ""
        txtpno.Text = ""
        txteid.Text = ""
        txtoccupation.Text = ""
        txtmstatus.Text = ""
        txtsname.Text = ""
        txtchildren.Text = ""
        txtbgroup.Text = ""
        txtallergies.Text = ""

    End Sub

    Private Sub cmdsub_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsub.Click

        Me.ReportTableAdapter.Fill(Me.Hms_dbDataSet10.Report)

        txtppiidd.Text = ""
        txtrr.Text = ""

    End Sub

    Private Sub cmdup_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdup.Click

        Me.Emergency_RecordTableAdapter.Fill(Me.Hms_dbDataSet11.Emergency_Record)

        txtppcode.Text = ""
        txtppname.Text = ""
        txtpgender.Text = ""
        txtpdob.Text = ""
        txtpadd.Text = ""
        txtpblood.Text = ""
        txtereport.Text = ""

    End Sub

End Class 'Class ends here




Sunday, May 25, 2014

An Application Package on Traffic Management System (TMS) ~~ VisualBasic Code Snippet + GUI Design



Traffic Light Interface Design


-: Tools Used : - 
1. label as Counter
2. OvalShape as Redlight, GreenLight and YellowLight
3. 2 Timer controls as Timer and TimerNext

Source code for "Traffic Light Interface Design"

Public Class Form2  'Class Declaration

    Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick

        Counter.Text = Counter.Text - 1
        If Counter.Text = 12 Then
            Counter.ForeColor = Color.Yellow
            YellowLight.BackColor = Color.Yellow
            RedLight.BackColor = Color.Black

        ElseIf Counter.Text = 0 Then
            GreenLight.BackColor = Color.Green
            Counter.ForeColor = Color.Green
            YellowLight.BackColor = Color.Black

            Timer.Enabled = False
            Counter.Text = 70
            TimerNext.Enabled = True

        End If
    End Sub

    Private Sub TimerNext_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerNext.Tick

        Counter.Text = Counter.Text - 1
        If Counter.Text = 12 Then
            Counter.ForeColor = Color.Red

        ElseIf Counter.Text = 0 Then
            GreenLight.BackColor = Color.Black
            Counter.ForeColor = Color.Red
            RedLight.BackColor = Color.Red

            TimerNext.Enabled = False
            Counter.Text = 70
            Timer.Enabled = True

        End If
    End Sub

End Class

Saturday, April 12, 2014

Printing Duplicate Character|String in a Sentence ~~ Java Code Snippet

Shown below is the source code for printing duplicate character or string in a sentence. Simply pass in the char/string as a command line argument i.e. args

~~~~~~~~~~~~~~~~~~~~~~~~~
import java.util.*;
import static java.lang.System.out;

public class Duplicate
{
  public static void main(String... args)
   {

   Set<String> s  = new HashSet<String>();
for(String ss : args)

 if (!s.add(ss))
  {
out.println("Duplicate Found:" + ss);
   }

   }
}

~~~~~~~~~~~~~~~~~~~~~~~~~

Monday, March 3, 2014

Obtaining Port Number for SQL Server Database Connection

Two simple ways of obtaining your port number for Connection String usage.

-- From start, right click on computer then click on Manage.
-- Click on Services and Applications
     |
     --SQL Server configuration manager
           |
 **      --SQL Server <year> Network configuration       
                   |
                    --Protocols for <Server type>
--Right click on TCP/IP then, select/click_on properties.
--Select the IP Address tab, look for TCP port; DONE!!!

          OR

-- From start 
     |
     -- All Programs
           |
           --Server configuration manager
           |
            --Microsoft SQL Server <year> 
                   |
                   --SQL Server <year> configuration manager
                 
 Continue from ** above

Statement, PreparedStatement and CallableStatement ~JDBC~ "Java Code"

Below are sample code used for database connection. In this case SQL Server database is used. 
~~~~~~~~~~~~~~~~~~
Using Statement Interface
~~~~~~~~~~~~~~~~~~

import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBase
{
     public static void main(String [] args) throws SQLException, ClassNotFoundException
     {
        try
        {
           // load driver
          Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
        }
        catch (ClassNotFoundException cnfe)
        {
            System.out.println(" ClassNotFoundException thrown");
        }

        try
        {
        // my Connection_String, which will definitely be different from yours' 
        String ConnString =  "jdbc:sqlserver://localhost:1433; databaseName= clems; username=Douby;password=clems";

        // creating the connection
        Connection conn = (DriverManager.getConnection(ConnString));
        Statement stmt = conn.createStatement();

        /* Using ResultSet.... using executeQuery() without ResultSet would throw a                  SQLException. REASON ~> executeQuery() returns result  */

        String sql_stmt = "Select First_Name from Employee";
       ResultSet rs = stmt.executeQuery(sql_stmt);

        while (rs.next())
        {
             //print all names in the First_Name column
            String a = rs.getString("First_Name");
            System.out.println(a);  
        } 
        }        
        catch (SQLException   sql)
        {
            System.out.println("SQLException thrown");
        }
    }
  }

~~~~~~~~~~~~~~~~~~~~~~~~
Using PreparedStatement Interface
~~~~~~~~~~~~~~~~~~~~~~~~
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;


public class DBase
{
     public static void main(String [] args) throws SQLException, ClassNotFoundException
     {
        try
        {
         // loading sql server driver
          Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        }
        catch (ClassNotFoundException cnfe)
        {
            System.out.println(" ClassNotFoundException thrown");
        }

        try
        {
           // 1433 = port number; Dont know how to get your port number? 
           // click here. 
        String ConnString =  "jdbc:sqlserver://localhost:1433; databaseName= clems; username=Douby;password=clems";
        Connection conn = (DriverManager.getConnection(ConnString));
        Statement stmt = conn.createStatement();

        String [] Fname = {" Wale", " Shina", " David"};
        String [] Lname = {" Ishegun", " Olowo", " Almond"};
        int [] Age = {42, 32, 53};

        String sql = "Insert into Employee values(?, ?, ?) ";

        PreparedStatement pstmt = conn.prepareStatement(sql);

        for (int i = 0; i< Fname.length; i++)
        {
            pstmt.setString(1, Fname[i]);
            pstmt.setString(2, Lname[i]);
            pstmt.setInt(3, Age[i]);

            pstmt.executeUpdate();
        }
        }                
        catch (SQLException   sql)
        {
            System.out.println("SQLException thrown");
        }
    }
  }
   
~~~~~~~~~~~~~~~~~~~~~~~
Using CallableStatement Interface
~~~~~~~~~~~~~~~~~~~~~~~


   
  

Wednesday, February 26, 2014

Hoe to Create/Establish a Java--SQL Server Database Connection

Ooo!k! First things first; you have to configure SQL Server, i mean, create an instance (sql server authentication ~>"optional"), Grant permissions, Enable TCP/IP, Get port number then Restart SQL service.
After that, you have to get/download ms sql server jdbc driver. if you already have then, unzip to any dir/location of your choice. all you need is the sqljdbc4.jar OR sqljdbc.jar file. Copy either file, based on you Connection/DBase type, paste on your desktop for easy access.
Next;
Add the sqljdbc.jar file in your 'compile time library'... see example on adding sqljdbc.jar using NetBeans IDE.

From your file menu item, click on "project properties (project_name); 
under categories list, select libraries

Next, click on 'Add JAR/Folder' button the add the sqljdbc.jar file, then click 'Ok'....Up next is your code.

Your code should look similar to the below code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBase {

     public static void main(String [] args) throws SQLException, ClassNotFoundException
     {
        try
        {
          Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

    String ConnString =  "jdbc:sqlserver://localhost:1433; databaseName= clems; username=Douby;password=clems";

        Connection conn = (DriverManager.getConnection(ConnString));
        Statement stmt = conn.createStatement();
        String sql_stmt = "Select First_Name from Employee";
       ResultSet rs = stmt.executeQuery(sql_stmt);

        while (rs.next())
        {
            String a = rs.getString("First_Name");
            System.out.println(a);
        } 
        }        
        catch (SQLException | ClassNotFoundException sql_cnfe)
        {
            System.out.println(" ClassNotFoundException thrown");
            sql_cnfe.printStackTrace();
        }
    }
  }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Still don't get it? feel free to reach me
   

  


Thursday, February 20, 2014

Microsoft SQL Server, Error: 4064


After creating a new SQL Server Authentication (login and password), you are bound, may be not, to get the above error message "Microsoft SQL Server, Error: 4064". But not to worry, cos problem's solved. All you have to do is first connect using Windows Authentication. Then, On the Object Explorer window, Right click on Server name_type, click on properties ~> Select permissions page, select your login name then Grant permissions i.e. Enable every check Boxes under the Grant column. Reload, Try to connect again.

Solved. Still not connecting? comment.

How to Create a new SQL Server Authentication login
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
follow the below steps:

  • Open object explorer, connect using windows authentication
  • Back to Object explorer, Right click on Security ~> New ~> Login
  • Select SQL Server Authentication r.button
  • Enter login details (name and password) then click 'OK' 
If you get error 4064 when trying to connect with your newly created login details, then, read the above.

Wednesday, February 12, 2014

Guidelines for Writing a Perfect Final Year Computer Science Project/Report

Shown below is the Guideline for writing a perfect final year computer science project/report
  • Title Page
Title page, Certification, Dedication, Acknowledgement, Table of content, Abstract
  • Chapter One – Introduction
-          Statement of problem (problem identification) & theory behind the problem
-          Aims/Objectives
-          Scope
-          Methodology
-          Definition of terms
  • Chapter Two – Literature Review
Review of study, review of what has been done in the area of research with technical details
  • Chapter Three – System Analysis and Design
System Analysis
-          System description
-          Historical background of the case study
-          Evaluation of the current system
-          Benefit of the current system
-          Problem of the current system
-          Technical details to solution of the problem
System Design
-          Overview of the new system
-          Output design
-          Input design
-          Database design
-          Process design
** Students are advised to used at least two of the following tools
                     i.            Program flowchart
                    ii.            Data flowchart
                   iii.            Algorithms
                  iv.            Uml e.t.c
  • Chapter Four – System Implementation and Documentation
-          Choice of programming language
-          Choice of DBMS
-          System requirement
-          Hardware requirement
-          Software requirement
-          System testing
-          File conversion
-          System documentation
  • Chapter Five – Summary, Conclusion and Recommendation
-          Summary of findings
-          Limitations
-          Conclusion
-          Recommendation
  • References
  • Appendices
-          Chart/Tables
-          Diagrams
-          Source codes
-          Screen shots