示例#1
0
        void reg_FPRegistrationStatus(RegistrationStatus Status)
        {
            log.Debug("IN");

            try
            {
                log.Debug("Status:" + Status.ToString());

                if (Status == RegistrationStatus.r_OK)
                {
                    MessageBox.Show("Fingerprint Recorded!", "Info");
                    string preview = fingerprint;
                    lblFingerprintCount.Text = "Fingerprint recorded.";
                    btnFingerprint.Enabled   = true;
                }
            }
            catch (Exception ex)
            {
                log.Error("Error", ex);
                MessageBox.Show(ex.Message, "Error - " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
        }
        public ActionResult Update(RegistrationStatus enrol_status, string message, long id,
                                   int?enrol_year, int?enrol_school, int?enrol_schoolyear,
                                   int?admission_day, int?admission_month, int?admission_year, int?left_day, int?left_month, int?left_year,
                                   string previous_school, string previous_class, string leaving_reason, bool?handicap, bool?learning_problems,
                                   string disability_details, bool?sendmessage
                                   )
        {
            if (!enrol_schoolyear.HasValue)
            {
                return(Json("Enrolling school year is not specified".ToJsonFail()));
            }

            if (!enrol_school.HasValue)
            {
                return(Json("Enrolling school is not specified".ToJsonFail()));
            }

            var r = repository.GetRegistration(id);

            r.status             = enrol_status.ToString();
            r.reviewer           = sessionid;
            r.reviewMessage      = message;
            r.previous_school    = previous_school;
            r.previous_class     = previous_class;
            r.leaving_reason     = leaving_reason;
            r.isHandicap         = handicap;
            r.hasLearningProblem = learning_problems;
            r.disability_details = disability_details;
            try
            {
                if (admission_year.HasValue)
                {
                    try
                    {
                        r.admissionDate = new DateTime(admission_year.Value, admission_month.Value, admission_day.Value);
                    }
                    catch (Exception ex)
                    {
                        return(Json("Invalid admission date".ToJsonFail()));
                    }
                }
                else
                {
                    r.user.settings = r.user.SetFlag(UserSettings.INACTIVE);
                    r.admissionDate = null;
                }

                if (left_year.HasValue)
                {
                    try
                    {
                        r.leftDate = new DateTime(left_year.Value, left_month.Value, left_day.Value);
                    }
                    catch (Exception ex)
                    {
                        return(Json("Invalid leaving date".ToJsonFail()));
                    }
                }
                else
                {
                    r.user.settings = r.user.UnsetFlag(UserSettings.INACTIVE);
                    r.leftDate      = null;
                }

                r.schoolid      = enrol_school.Value;     // checked
                r.enrollingYear = enrol_year;
                r.schoolyearid  = enrol_schoolyear.Value; // checked

                repository.Save();

                // send email to applicant
                if (sendmessage.HasValue &&
                    sendmessage.Value &&
                    r.user1 != null &&
                    !string.IsNullOrEmpty(r.user1.email))
                {
                    var email = new EmailRegistrationUpdateViewModel();
                    email.applicantName = r.user1.ToName();
                    email.message       = message.ToHtmlBreak();

                    this.SendEmail(
                        EmailViewType.REGISTRATION_UPDATE,
                        email,
                        " School Enrolment Update",
                        r.user1.email,
                        email.applicantName);
                }
            }
            catch (Exception ex)
            {
                return(SendJsonErrorResponse(ex));
            }

            return(Json("Enrolment updated successfully".ToJsonOKMessage()));
        }