Exemple #1
0
    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;
        }
    }
Exemple #2
0
 //Loads the common fields Juvenile and Adult members share.
 private void LoadGenericFields(LibraryWebService.Member myMember)
 {
     txtMemberID.Text      = myMember.MemberID.ToString();
     txtExpDte.Text        = myMember.ExpirationDate.ToString("MM/dd/yyyy");
     txtFirstName.Text     = myMember.FirstName;
     txtLastName.Text      = myMember.LastName;
     txtMiddleInitial.Text = myMember.MiddleInitial;
     txtAddress.Text       = myMember.Street;
     txtCity.Text          = myMember.City;
     txtState.Text         = myMember.State;
     txtZip.Text           = myMember.ZipCode;
     txtTelephone.Text     = myMember.PhoneNumber;
 }
Exemple #3
0
    protected void btnGetInfo_Click(object sender, EventArgs e)
    {
        string myErr;

        try
        {
            myMember = myDb.GetMember(Convert.ToInt16(txtMemberID.Text));
            LoadGenericFields(myMember);
            if (myMember is LibraryWebService.JuvenileMember)
            {
                LoadJuvenileFields(myMember);
            }
            else
            {
                FormatAdultWindow();
            }
            Session["MemberID"] = myMember.MemberID.ToString();

            CheckExpirationDate(myMember);

            if (!isExpired)
            {
                if (GridView1.Rows.Count < 4)
                {
                    btnCheckout.Visible = true;
                }
                else
                {
                    btnCheckout.Visible = false;
                }
            }

            ConvertToAdult(myMember);
            //load the datagrid view.
            ObjectDataSource1.DataBind();
        }
        catch (SoapException)
        {
            myErr = string.Format("Member ID: {0} was not found.", txtMemberID.Text);
            Label lbl = (Label)Page.Master.FindControl("lblStatus");
            lbl.Text      = myErr;
            lbl.ForeColor = Color.Red;
            txtMemberID.Focus();
        }
        catch (WebException)
        {
            Label lbl = (Label)Page.Master.FindControl("lblStatus");
            lbl.Text      = "Web service is not responding, please try again later.";
            lbl.ForeColor = Color.Red;
        }
    }
Exemple #4
0
    //loads the fields that are common to Juvenile members.
    private void LoadJuvenileFields(LibraryWebService.Member myMember)
    {
        juve = (LibraryWebService.JuvenileMember)myMember;

        //set the fields visibles
        lblBirthDte.Visible      = true;
        lblAdultMember.Visible   = true;
        txtBirthDte.Visible      = true;
        txtAdultMemberID.Visible = true;

        //move the myMemberfields into the txt fields.
        txtAdultMemberID.Text = juve.AdultMemberID.ToString();
        txtBirthDte.Text      = juve.BirthDate.ToString("MM/dd/yyyy");
    }
Exemple #5
0
    private void CheckExpirationDate(LibraryWebService.Member myMember)
    {
        string myErr;

        //check member Expireation date
        if ((DateTime)myMember.ExpirationDate.Date < DateTime.Now.Date)
        {
            txtExpDte.BackColor = Color.Red;
            if (myMember is LibraryWebService.JuvenileMember)
            {
                btnRenewMember.Visible = false;
                myErr = string.Format("Member ID: {0} is expired. Renew Adult Member.", txtMemberID.Text);
            }
            else
            {
                btnRenewMember.Visible = true;
                myErr = string.Format("Member ID: {0} is expired.", txtMemberID.Text);
            }
            btnCheckout.Visible = false;
            Label lbl = (Label)Page.Master.FindControl("lblStatus");
            lbl.Text      = myErr;
            lbl.ForeColor = Color.Red;
            isExpired     = true;
        }
        else if ((DateTime)myMember.ExpirationDate.Date < DateTime.Now.Date.AddDays(14) &&
                 (DateTime)myMember.ExpirationDate.Date == DateTime.Now.Date)
        {
            txtExpDte.BackColor = Color.Yellow;
            if (myMember is LibraryWebService.JuvenileMember)
            {
                btnRenewMember.Visible = false;
                myErr = string.Format("Member ID: {0} is set to expire in 14 days. Renew Adult Member", txtMemberID.Text);
            }
            else
            {
                btnRenewMember.Visible = true;
                myErr = string.Format("Member ID: {0} is set to expire in 14 days.", txtMemberID.Text);
            }
            myErr = string.Format("Member ID: {0} is set to expire in 14 days.", txtMemberID.Text);
            Label lbl = (Label)Page.Master.FindControl("lblStatus");
            lbl.Text      = myErr;
            lbl.ForeColor = Color.Yellow;
            isExpired     = false;
        }
        else
        {
            txtExpDte.BackColor    = Color.White;
            btnRenewMember.Visible = false;
        }
    }
Exemple #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        myDb.SetPolicy("LibraryClientPolicy");

        if (!IsPostBack)
        {
            if (Session["MemberID"] != null && Convert.ToInt16(Session["MemberID"]) > 0)
            {
                try
                {
                    myMember = myDb.GetMember(Convert.ToInt16(Session["MemberID"]));
                    LoadGenericFields(myMember);
                    if (myMember is LibraryWebService.JuvenileMember)
                    {
                        LoadJuvenileFields(myMember);
                    }
                    else
                    {
                        FormatAdultWindow();
                    }
                }
                catch (SoapException)
                {
                    string myErr = string.Format("Member ID: {0} was not found.", txtMemberID.Text);
                    Label  lbl   = (Label)Page.Master.FindControl("lblStatus");
                    lbl.Text      = myErr;
                    lbl.ForeColor = Color.Red;
                    txtMemberID.Focus();
                }
                catch (WebException)
                {
                    Label lbl = (Label)Page.Master.FindControl("lblStatus");
                    lbl.Text      = "Web service is not responding, please try again later.";
                    lbl.ForeColor = Color.Red;
                }
            }
        }
        else
        {
            Session["SessionStatus"] = null;
        }
    }
Exemple #7
0
    private void ConvertToAdult(LibraryWebService.Member myMember)
    {
        string myErr;

        if (myMember is LibraryWebService.JuvenileMember)
        {
            LibraryWebService.JuvenileMember myJuv = (LibraryWebService.JuvenileMember)myMember;
            if ((DateTime)myJuv.BirthDate.AddYears(+18) <= DateTime.Today)
            {
                try
                {
                    myDb.ConvertJuvenile(myJuv.MemberID);
                    myErr    = string.Format("Member ID: {0} Converted to Adult.", txtMemberID.Text);
                    myMember = myDb.GetMember(Convert.ToInt16(txtMemberID.Text));

                    LoadGenericFields(myMember);
                    FormatAdultWindow();

                    Label lbl = (Label)Page.Master.FindControl("lblStatus");
                    lbl.Text               = myErr;
                    lbl.ForeColor          = Color.Blue;
                    txtExpDte.BackColor    = Color.White;
                    btnRenewMember.Visible = false;
                }
                catch (SoapException)
                {
                    myErr = string.Format("Member ID: {0} could not be converted from Juvenile to Adult.", txtMemberID.Text);
                    Label lbl = (Label)Page.Master.FindControl("lblStatus");
                    lbl.Text = myErr;
                }
                catch (WebException)
                {
                    Label lbl = (Label)Page.Master.FindControl("lblStatus");
                    lbl.Text      = "Web service is not responding, please try again later.";
                    lbl.ForeColor = Color.Red;
                }
            }
        }
    }
Exemple #8
0
    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;
        }
    }