Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microsoft C# Professional Projects - Premier Press.pdf
Скачиваний:
177
Добавлен:
24.05.2014
Размер:
14.65 Mб
Скачать

IMPLEMENTING THE BUSINESS LOGIC

Chapter 33

785

 

 

 

 

the strWrite object. Figure 33-12 shows the status of the C002 call changed to

Complete.

FIGURE 33-12 The status of the C002 call changed to Complete

Once the changes are made to the Calls.xml file, the changes should be reflected in the frmPending form. To do this, an object reader of the XmlTextReader class is created that will read the content of the Calls.xml file.This content is then added to the lstPending SelectionList control and displayed in the frmPending form.

After the user makes changes to the frmPending form, the user needs to return to the frmSelectOption form. To do this, a Back button is added to the frmPending form.

Adding Code to the Back Button in the frmPending Form

To display the frmPending form, when the user clicks on the Back button, add the following code to the cmdBack button.

private void cmdBack1_Click(object sender, System.EventArgs e)

{

lstPending.Items.Clear(); ActiveForm=frmSelectOption;

}

786 Project 6 CREATING A MOBILE APPLICATION

Adding Code to the Accept checked call(s) Button in the frmUnattended Form

After writing the code for the cmdUpdate button in the frmPending form, you can easily write the code for the cmdAcceptCall button. The code for the Click event of the cmdAcceptCall button is as follows:

private void cmdAcceptCall_Click(object sender, System.EventArgs e)

{

StreamReader strRead; string content, strText; int index;

strRead= new StreamReader(“C:\\Electronix\\Calls.xml”); content=strRead.ReadToEnd();

strRead.Close();

for (int i=0; i<lstUnattended.Items.Count; i++)

{

if (lstUnattended.Items[i].Selected==true)

{

strText=lstUnattended.Items[i].Text; strText=strText.Substring(0,4); index=content.IndexOf(strText); content=content.Remove(index+14,10); content=content.Insert(index+14, “Pending”);

}

}

StreamWriter strWrite;

strWrite = new StreamWriter(“C:\\Electronix\\Calls.xml”); strWrite.Write(content);

strWrite.Close(); lstUnattended.Items.Clear(); string lstItem; XmlTextReader reader;

reader = new XmlTextReader(“C:\\Electronix\\Calls.xml”); reader.MoveToContent();

while (reader.Read())

IMPLEMENTING THE BUSINESS LOGIC

Chapter 33

787

 

 

 

 

{

lstItem=””;

if (reader.HasAttributes)

{

reader.MoveToNextAttribute(); reader.MoveToNextAttribute(); if (reader.Value==”Unattended”)

{

reader.MoveToFirstAttribute(); lstItem=reader.Value + “: “; reader.MoveToElement(); lstItem=lstItem+ reader.ReadInnerXml(); lstUnattended.Items.Add(lstItem);

}

}

}

reader.Close();

}

Figure 33-13 shows the frmUnattended form at run time.

FIGURE 33-13 The frmUnattended form at run time

788 Project 6 CREATING A MOBILE APPLICATION

Adding Code to the Back Button in the frmUnattended Form

Similar to writing the code for the Back button in the frmPending form, you can add the following code to the Back button of the frmUnattended form.

private void cmdBack2_Click(object sender, System.EventArgs e)

{

 

Y

stUnattended.Items.Clear();

 

ActiveForm=frmSelectOption;

 

}

 

 

 

After creating the MobileCallStatus application,you can test the application in an

 

L

emulator. The following section discusses how to test a mobile application in an

emulator.

F

 

M

 

Testing the MobileCallStatusA

E

 

Application in an Emulator

T

 

 

To test your application in an emulator, perform the following steps:

1.On the View menu, point to the Mobile Explorer Browser option.

2.In the displayed list, select the Show Browser option.

3.Type the address of the mobile Web form in the Address box of the emulator and then press Enter.

TIP

While using an emulator, you can use the keyboard to type the information or navigate through the pages. While working with the actual device, such as a mobile phone, you can use the keys on the mobile phone.

You can type the address of the forms in the Address box to view all the forms in the MobileCallStatus application. Figure 33-14 shows the frmLogon form in an emulator.

Team-Fly®

IMPLEMENTING THE BUSINESS LOGIC

Chapter 33

789

 

 

 

 

FIGURE 33-14 The frmLogon form in an emulator

Navigating to the next form takes you to the frmSelectOption form, as shown in Figure 33-15.

FIGURE 33-15 The frmSelectOption form in an emulator

790 Project 6 CREATING A MOBILE APPLICATION

In the frmSelectOption form, if the user selects the View Pending Calls option, the frmPending form is displayed as shown in Figure 33-16.

FIGURE 33-16 The frmPending form in an emulator

However, if the user selects the Show Unattended Calls option in the frmSelectOption form, the frmUnattended form is displayed. Figure 33-17 shows the frmUnattended form in an emulator.