예제 #1
0
        protected void search_Click(object sender, EventArgs e)
        {
            ManagementService service = new ManagementService();
            ManagementService.Job job = service.GetJobInfo(firstName.Text, lastName.Text);

            if (job == null)
            {
                result.Text = "Not Found";
            }

            else
            {
                result.Text = job.ToString();
            }
        }
예제 #2
0
        protected void save_Click(object sender, EventArgs e)
        {
            // Clear the old validation
            postCodeError.Text = "";
            generalErrorLbl.Text = "";

            // First check the postcode matches the state
            AusPostcodeValidationService postCodeValidator = new AusPostcodeValidationService();
            int postCode = Convert.ToInt32(postcode.Text);

            if (!postCodeValidator.PostcodeValidation(postCode, state.Text))
            {
                postCodeError.Text = "postcode does not match state";
                return;
            }

            ManagementService service = new ManagementService();
            bool result = false;
            try
            {
                result = service.SaveInfo(firstName.Text, lastName.Text, Convert.ToDateTime(dateBirth.Text),
                                 email.Text, street.Text, suburb.Text, state.Text, Convert.ToInt32(postcode.Text),
                                 new ManagementService.Job()
                                 {
                                     PositionNumber = Convert.ToInt32(jobPos.Text),
                                     PositionDescription = jobDesc.Text,
                                     PositionTitle = jobTitle.Text,
                                     CompanyName = companyName.Text
                                 });
            }
            catch (Exception excep)
            {
                // catch format errors
                generalErrorLbl.Text = "Could not save: " + excep.Message;
                return;
            }

            if (result)
            {
                generalErrorLbl.Text = "Saved successfully";
            }
            else
            {
                // catch service errors
                generalErrorLbl.Text = "Could not save";
            }
        }
        protected void search_Click(object sender, EventArgs e)
        {
            ManagementService service = new ManagementService();
            List<ManagementService.Person> people = service.GetColleagues(firstName.Text, lastName.Text);

            if (people == null || people.Count == 0)
            {
                result.Text = "Not Found";
            }

            else
            {
                StringBuilder resultString = new StringBuilder();
                foreach (ManagementService.Person person in people)
                {
                    resultString.AppendLine(person.ToString());
                }
                result.Text = resultString.ToString();
            }
        }
        public bool SaveInfo(string firstName, string lastName, DateTime dateOfBirth, string email, string streetAddress,
            string suburb, string state, int postcode, ManagementService.Job job)
        {
            StreamWriter personWriter = File.AppendText(PERSON_PATH);
            StreamWriter jobWriter = File.AppendText(JOB_PATH);

            string personRecord = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}",
                firstName, lastName, dateOfBirth, email, streetAddress, suburb, state, postcode, job.PositionNumber);

            string jobRecord = String.Format("{0},{1},{2},{3}",
                job.PositionNumber, job.PositionTitle, job.PositionDescription, job.CompanyName);

            try
            {
                personWriter.WriteLine(personRecord);
                personWriter.Close();
                jobWriter.WriteLine(jobRecord);
                jobWriter.Close();
            }
            catch
            {
                return false;
            }

            return true;
        }