protected void btnCheckOut_Click(object sender, EventArgs e) { try { int myIsbn = Convert.ToInt32(txtISBN.Text); short myCopyNum = Convert.ToInt16(txtCopyNum.Text); myItem = myDb.GetItem(myIsbn, myCopyNum); StringBuilder myString = new StringBuilder(); if (OnLoan(myItem)) { StringBuilder myStr = new StringBuilder(); myStr.Append("Item is on loan to "); LibraryWebService.Member temp = myDb.GetMember(myItem.MemberNumber); myStr.Append(temp.FirstName + " " + temp.LastName + " (" + temp.MemberID.ToString()); myStr.Append("), Check in, and check out?"); Label lbl = (Label)Page.Master.FindControl("lblStatus"); lbl.Text = myStr.ToString(); } myString.Append("Check Out \""); myString.Append(myItem.Title.ToString()); myString.Append("\" by "); myString.Append(myItem.Author.ToString()); myString.Append(" ?"); lblStatus.Text = myString.ToString(); //lock the fields for editing txtISBN.ReadOnly = true; txtCopyNum.ReadOnly = true; btnCancel.Visible = true; btnCheckOut.Visible = false; btnFinalCheckOut.Visible = true; } catch (SoapException ex) { if (ex.Code == ExceptionCodes.ItemNotFound) { string myString = string.Format("Item Not Found."); Label lbl = (Label)Page.Master.FindControl("lblStatus"); lbl.Text = myString; lbl.ForeColor = Color.Red; } else { string myString = string.Format("ERROR: An error was encountered on check in."); Label lbl = (Label)Page.Master.FindControl("lblStatus"); lbl.Text = myString; lbl.ForeColor = Color.Red; } } catch (WebException) { Label lbl = (Label)Page.Master.FindControl("lblStatus"); lbl.Text = "Web service is not responding, please try again later."; lbl.ForeColor = Color.Red; } }
private bool OnLoan(LibraryWebService.Item myItem) { if (myItem.MemberNumber > 0) { return(true); } else { return(false); } }
protected void btnCheckIn_Click(object sender, EventArgs e) { try { int myIsbn = Convert.ToInt32(txtISBN.Text); short myCopyNum = Convert.ToInt16(txtCopyNum.Text); myItem = myDb.GetItem(myIsbn, myCopyNum); if (myItem.MemberNumber == 0) //item is not checked out. { StringBuilder myString = new StringBuilder(); myString.Append("\""); myString.Append(myItem.Title.ToString()); myString.Append("\" is not on loan."); lblStatus.Text = myString.ToString(); } else { myMember = myDb.GetMember(myItem.MemberNumber); StringBuilder myString = new StringBuilder(); myString.Append("Check in \""); myString.Append(myItem.Title.ToString()); myString.Append("\" by "); myString.Append(myItem.Author.ToString()); myString.Append(" on loan to "); myString.Append(myMember.FirstName); myString.Append(" "); myString.Append(myMember.LastName); myString.Append("("); myString.Append(myMember.MemberID); myString.Append(")"); lblStatus.Text = myString.ToString(); btnFinalCheckIn.Visible = true; btnCancel.Visible = true; btnCheckIn.Visible = false; //lock the fields from being edited txtCopyNum.ReadOnly = true; txtISBN.ReadOnly = true; } Label lbl = (Label)Page.Master.FindControl("lblStatus"); lbl.Text = string.Empty; } catch (SoapException ex) { if (ex.Code == ExceptionCodes.ItemNotFound) { StringBuilder myString = new StringBuilder(); myString.Append("Item not found"); Label lbl = (Label)Page.Master.FindControl("lblStatus"); lbl.Text = myString.ToString(); lbl.ForeColor = Color.Red; } else if (ex.Code == ExceptionCodes.ItemNotOnLoan) { Label lbl = (Label)Page.Master.FindControl("lblStatus"); lbl.Text = "Item not checked out."; lbl.ForeColor = Color.Red; } else { StringBuilder myString = new StringBuilder(); myString.Append("An error was encountered on check in. "); myString.Append(ex.Message); Label lbl = (Label)Page.Master.FindControl("lblStatus"); lbl.Text = myString.ToString(); lbl.ForeColor = Color.Red; } } catch (WebException) { Label lbl = (Label)Page.Master.FindControl("lblStatus"); lbl.Text = "Web service is not responding, please try again later."; lbl.ForeColor = Color.Red; } }