コード例 #1
0
 //Add the current title to the book tag in the user.xml
 protected void BorrowButton_Click(object sender, EventArgs e)
 {
     try {
         //Create a service reference object
         Assignment5ServiceRefs.Service1Client client = new Assignment5ServiceRefs.Service1Client();
         //Get the user id from the cookie
         HttpCookie userCookies = Request.Cookies["userInfo"];
         String     userId      = "";
         if (!(userCookies == null) && !(userCookies["id"] == ""))
         {
             userId = userCookies["id"];
             String title = BookList.SelectedItem.Text;
             //call the opearation in the service to add the book tag
             if (client.addBorrowed(title, userId))
             {
                 BorrowStatusLbl.Text = "Book borrowed successfully!";
             }
             else
             {
                 BorrowStatusLbl.Text = "Unexpected Error Occured!";
             }
         }
         else
         {
             BorrowStatusLbl.Text = "Unexpected Error Occured!";
         }
     } catch
     {
         BorrowStatusLbl.Text = "Unexpected Error Occured!";
     }
 }