Big brother
Full text
BIG BROTHER Raul Ibanez A project submitted in partial fulfilment of the requirements for the University of Wales award of B.Sc. in Computing & IT School of Computing and Communications Technology North East Wales Institute, Wrexham May 2007
ACKNOWLEDGEMENTS I want to thank John Worden to have borrowed me a suitable scanner reader to be able to achieve the practical work of this project, and also thank his time dedicated on my consults to clarify my ideas towards this project. I also have to mention Jason Matthews, who provide me with the Software Development Kit files that have been really helpful. Finally, I can’t forget all the friends that have been there supporting me until the end.
CONTENTS Introduction……………………………………………………….………….….…………….1 Barcodes……………………………………………………………..……….…….……………3 Visual Basic.NET…………………………………………………….……..….……………21 Microsoft Access……………………………………………………………..….………….22 ASP.NET…………………….……………………………………………………….………….23 Visual Basic.NET application………………………………………………………….27 ASP.NET website……………………………………………….……………………………30 Conclusions…………………………………………………………………………………….36 Appendix A……………………………………………………………..……………………..37 Appendix B………………………………………………………………..…………………..40 Appendix C………………………………………………………………..…………………..45 References…...…………………………………………………………...………………….54
1 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT INTRODUCTION The incorporation of barcodes in our day live has made easy the manipulation of long numbers. Avoiding in big measure the human’s errors caused by transcribing the number impressed in a paper to a computer using a manual touchpad. This has been accomplished using scanner readers. The scanner reader is able to transfer a number faster and more efficient than any person could do. These good qualities together with the facility of use of scanner readers has done that barcodes have been use in a huge range of sectors. From small offices to big corporations that need to do a tracking of its products. The idea of this project is to use this technology in the academic field. The objectives are design and develop a student register. This can be achieved through the use of two elements. A unique and personal identifier for the student and a device able to read this identifier. The student will be identified through the barcode located in his student card. The device able to read this information will be a scanner reader barcode. The scanner reader model is a portable one, working with batteries and able to save up to 500 barcodes approximately* (depending the type of barcode read). It also has USB cable to transfer the data. _____________________________ * see appendix A for Barcode scanner specifications
2 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT To achieve the objectives marked is necessary use the right technology for the needs of every step. The objectives include: read the barcode, save the barcodes in the scanner, transfer the barcodes from the scanner to the computer, save all the barcodes in a database in the computer and show the information in a website. As we can see is a project that covers several technologies. This can very useful to put in practice concepts learned in some of the career subjects. To transfer the barcodes from the scanner to the computer I will use Visual Basic.NET, to save the barcodes I will use an Access database and finally to show the data I will use ASP.NET. Next, I will explain the technologies covered in that project.
3 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT BARCODES The first barcode appeared more than 50 years ago, specifically in 1949 and its creators were Noman Woodland and Bernard Silver. Not too much in common had this code with the actual ones. The first code was done from concentric circles and was read by photodetector. Far away was still unifying the information that was contained in this first codes. Later in 1961 appeared the first barcode scanner installed in USA by Silvana General Telephone and was used to identify train wagons. This device was able to read barcodes codified in color red, blue and white. Seven years after its creation, the railway association wanted to used this system to control the boarding traffic, although the project failed through lack of maintenance in the labels that had the codes. In 1969 appears the first scanner using helium and neon light and with it the first industrial applications able to use the barcodes to manage information as well. This same year Rust-Oleum is able to create a system able to interact with a barcode reader, it was the first application ready to manage stocks and print boarding reports. In the 70s appears the first contact pen and Plessey code used by the army to control files and documents. Gradually this system was introduced on libraries and new implementations appeared like Codabar that was used in blood banks. Also the company Buick starts using automatic identification in its assembling operations to get a daily meter of the pieces created. The barcodes start to show their utility to identify products and information management. In 1971 the Doctor David Allais creates the ITF code (Interleaved 2 of 5) and in 1973 was created in USA the UPC (Universal Product Code) developed by the Uniform Code Council (UCC) that will become the national identifying standard. In 1974 David Allais and Ray Stevens develop the first alphanumeric, code 39, being adopted by the Defense Department (LOGMARS), the Services Administration (GSA) and the car Industry (AIAG).
4 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT In 1974, manufactures and distributors from 12 European countries form a council to discuss the possibility to use a global standard system, unique in Europe and common with the international commerce, similar to the UPC used in USA. The result of this council was the creation of the EAN system (European Article Number), in 1977 an association with the same name was form. In 1980 appears Postnet, this code is used by the USA post service. One year later in 1981 a new alphanumeric code is created the 128. At this point is evident that barcodes had become the method more used to identify products. In 1987 a new type of code is created, the bidimensional code, named 49. The 2D codes are formed by squares instead of bars. These can contain a huge amount of information in comparison with the simple barcodes. This same year another 2D code is created, the 16k. In 1990 appears another 2D code that has become the most used in 2D codification the PDF417. In 1992 the EAN and UCC decide to put together their standards to generate a codification language available worldwide. This shows us how important have become the barcodes in the actual society.
5 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT Definition A barcode is a codification system to identify objects. This is made up of parallels lines and spaces of different thickness. This system provides a simple and easy method to encode information, numbers as well as text, which can be read by electronic readers. It allows any product to be identify anywhere in the world, on an agile way and without error possibility. It can be used for all related with data collection and manipulation that later will be associated with a database. However can seem that all barcodes are the same, the reality is that we can find a specific barcode for each necessity.
6 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT Codification systems There are two different techniques o codification systems depending which methodology is going to be used to represent zeros and ones inside the barcode. Module Width Encoding. This method uses a simple codification technique where to represent zeros and ones just two different widths are used. Usually zero is represented with the thinnest bar and one with the thickest one. When the barcode is based in this codification technique is said that is a two levels code. NRZ codification. This method is based in a complex structure where the bars represent one and the spaces zero, but it can be bars or spaces with different widths in case it had the same consecutive element. The maximum repetitions of the same elements are four. In that case when we are using this technique we will said that is a four levels code. We can make a barcodes classification in function of the codification type.
13 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT Code 11 Also known as code USD-8. This symbologie is able to codify 11 different characters. Due its high density offers the possibility to use two control characters. Each character is represented with five elements that where in most cases two are thick and three thin. The length is variable.
14 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT Code 128 It is able to represent the 128 ASCII characters, being one the systems with higher density. That’s why it has been the base to generate other systems like EAN 128. CODE 128 has 106 different bar and space patterns and each pattern can have one of three different meanings. Special start characters tell the reader which of the character sets is initially being used and three special codes permit changing character sets inside a code. One character sets encodes all upper case and ASCII control characters, another encodes all upper and lower case characters and the third set encodes numeric digit pairs 00 through 99. CODE 128 also uses a check digit for data security. Apart of the ASCII characters, CODE 128 also allows the use of four special function codes (FNC1 - FNC4). The meaning of function code FNC1 and FNC4 were originally left open for application specific purposes. CODE 93 CODE 93 can encode all the ASCII characters (128). CODE 93 was developed as an improvement of CODE 39 because it provides a higher character density than CODE 39. CODE 93 also incorporates two check digits to add security. Although CODE 93 is considered more robust than CODE 39, it has never been as popular as CODE 39.
15 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT UPC-A UPC-A is a code created with 12 numbers. UPC-A codes consist of 11 data digits and one check digit. The first digit is a number that usually represents the type of product. The following 5 digits are a manufacturer’s code and the next 5 digits are used to identify a specific product. UPC numbers are assigned to specific products and manufacturers by the Uniform Code Council (UCC). To print UPC-A codes usually is only necessary to write 11 numbers of data and the software calculates the 12th digit. UPC-E UPC-E is a smaller version of UPC-A code. The user only needs to input 6 digits and the software will calculate the seventh. UPC-A and UPC-E allow a supplementary code of two or five numbers. This supplementary code is added to the right of the main one. Differences between Type A and Type E UPC-E contains the same information as UPC-A, but UPC-E compress the 12 digits into 6 suppressing the zeros.
16 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT EAN-8/EAN-13 EAN or European Article Numbering is a European version of UPC. It has the same size and a similar encoding scheme as UPC codes. EAN-8 encodes 8 numbers split in two codes. EAN-13 is the European version of UPC-A. The difference between EAN-13 and UPCA is that EAN-13 encodes a 13th digit of parity into the left. This 13th digit, combined with the 12th digit, usually represent a country code. Both EAN-8 and EAN-13 support an additional code of two or five digit number, that will be added to right side to the main one. EAN-13 has been adopted as the standard in the publishing industry for encoding ISBN numbers on books. An ISBN is simply an EAN-13 code. EAN/UCC 128 The EAN/UCC 128 code is a variation of the original CODE 128 designed mainly for use in product identification applications. The EAN/UCC 128 specification uses the same code set as CODE 128 except that it does not allow the use of FNC2-FNC4 and FNC1 is used as part of the start code in the symbol.
17 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT POSTNET POSTNET (POSTal Numeric Encoding Technique) is a 5, 9 or 11 digit numeric barcode used by the U.S. Postal Service to encode ZIP Code information for automatic mail sorting by zip code. The barcode represents a five digit ZIP Code (32 bars), a nine digit ZIP + 4 code (52 bars) or an eleven digit Delivery Point code (62 bars). POSTNET is unlike other bar codes because data is encoded in the height of the bars instead of in the widths of the bars and spaces. Most standard bar code readers cannot decode POSTNET. This symbology was chosen by the Postal Service mainly because it is extremely easy to print on almost any type of printer. BPO 4 State Code (British Post Office, Royal Mail Code) BPO (British Post Office) 4 State Code is a new postal bar code that has been developed by the British Post office for encoding European postcode data similar to the way the U.S. PostNET is used for encoding Zip Code data. The U.S. PostNET encodes numeric characters in a pattern of four bars per character with each bar being either tall or short. The U.S. technique allows 16 different possible bar patterns for each set of four bars and is adequate for encoding the ten digits zero through nine. Because European postcodes contain both alpha and numeric characters, each character in the BPO 4 State Code is encoded into four bars with each bar having four possible "states". The four states are: tall bars, short bars, medium height bars extended up from the middle of the symbol and medium height bars extended down from the middle of the symbol.
18 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT RSS-14 The purpose of that code is to increase the amount of information that can be put into a barcode without having to increase the area of the code. This type of code is particularly useful for applications where there are space limitations. RSS allows businesses to go beyond the typical manufacturer and product identification information embedded in a barcode. PDF417 PDF417 is a high density 2 dimensional barcode that essentially consists in a group of small barcodes. The code is capable of encoding the entire (255 characters) ASCII set. PDF stands for "Portable Data File" because it can encode as many as 2725 data characters in a single bar code. The complete specification for PDF417 provides many encoding options including data compaction options, error detection and correction options, and variable size and aspect ratio symbols. An individual code word consists of a bar and space pattern 17 modules wide. The user may specify the module width, the module height, and the overall aspect ratio (overall height to width ratio) for the complete symbol. A complete PDF417 symbol consists of at least 3 rows of up to 30 code words and may contain up to 90 code word rows per symbol with a maximum of 928 code words per symbol. Because different data compaction algorithms may be used, it is possible for different printed symbols to be created from the same input data. The code also allows for varying degrees of data security or error correction and detection.
19 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT DATA MATRIX Data Matrix is a high density 2 dimensional matrix style barcode that can encode up to 3116 characters from the entire 256 byte ASCII character set. The symbol is built on a square grid. There are two types of Data Matrix symbols each using a different error checking and correction scheme (ECC). The different types of Data Matrix symbols are identified using the terminology "ECC" followed by a number representing the type of error correction that is used by the encoding software. ECC 000 to ECC 140 are the original type of Data Matrix symbols and are now considered obsolete. The newest version of Data Matrix is called ECC 200. MAXICODE MaxiCode is a fixed size matrix which is made from hexagonal modules arranged around a unique bulls-eye finder pattern. Each MaxiCode symbol has 884 hexagonal modules arranged in 33 rows with each row containing up to 30 modules. The maximum data capacity for a MaxiCode symbol is 93 alphanumeric characters or 138 Numeric characters. The design of the MaxiCode symbology was chosen because it is well suited to high speed, orientation independent scanning. Although the capacity of a MaxiCode symbol is not as high as other matrix style barcode symbologies, it was primarily designed to encode address data which rarely requires more than about 80 characters.
20 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT AZTEC CODE Aztec Code is a high density 2 dimensional matrix barcode, that can encode up to 3750 characters from the entire 256 byte ASCII character set. The symbol is built on a square grid with a bulls-eye pattern at its centre. Data is encoded in a series of "layers" that circle around the bull’s-eye pattern. Each additional layer completely surrounds the previous layer causing the symbol to grow in size as more data is encoded, but the symbol remains square.
21 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT VISUAL BASIC.NET Visual Basic.NET is an object oriented language. Is the latest version of Visual Basic and can be found in Visual Studio. It is part of the framework .NET. The development environment is fully customizable and contains all necessary tools for build Microsoft Windows programs. Because the development environment contains multiples windows and functionalities is call integrated development environment. The main window is the designer window, where is the development form. The toolbox is localize into the left side. In the right side we have the solution explorer. The properties window contains three parts: 1. The top part contains a combo box that shows the name and class from the selected object. 2. The middle part contains a properties list from the selected object. 3. The lower part is a descriptive frame that gives us a brief description of the selected property. In Visual Basic.NET in contrast with previous Visual Basic versions, there is only one kind of code file, which has the extension .vb, in that kind of file can be together different elements. While, in previous versions, every element had his own file type, with its own extension. There are two types of executables in VB.NET. One by console, without graphic mode and the other is the typical windows interface.
22 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT MICROSOFT ACCESS Microsoft Access is a powerful program to create and manage databases. It has many built in features to assist in constructing and viewing the information. It uses cover personal use and small companies. The main functionalities are: - Creation of index data tables. - Modify data tables. - Relations betweens tables - Creation of statements - Cross references statements - Action statements (insert, delete, update) - Forms - Reports - Macros It can create frontends from more powerful databases, because is able to access to external tables through ODBC like if they were Access tables. One of the main disadvantages is that can only be used in Microsoft operative systems and doesn’t allow transactions. Microsoft Access breaks down a database in some keywords. These keywords are: Database File, Table, Record, Field, Data-type. Database File: This is the main file that covers the entire database. Table: A table is a collection of data about a specific topic. There can be multiple tables in a database. Field: Fields are the different categories within a Table. Tables usually contain multiple fields. Datatypes: Datatypes are the properties of each field. A field only has 1 datatype.
29 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT Download button When this button is pressed the application gets the number of barcodes that are in the scanner memory. It opens the connection with the database. Then creates a loop, in every iteration a new row added to the database with a new barcode in it. At the same time that barcodes have been added to the database, they are also show in the listbox. When all barcodes have been saved, the barcodes from the scanner memory are deleted. Exit button The application will end, previously we have been asked about our decision. The code of this application can be found in appendix B.
30 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT ASP.NET WEBSITE This website is able to manage the information that is saved in databases. The main objective of this page is show to a teacher, in a structured way, the students that have attend to his classes in a specific day. Databases This website has been designed using the subjects given in the computing department. For each subject there is a database that contains all the students enrolled in the subject and all the days that will be classes. If a student has been in class, this day he will be mark with TRUE in the corresponding box, in case the student wasn’t in class the box will remain marked FALSE. I have created the subjects databases with ten students as example of possible students. In a real implementation of this website, in every database the student name will be replaced by the student code (example: 06002185) enrolled in the subject. This number will be the same that the scanner will read. A part from these databases, I have created two more databases, Subjects and Teachers. In the Subjects database there is all the information related with the computing subjects, code and name of the subject, teacher, time, day and room where is given it.
31 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT The last database designed, Teachers, contains the teacher name and his password. This website hasn’t been thought to allow new users to register because only teachers are the ones that have to be able to see this information. At the beginning the password is the same as the name, after have been logged in he can change the password.
32 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT This website has been structured in three pages, login, password and the main one. Next, I will explain every page. LOGIN This is the first page that the user will see. As it can be seen there is not possible registration. Only users that are in the database can accede. If it’s the first time that the user accede to this page the password will be the same as he’s name plus surname, for example, user name: john smith and password: john smith. The website checks possible errors, like: - If one or both fields are empty a message will tell us: Both fields are required to check identity - If the user is not in the database: User not register - If the user is in the database but the password is not correct: Invalid authentication Once we have logged in, we see the main page.
33 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT MAIN In the main page we can see a lot of useful information, I will start from the top until the bottom to explain all features.
34 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT In topright corner we see the user name that has logged in and two links. One for logging out the page and the other to change our current password. After this, the user will see some links with the subjects that his teaching. To do this the webpage search in the Subjects database all the subjects that match with the teacher. Once a subject has been clicked the next information will be different for every subject selected. If a day is clicked in the calendar, we will see which students have been in the class that day. If the day clicked there is not class, we will see a message that tells it. In the right we can see all the information related with that class, like day, hour or room. PASSWORD
35 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT The last page allows the user to change his current password for a new one. Some possible errors that the page checks are the next ones: - If one or more fields are empty, we will read: All fields are required to change password - If the introduced password doesn’t match with the current one: Password incorrect - If the new password and the confirmation are not the same: New password doesn't match - If the new password is the same as the current one: New password has to be different from current The code of this website can be found in appendix C.
36 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT CONCLUSIONS This project has been a challenge for me because this year was the first time I have learn how to program with visual basic and also was the first time I use ASP. I think I have reached the objectives of this project developing two functional applications. I have learn a lot from this project I have had to study in depth some technologies and learn new stuff that before I didn’t know. It has been a shame that these applications can not interact with the barcodes from the students cards but at least I developed the applications supposing that everything it’s fine. This can be the base for another project using a different scanner or student identification. An idea for a future project related with the fact of having a control of people on classes, could be the use of RFID technology. The implementation is more expensive but for the end user is less time consuming.
37 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT APPENDIX A Scanner specifications
38 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT
45 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT APPENDIX C ASP website code
46 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT login.aspx.vb Imports System.Data Imports System.Data.OleDb Partial Class login Inherits System.Web.UI.Page Dim c As New OleDb.OleDbConnection Dim da As OleDb.OleDbDataAdapter Dim ds As New DataSet Dim query As String Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load c.ConnectionString = "PROVIDER = Microsoft.jet.oledb.4.0;Data Source = C:\Temp\teachers.mdb" query = "select * from teachers" c.Open() da = New OleDb.OleDbDataAdapter(query, c) c.Close() da.Fill(ds, "teachers") End Sub Protected Sub btnlogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnlogin.Click Dim row As Integer = -1 Dim i As Integer = 0 lblmessage.Text = "" If ((txtname.Text = "") Or (txtpassword.Text = "")) Then lblmessage.Text = "Both fields are required to check identity." Else While (i < ds.Tables("teachers").Rows.Count - 1) If (StrComp(ds.Tables("teachers").Rows(i).Item(0), txtname.Text, CompareMethod.Text) = 0) Then row = i End If i += 1 End While If (row <> -1) Then If (StrComp(ds.Tables("teachers").Rows(row).Item(1), txtpassword.Text, CompareMethod.Text) = 0) Then Response.Redirect("main.aspx?User=" + txtname.Text) Else lblmessage.Text = "Invalid authentication" End If Else lblmessage.Text = "User not register" End If End If End Sub End Class
47 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT main.aspx.vb Imports System.Data Imports System.Data.OleDb Partial Class main Inherits System.Web.UI.Page Dim code1, daytimelect1, daytimelab1, locationlect1, locationlab1 As String Dim code2, daytimelect2, daytimelab2, locationlect2, locationlab2 As String Dim code3, daytimelect3, daytimelab3, locationlect3, locationlab3 As String Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim c As New OleDb.OleDbConnection Dim da As OleDb.OleDbDataAdapter Dim ds As New DataSet Dim query As String Dim i As Integer = 0 Dim f As Boolean = False hideinfo() lbluser.Text = Request("User") c.ConnectionString = "PROVIDER = Microsoft.jet.oledb.4.0;Data Source = C:\Temp\subjects.mdb" query = "select * from subjects" c.Open() da = New OleDb.OleDbDataAdapter(query, c) c.Close() da.Fill(ds, "subjects") While (i < ds.Tables("subjects").Rows.Count And f = False) If (StrComp(ds.Tables("subjects").Rows(i).Item(2), lbluser.Text, CompareMethod.Text) = 0) Then lnksubject1.Text = ds.Tables("subjects").Rows(i).Item(1) code1 = ds.Tables("subjects").Rows(i).Item(0) daytimelect1 = ds.Tables("subjects").Rows(i).Item(3) daytimelab1 = ds.Tables("subjects").Rows(i).Item(4) locationlect1 = ds.Tables("subjects").Rows(i).Item(5) locationlab1 = ds.Tables("subjects").Rows(i).Item(6) f = True End If i += 1 End While f = False While (i < ds.Tables("subjects").Rows.Count And f = False) If (StrComp(ds.Tables("subjects").Rows(i).Item(2), lbluser.Text, CompareMethod.Text) = 0) Then lnksubject2.Text = ds.Tables("subjects").Rows(i).Item(1) code2 = ds.Tables("subjects").Rows(i).Item(0) daytimelect2 = ds.Tables("subjects").Rows(i).Item(3) daytimelab2 = ds.Tables("subjects").Rows(i).Item(4) locationlect2 = ds.Tables("subjects").Rows(i).Item(5) locationlab2 = ds.Tables("subjects").Rows(i).Item(6) f = True End If i += 1 End While f = False While (i < ds.Tables("subjects").Rows.Count And f = False) If (StrComp(ds.Tables("subjects").Rows(i).Item(2), lbluser.Text, CompareMethod.Text) = 0) Then lnksubject3.Text = ds.Tables("subjects").Rows(i).Item(1) code3 = ds.Tables("subjects").Rows(i).Item(0) daytimelect3 = ds.Tables("subjects").Rows(i).Item(3) daytimelab3 = ds.Tables("subjects").Rows(i).Item(4) locationlect3 = ds.Tables("subjects").Rows(i).Item(5)
48 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT locationlab3 = ds.Tables("subjects").Rows(i).Item(6) f = True End If i += 1 End While End Sub Protected Sub Calendar_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar.SelectionChanged Dim c As New OleDb.OleDbConnection Dim da As OleDb.OleDbDataAdapter Dim ds As New DataSet Dim query As String Dim i As Integer = 1 Dim j As Integer = 0 Dim f As Integer = -1 If lblcurrent.Text = "" Then Exit Sub End If c.ConnectionString = "PROVIDER = Microsoft.jet.oledb.4.0;Data Source = C:\Temp\" & lblcurrent.Text & ".mdb" query = "select * from " & lblcurrent.Text c.Open() da = New OleDb.OleDbDataAdapter(query, c) c.Close() da.Fill(ds, lblcurrent.Text) lblday.Text = Calendar.SelectedDate While (i < ds.Tables(lblcurrent.Text).Columns.Count - 1) If (StrComp(ds.Tables(lblcurrent.Text).Columns(i).ColumnName, lblday.Text, CompareMethod.Text) = 0) Then f = 1 '****************************************************************** 'The most efficient way to do this is using a loop, 'but because I don't know how to accede to every image 'using a counter, I have done manually. 'It should be something like this: 'While (j < ds.Tables(lblactual.Text).Rows.Count) 'If ds.Tables(lblactual.Text).Rows(j).Item(i).ToString = True Then ''imgtick(j).Visible = True ''imgcross(j).Visible = False 'Else ''imgtick(j).Visible = False ''imgcross(j).Visible = True 'End If 'j += 1 'End While lblstudent0.Text = ds.Tables(lblcurrent.Text).Rows(0).Item(0).ToString If ds.Tables(lblcurrent.Text).Rows(0).Item(i).ToString = True Then imgtick0.Visible = True imgcross0.Visible = False Else imgtick0.Visible = False imgcross0.Visible = True End If lblstudent1.Text = ds.Tables(lblcurrent.Text).Rows(1).Item(0).ToString If ds.Tables(lblcurrent.Text).Rows(1).Item(i).ToString = True Then imgtick1.Visible = True imgcross1.Visible = False Else imgtick1.Visible = False
49 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT imgcross1.Visible = True End If lblstudent2.Text = ds.Tables(lblcurrent.Text).Rows(2).Item(0).ToString If ds.Tables(lblcurrent.Text).Rows(2).Item(i).ToString = True Then imgtick2.Visible = True imgcross2.Visible = False Else imgtick2.Visible = False imgcross2.Visible = True End If lblstudent3.Text = ds.Tables(lblcurrent.Text).Rows(3).Item(0).ToString If ds.Tables(lblcurrent.Text).Rows(3).Item(i).ToString = True Then imgtick3.Visible = True imgcross3.Visible = False Else imgtick3.Visible = False imgcross3.Visible = True End If lblstudent4.Text = ds.Tables(lblcurrent.Text).Rows(4).Item(0).ToString If ds.Tables(lblcurrent.Text).Rows(4).Item(i).ToString = True Then imgtick4.Visible = True imgcross4.Visible = False Else imgtick4.Visible = False imgcross4.Visible = True End If lblstudent5.Text = ds.Tables(lblcurrent.Text).Rows(5).Item(0).ToString If ds.Tables(lblcurrent.Text).Rows(5).Item(i).ToString = True Then imgtick5.Visible = True imgcross5.Visible = False Else imgtick5.Visible = False imgcross5.Visible = True End If lblstudent6.Text = ds.Tables(lblcurrent.Text).Rows(6).Item(0).ToString If ds.Tables(lblcurrent.Text).Rows(6).Item(i).ToString = True Then imgtick6.Visible = True imgcross6.Visible = False Else imgtick6.Visible = False imgcross6.Visible = True End If lblstudent7.Text = ds.Tables(lblcurrent.Text).Rows(7).Item(0).ToString If ds.Tables(lblcurrent.Text).Rows(7).Item(i).ToString = True Then imgtick7.Visible = True imgcross7.Visible = False Else imgtick7.Visible = False imgcross7.Visible = True End If lblstudent8.Text = ds.Tables(lblcurrent.Text).Rows(8).Item(0).ToString If ds.Tables(lblcurrent.Text).Rows(8).Item(i).ToString = True Then imgtick8.Visible = True imgcross8.Visible = False Else imgtick8.Visible = False imgcross8.Visible = True End If lblstudent9.Text = ds.Tables(lblcurrent.Text).Rows(9).Item(0).ToString If ds.Tables(lblcurrent.Text).Rows(9).Item(i).ToString = True Then imgtick9.Visible = True imgcross9.Visible = False Else
50 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT imgtick9.Visible = False imgcross9.Visible = True End If '****************************************************************** End If i += 1 End While If (f = 1) Then lblinfo.Text = "" Else lblinfo.Text = "Not class this day" hideinfo() End If End Sub Protected Sub lnklogout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnklogout.Click Response.Redirect("login.aspx") End Sub Protected Sub lnksubject1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnksubject1.Click Dim c As New OleDb.OleDbConnection Dim da As OleDb.OleDbDataAdapter Dim ds As New DataSet Dim query As String lblsentence.Text = "Choose one day to see who has been in " & lnksubject1.Text lblcurrent.Text = code1 lbllecture.Text = "Lecture: " & daytimelect1.ToString & " in " & locationlect1.ToString lbllab.Text = "Lab: " & daytimelab1.ToString & " in " & locationlab1.ToString c.ConnectionString = "PROVIDER = Microsoft.jet.oledb.4.0;Data Source = C:\Temp\" & code1 & ".mdb" query = "select * from " & code1 c.Open() da = New OleDb.OleDbDataAdapter(query, c) c.Close() da.Fill(ds, code1) End Sub Protected Sub lnksubject2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnksubject2.Click Dim c As New OleDb.OleDbConnection Dim da As OleDb.OleDbDataAdapter Dim ds As New DataSet Dim query As String lblsentence.Text = "Choose one day to see who has been in " & lnksubject2.Text lblcurrent.Text = code2 lbllecture.Text = "Lecture: " & daytimelect2.ToString & " in " & locationlect2.ToString lbllab.Text = "Lab: " & daytimelab2.ToString & " in " & locationlab2.ToString c.ConnectionString = "PROVIDER = Microsoft.jet.oledb.4.0;Data Source = C:\Temp\" & code2 & ".mdb" query = "select * from " & code2 c.Open() da = New OleDb.OleDbDataAdapter(query, c) c.Close() da.Fill(ds, code2) End Sub
51 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT Protected Sub lnksubject3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnksubject3.Click Dim c As New OleDb.OleDbConnection Dim da As OleDb.OleDbDataAdapter Dim ds As New DataSet Dim query As String lblsentence.Text = "Choose one day to see who has been in " & lnksubject3.Text lblcurrent.Text = code3 lbllecture.Text = "Lecture: " & daytimelect3.ToString & " in " & locationlect3.ToString lbllab.Text = "Lab: " & daytimelab3.ToString & " in " & locationlab3.ToString c.ConnectionString = "PROVIDER = Microsoft.jet.oledb.4.0;Data Source = C:\Temp\" & code3 & ".mdb" query = "select * from " & code3 c.Open() da = New OleDb.OleDbDataAdapter(query, c) c.Close() da.Fill(ds, code3) End Sub Protected Sub lnkpassword_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkpassword.Click Response.Redirect("password.aspx?User=" + lbluser.Text) End Sub Function hideinfo() imgtick0.Visible = False imgcross0.Visible = False imgtick1.Visible = False imgcross1.Visible = False imgtick2.Visible = False imgcross2.Visible = False imgtick3.Visible = False imgcross3.Visible = False imgtick4.Visible = False imgcross4.Visible = False imgtick5.Visible = False imgcross5.Visible = False imgtick6.Visible = False imgcross6.Visible = False imgtick7.Visible = False imgcross7.Visible = False imgtick8.Visible = False imgcross8.Visible = False imgtick9.Visible = False imgcross9.Visible = False lblstudent0.Text = "" lblstudent1.Text = "" lblstudent2.Text = "" lblstudent3.Text = "" lblstudent4.Text = "" lblstudent5.Text = "" lblstudent6.Text = "" lblstudent7.Text = "" lblstudent8.Text = "" lblstudent9.Text = "" End Function End Class
52 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT password.aspx.vb Imports System.Data Imports System.Data.OleDb Partial Class password Inherits System.Web.UI.Page Dim c As New OleDb.OleDbConnection Dim da As OleDb.OleDbDataAdapter Dim ds As New DataSet Dim query As String Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load c.ConnectionString = "PROVIDER = Microsoft.jet.oledb.4.0;Data Source = C:\Temp\teachers.mdb" query = "select * from teachers" c.Open() da = New OleDb.OleDbDataAdapter(query, c) c.Close() da.Fill(ds, "teachers") End Sub Protected Sub btnchange_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnchange.Click Dim row As Integer = -1 Dim i As Integer = 0 Dim user As String Dim cb As New OleDb.OleDbCommandBuilder(da) user = Request("User") lblmessage.Text = "" If ((txtpassword.Text = "") Or (txtnewpassword1.Text = "") Or (txtnewpassword2.Text = "")) Then lblmessage.Text = "All fields are required to change password." Else While (i < ds.Tables("teachers").Rows.Count - 1 And row = -1) If (StrComp(ds.Tables("teachers").Rows(i).Item(0), user, CompareMethod.Text) = 0) Then row = i If (StrComp(ds.Tables("teachers").Rows(row).Item(1), txtpassword.Text, CompareMethod.Text) <> 0) Then lblmessage.Text = "Password incorrect" Exit Sub End If End If i += 1 End While If (StrComp(txtnewpassword1.Text, txtnewpassword2.Text, CompareMethod.Text) = 0) Then If (StrComp(txtpassword.Text, txtnewpassword1.Text, CompareMethod.Text) = 0) Then lblmessage.Text = "New password has to be different from current" Else ds.Tables("teachers").Rows(row).Item(1) = txtnewpassword1.Text da.Update(ds, "teachers") Server.Transfer("main.aspx") End If Else lblmessage.Text = "New password doesn't match" End If End If End Sub
53 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT Protected Sub btncancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btncancel.Click Server.Transfer("main.aspx") End Sub End Class
54 __________________________________________________________________________________________________ Raul Ibanez BSc Computing & IT REFERENCES [1] Reynolds, M. (2002) Beginning VB. NET (2nd edn.), Birmingham, Wrox Press Ltd. [2] Halvorson, M. (2002) Microsoft Visual Basic.Net step by step, Redmond, Wash, Microsoft Press. [3] Deitel, H. (2003) Simply Visual Basic .NET, Upper Saddle River, NJ, Prentice Hall. [4] Scott Barrer, F. (2003) Database programming with Visual Basic. NET and ADO. NET : tips, tutorials and code, Indianapolis, Ind, Sams. [5] Crouch, M. (2002) ASP. NET and VB. NET Web programming, Boston, AddisonWesley. [6] Buczek, G. (2002) ASP. Net developer's guide, New York, McGraw-Hill. [7] Carter, J. (2003) Database design and programming with Access, SQL, Visual Basic and ASP (2nd edn.), London, McGraw-Hil [8] Palmer, R. (1995) The Bar Code Book (3rd edn.), Helmers Publishing Webpages http://support.microsoft.com http://www.howstuffworks.com/upc.htm http://www.barcodeisland.com/symbolgy.phtml