protected void btnSubmitViewingRequest_Click(object sender, EventArgs e) { // new viewing request object ViewingRequest objViewingRequest = new ViewingRequest(); //appending entered details into object var parid = txtPName.Text; objViewingRequest.parentid = Convert.ToInt32(parid); objViewingRequest.studentname = txtChildName.Text; var stdid = txtChildStdID.Text; objViewingRequest.studentid = Convert.ToInt32(stdid); objViewingRequest.status = "P"; objViewingRequest.datecreated = DateTime.Now; //call add method int id = objViewingRequest.addRequest(); lblConfirmation.Text = "Congratulations! You have successfully submitted the Request! " + "<br/>" + "Viewing Request ID: " + id + "<br/>" + "Your ID: " + txtPName.Text + "<br/>" + "Your Child's Name: " + txtChildName.Text + "<br/>" + "Your Child's ID: " + txtChildStdID.Text + "<br/>" + "Status: " + "Pending" + "<br/>" + "Date Created " + DateTime.Now.ToString(); }
protected void Button1_Click(object sender, EventArgs e) // Send Button for SendRequest.aspx { using (var context = new DatabaseContext()) // Our version using database required for any SQL shit { ViewingRequest request = new ViewingRequest(); request.StudentName = StudName.Text; // Name of Student request.Parent = context.Parent.Single(p => p.ID == (Session["Account"] as Models.Parent).ID); /*This is code uses the Logged in Parents ID to search the Database to retrieve the records * and set them as the Parent who is requesting Access in SendRequest.aspx.*/// The simpler version of the SQL INSERT INTO thing. request.Status = "P"; // This line will set a default value for Statu tab as "P" for Pending context.Add(request); context.SaveChanges(); // This line saves and adds the data into the ViewingRequest table. } Response.Redirect("/Pages/Settings.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if ((string)Session["LoginID"] != null) { //Create a new Mentor, Reply, Parent and ViewingRequest object MentorClass objMentor = new MentorClass(); MessageClass objMessage = new MessageClass(); ParentClass objParent = new ParentClass(); ViewingRequest objViewingRequest = new ViewingRequest(); //Read Mentor, Reply, Parent and ViewingRequest from query string objMentor.mentorId = Convert.ToInt32(Session["MentorId"]); objMessage.messageId = Convert.ToInt32(Request.QueryString["MessageId"]); objParent.parentId = Convert.ToInt32(Request.QueryString["ParentId"]); objViewingRequest.parentId = Convert.ToInt32(Request.QueryString["ParentId"]); //Load Mentor, Reply, Parent and ViewingRequest information to controls int mentorerrorCode = objMentor.getDetails(); int messageerrorCode = objMessage.getDetails(); int parenterrorCode = objParent.getDetails(); int viewingrequesterrorCode = objViewingRequest.getDetails(); if (mentorerrorCode == 0) { lblMentorName.Text = objMentor.mentorname; } else if (mentorerrorCode == -2) { lblMentorName.Text = "Unable to retrieve Mentor details for ID " + objMentor.mentorId; lblMentorName.ForeColor = System.Drawing.Color.Red; } if (messageerrorCode == 0) { lblMessage.Text = objMessage.text; lblOriginalMessage.Text = objMessage.text; } else if (messageerrorCode == -2) { lblMessage.Text = "Unable to retrieve Message details for ID " + objMessage.messageId; lblMessage.ForeColor = System.Drawing.Color.Red; } if (parenterrorCode == 0) { lblParentName.Text = objParent.parentName; lblOriginalParent.Text = objParent.parentName; } else if (parenterrorCode == -2) { lblParentName.Text = "Unable to retrieve Parent details for ID " + objParent.parentId; lblParentName.ForeColor = System.Drawing.Color.Red; } if (viewingrequesterrorCode == 0) { lblStudent.Text = objViewingRequest.studentName; } else if (viewingrequesterrorCode == -2) { lblStudent.Text = "Unable to retrieve Student details for ID " + objViewingRequest.parentId; lblStudent.ForeColor = System.Drawing.Color.Red; } displayReplyList(); } }