示例#1
0
        protected void Create_Click(object sender, EventArgs e)
        {
            // check if we have an ID for editing
            Int32 camperID = 0;

            if (!String.IsNullOrEmpty(Request.QueryString["camperID"]))
            {
                camperID = Convert.ToInt32(Request.QueryString["camperID"]);
            }

            //connect to db
            var conn = new muskokaModel();

            //use camper class to create a new camper object
            Models.camperProfile c = new Models.camperProfile();

            //fill the properties of the new camper
            c.firstName       = firstName.Text;
            c.lastName        = lastName.Text;
            c.familyName      = familyName.Text;
            c.rate            = rate.Text;
            c.age             = Convert.ToInt32(age.Text);
            c.address         = address.Text;
            c.contactName     = contactName.Text;
            c.contactRelation = contactRelation.Text;
            c.contactNumber   = contactNumber.Text;
            c.importantNotes  = impNotes.Text;

            //save the new object to the database
            if (camperID == 0)
            {
                conn.camperProfiles.Add(c);
            }
            else
            {
                c.camperID = camperID;
                conn.camperProfiles.Attach(c);
                conn.Entry(c).State = System.Data.Entity.EntityState.Modified;
            }

            conn.SaveChanges();

            //redirect to the Index page
            Response.Redirect("Index.aspx?");
        }
示例#2
0
        protected void submitPayment_Click(object sender, EventArgs e)
        {
            Int32 camperID = 0;

            if (!String.IsNullOrEmpty(Request.QueryString["camperID"]))
            {
                camperID = Convert.ToInt32(Request.QueryString["camperID"]);
            }

            // connect to db
            var conn = new muskokaModel();

            // use the payment class to create new payment
            Models.payment p = new Models.payment();

            p.date         = payCalendar.Text;
            p.amount       = "$" + makePayment.Text;
            p.payment_type = payType.SelectedItem.Text;
            p.camperID     = Convert.ToInt32(Request.QueryString["camperID"]);

            if (camperID == 0)
            {
                lblPayment.Text = "Cannot Submit Payment";
            }
            else
            {
                p.camperID = camperID;
                conn.payments.Attach(p);
                conn.Entry(p).State = System.Data.Entity.EntityState.Modified;
            }

            conn.SaveChanges();

            //redirect
            Response.Redirect("Pay.aspx");
        }