Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Parent"] != null) //Check if parent is logged in
            {
                parent = (Parent)Session["Parent"];
                if (Session["Payment"] != null) //Check if user has paid succesfully
                {
                    payment = (Payment)Session["Payment"];
                }
                else
                {
                    Response.Redirect("~/ParentTools/MakeAPayment.aspx");
                }
            }
            else
            {
                Response.Redirect("~/Login.aspx");
            }

            if (!IsPostBack)
            {
                Title = "Payment Confirmation";

                /* Set all labels to payment data */
                recipientValueLabel.Text          = "Learn-On-Line PLC";
                invoiceNumberValueLabel.Text      = Payment.InvoiceNumber.ToString();
                confirmationNumberValueLabel.Text = payment.ConfirmationNumber;
                totalAmountPaidValueLabel.Text    = payment.Fee.ToString("C",
                                                                         CultureInfo.CreateSpecificCulture(payment.CultureInfo));
                transactionDateValueLabel.Text = DateTime.Now.ToString("d/M/yyyy");

                parent.PaymentDate = DateTime.Now.ToString("d/M/yyyy");
                parentDAO.updateParent(parent);
            }
        }
Beispiel #2
0
        protected void editBtn_Click(object sender, EventArgs e)
        {
            if (Page.IsValid) //Check if form is valid
            {
                try
                {
                    if (childEdit != null)
                    {
                        if (userTypeDD.SelectedValue == "Child")
                        {
                            childEdit.Username  = usernameTxt.Text;
                            childEdit.Password  = passwordTxt.Text;
                            childEdit.FirstName = firstNameTxt.Text;
                            childEdit.Surname   = surnameTxt.Text;
                            childEdit.BirthDate = birthDateTxt.Text;
                            childEdit.Gender    = genderRadioBtnList.SelectedValue;
                            childDAO.updateChild(childEdit);
                        }
                        if (userTypeDD.SelectedValue == "Parent")
                        {
                            childDAO.deleteChild(childEdit.ID);

                            parentDAO = new ParentDAOImpl();
                            parentDAO.addParent(new Parent(usernameTxt.Text, passwordTxt.Text, firstNameTxt.Text,
                                                           surnameTxt.Text, postcodeTxt.Text, telephoneTxt.Text, emailTxt.Text, "",
                                                           new List <Child>()));
                        }
                        if (userTypeDD.SelectedValue == "Administrator")
                        {
                            childDAO.deleteChild(childEdit.ID);

                            administratorDAO = new AdministratorDAOImpl();
                            administratorDAO.addAdministrator(new Administrator(usernameTxt.Text, passwordTxt.Text));
                        }
                    }

                    if (parentEdit != null)
                    {
                        if (userTypeDD.SelectedValue == "Child")
                        {
                            parentDAO.deleteParent(parentEdit.ID);
                            childDAO = new ChildDAOImpl();
                            childDAO.addChild(new Child(usernameTxt.Text, passwordTxt.Text, firstNameTxt.Text,
                                                        surnameTxt.Text,
                                                        birthDateTxt.Text, genderRadioBtnList.SelectedValue, "", new List <Grade>(),
                                                        int.Parse(parentsDropdownList.SelectedValue)));
                        }
                        if (userTypeDD.SelectedValue == "Parent")
                        {
                            parentEdit.Username  = usernameTxt.Text;
                            parentEdit.Password  = passwordTxt.Text;
                            parentEdit.FirstName = firstNameTxt.Text;
                            parentEdit.Surname   = surnameTxt.Text;
                            parentEdit.Postcode  = postcodeTxt.Text;
                            parentEdit.Telephone = telephoneTxt.Text;
                            parentEdit.Email     = emailTxt.Text;
                            parentDAO.updateParent(parentEdit);
                        }
                        if (userTypeDD.SelectedValue == "Administrator")
                        {
                            parentDAO.deleteParent(parentEdit.ID);
                            administratorDAO = new AdministratorDAOImpl();
                            administratorDAO.addAdministrator(new Administrator(usernameTxt.Text, passwordTxt.Text));
                        }
                    }
                    if (administratorEdit != null)
                    {
                        if (userTypeDD.SelectedValue == "Child")
                        {
                            administratorDAO.deleteAdministrator(administratorEdit.ID);

                            childDAO = new ChildDAOImpl();
                            childDAO.addChild(new Child(usernameTxt.Text, passwordTxt.Text, firstNameTxt.Text,
                                                        surnameTxt.Text,
                                                        birthDateTxt.Text, genderRadioBtnList.SelectedValue, "", new List <Grade>(),
                                                        int.Parse(parentsDropdownList.SelectedValue)));
                        }
                        if (userTypeDD.SelectedValue == "Parent")
                        {
                            administratorDAO.deleteAdministrator(administratorEdit.ID);

                            parentDAO = new ParentDAOImpl();
                            parentDAO.addParent(new Parent(usernameTxt.Text, passwordTxt.Text, firstNameTxt.Text,
                                                           surnameTxt.Text, postcodeTxt.Text, telephoneTxt.Text, emailTxt.Text, "",
                                                           new List <Child>()));
                        }
                        if (userTypeDD.SelectedValue == "Administrator")
                        {
                            administratorEdit.Username = usernameTxt.Text;
                            administratorEdit.Password = passwordTxt.Text;
                            administratorDAO.updateAdministrator(administratorEdit);
                        }
                    }
                    Session["SuccessEdit"] = true;
                }
                catch (Exception ex)
                {
                    Session["SuccessEdit"] = false;
                }
                Response.Redirect("~/AdministratorTools/EditAUser", true);
            }
        }