Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

C# ПІДРУЧНИКИ / c# / Premier Press - C# Professional Projects

.pdf
Скачиваний:
475
Добавлен:
12.02.2016
Размер:
14.7 Mб
Скачать

708 Project 5 CREATING A WEB PORTAL FOR A BOOKSTORE

else if(val>9 & val<=99)

{

str =”C00” + Convert.ToString (val);

}

else if(val>99 & val <=999)

{

 

str = “C0” + Convert.ToString (val);

}

 

 

 

 

 

else

 

 

 

 

{

 

 

 

 

 

 

str = “C” + Convert.ToString (val);

}

 

 

 

 

Y

 

 

 

L

//Store

customer details

F

string InsStr;

 

 

 

 

InsStr

= “Insert Into BookerCustDetails Values(@CID, @CN, @BA1, @BA2,

 

@BC, @BS)”;

M

 

SqlCommand InsCom;A

 

InsCom = new SqlCommand(InsStr, sqlConnection1);

 

 

E

 

 

sqlDataAdapter1.InsertCommand = InsCom;

 

 

T

 

 

 

sqlDataAdapter1.InsertCommand.Parameters.Add(“@CID”, SqlDbType.Char,6).Value = str;

sqlDataAdapter1.InsertCommand.Parameters.Add(“@CN”, SqlDbType.VarChar,50).Value = txtName.Text;

sqlDataAdapter1.InsertCommand.Parameters.Add(“@BA1”, SqlDbType

.VarChar ,50).Value= txtAddr1.Text ; sqlDataAdapter1.InsertCommand.Parameters.Add(“@BA2”, SqlDbType.VarChar,50)

.Value= txtAddr2.Text ; sqlDataAdapter1.InsertCommand.Parameters.Add(“@BC”,SqlDbType.VarChar,20)

.Value = txtCity.Text ; sqlDataAdapter1.InsertCommand.Parameters.Add(“@BS”, SqlDbType

.VarChar ,10).Value = txtState.Text ; if(sqlConnection1.State== ConnectionState.Closed )

{

sqlConnection1.Open ();

}

Team-Fly®

 

DEVELOPING WEB SERVICE CLIENTS

Chapter 30

709

sqlDataAdapter1.InsertCommand.ExecuteNonQuery();

 

 

 

 

 

 

sqlConnection1.Close();

 

 

 

//Store

Order Details

 

 

 

string

InsStr1;

 

 

 

InsStr1 = “Insert Into BookersOrders Values(@ON, @CID, @ISBN)”;

 

SqlCommand InsCom1;

 

 

 

InsCom1 = new SqlCommand(InsStr1, sqlConnection1);

 

 

 

sqlDataAdapter1.InsertCommand = InsCom1;

 

 

 

sqlDataAdapter1.InsertCommand.Parameters.Add(“@ON”, SqlDbType.Char,10)

 

.Value = order;

 

 

 

sqlDataAdapter1.InsertCommand.Parameters.Add(“@CID”, SqlDbType.Char,6)

 

.Value = str;

 

 

 

sqlDataAdapter1.InsertCommand.Parameters.Add(“@ISBN”, SqlDbType.Char,10)

 

.Value = txtISBN.Text;

 

 

 

if(sqlConnection1.State== ConnectionState.Closed )

 

 

 

{

 

 

 

 

sqlConnection1.Open ();

 

 

 

}

 

 

 

 

sqlDataAdapter1.InsertCommand.ExecuteNonQuery();

 

 

 

sqlConnection1.Close();

 

 

 

return

str;

 

 

 

}

 

 

 

 

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

{

txtISBN.Text=””; txtTitle.Text =””; txtAuthor.Text =””; txtName.Text=””; txtAddr1.Text=””; txtAddr2.Text=””; txtCity.Text=””; txtState.Text=””; TextBox1.Text =””; txtCardNumber.Text =””; lstCardType.SelectedIndex =0;

}

710 Project 5 CREATING A WEB PORTAL FOR A BOOKSTORE

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

{

Response.Redirect (“Mainform.aspx”);

}

}

}

Adding Code to the Construction Form

The Main form in the Bookers Paradise Web site contains some hyperlinks. On clicking the hyperlinks, the user is taken to the ConstructionForm form. However, the Construction form displays a message that the page to which the user wants to connect is under construction.

The Construction form includes a hyperlink control that takes you to the Home page. The code for the Construction form includes the declarations for the controls added to the form. The code for the Construction form is as shown as follows:

using System;

using System.Collections; using System.ComponentModel; using System.Data;

using System.Drawing; using System.Web;

using System.Web.SessionState; using System.Web.UI;

using System.Web.UI.WebControls; using System.Web.UI.HtmlControls;

namespace BookersClient

{

public class ConstructionForm : System.Web.UI.Page

{

protected System.Web.UI.WebControls.Label Label2; protected System.Web.UI.WebControls.HyperLink HyperLink1; protected System.Web.UI.WebControls.Label Label1;

DEVELOPING WEB SERVICE CLIENTS

Chapter 30

711

 

 

 

 

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

{

}

}

}

Summary

In this chapter, you learned about how to create the forms required for the Web site of Bookers Paradise. In addition, you learned to add code to the Web forms created for the Web site.

This page intentionally left blank

PARTVIIIProfessional Project 6

This page intentionally left blank

Project 6

Creating a Mobile

Application

Project 6 Overview

In the preceding projects, you have developed Windows applications, Web applications, and Web services. In this project, you will learn to create a mobile Web application for an electronic goods company named Electronix, Inc.The mobile application that you will develop is called MobileCallStatus.

To begin with, I will discuss the case study and design of the MobileCallStatus application.Then, I will discuss the basics of the mobile Web applications that involve the need for developing mobile Web applications. In addition, in this project you will be introduced to the technologies responsible for creating, testing, and deploying mobile Web applications. Finally, based on this knowledge, you will create the MobileCallStatus application.

Chapter 31

Project Case

Study and Design