コード例 #1
0
        /// <summary>
        /// Create a text file containing formatted output
        /// </summary>
        /// <param name="iDisp">an object of type IDisplay</param>
        public void GenerateTextReport(IDisplay iDisp)
        {
            string filename = "";

            if (iDisp == null)
            {
                MessageBox.Show("First select the item to be sent to the report file", "No item selected");
            }
            else
            {
                if (iDisp is Applicant)
                {
                    Applicant a = (Applicant)iDisp;
                    filename = a.RegNo;
                }
                else if (iDisp is ForceService)
                {
                    ForceService s = (ForceService)iDisp;
                    filename = s.FSNo;
                }
                else if (iDisp is ApplicantList)
                {
                    filename = AppData.Applicants;
                }
                else
                {
                    filename = AppData.ForceServices;
                }
                textReportGenerator.GenerateReport(iDisp, filename + ".txt");
                MessageBox.Show("Text report " + filename + ".txt" + " created.");
            }
        }
コード例 #2
0
 public ResultInput(ForceService forceService, Applicant applicant, int grade)
 {
     ForceService = forceService;
     Grade        = grade;
     // Any grade archieved must be noted and added to the grade
     applicant.Result.AddResultInput(this);
 }
コード例 #3
0
        /// <summary>
        /// Unenrol a Applicant from a ForceService
        /// </summary>
        public void UnenrolApplicant()
        {
            // Get selected Applicant and ForceService
            ForceService forceService = (ForceService)cboForceServices.SelectedItem;
            Applicant    applicant    = (Applicant)cboApplicants.SelectedItem;

            try
            {
                DialogResult dr = MessageBox.Show("Unenrol " + applicant.RegNo + " from " + forceService.FSNo + "?", "Enrol",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dr == DialogResult.Yes)
                {
                    // Unenrol the Applicant from this ForceService program
                    forceService.Unenrol(applicant);

                    MessageBox.Show("Succcesful unenrolment");
                    txtDisplay.Clear();
                    //txtDisplay.Text = applicant.Display();
                    //txtDisplay.Text = forceService.Display();
                }
            }

            // catch exceptions if applicant not enrolled or already passed exam for ForceService
            catch (NotEnrolledException ne)
            {
                MessageBox.Show(ne.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (AlreadyPassedException ap)
            {
                MessageBox.Show(ap.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
        /// <summary>
        ///  Enrol Applicant onto a particular ForceService
        /// </summary>
        public void EnrolApplicant()
        {
            // Get selected Applicant and ForceService
            ForceService forceService = (ForceService)cboForceServices.SelectedItem;
            Applicant    applicant    = (Applicant)cboApplicants.SelectedItem;

            try
            {
                // Enrol this Applicant onto this ForceService
                DialogResult dr = MessageBox.Show("Enrol " + applicant.RegNo + " onto " + forceService.FSNo + "?", "Enrol",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dr == DialogResult.Yes)
                {
                    forceService.Enrol(applicant);
                    MessageBox.Show("Succcesful enrolment");
                    txtDisplay.Clear();
                    //txtDisplay.Text = applicant.Display();
                    //txtDisplay.Text = forceService.Display();
                }
            }

            // Catch exceptions if student already enrolled or already passed module
            catch (AlreadyEnrolledException ae)
            {
                MessageBox.Show(ae.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (AlreadyPassedException ap)
            {
                MessageBox.Show(ap.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
        /// <summary>
        /// Add new ForceService to the system
        /// </summary>
        public void AddServiceForce()
        {
            //Open new form to input ForceService's data
            AddNewDataForm addForm = new AddNewDataForm("forceService");

            if (addForm.ShowDialog() == DialogResult.OK)
            {
                // Get new forceService data from second form
                ForceService newForceService = addForm.GetForceServiceData();

                //Add new forceService to forceService list
                bool success = forceServiceList.AddForceService(newForceService);
                if (success)
                {
                    MessageBox.Show(newForceService.FSNo + " has been added to the list");
                    //redisplay list of ForceServices
                    DisplayAll(forceServiceList);

                    // Display new forceService
                    txtDisplay.Clear();
                    //txtDisplay.Text = newForceService.Display();
                }
                else
                {
                    MessageBox.Show("\nUnable to add. This forceService FSNo already been used");
                }
            }
        }
コード例 #6
0
        // find and return ForceService that matches the search

        public ForceService FineItem(string sFSNo)
        {
            ForceService forceService = null;

            foreach (ForceService s in ForceService)
            {
                if (s.FSNo == sFSNo)
                {
                    forceService = s;
                }
            }
            return(forceService);
        }
コード例 #7
0
        // Add new services to the list of all the officer
        // check if it has not been used
        public bool AddForceService(ForceService forceService)
        {
            bool success = true;

            foreach (ForceService s in ForceService)
            {
                if (s.FSNo == forceService.FSNo)
                {
                    success = false;
                }
            }
            if (success)
            {
                ForceService.Add(forceService);
            }
            return(success);
        }
コード例 #8
0
        public IDisplay GetItem(string sType)
        {
            IDisplay res;

            if (sType == "A")
            {
                Applicant app = (Applicant)cboApplicants.SelectedItem;
                res = app;
            }

            else
            {
                ForceService fServe = (ForceService)cboForceServices.SelectedItem;
                res = fServe;
            }

            return(res);
        }
コード例 #9
0
        // return the strings that containing all the Result data
        public string Display()
        {
            string msg;
            string CR = Environment.NewLine;

            msg = String.Format("{0} Applicant Result {1} ", CR, CR);

            // Be sure if the ResultInput is not entered yet
            if (ResultInputs.Count < 0)
            {
                msg += String.Format(" (no entries yet) {0}", CR);
            }
            else
            {
                foreach (ResultInput ri in ResultInputs)
                {
                    ForceService s = ri.ForceService;
                    msg += String.Format(" ForceService: {0} {1}", s.FSNo, CR);

                    msg += String.Format(" FSCredits: {0} {1}", s.FSCredits, CR);

                    // add the result passed to the Grade
                    if (ri.Grade >= AppData.PASSMARK)
                    {
                        msg += String.Format(" Mark: {0} *** Approved TO MILITARY SCHOOL**** {1}", ri.Grade, CR);
                    }
                    else
                    {
                        msg += String.Format(" Mark: {0} ** Fail ** {1}", ri.Grade, CR);
                    }
                }
                // collect and add the actual scores
                msg += String.Format(" {0} Total mark earned: {1} {2} ", CR, GetTotalGrade(), CR);
            }
            // check to see the applicant have enough mark to proceed
            if (GetTotalGrade() >= AppData.MAXCREDITS)
            {
                msg += String.Format(" *** Applicant has bee Approved for Program *** {0}", CR);
            }
            return(msg);
        }
コード例 #10
0
 // Remove forceService from attends List. Applicant has either
 // passed the forceService or has unenrolled from it
 public void DropForceService(ForceService forceService)
 {
     EnrolledOn.Remove(forceService);
 }
コード例 #11
0
 // Add ForceService to List Applicant's result
 public void AddForceService(ForceService forceService)
 {
     EnrolledOn.Add(forceService);
 }
コード例 #12
0
        /// <summary>
        /// Get data from visual controls and instantiates a new ForceService object
        /// </summary>
        /// <returns> a ForceService object</returns>

        public ForceService GetForceServiceData()
        {
            ForceService newForceService = new ForceService(txtFirst.Text, lblSecond.Text, lblThird.Text, txtFourth.Text, txtFive.Text);

            return(newForceService);
        }
コード例 #13
0
        /// <summary>
        /// Code which can be used to generate data for Military Recruitment if
        /// the data fill becomes lost or corrupted
        /// </summary>
        public void GenerateTestData()
        {
            // Instantiate Applicant object
            Applicant a1 = new Applicant("100", "Mamsol Riches", "AirForce Officer", "15 Riverside avenue dh4 5lm", " [email protected]");
            Applicant a2 = new Applicant("300", "David Cameroon", "Army Cadet Officer", "27 Adelaide Avenu, Newcastle ne1 5tr", " [email protected]");
            Applicant a3 = new Applicant("500", "Goodluck Jonathan", "AirForce Officer", "104 Port arthur road, Nothingham ng2 4lt", " [email protected]");
            Applicant a4 = new Applicant("700", "Richard Mark", "Naval Force Officer", "11 Macdonals street, Hartlepool ts26 5rm ", " [email protected]");
            Applicant a5 = new Applicant("900", "Solomon Olutunde", "AirForce supretendent Officer", "301 ramson Noal Road, Surerest Sunderland sr2 6de", " [email protected]");
            Applicant a6 = new Applicant("1900", "Okonko Malik", "Army Officer", "101 Julios Mountain Avenue, London se18 6dy", " [email protected]");
            Applicant a7 = new Applicant("3200", "Janet Laurell", "Naval Force supretendent Officer", "301 ramson Noal Road, Surerest Sunderland sr2 6de", " [email protected]");
            Applicant a8 = new Applicant("1100", "Write Harmmer", "AirForce supretendent Officer", "3003 ramson Lord Road, Surerest Sunderland sr17 9de", " [email protected]");
            Applicant a9 = new Applicant("2300", "John Kerry", "Army Officer  Officer", "277 Malifax Addex Road, Surerest Sunderland sr22 8ae", " [email protected]");

            applicantList.AddApplicant(a1);
            applicantList.AddApplicant(a2);
            applicantList.AddApplicant(a3);
            applicantList.AddApplicant(a4);
            applicantList.AddApplicant(a5);
            applicantList.AddApplicant(a6);
            applicantList.AddApplicant(a7);
            applicantList.AddApplicant(a8);
            applicantList.AddApplicant(a9);

            // Instantiate ForceService object

            ForceService s1 = new ForceService("MR1001", "Logical Reasoning", " 30 ", "Right Philip", " [email protected]");
            ForceService s2 = new ForceService("MR1002", "Abstract Reasoning", "60", "James Cook", " [email protected]");
            ForceService s3 = new ForceService("MR1004", "Running Exercise", "40", "Tommy Jerry", "*****@*****.**");
            ForceService s4 = new ForceService("MR1006", "Communication Test", "60", "Lord Luggard", "*****@*****.**");
            ForceService s5 = new ForceService("MR1008", "Swimming Skill Test", "40", "Deep.Seewood", "*****@*****.**");
            ForceService s6 = new ForceService("MR2009", "Long Walk Test", "20", "Maggic Johnson", "*****@*****.**");
            ForceService s7 = new ForceService("MR2005", "Road Mapping Test", "40", "Marggor Lyrics", "*****@*****.**");
            ForceService s8 = new ForceService("MR2007", "GIS Management", "20", "Manny Lorrell", "*****@*****.**");
            ForceService s9 = new ForceService("MR2008", "GIS Management", "20", "Danny Maxorrell", "*****@*****.**");

            forceServiceList.AddForceService(s1);
            forceServiceList.AddForceService(s2);
            forceServiceList.AddForceService(s3);
            forceServiceList.AddForceService(s4);
            forceServiceList.AddForceService(s5);
            forceServiceList.AddForceService(s6);
            forceServiceList.AddForceService(s7);
            forceServiceList.AddForceService(s8);
            forceServiceList.AddForceService(s9);


            // Enrol some Applicant into the Military Recruitment Force Services
            s1.Enrol(a1);
            s2.Enrol(a1);
            s3.Enrol(a1);

            s2.Enrol(a2);
            s3.Enrol(a2);
            s4.Enrol(a2);

            s5.Enrol(a3);
            s6.Enrol(a3);

            s5.Enrol(a4);
            s8.Enrol(a5);
            s2.Enrol(a7);

            s9.Enrol(a1);
            s1.Enrol(a9);
            s2.Enrol(a8);

            // Enter some Grade for Applicants on ForceService Examination
            s1.EnterMark(a1, 40);
            s2.EnterMark(a2, 30);
            s3.EnterMark(a3, 40);
        }