asp.net qr code reader The medicines Example in .NET framework

Decode QR Code in .NET framework The medicines Example

The medicines Example
Decoding QR Code In Visual Studio .NET
Using Barcode scanner for .NET framework Control to read, scan QR-Code image in .NET applications.
www.OnBarcode.com
QR Code Scanner In .NET Framework
Using Barcode decoder for .NET framework Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Many databases require some flexibility on the part of the database application For example, we might put together a database application that keeps track of the medicines a set of patients is taking Not every patient will take the same number of medicines, so we must allow for variable-length records; some patients may be taking three medications, some only one XML is up to the task: the variable-length nature of our records is reflected in the DTD of our new example's XML file, +, where we indicate that each record can contain exactly one <LASTNAME> element, exactly one <FIRSTNAME> element, but zero or more occurrences of the <MEDICINE> element:
Read Bar Code In .NET Framework
Using Barcode scanner for VS .NET Control to read, scan barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Barcode Scanner In Visual Studio .NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
< XML version = "10" >
Recognizing QR Code In C#.NET
Using Barcode recognizer for .NET framework Control to read, scan QR Code JIS X 0510 image in .NET applications.
www.OnBarcode.com
Recognizing QR Code 2d Barcode In .NET Framework
Using Barcode decoder for ASP.NET Control to read, scan QR Code ISO/IEC18004 image in ASP.NET applications.
www.OnBarcode.com
<!DOCTYPE DOCUMENT [
Scan QR-Code In .NET Framework
Using Barcode reader for VS .NET Control to read, scan QR Code 2d barcode image in VS .NET applications.
www.OnBarcode.com
Scan QR In VB.NET
Using Barcode reader for .NET framework Control to read, scan QR Code JIS X 0510 image in .NET applications.
www.OnBarcode.com
<!ELEMENT DOCUMENT (NAME)*>
1D Decoder In VS .NET
Using Barcode reader for .NET Control to read, scan 1D Barcode image in VS .NET applications.
www.OnBarcode.com
Bar Code Scanner In VS .NET
Using Barcode scanner for .NET framework Control to read, scan barcode image in VS .NET applications.
www.OnBarcode.com
<!ELEMENT NAME (LASTNAME,FIRSTNAME,MEDICINE*)>
Matrix Barcode Reader In VS .NET
Using Barcode reader for .NET Control to read, scan 2D Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Decoding UPCA In VS .NET
Using Barcode decoder for VS .NET Control to read, scan UPC-A Supplement 2 image in Visual Studio .NET applications.
www.OnBarcode.com
<!ELEMENT LASTNAME (#PCDATA)>
Recognizing USD8 In Visual Studio .NET
Using Barcode recognizer for .NET framework Control to read, scan USD8 image in VS .NET applications.
www.OnBarcode.com
ANSI/AIM Code 39 Decoder In None
Using Barcode recognizer for Software Control to read, scan Code 3/9 image in Software applications.
www.OnBarcode.com
<!ELEMENT FIRSTNAME (#PCDATA)>
Scan PDF417 In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Linear Barcode Reader In VB.NET
Using Barcode scanner for Visual Studio .NET Control to read, scan 1D image in VS .NET applications.
www.OnBarcode.com
<!ELEMENT MEDICINE (#PCDATA)>
Recognizing Code 128 Code Set B In Objective-C
Using Barcode recognizer for iPad Control to read, scan Code 128C image in iPad applications.
www.OnBarcode.com
Barcode Decoder In Visual C#.NET
Using Barcode decoder for .NET framework Control to read, scan bar code image in .NET framework applications.
www.OnBarcode.com
Here's the whole database for this example, +: < XML version = "10" >
Barcode Decoder In Visual Studio .NET
Using Barcode scanner for Reporting Service Control to read, scan barcode image in Reporting Service applications.
www.OnBarcode.com
Bar Code Reader In None
Using Barcode scanner for Font Control to read, scan bar code image in Font applications.
www.OnBarcode.com
<!DOCTYPE DOCUMENT [
<!ELEMENT DOCUMENT (NAME)*>
<!ELEMENT NAME (LASTNAME,FIRSTNAME,MEDICINE*)>
<!ELEMENT LASTNAME (#PCDATA)>
<!ELEMENT FIRSTNAME (#PCDATA)>
<!ELEMENT MEDICINE (#PCDATA)>
<DOCUMENT>
<NAME>
<LASTNAME>Franklin</LASTNAME>
<FIRSTNAME>Tom</FIRSTNAME>
<MEDICINE>
Medicine 1
</MEDICINE>
<MEDICINE>
Medicine 2
</MEDICINE>
<MEDICINE>
Medicine 3
</MEDICINE>
</NAME>
<NAME>
<LASTNAME>Johnson</LASTNAME>
<FIRSTNAME>Ed</FIRSTNAME>
<MEDICINE>
Medicine 1
</MEDICINE>
<MEDICINE>
Medicine 2
</MEDICINE>
</NAME>
<NAME>
<LASTNAME>Edwards</LASTNAME>
<FIRSTNAME>Phoebe</FIRSTNAME>
<MEDICINE>
Medicine 1
</MEDICINE>
</NAME>
<NAME>
<LASTNAME>Parnell</LASTNAME>
<FIRSTNAME>Britta</FIRSTNAME>
<MEDICINE>
Medicine 1
</MEDICINE>
<MEDICINE>
Medicine 2
</MEDICINE>
<MEDICINE>
Medicine 3
</MEDICINE>
</NAME>
<NAME>
<LASTNAME>Tompkins</LASTNAME>
<FIRSTNAME>Tina</FIRSTNAME>
<MEDICINE>
Medicine 1
</MEDICINE>
<MEDICINE>
Medicine 2
</MEDICINE>
</NAME>
</DOCUMENT>
Our application for this example will display each record, including the person's name and the medications they take: Using the forward and back navigation buttons, the user can move through the database displaying record after record, including the medications the patient is taking, whether that's one, two, or three medications: We begin this example as we have with the previous examples in this chapter[md]by setting up the applet in a window, displaying the controls we'll need, as well as loading in the document (+ here) and displaying the first record: import commsxmlParseException;
import commsxmlDocument;
import commsxmlElement;
import javaawt*;
import javanet*;
import javaappletApplet;
public class medicines extends Applet{
static String filename;
Label firstNameLabel, lastNameLabel;
TextField text1, text2;
TextField medicine1, medicine2, medicine3;
Button button1, button2;
Document d;
int currentRecordNumber = 0;
public static void main(String args[])
medicinesFrame frame = new medicinesFrame("The medicines application");
frameshow();
framehide();
frameresize(320, 240);
medicines applet = new medicines();
frameadd("Center", applet);
appletinit();
appletstart();
frameshow();
public void init(){
firstNameLabel = new Label("First Name:");
add(firstNameLabel);
text1 = new TextField(24);
add(text1);
lastNameLabel = new Label("Last Name:");
add(lastNameLabel);
text2 = new TextField(24);
add(text2);
medicine1 = new TextField(35);
add(medicine1);
medicine2 = new TextField(35);
add(medicine2);
medicine3 = new TextField(35);
add(medicine3);
button1 = new Button("<");
add(button1);
button2 = new Button(">");
add(button2);
URL url = null;
try {
url = new URL("file:////c://xml//medicines//medicines xml");
catch (MalformedURLException e1) {
Systemoutprintln("Cannot create URL for: " + filename);
Systemexit(0);
d = new Document();
try {
dload(url);
catch (ParseException e3) {
dreportError(e3, Systemout);
if (d != null) {
showRecord(0);
We also enable the forward and back buttons as we have before, incrementing or decrementing the current record number and calling the method we'll name +:
public boolean action (Event e, Object o){
if(etargetequals(button1)){
//The < button
if(currentRecordNumber > 0){
currentRecordNumber--;
showRecord(currentRecordNumber);
if(etargetequals(button2)){
//The > button
if(currentRecordNumber < 4){
currentRecordNumber++;
showRecord(currentRecordNumber);
return true;
Writing the showRecord() Method
The showRecord() method is where we have to allow for a variable number of medicine fields in each record We start that method by getting the root element of the document and looping over an enumeration of the root's child elements until we get to the record we're supposed to display: void showRecord(int recordNumber)
Element root = dgetRoot();
Element elem = null, elem2 = null;
Enumeration enum = rootgetChildren();
for(int index = 0; index <= recordNumber; index++){
elem = (Element)enumnextElement();
Next, we clear all the text fields that display the medicines the person is taking (because although this person may only be taking one medicine, the last record displayed may have included two or three medicines, and we don't want to leave any data left over in the medicine text fields from the last record displayed): void showRecord(int recordNumber)
Element root = dgetRoot();
Element elem = null, elem2 = null;
Enumeration enum = rootgetChildren();
for(int index = 0; index <= recordNumber; index++){
elem = (Element)enumnextElement();
medicine1setText("");
medicine2setText("");
medicine3setText("");
Now we get the + elements and filling the text1 and text2 text fields with the patient's first and last names: void showRecord(int recordNumber)
Element root = dgetRoot();
Element elem = null, elem2 = null;
Enumeration enum = rootgetChildren();
for(int index = 0; index <= recordNumber; index++){
elem = (Element)enumnextElement();
medicine1setText("");
medicine2setText("");
medicine3setText("");
Enumeration enum2 = elemgetChildren();
while(enum2hasMoreElements()){
elem2 = (Element)enum2nextElement();
if (elem2getTagName()equals("FIRSTNAME")) {
text1setText(elem2getText());
if (elem2getTagName()equals("LASTNAME")) {
text2setText(elem2getText());
Finally, if the element is a <MEDICINE> element, we want to display its text in the medicine text fields, which we have declared as medicine1, medicine2, and medicine3 Before placing the medicine name into one of those text fields, we check to make sure that text field is empty, and if it is, we display the medicine name in that text field this way: void showRecord(int recordNumber)
Element root = dgetRoot();
Element elem = null, elem2 = null;
Enumeration enum = rootgetChildren();
for(int index = 0; index <= recordNumber; index++){
elem = (Element)enumnextElement();
medicine1setText("");
medicine2setText("");
medicine3setText("");
Enumeration enum2 = elemgetChildren();
while(enum2hasMoreElements()){
elem2 = (Element)enum2nextElement();
if (elem2getTagName()equals("FIRSTNAME")) {
text1setText(elem2getText());
if (elem2getTagName()equals("LASTNAME")) {
text2setText(elem2getText());
if (elem2getTagName()equals("MEDICINE")) {
if(medicine1getText()equals("")){
medicine1setText(elem2getText());
else if(medicine2getText()equals("")){
medicine2setText(elem2getText());
else if(medicine3getText()equals("")){
medicine3setText(elem2getText());
In this way we're able to fill the medicine text fields successively with entry after entry That's it[md]run the medicines application now, as shown in Figure 57 As you can see in that figure, the program is displaying the first record in the medicinesxml database
Figure 57 The medicines application When the user clicks the forward button, we move to the next record in the database, as shown in Figure 58 Here, there are only two medicines, but the program handles the variable-length records as we have designed it
Figure 58 Handling variable-length records in the medicines application The medicinesjava program is a success; now we're handling databases with variable-length records The code for this application, medicinesjava, appears in Listing 57, and the document it reads in, +, appears in Listing 58
Listing 57 medicinesjava import commsxmlParseException;
import commsxmlDocument;
import commsxmlElement;
import javautilEnumeration;
import javaawt*;
import javanet*;
import javaappletApplet;
public class medicines extends Applet{
static String filename;
Label firstNameLabel, lastNameLabel;
TextField text1, text2;
TextField medicine1, medicine2, medicine3;
Button button1, button2;
Document d;
int currentRecordNumber = 0;
public static void main(String args[])
medicinesFrame frame = new medicinesFrame("The medicines application");
frameshow();
framehide();
frameresize(320, 240);
medicines applet = new medicines();
frameadd("Center", applet);
appletinit();
appletstart();
frameshow();
public void init(){
firstNameLabel = new Label("First Name:");
add(firstNameLabel);
text1 = new TextField(24);
add(text1);
lastNameLabel = new Label("Last Name:");
add(lastNameLabel);
text2 = new TextField(24);
add(text2);
medicine1 = new TextField(35);
add(medicine1);
medicine2 = new TextField(35);
add(medicine2);
medicine3 = new TextField(35);
add(medicine3);
button1 = new Button("<");
add(button1);
button2 = new Button(">");
add(button2);
URL url = null;
try {
url = new URL("file:////c://xml//medicines//medicines xml");
catch (MalformedURLException e1) {
Systemoutprintln("Cannot create URL for: " + filename);
Systemexit(0);
d = new Document();
try {
dload(url);
catch (ParseException e3) {
dreportError(e3, Systemout);
if (d != null) {
showRecord(0);
public boolean action (Event e, Object o){
if(etargetequals(button1)){
Copyright © OnBarcode.com . All rights reserved.