Your SlideShare is downloading. ×
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Portfolio Martin Roy
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Portfolio Martin Roy

228

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
228
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Martin Roy<br />.Net Portfolio<br />Mroy513@gmail.com<br />(513)941-2398<br />Library Project Phase 1<br />Introduction:<br /> Create a Windows Forms front end C# application and a business tier for an n-tier project. <br />Audience:<br />Library employees managing Member and Item information<br />Project Goals:<br />Build parts of the business tier for a library involving members and items. <br />Create and test two assemblies. <br />The first assembly is a class library project containing various interfaces and base classes. <br />The second assembly is a class library project containing various entity, collection, and validation classes used by existing business processes. <br />Code should follow best practices <br />Produce a user interface that is intuitive, requiring minimal training for users while minimizing resource utilization<br />Include easily maintainable code, form-based field validation, and all required error handling.<br />Phase 1 – MDI Screen with Member Info<br />The application runs inside an MDI form. The Member Info screen displays when application is brought up. It displays the items currently checked out. Librarian can select one or more checked out items to check in. If the member has less than four items checked out a check out button will appear. Juvenile members will show two additional fields: Birth Date and Adult Member ID.<br />Sample Code<br /> public void LoadMemberInfo()<br /> {<br /> memIDTextBox.Text = memID.ToString();<br /> LibraryAccess la = new LibraryAccess();<br /> try<br /> {<br /> Member member = la.GetMember(memID);<br /> JuvenileMember juv = member as JuvenileMember;<br /> if (juv == null)<br /> {<br /> AdultMember adult = member as AdultMember;<br /> if (adult == null)<br /> {<br /> memInfoStatusLabel.Text = " System Error - Try Again" ;<br /> return;<br /> }<br /> else<br /> {<br /> LoadAdultData(adult);<br /> }<br /> }<br /> else<br /> {<br /> LoadJuvData(juv);<br /> }<br /> LoadCheckOutList();<br /> }<br /> catch (LibraryException ex)<br /> {<br /> memInfoStatusLabel.Text = " Member Id was not found" ;<br /> ClearForm();<br /> }<br /> catch<br /> {<br /> memInfoStatusLabel.Text = " System Error. Check Member ID and Try Again" ; <br /> ClearForm();<br /> }<br /> }<br /> private void LoadAdultData(AdultMember memb)<br /> {<br /> firstNameTextBox.Text = memb.FirstName;<br /> initialTextBox.Text = memb.MiddleInitial;<br /> lastNameTextBox.Text = memb.LastName;<br /> streetTextBox.Text = memb.Street;<br /> cityTextBox.Text = memb.City;<br /> zipTextBox.Text = memb.ZipCode;<br /> expDateTextBox.Text = memb.ExpirationDate.ToString(" d" );<br /> TimeSpan ts = DateTime.Now - memb.ExpirationDate;<br /> if (ts.Days > 0)<br /> {<br /> expDateTextBox.BackColor = Color.Yellow;<br /> memIdExpired = true;<br /> }<br /> else<br /> {<br /> expDateTextBox.BackColor = Color.WhiteSmoke;<br /> memIdExpired = false;<br /> }<br /> stateTextBox.Text = memb.State;<br /> phoneTextBox.Text = memb.PhoneNumber;<br /> birthDateLable.Hide();<br /> birthDateTextBox.Hide();<br /> adultIDLabel.Hide();<br /> adultIDTextBox.Hide();<br /> }<br /> private void LoadJuvData(JuvenileMember memb)<br /> {<br /> firstNameTextBox.Text = memb.FirstName;<br /> initialTextBox.Text = memb.MiddleInitial;<br /> lastNameTextBox.Text = memb.LastName;<br /> streetTextBox.Text = memb.Street;<br /> cityTextBox.Text = memb.City;<br /> zipTextBox.Text = memb.ZipCode;<br /> expDateTextBox.Text = memb.ExpirationDate.ToString(" d" );<br /> TimeSpan ts = DateTime.Now - memb.ExpirationDate;<br /> if (ts.Days > 0)<br /> {<br /> expDateTextBox.BackColor = Color.Yellow;<br /> memIdExpired = true;<br /> }<br /> else<br /> {<br /> expDateTextBox.BackColor = Color.WhiteSmoke;<br /> memIdExpired = false;<br /> }<br /> stateTextBox.Text = memb.State;<br /> phoneTextBox.Text = memb.PhoneNumber;<br /> birthDateLable.Show();<br /> birthDateTextBox.Show();<br /> adultIDLabel.Show();<br /> adultIDTextBox.Show();<br /> birthDateTextBox.Text = memb.BirthDate.ToString(" d" );<br /> adultIDTextBox.Text = memb.AdultMemberID.ToString();<br /> }<br /> public void LoadCheckOutList()<br /> {<br /> LibraryAccess la = new LibraryAccess();<br /> try<br /> {<br /> ItemsDataSet bookList = la.GetCheckedOutBooks(memID);<br /> itemsBindingSource.DataSource = bookList;<br /> if (memIdExpired || bookList.Items.Count > 3)<br /> checkOutButton.Visible = false;<br /> else<br /> checkOutButton.Visible = true;<br /> }<br /> catch<br /> {<br /> memInfoStatusLabel.Text = " System Error Try Again" ;<br /> }<br /> }<br />The Member Information screen displays both Juvenile and Adult information. If the Membership has expired than the expiration date is Highlighted and the Check Out button is hidden. If the member has 4 items checked out the Check Out button is hidden. The Librarian can highlight any checked out item and click the Check In Selected to check in books. There is a separate Check In screen to check in a book without a Member ID.<br /> Add Adult, Add Juvenile and Check In Screens<br />There are basic edits for the fields. All names must begin with a capital letter. State is selected from a drop down. Zip code must be 5 or 9 numeric characters. Birth date must show member is less than 18 years old. The Adult Member Id must be numeric and will be validated against the data base. ISBN and Copy must be numeric and within valid range.<br /> Sample Validation Code<br /> public static bool AdultIDValid(string str)<br /> {<br /> int memID;<br /> if (int.TryParse(str, out memID))<br /> {<br /> if (memID > 0 && memID <= 32767)<br /> {<br /> // get from db<br /> return true;<br /> }<br /> else<br /> {<br /> return false;<br /> }<br /> }<br /> else<br /> {<br /> return false;<br /> }<br /> }<br /> /// <summary><br /> /// Validates first name strats with a capital letter and all others are lower case a-z<br /> /// </summary><br /> /// <param name=" str" ></param><br /> /// <returns></returns><br /> public static bool FirstNameValid(string str)<br /> {<br /> if(Regex.IsMatch(str," ^[A-Z][a-z]{0,14}$" ))<br /> return true;<br /> else<br /> return false;<br /> }<br /> /// <summary><br /> /// Validates that the Initial is a capital lettr A-Z or blank<br /> /// </summary><br /> /// <param name=" str" ></param><br /> /// <returns></returns><br /> public static bool InitialValid(string str)<br /> {<br /> if (Regex.IsMatch(str, @" ^[A-Zs]{0,1}$" ))<br /> return true;<br /> else<br /> return false;<br /> }<br /> /// <summary><br /> /// Validates Last name strats with a capital letter and all others are lower case a-z<br /> /// </summary><br /> /// <param name=" str" ></param><br /> /// <returns></returns><br /> public static bool LastNameValid(string str)<br /> {<br /> if (Regex.IsMatch(str, " ^[A-Z][a-z]{0,14}$" ))<br /> return true;<br /> else<br /> return false;<br /> }<br /> /// <summary><br /> /// Validates that ISBN is a valid positive integer<br /> /// </summary><br /> /// <param name=" str" ></param><br /> /// <returns></returns><br /> public static bool ISBNValid(string str)<br /> {<br /> int isbn;<br /> if (int.TryParse(str, out isbn))<br /> {<br /> if (isbn > 0)<br /> {<br /> return true;<br /> }<br /> else<br /> {<br /> return false;<br /> }<br /> }<br /> else<br /> {<br /> return false;<br /> }<br /> }<br /> /// <summary><br /> /// Validated that Copy Number is a valid positive Short int<br /> /// </summary><br /> /// <param name=" str" ></param><br /> /// <returns></returns><br /> public static bool CopyNumValid(string str)<br /> { <br /> short copyNum;<br /> if (short.TryParse(str, out copyNum))<br /> {<br /> if (copyNum > 0 && copyNum <= 32767)<br /> {<br /> return true;<br /> }<br /> else<br /> {<br /> return false;<br /> }<br /> }<br /> else<br /> {<br /> return false;<br /> }<br /> }<br /> <br /> /// <summary><br /> /// Validated that Member ID is a valid positive Short int<br /> /// </summary><br /> /// <param name=" str" ></param><br /> /// <returns></returns><br /> public static bool MemberIDValid(string str)<br /> {<br /> short memID;<br /> if (short.TryParse(str, out memID))<br /> {<br /> if (memID > 0 && memID <= 32767)<br /> {<br /> return true;<br /> }<br /> else<br /> {<br /> return false;<br /> }<br /> }<br /> else<br /> {<br /> return false;<br /> }<br /> }<br /> }<br />}<br />Library Project Phase 2<br />Introduction:<br /> Create the data access layer for the library application.<br />Audience:<br />Library employees managing Member and Item information<br />Project Goals:<br />Build parts Data access Layer <br />Develop code to call the store procedures.<br />Return data or throw errors to Business Layer.<br />Develop Store procedures for all processes <br />Create Entities classes to pass data between layers.<br />Member<br />Adult (derived from member)<br />Juvenile (derived from member)<br />Item<br />ItemsDataSet (holds multiple Items)<br />Library Exception<br /> Sql Examples<br />The following validates the juvenile data than creates a Juvenile Member<br />CREATE proc [dbo].[AddJuvenile] <br /> @firstname varchar(15),<br /> @middleinitial char(1),<br />@lastname varchar(15),<br /> @adultmemno smallint,<br /> @birthdate datetime,<br /> @member_no smallint output<br />as<br />if @firstname = null or @firstname = ''<br />begin<br /> raiserror('First Name is required', 11,1)<br /> return<br />end<br />if @lastname = null or @lastname = ''<br />begin<br /> raiserror('Last Name is required', 11,1)<br /> return<br />end<br />if not exists (select member_no from adult<br /> where member_no = @adultmemno and<br /> datediff(day,getdate(),expr_date) > 0)<br />begin<br /> raiserror('Invalid Adult Member Number', 12,1)<br /> return<br />end<br />if datediff(day,@birthdate,getdate()) > 6575<br />begin<br /> raiserror('Birthdate is over 17 years not valid for juvenile', 13,1)<br /> return<br />end<br />begin tran<br />insert into member (lastname,firstname,middleinitial)<br />values (@lastname,@firstname,@middleinitial)<br />if @@ERROR <> 0 <br />begin<br /> rollback tran<br /> raiserror('System failure. Unable to add member',16,1)<br /> return<br />end<br />set @member_no = scope_identity()<br />insert into juvenile(member_no,adult_member_no,birth_date)<br />values(@member_no, @adultmemno,@birthdate)<br />if @@ERROR <> 0 <br />begin<br /> rollback tran<br /> raiserror('System failure. Unable to add juvenile',16,1)<br /> return<br />end<br />commit tran<br />The following Proc is used to check in an item<br />CREATE proc [dbo].[CheckInItem] <br /> @isbn int,<br />@copy smallint<br />as<br />if not exists (select isbn from copy where isbn = @isbn<br /> and copy_no = @copy)<br />begin<br /> raiserror('Invalid isbn and copy num', 11,1)<br /> return<br />end<br />if exists (select isbn from copy where isbn = @isbn<br /> and copy_no = @copy and on_loan = 'N')<br />begin<br /> raiserror('Item not currently on loan', 12,1)<br /> return<br /> end<br />begin tran<br />update copy set on_loan = 'N' <br />where isbn = @isbn and copy_no = @copy<br />if @@error <> 0<br /> begin<br /> rollback tran<br /> raiserror('System error - occured in update to copy', 16,1)<br /> return<br /> end<br />insert into loanhist (isbn,copy_no,out_date,title_no,member_no,due_date,<br /> in_date)<br />select isbn,copy_no,out_date,title_no,member_no, due_date,<br /> getdate() from loan where isbn = @isbn and copy_no = @copy <br />if @@error <> 0<br /> begin<br /> rollback tran<br /> raiserror('System error - occured inserting into loanhist', 16,1)<br /> return<br /> end<br />delete from loan where isbn = @isbn and copy_no = @copy<br />if @@error <> 0<br /> begin<br /> rollback tran<br /> raiserror('System error - occured deleting record from loan', 16,1)<br /> return<br /> end<br />commit tran<br />The following proc will retrieve either the juvenile or adult member<br />CREATE proc [dbo].[GetMemberInfo] <br /> @memno smallint<br />as <br />if not exists (select member_no from member where member_no = @memno)<br />begin<br /> raiserror('Member not found for member number',11,1)<br /> return<br />end<br />if exists(select member_no from adult where member_no = @memno)<br /> begin<br /> select m.firstname,m.middleinitial,m.lastname,a.street,a.city,a.state,<br /> a.zip,a.phone_no,a.expr_date,null adult_member_no,null birth_date<br /> from member m<br /> join adult a <br /> on a.member_no = m.member_no<br /> where m.member_no = @memno<br /> if @@error <> 0<br /> begin<br /> raiserror('System error getting adult info',16,1)<br /> return<br /> end<br /> end<br />else<br /> begin<br /> select m.firstname,m.middleinitial,m.lastname,a.street,a.city,a.state,<br /> a.zip,a.phone_no,a.expr_date,j.adult_member_no,j.birth_date<br /> from member m<br /> join juvenile j <br /> on m.member_no = j.member_no<br /> join adult a<br /> on a.member_no = j.adult_member_no<br /> where m.member_no = @memno<br /> if @@error <> 0<br /> begin<br /> raiserror('System error getting juvenile info',16,1)<br /> return<br /> end<br />end<br />Sample Access Layer Code<br />Check in an item throwing an exception if insert failes<br />/// <summary><br />/// Checks in a book using the ISBN and copy num<br />/// </summary><br />/// <param name=" isbn" ></param><br />/// <param name=" copy" ></param><br />/// <returns></returns><br />public void CheckInItem(int isbn, short copy)<br />{<br /> try<br /> {<br /> using (SqlConnection cnn = new SqlConnection(<br /> Properties.Settings.Default.LibraryConnectionString))<br /> {<br /> using (SqlCommand cmd = new SqlCommand(" CheckInItem" , cnn))<br /> {<br /> cmd.CommandType = CommandType.StoredProcedure;<br /> cmd.Parameters.AddWithValue(" @isbn" , isbn);<br /> cmd.Parameters.AddWithValue(" @copy" , copy);<br /> cnn.Open();<br /> int results = cmd.ExecuteNonQuery();<br /> if (results > 0)<br /> {<br /> return;<br /> }<br /> else<br /> {<br /> LibraryException lex = new LibraryException(" System error no rows were updated" );<br /> throw lex;<br /> }<br /> }<br /> }<br /> }<br /> catch (SqlException ex)<br /> {<br /> if (ex.Class == 11)<br /> throw new LibraryException(ErrorCodes.ItemNotFound, ex.Message);<br /> else<br /> if (ex.Class == 12)<br /> throw new LibraryException(ErrorCodes.ItemNotOnLoan, sex.Message);<br /> else<br /> throw new LibraryException(ErrorCodes.CheckInFailed, <br />This procedures gets the member info. It determins if this is a juvenile or adault depending on the presence of an adult member ID.<br />public Member GetMember(short memID)<br />{<br /> try<br /> {<br /> using (SqlConnection cnn = new SqlConnection(<br /> Properties.Settings.Default.LibraryConnectionString))<br /> {<br /> using (SqlCommand cmd = new SqlCommand(" GetMemberInfo" , cnn))<br /> {<br /> cmd.CommandType = CommandType.StoredProcedure;<br /> cmd.Parameters.AddWithValue(" @memno" , memID);<br /> cnn.Open();<br /> using (SqlDataReader rdr = cmd.ExecuteReader())<br /> {<br /> if (rdr.Read())<br /> {<br /> if (rdr[" adult_member_no" ].ToString() == " " )<br /> {<br /> AdultMember amem = new AdultMember();<br /> LoadMember(rdr, amem, memID);<br /> return amem;<br /> }<br /> else<br /> {<br /> JuvenileMember jmem = new JuvenileMember();<br /> LoadMember(rdr, jmem, memID);<br /> return jmem;<br /> }<br /> }<br /> else<br /> {<br /> LibraryException lex = new LibraryException(" System error no rows returned" );<br /> throw lex;<br /> }<br /> }<br /> }<br /> }<br /> }<br /> catch (SqlException sqex)<br /> {<br /> if (sqex.Class == 11)<br /> throw new LibraryException(ErrorCodes.NoSuchMember, sqex.Message);<br /> else<br /> throw new LibraryException(ErrorCodes.GenericException, sqex.Message, sqex);<br /> }<br />}<br />Sample Item Entity<br />public class Item<br />{<br /> private int isbn;<br /> private short copyNumber;<br /> private string title;<br /> private string author;<br /> private short memberNumber;<br /> private DateTime checkoutDate;<br /> private DateTime dueDate;<br /> <br /> /// <summary><br /> /// <br /> /// </summary><br /> /// <param name=" Isbn" ></param><br /> /// <param name=" copy" ></param><br /> /// <param name=" itemtitle" ></param><br /> /// <param name=" author" ></param><br /> /// <param name=" memberno" ></param><br /> /// <param name=" checkoutDate" ></param><br /> /// <param name=" dueDate" ></param><br /> public Item(int Isbn, short copy, string itemtitle, string authr, short memno,<br /> DateTime outDate, DateTime due)<br /> {<br /> isbn = Isbn;<br /> copyNumber = copy;<br /> title = itemtitle;<br /> author = authr;<br /> memberNumber = memno;<br /> checkoutDate = outDate;<br /> dueDate = due;<br /> }<br /> /// <summary><br /> /// Get Isbn<br /> /// </summary><br /> public int ISBN<br /> {<br /> get { return isbn; }<br /> }<br /> /// <summary><br /> /// Get Copy number<br /> /// </summary><br /> public short CopyNumber<br /> {<br /> get { return copyNumber; }<br /> }<br /> /// <summary><br /> /// Get title for isbn<br /> /// </summary><br /> public string Title<br /> {<br /> get { return title; }<br /> }<br /> /// <summary><br /> /// get author for the isbn<br /> /// </summary><br /> public string Author<br /> {<br /> get { return author; }<br /> }<br /> /// <summary><br /> /// get member no of member who has item checked out<br /> /// </summary><br /> public short MemberNumber<br /> {<br /> get { return memberNumber; }<br /> }<br /> /// <summary><br /> /// Date item was last checked out<br /> /// </summary><br /> public DateTime CheckoutDate<br /> {<br /> get { return checkoutDate; }<br /> }<br /> /// <summary><br /> /// date item is due back<br /> /// </summary><br /> public DateTime DueDate<br /> {<br /> get { return dueDate; }<br /> set { dueDate = value; }<br /> }<br />}<br />Library Project Phase 3<br />Introduction:<br /> Replace Windows front-end with Web front-end <br />Audience:<br />Library employees managing Member and Item information<br />Project Goals:<br />Replace all Windows forms with Web front end<br />Additional requirements.<br />New screen to add a new item to inventory<br />Automatic conversion to an adult Membership if Juvenile is age is 18 or above. <br />Membership renewal for expired Member IDs<br />Add Security<br />Add logon screen<br />Prevent access to any screen without valid login<br /> Member Information Window<br />The application runs inside a Master Page. The Member Info screen displays when after a successful login. It displays the items currently checked out. Librarian can select one or more checked out items to check in. If the member has less than four items checked out a check out button will appear. Juvenile members will show two additional fields: Birth Date and Adult Member ID. <br />New Features added. If member is expired it will transfer to a new window asking the librarian if they want to renew. Also if Juvenile is over 17 their membership will automatically be changed to an adult member. A notification of change is sent to librarian.<br />Sample Code<br />This code will set up the screen with the current user info when returning from the other screens.<br />protected void Page_Load(object sender, EventArgs e)<br /> {<br /> if (!Page.IsPostBack)<br /> {<br /> ClearForm();<br /> }<br /> object newid = Session[" NewMemID" ];<br /> if(Session[" NewMemID" ] != null &&<br /> (short)Session[" NewMemID" ] != 0)<br /> {<br /> MemID = (short)Session[" NewMemID" ];<br /> txtMemberID.Text = MemID.ToString();<br /> Session[" NewMemID" ] = (short) 0;<br /> Session[" MemID" ] = MemID;<br /> LoadMemberInfo();<br /> }<br /> else<br /> {<br /> if (Session[" MemID" ] != null)<br /> {<br /> if (short.Parse(txtMemberID.Text) == 0)<br /> {<br /> MemID = (short)Session[" MemID" ];<br /> txtMemberID.Text = MemID.ToString();<br /> LoadMemberInfo();<br /> }<br /> }<br /> }<br /> }<br /> private void LoadMemberInfo()<br /> {<br /> LibraryAccess la = new LibraryAccess();<br /> try<br /> {<br /> Member member = la.GetMember(memID);<br /> JuvenileMember juv = member as JuvenileMember;<br /> if (juv == null)<br /> {<br /> AdultMember adult = member as AdultMember;<br /> if (adult == null)<br /> {<br /> memInfoStatusLabel.Text = " System Error - Try Again" ;<br /> return;<br /> }<br /> else<br /> {<br /> LoadAdultData(adult);<br /> }<br /> }<br /> else<br /> {<br /> LoadJuvData(juv);<br /> }<br /> if ( TextBoxBirthDate.Text != " " )<br /> {<br /> DateTime bday = DateTime.Parse(TextBoxBirthDate.Text);<br /> TimeSpan ts = DateTime.Now - bday;<br /> if ((ts.Days - 5) / 365 > 17)<br /> {<br /> CreateAdultIDfromJuv();<br /> }<br /> }<br /> <br /> }<br /> catch (LibraryException ex)<br /> {<br /> memInfoStatusLabel.Text = ex.Message;<br /> ClearForm();<br /> }<br /> catch<br /> {<br /> memInfoStatusLabel.Text = " System Error. Check Member ID and Try Again" ;<br /> ClearForm();<br /> }<br /> }<br /> private void LoadAdultData(AdultMember memb)<br /> {<br /> TextBoxFirstName.Text = memb.FirstName;<br /> TextBoxInit.Text = memb.MiddleInitial;<br /> TextBoxLastName.Text = memb.LastName;<br /> TextBoxStreet.Text = memb.Street;<br /> TextBoxCity.Text = memb.City;<br /> TextBoxZip.Text = memb.ZipCode;<br /> TextBoxExpDate.Text = memb.ExpirationDate.ToString(" d" );<br /> TimeSpan ts = DateTime.Now - memb.ExpirationDate;<br /> if (ts.Days > 0)<br /> {<br /> if (Session[" RenewalRefused" ] == null)<br /> Response.Redirect(" ~/Renew.aspx" , true);<br /> else<br /> {<br /> if ((bool)Session[" RenewalRefused" ])<br /> {<br /> TextBoxExpDate.BackColor = Color.Yellow;<br /> memIdExpired = true;<br /> Session[" RenewalRefused" ] = null;<br /> }<br /> }<br /> }<br /> else<br /> {<br /> Session[" RenewalRefused" ] = null;<br /> TextBoxExpDate.BackColor = Color.WhiteSmoke;<br /> memIdExpired = false;<br /> }<br /> TextBoxState.Text = memb.State;<br /> TextBoxPhone.Text = memb.PhoneNumber;<br /> LabelBirthDate.Visible = false;<br /> TextBoxBirthDate.Text = " " ;<br /> TextBoxBirthDate.Visible = false;<br /> LabelAdultID.Visible= false;<br /> TextBoxAdultID.Visible = false;<br />}<br /> private void LoadJuvData(JuvenileMember memb)<br /> {<br /> TextBoxFirstName.Text = memb.FirstName;<br /> TextBoxInit.Text = memb.MiddleInitial;<br /> TextBoxLastName.Text = memb.LastName;<br /> TextBoxStreet.Text = memb.Street;<br /> TextBoxCity.Text = memb.City;<br /> TextBoxZip.Text = memb.ZipCode;<br /> TextBoxExpDate.Text = memb.ExpirationDate.ToString(" d" );<br /> TimeSpan ts = DateTime.Now - memb.ExpirationDate;<br /> if (ts.Days > 0)<br /> {<br /> TextBoxExpDate.BackColor = Color.Yellow;<br /> memIdExpired = true;<br /> }<br /> else<br /> {<br /> TextBoxExpDate.BackColor = Color.WhiteSmoke;<br /> memIdExpired = false;<br /> }<br /> TextBoxState.Text = memb.State;<br /> TextBoxPhone.Text = memb.PhoneNumber;<br /> LabelBirthDate.Visible = true;<br /> TextBoxBirthDate.Text = memb.BirthDate.ToString(" d" );<br /> TextBoxBirthDate.Visible =true;<br /> LabelAdultID.Visible= true;<br /> TextBoxAdultID.Visible = true;<br /> TextBoxAdultID.Text = memb.AdultMemberID.ToString();<br /> }<br /> New Add Item Screen<br />Librarian can enter the ISBN and click Get Info for ISBN to get current information about an Item. It will also show the highest number copy number used. The librarian can add a new copy by updating the copy no and clicking Add New Item.<br /> To add a new ISBN the librarian must enter all the information except Synopsis is optional.<br /> Selected Code for Add Item Screen<br /> protected void ButtonGetInfo_Click(object sender, EventArgs e)<br /> {<br /> LibraryAccess la = new LibraryAccess();<br /> try<br /> {<br /> ItemAddInfo itm = la.GetLastCopyItem(short.Parse(TextBoxISBN.Text));<br /> TextBoxCopy.Text = " " ;<br /> TextBoxTitle.Text = itm.Title;<br /> TextBoxAuthor.Text = itm.Author;<br /> TextBoxSynopsis.Text = itm.Synopsis;<br /> TextBoxTrans.Text = itm.Translation;<br /> LabelLastCopy.Text = string.Format(" Highest Copy No used {0}" , itm.CopyNumber);<br /> if (itm.Cover == " HARDBACK" || itm.Cover == " Hardback" )<br /> {<br /> RadioButtonSoft.Checked = false;<br /> RadioButtonHard.Checked = true;<br /> }<br /> else<br /> {<br /> RadioButtonHard.Checked = false;<br /> RadioButtonSoft.Checked = true;<br /> }<br /> if (itm.Loanable == " Y" || itm.Loanable == " y" )<br /> {<br /> RadioButtonInHouse.Checked = false;<br /> RadioButtonLoan.Checked = true;<br /> }<br /> else<br /> {<br /> RadioButtonLoan.Checked = false;<br /> RadioButtonInHouse.Checked = true;<br /> }<br /> }<br /> catch (LibraryException lex)<br /> {<br /> TextBoxTitle.Text = " " ;<br /> TextBoxAuthor.Text = " " ;<br /> TextBoxSynopsis.Text = " " ;<br /> TextBoxTrans.Text = " " ;<br /> LabelLastCopy.Text = " " ;<br /> RadioButtonHard.Checked = true;<br /> RadioButtonLoan.Checked = true;<br /> LabelErrorMsg.Text = lex.Message;<br /> }<br /> catch (Exception ex)<br /> {<br /> TextBoxTitle.Text = " " ;<br /> TextBoxAuthor.Text = " " ;<br /> TextBoxSynopsis.Text = " " ;<br /> TextBoxTrans.Text = " " ;<br /> LabelLastCopy.Text = " " ;<br /> RadioButtonHard.Checked = true;<br /> RadioButtonLoan.Checked = true;<br /> LabelErrorMsg.Text = " System Error " + ex.Message;<br /> }<br /> }<br /> /// <summary><br /> /// Adds the new Item. If ISBN exist than only a new copy is added<br /> /// otherwise it creates a title item and copy row<br /> /// </summary><br /> /// <param name=" sender" ></param><br /> /// <param name=" e" ></param><br /> protected void ButtonAddItem_Click(object sender, EventArgs e)<br /> {<br /> try<br /> {<br /> LibraryAccess la = new LibraryAccess();<br /> string cover;<br /> if(RadioButtonHard.Checked == true)<br /> cover = " HARDBACK" ;<br /> else<br /> cover = " SOFTBACK" ;<br /> string loanable;<br /> if(RadioButtonLoan.Checked == true)<br /> loanable = " Y" ;<br /> else<br /> loanable = " N" ;<br /> la.AddNewItem(int.Parse(TextBoxISBN.Text), short.Parse(TextBoxCopy.Text),<br /> TextBoxTitle.Text, TextBoxAuthor.Text, TextBoxSynopsis.Text, TextBoxTrans.Text,<br /> cover, loanable);<br /> LabelErrorMsg.Text = " Item Added" ;<br /> }<br /> catch (LibraryException lex)<br /> {<br /> LabelErrorMsg.Text = lex.Message;<br /> }<br /> catch (Exception ex)<br /> {<br /> LabelErrorMsg.Text = ex.Message;<br /> }<br /> }<br />}<br />

×