コード例 #1
0
        protected void signin_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 muskokaEntites();

            //use camper class to create a new camper object
            registrationDate render = (from r in conn.registrationDates
                                       join cR in conn.camperRegistrations on r.ID equals cR.registrationDateID into rID
                                       from cR in rID
                                       join c in conn.camperProfiles on cR.camperID equals c.ID
                                       where c.ID == camperID && r.date == currentDate2.Text
                                       select r).FirstOrDefault();

            //fill the properties of the camper time
            render.signedInBy = signedInBy.Text;
            render.signInTime = DateTime.Now.ToString("h:mm:ss tt");

            conn.registrationDates.Attach(render);
            conn.Entry(render).State = System.Data.Entity.EntityState.Modified;
            conn.SaveChanges();

            //redirect
            Response.Redirect("CamperAttendence.aspx");
        }
コード例 #2
0
        protected void grdRegistration_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //function to delete a camper from the list of profiles
            // 1. determine row in the grid
            Int32 gridIndex = e.RowIndex;

            // 2. find the camper id value in the selected row
            Int32 camperID = Convert.ToInt32(grdRegistration.DataKeys[gridIndex].Values["camperID"]);
            var   date     = datebox1.Text;

            // 3. connect to db
            using (muskokaEntites db = new muskokaEntites())
            {
                registrationDate camp = (from r in db.registrationDates
                                         join cR in db.camperRegistrations on r.ID equals cR.registrationDateID into rID
                                         from cR in rID
                                         join c in db.camperProfiles on cR.camperID equals c.ID
                                         where c.ID == camperID && r.date == date
                                         select r).FirstOrDefault();

                // 4. delete the selected camper
                db.registrationDates.Remove(camp);
                db.SaveChanges();

                // 5. referesh the grid
                getCampers();
            }
        }
コード例 #3
0
        protected void submitPayment_Click(object sender, EventArgs e)
        {
            // connect
            using (muskokaEntites db = new muskokaEntites())
            {
                // create new payment
                payment pay = new payment();

                Int32 camperID = 0;

                // check for ID in url
                if (!String.IsNullOrEmpty(Request.QueryString["camperID"]))
                {
                    //get the id from the url
                    camperID = Convert.ToInt32(Request.QueryString["camperID"]);

                    // get the payment
                    pay = (from p in db.payments
                           where p.camperID == camperID
                           select p).FirstOrDefault();
                }

                //fill properties to make a payment
                pay.date        = payCalendar.Text;
                pay.amount      = "$" + makePayment.Text;
                pay.paymentType = payType.SelectedItem.Text;
                pay.camperID    = Convert.ToInt32(Request.QueryString["camperID"]);

                db.payments.Add(pay);
                db.SaveChanges();

                // redirect
                Response.Redirect("Pay.aspx");
            }
        }
コード例 #4
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 muskokaEntites();

            //use camper class to create a new camper object
            camperProfile c = new 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.ID = 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?");
        }
コード例 #5
0
        protected void grdCampers_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //function to delete a camper from the list of profiles
            // 1. determine row in the grid
            Int32 gridIndex = e.RowIndex;

            // 2. find the camper id value in the selected row
            Int32 camperID = Convert.ToInt32(grdCampers.DataKeys[gridIndex].Values["camperID"]);

            // 3. connect to db
            using (muskokaEntites db = new muskokaEntites())
            {
                camperProfile camp = (from c in db.camperProfiles
                                      where c.ID == camperID
                                      select c).FirstOrDefault();

                // 4. delete the selected camper
                db.camperProfiles.Remove(camp);
                db.SaveChanges();

                // 5. referesh the grid
                getCampers();
            }
        }