protected void Page_Load(object sender, EventArgs e) { //Show current Date currentDate.Text = DateTime.Now.DayOfWeek.ToString(); currentDate2.Text = DateTime.Now.ToString("MM-dd-yyyy").Replace("-", "/"); if (IsPostBack == false) { //check the url for an ID for editing if (!String.IsNullOrEmpty(Request.QueryString["camperID"])) { // get the ID from url Int32 camperID = Convert.ToInt32(Request.QueryString["camperID"]); // connect to db var conn = new muskokaEntities(); // look up the selected camper var objCamper = (from r in conn.registrationDates where r.camperID == camperID && r.date == currentDate2.Text select r).FirstOrDefault(); // populate the form signedInBy.Text = objCamper.signedInBy; } } }
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 muskokaEntities(); //use camper class to create a new camper object registrationDate render = (from r in conn.registrationDates where r.camperID == camperID && r.date == currentDate2.Text select r).First(); //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"); }
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 (muskokaEntities db = new muskokaEntities()) { registrationDate camp = (from r in db.registrationDates where r.camperID == camperID && r.date == date select r).FirstOrDefault(); // 4. delete the selected camper db.registrationDates.Remove(camp); db.SaveChanges(); // 5. referesh the grid getCampers(); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack == false) { //check the url for an ID for editing if (!String.IsNullOrEmpty(Request.QueryString["camperID"])) { // get the ID from url Int32 camperID = Convert.ToInt32(Request.QueryString["camperID"]); // connect to db var conn = new muskokaEntities(); // look up the selected camper var objCamper = (from c in conn.camperProfiles where c.camperID == camperID select c).FirstOrDefault(); // populate the form firstName.Text = objCamper.firstName; lastName.Text = objCamper.lastName; familyName.Text = objCamper.familyName; rate.Text = objCamper.rate; age.Text = Convert.ToString(objCamper.age); address.Text = objCamper.address; contactName.Text = objCamper.contactName; contactRelation.Text = objCamper.contactRelation; contactNumber.Text = objCamper.contactNumber; impNotes.Text = objCamper.importantNotes; } } }
protected void Page_Load(object sender, EventArgs e) { //connect to database var conn = new muskokaEntities(); //table query var Campers = from c in conn.camperProfiles select c; //show the values totalCamper.Text = Convert.ToString(Campers.Count()); }
protected void getCampers() { //connect to db var conn = new muskokaEntities(); //run the query using LINQ var Campers = from c in conn.camperProfiles select c; //display the query results in grid view grdRegistration.DataSource = Campers.ToList(); grdRegistration.DataBind(); }
protected void Getparents() { using (muskokaEntities conn = new muskokaEntities()) { var camperDates = (from cp in conn.camperProfiles join r in conn.registrationDates on cp.camperID equals r.camperID where r.date == currentDate2.Text select new { cp.camperID, cp.familyName, cp.firstName, r.signInTime, r.signOutTime, r.signedInBy, r.signedOutBy }); grdCampers.DataSource = camperDates.ToList(); grdCampers.DataBind(); } }
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 muskokaEntities(); //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.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?"); }
protected void getCampers() { //connect to db var conn = new muskokaEntities(); //run the query using LINQ var camperDates = (from cp in conn.camperProfiles join r in conn.registrationDates on cp.camperID equals r.camperID where r.date == datebox1.Text select new { cp.camperID, cp.familyName, cp.firstName, r.signInTime, r.signOutTime, r.signedInBy, r.signedOutBy }); //display the query results in grid view grdRegistration.DataSource = camperDates.ToList(); grdRegistration.DataBind(); }
protected void getCampers() { //connect to db var conn = new muskokaEntities(); Int32 camperID = Convert.ToInt32(Request.QueryString["camperID"]); //run the query using LINQ var dates = from r in conn.registrationDates where r.camperID == camperID select r; //display the query results in grid view grdRegistration.DataSource = dates.ToList(); grdRegistration.DataBind(); }
protected void Calculate2_Click(object sender, EventArgs e) { //connect to database var conn = new muskokaEntities(); //table query var startdate = from r in conn.registrationDates where r.date == datebox3.Text select r; var enddate = from r in conn.registrationDates where r.date == datebox4.Text select r; var count3 = Convert.ToInt32(startdate.Count()); var count4 = Convert.ToInt32(enddate.Count()); var total = (count3 + count4) / 2; result2.Text = Convert.ToString(total); }
protected void Calculate1_Click(object sender, EventArgs e) { //connect to database var conn = new muskokaEntities(); //table query var startdate = from r in conn.registrationDates where r.date == datebox1.Text && r.signInTime != null select r; var enddate = from r in conn.registrationDates where r.date == datebox2.Text && r.signInTime != null select r; var count1 = Convert.ToInt32(startdate.Count()); var count2 = Convert.ToInt32(enddate.Count()); var total = (count1 + count2) / 2; result1.Text = Convert.ToString(total); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack == false) { getPayment(); //check id so that we can edit or add if (!String.IsNullOrEmpty(Request.QueryString["camperID"])) { //get id from URL Int32 camperID = Convert.ToInt32(Request.QueryString["camperID"]); //Connect var conn = new muskokaEntities(); //look up the selected campers var objCamper = (from c in conn.camperProfiles where c.camperID == camperID select c).FirstOrDefault(); var objPayment = (from p in conn.payments where p.camperID == camperID select p).FirstOrDefault(); //run the query using LINQ var payment = from p in conn.payments where p.camperID == camperID select p; //display the query results in grid view grdPayment.DataSource = payment.ToList(); grdPayment.DataBind(); //populate the camper form familyName.Text = objCamper.familyName; firstName.Text = objCamper.firstName; rate.Text = "$" + objCamper.rate; } } }
protected void submitPayment_Click(object sender, EventArgs e) { //connect to db var db = new muskokaEntities(); // create new payment in the memory payment pay = new payment(); //fill properties to make a payment pay.date = datebox1.Text; pay.amount = "$" + makePayment.Text; pay.payment_type = payType.SelectedItem.Text; pay.camperID = Convert.ToInt32(Request.QueryString["camperID"]); //save the new object to the database db.payments.Add(pay); db.SaveChanges(); //redirect Response.Redirect("Index.aspx"); }
protected void Unnamed_Click(object sender, EventArgs e) { using (muskokaEntities conn = new muskokaEntities()) { //use camper class to create a new camper object registrationDate r = new registrationDate(); Int32 camperID = Convert.ToInt32(Request.QueryString["camperID"]); //fill the properties of the new camper string phrase = datePick.Text; string[] words; string[] stringSeparators = new string[] { ", " }; words = phrase.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries); foreach (string s in words) { string str; str = s; //remove next two statment and enter value of str in database r.date = str; r.camperID = camperID; //save the new object to the database conn.registrationDates.Add(r); conn.SaveChanges(); } } //redirect getCampers(); }
protected void getPayment() { //connect to db var conn = new muskokaEntities(); }