Thursday, October 23, 2014

An Application Package on Library Management System (LMS) ~~ VisualBasic Code Snippet + GUI Design

Librarian & Member Login

                                                      
                                              Member Management

Source Code Snippet

Wednesday, August 20, 2014

An Application Package on, 3DES, Data Encryption & Decryption ~~ VisualBasic Code Snippet + GUI Design

                                  File Menu { --New  --Open  --Save  --Exit  

                                                                        
 Operation Menu--Encrypt file/Data --Decrypt file/Data


Encrypting Data/File (plain text) Using Encryption Key (9090)
** You 're to use your own key **


            Encrypted Data/File


Decrypting Data/File (cipher text) Using  Key (9090)


Decrypted Data/File


                           Format Menu { --Font  --Fore-Color --BackGround-Color
             

**SOURCE CODE "Snippet" ** 


Imports System.Security.Cryptography

Public Class Index   ' Class Begins

    Sub Encryption()

   Dim plainText As String = txtPlain_Cipher_Text.Text    'InputBox("Enter the plain text:")
   Dim EncryptionKey As String = InputBox("Enter Encryption Key")

        Dim container As New Main(EncryptionKey)
        Dim cipherText As String = container.EncryptData(plainText) 
        txtPlain_Cipher_Text.Text = cipherText 
    End Sub
'==================================================
    Sub Decryption()

        If txtPlain_Cipher_Text.Text = String.Empty Then

            Try

                OpenFileDialog.ShowDialog()
                txtPlain_Cipher_Text.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog.FileName)

            Catch Ooops As IO.FileNotFoundException
                'Do nothing
            End Try

        Else

            Dim DecryptionKey As String = InputBox("Enter Decryption Key:")
            Dim container As New Main(DecryptionKey)

            Try
                Dim plainText As String = container.DecryptData(txtPlain_Cipher_Text.Text)
                txtPlain_Cipher_Text.Text = plainText

            Catch ex As System.Security.Cryptography.CryptographicException
                MsgBox("Invalid Key.", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
            End Try

        End If
    End Sub
 '==================================================
    Private Sub EncryptToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EncryptToolStripMenuItem.Click

        Encryption()

    End Sub
 '==================================================
    Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click

        txtPlain_Cipher_Text.Text = String.Empty

    End Sub
 '==================================================
    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click

        If txtPlain_Cipher_Text.Text = String.Empty Then
            MsgBox("No text found", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
        Else
            SaveFileDialog.ShowDialog()
            Dim path As String = SaveFileDialog.FileName
            Try
                System.IO.File.WriteAllText(path, txtPlain_Cipher_Text.Text)
            Catch ae As ArgumentException
                MsgBox("File not saved; No file name selected", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
            End Try
        End If
    End Sub
 '==================================================
    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click

        Try
            OpenFileDialog.ShowDialog()
            txtPlain_Cipher_Text.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog.FileName)
        Catch ex As IO.FileNotFoundException ' Exception caught when closing the Dialog box without making any selection
            'do nothing
        End Try
    End Sub
 '==================================================
    Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click
        FontDialog.ShowDialog()

        txtPlain_Cipher_Text.Font = FontDialog.Font

    End Sub
 '==================================================
    Private Sub ForeColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ForeColorToolStripMenuItem.Click

        ColorDialog.ShowDialog()
        txtPlain_Cipher_Text.ForeColor = ColorDialog.Color

    End Sub
 '==================================================
    Private Sub BackGroundColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackGroundColorToolStripMenuItem.Click

        ColorDialog.ShowDialog()
        txtPlain_Cipher_Text.BackColor = ColorDialog.Color

    End Sub
 '==================================================
   
    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click

        Me.Close()

    End Sub
 '==================================================
    Private Sub DecryptToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DecryptToolStripMenuItem.Click

        Decryption()

    End Sub 

End Class  ' Class Ends Here
 '==================================================
   

Wednesday, July 30, 2014

My first html/javascript code on "functions"

  My first html/javascript code on functions. 

 @ first I thought javascript would be java and nothing more. But, today, I can say YES it is and NO it’s not. Yes because, if you understand java then you ‘re almost done with javascript. No because, you still got some catching up to do. See the below code. In java, you dare not call a no argument(s) method with argument(s).
 More so, everything (variables, data types, etc…) you use is either implicitly defined which you‘ve to import to your code ""except java.lang class"" OR explicitly defined by you.
 Well, I believe every language has it own style. You just have to understand every single logic.
---------------------------------------------------------
Line 8 declared a function add with no argument. Line 17 calls the add functions with arguments… Even though i clearly understands how it works, it still looks awful to me compare to java.
 What the below code actually does is – create a function call add(), line 8. Declare a variable named value which is initialized to 0, line 9. Create a for loop that add/sum the passed in parameters, line 11 – 13. Return the sum value, line 14. Line 17 shows the passes in values/parameters (2,4,6,8,10) while line 18 displays the value (sum).
---------------------------------------------------------

1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title> JavaScript Functions </title>
5.
6.   <script type="text/javascript">
7. 
8.    function add() {
9.     var value = 0
10.       
11.        for(i=0; i < arguments.length; i++) {
12.        value+=arguments[i];
13.        }
14.     return value;
15.    }
16.   
17.    var mainValue = add(2,4,6,8,10);
18.    alert(mainValue);  
19.
20.   </script>
21.
22.
23. </head>
24. <body>
25. <h1> JavaScript Functions  </h1>
26. </body>
27. </html>
-----------------------------------------------------------
RESULT = 30
-----------------------------------------------------------

--------------------------------------------
LITERAL FUNCTION – create a function without a name then assign it to a named variable Ooops. @ the end of the function declaration, include the function parameters (line 10)
--------------------------------------------

1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title> JavaScript Function </title>
5.
6.   <script type="text/javascript">
7.  
8.   var Ooops = (function(){
9.     return arguments[1] + arguments[2];
10.   })(1,2,3);
11.
12.    alert(Ooops);
13.
14.   </script>
15.
16. </head>
17. <body>
18. <h1> JavaScript Function </h1>
19. </body>
20. </html>
-----------------------------------------------------------
RESULT = 5
-----------------------------------------------------------

--------------------------------------------
ANONYMOUS FUNCTION – create a function without a name. @ the end of the function declaration, include the function parameters (line 10)
--------------------------------------------

1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title> JavaScript Anonymous Function </title>
5.
6.   <script type="text/javascript">
7.  
8.   alert((function(){
9.     return arguments[0] + arguments[1];
10.   })(4,5,3));
11.
12.   </script>
13.
14. </head>
15. <body>
16. <h1> JavaScript Anonymous Function </h1>
17. </body>
18. </html>
-----------------------------------------------------------
RESULT = 9
-----------------------------------------------------------
KNOW THIS – if you ‘re already familiar with java & new to javascript THEN your new friend will be SYNTAX ERROR(S)

Thursday, July 24, 2014

An Application Package on Automated Teller Machine (ATM) ~~ VisualBasic Code Snippet + GUI Design



 CODE SNIPPET

Public Class atm
    Public Sub countpin()
        If txtpin.TextLength > 3 Then
            errpro.SetError(txtpin, "Invalid Entry!!! Maximum Entry Reached")
            txtpin.Text = txtpin.Text & "" 
        End If
    End Sub

    Public Sub btnclick()
        If btninsertcard.Text = "Card Inserted" Then
            entervalue()
        Else
        End If
        disablebuttons() ' disabling the buttons
    End Sub

    ' declaring a method for entering values e.g pin e.t.c
    Sub entervalue()
        If txtpin.Text = String.Empty Then
            txtpin.Text = Me.ActiveControl.Text
        Else
            txtpin.Text = txtpin.Text & Me.ActiveControl.Text
        End If
        If txtpin.Text.Length = 5 Then
            MessageBox.Show("Maximum Entry Exceeded""SkyeBank", MessageBoxButtons.OK, MessageBoxIcon.Information)
            txtpin.Text = String.Empty
        End If
    End Sub

    Public Sub disablebuttons()
        If txtpin.Text.Length = 4 Then
        Else
            enablebuttons()
        End If
    End Sub

    Public Sub enablebuttons()
        groupboxbtn.Enabled = True
    End Sub

    Private Sub TimerPendulum_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerPendulum.Tick
        txtwelcome.Left = txtwelcome.Left - 1
        If txtwelcome.Left = 69 Then
            TimerPendulum.Enabled = False
            TimerPendulum1.Enabled = True
        End If
    End Sub

    Private Sub TimerPendulum1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerPendulum1.Tick
        txtwelcome.Left = txtwelcome.Left + 1
        If txtwelcome.Left = 177 Then
            TimerPendulum1.Enabled = False
            TimerPendulum.Enabled = True
        End If
    End Sub

    Private Sub atm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtmainscreen.Visible = False
        Me.ActiveControl = btnminus
        txtboxstmt.Visible = False

        'Panelmain.Visible = False
        lblcount.Visible = False
        txtpin.Visible = False
        txtpin.BackColor = txtboard.BackColor
  End Sub

    Private Sub TimerChangeColor_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerChangeColor.Tick
        lblcount.Text = lblcount.Text + 1
        If lblcount.Text = 4 Then
            txtChangeColor.BackColor = Color.LightGreen
        ElseIf lblcount.Text = 10 Then
            txtChangeColor.BackColor = Color.White
            TimerChangeColor.Enabled = False
            lblcount.Text = 0
            TimerChangeColor.Enabled = True
        End If
    End Sub

    Private Sub btnzero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnzero.Click
        btnclick()
        ' countpin()
    End Sub

    Private Sub btninsertcard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btninsertcard.Click
        enablebuttons()
        ' making the textpin visibility to be true...
        TimerChangeColor.Enabled = False
        txtChangeColor.BackColor = Color.LightGreen
        txtwelcome.Visible = False
        txtpin.Visible = True
        txtpin.Text = String.Empty
        txtboxstmt.Visible = True    'making the enter pin stmt visible...
        If btninsertcard.Text = "Insert Card" Then
            btninsertcard.Text = "Card Inserted"
            btninsertcard.Enabled = False
        End If
        txtpin.Focus()
    End Sub

    Private Sub btnone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnone.Click
        btnclick()
    End Sub

    Private Sub btntwo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntwo.Click
        btnclick()
    End Sub

    Private Sub btnthree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthree.Click
        btnclick()
    End Sub

    Private Sub btnfour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfour.Click
        btnclick()
    End Sub

    Private Sub btnfive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfive.Click
        btnclick()
    End Sub

    Private Sub btnsix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsix.Click
        btnclick()
    End Sub

    Private Sub btnseven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnseven.Click
        btnclick()
    End Sub

    Private Sub btneight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btneight.Click
        btnclick()
    End Sub

    Private Sub btnnine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnine.Click
        btnclick()
    End Sub

    Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancel.Click
        txtwelcome.Visible = True
        txtboxstmt.Visible = False
        txtpin.Text = String.Empty
        txtpin.Visible = False
        btninsertcard.Text = "Insert Card"
        btninsertcard.Enabled = True
        TimerChangeColor.Enabled = True
    End Sub 
  
End Class
________________________________________________________
....Just Snippet; need the full atm design? feel free to reach me

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