예제 #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            myAdult.FirstName     = txtFirstName.Text.ToString();
            myAdult.MiddleInitial = txtMidInit.Text.ToString();
            myAdult.LastName      = txtLastName.Text.ToString();
            myAdult.Street        = txtAddress.Text.ToString();
            myAdult.City          = txtCity.Text.ToString();
            myAdult.State         = ddState.Text.ToString();
            myAdult.ZipCode       = txtZip.Text.ToString();
            myAdult.PhoneNumber   = txtTelephone.Text.ToString();

            myDb.AddMember(myAdult);

            Session["MemberID"]      = myAdult.MemberID;
            Session["SessionStatus"] = "Adult Added";
            Response.Redirect("~/MainPanel.aspx");
        }
        catch (LibraryException ex)
        {
            if (ex.LibraryErrorCode == ErrorCode.AddAdultFailed)
            {
                Label lbl = (Label)Page.Master.FindControl("lblStatus");
                lbl.Text      = "Add Adult Failed";
                lbl.ForeColor = Color.Red;
            }
            if (ex.LibraryErrorCode == ErrorCode.GenericException)
            {
                Label lbl = (Label)Page.Master.FindControl("lblStatus");
                lbl.Text      = "ERROR: " + ex.Message;
                lbl.ForeColor = Color.Red;
            }
        }
    }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                myJuve.BirthDate     = Convert.ToDateTime(dtpBirthDate.Text);
                myJuve.FirstName     = txtFirstName.Text;
                myJuve.MiddleInitial = txtMidInit.Text;
                myJuve.LastName      = txtLastName.Text;
                myJuve.AdultMemberID = Convert.ToInt16(txtAdultMemberID.Text);

                try
                {
                    myDb.AddMember(myJuve);
                    frmMemberInfo memberInfo = new frmMemberInfo((Member)myJuve);
                    memberInfo.MdiParent = this.MdiParent;
                    memberInfo.Show();
                    this.Close();
                }
                catch (LibraryException)
                {
                    string myErr = string.Format("Add Juvenile Failed");
                    tsslStatusLabel.Text = myErr;
                    return;
                }
            }
        }
예제 #3
0
파일: Service.cs 프로젝트: Emtey/BootCamp
 public void AddAdultMember(ref AdultMember member)
 {
     try
     {
         DBInteraction db = new DBInteraction();
         db.AddMember(member);
     }
     catch (LibraryException ex)
     {
         throw new SoapException(ex.Message, ExceptionCodes.AddAdultFailed);
     }
 }
예제 #4
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        DateTime myDate;

        try
        {
            myJuve.FirstName     = txtFirstName.Text.ToString();
            myJuve.MiddleInitial = txtMidInit.Text.ToString();
            myJuve.LastName      = txtLastName.Text.ToString();
            myJuve.AdultMemberID = Convert.ToInt16(txtAdultMemberID.Text);
            myDate = Convert.ToDateTime(txtBirthDate.Text);
            if (myDate.AddYears(18).Date < DateTime.Today.Date)
            {
                Label lbl = (Label)Page.Master.FindControl("lblStatus");
                lbl.Text      = "Person is older than 18.  Add as Adult instead.";
                lbl.ForeColor = Color.Red;
                return;
            }
            else if (myDate.Date > DateTime.Today.Date)
            {
                Label lbl = (Label)Page.Master.FindControl("lblStatus");
                lbl.Text      = "Person is not born yet, please wait till they are born to add them.";
                lbl.ForeColor = Color.Red;
                return;
            }
            else
            {
                myJuve.BirthDate = myDate;
            }


            myDb.AddMember(myJuve);

            Session["MemberID"]      = myJuve.MemberID;
            Session["SessionStatus"] = "Juvenile Added";
            Response.Redirect("~/MainPanel.aspx");
        }
        catch (LibraryException ex)
        {
            if (ex.LibraryErrorCode == ErrorCode.AddJuvenileFailed)
            {
                Label lbl = (Label)Page.Master.FindControl("lblStatus");
                lbl.Text      = "Add Juvenile Failed";
                lbl.ForeColor = Color.Red;
            }
            if (ex.LibraryErrorCode == ErrorCode.GenericException)
            {
                Label lbl = (Label)Page.Master.FindControl("lblStatus");
                lbl.Text      = "ERROR: " + ex.Message;
                lbl.ForeColor = Color.Red;
            }
        }
    }
예제 #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                myAdult.FirstName     = txtFirstName.Text;
                myAdult.MiddleInitial = txtMidInit.Text;
                myAdult.LastName      = txtLastName.Text;
                myAdult.Street        = txtStreet.Text;
                myAdult.City          = txtCity.Text;
                myAdult.State         = cbState.Text;
                myAdult.ZipCode       = txtZip.Text;
                myAdult.PhoneNumber   = txtPhone.Text;

                try
                {
                    myDb.AddMember(myAdult);
                    frmMemberInfo memberInfo = new frmMemberInfo((Member)myAdult);
                    memberInfo.MdiParent = this.MdiParent;
                    memberInfo.Show();
                    this.Close();
                }
                catch (LibraryException ex)
                {
                    if (ex.LibraryErrorCode == ErrorCode.AddAdultFailed)
                    {
                        string myErr = string.Format("Add Adult Failed");
                        tsslLabel.Text = myErr;
                        return;
                    }
                    if (ex.LibraryErrorCode == ErrorCode.GenericException)
                    {
                        tsslLabel.Text = "ERROR: " + ex.Message;
                        return;
                    }
                }
            }
        }