private void GetOperators() { DeserializeXml dx = new DeserializeXml(); Trainees = dx.DeserializePersons(); DateTreeView dv = new DateTreeView(); if (Trainees != null) { var listOperator = dv.GetDates(Trainees); BindTree(listOperator); } }
private void ShowTraineesList(object sender) { var types = ((TreeView)sender).SelectedItem; DeserializeXml dx = new DeserializeXml(); PersonAndDbidsOperators allTrainees = dx.DeserializePersons(); DateTreeView dv = new DateTreeView(); if (types != null) { TrainingDate traningDate = types as TrainingDate; if (traningDate != null) { var traineesByDate = allTrainees.Persons.Where(p => p.LastTrainedDate.Equals(traningDate.DateOfTraining)).Select(p => p).ToList(); GetTrainees(traineesByDate); lbxTrainee.ItemsSource = TraineeByDate; } } }
private void SaveTrainee() { try { if (cbxPolicyAgreement.IsChecked == true) { bool isExist = false; Person = new PersonAndDbidsOperators.Person(); PersonAndDbidsOperators.Person personExist = new PersonAndDbidsOperators.Person(); string date = DateTime.Now.ToShortDateString(); string birth = dpkDateOfBirth.SelectedDate.ToString(); string pid = SetPID(); string filename = string.Format(@"Images\{0}{1}{2}.jpg", txtLastName.Text, txtFirstName.Text.Substring(0, 1), pid.Substring(pid.Length - 4, 4)); if (Operators != null) { foreach (PersonAndDbidsOperators.Person person in Operators.Persons) { if (pid == person.PID) { isExist = true; personExist = person; } } } else { Operators = new PersonAndDbidsOperators(); Operators.Persons = new List<PersonAndDbidsOperators.Person>(); } Person.PID = pid; Person.LastName = txtLastName.Text; Person.MobilePhone = string.Format("{0}-{1}-{2}", cbxMobilePhoneArea.SelectedValue, txtMobilePhonePrefix.Text, txtMobilePhoneNumber.Text); Person.FirstName = txtFirstName.Text; Person.MiddleName = txtMiddleName.Text; Person.DateOfBirth = birth; Person.Gender = cbxGender.SelectedValue.ToString(); Person.OfficePhone = string.Format("{0}-{1}-{2}", cbxOfficePhoneArea.SelectedValue, txtOfficePhonePrefix.Text, txtOfficePhoneNumber.Text); //Person.Fax = string.Format("{0}-{1}-{2}", cbxFaxArea.SelectedValue, txtFaxPrefix.Text, txtFaxNumber.Text); Person.Photo = filename; if (cbxEmailServer.SelectedValue.ToString() != "** Manual Input **") Person.Email = string.Format("{0}@{1}", txtEmail.Text, cbxEmailServer.SelectedValue); else Person.Email = txtEmail.Text; Person.ServiceType = cbxService.SelectedValue.ToString(); Person.RankID = cbxRank.SelectedValue.ToString(); Person.OfficeCode = cbxOffice.SelectedValue.ToString(); Person.TypeOfPID = cbxTypeOfPID.SelectedValue.ToString(); Person.RegDate = date; Person.JobTitle = txtJobTitle.Text; Person.PersonRemarks = txtPRRemarks.Text; Person.OperatorType = cbxOperatorType.SelectedValue.ToString(); Person.LastTrainedDate = date; Person.Installation = cbxInstallation.SelectedValue.ToString(); Person.Nationality = cbxNationality.SelectedValue.ToString(); Person.isPolicyAgree = cbxPolicyAgreement.IsChecked.ToString(); //if (cbxPolicyAgreement.IsChecked == true) // Person.isPolicyAgree = "true"; //else // Person.isPolicyAgree = "false"; if (isExist) { Operators.Persons.Remove(personExist); } if (imgDBIDSOperator.Source != null) SaveImage(Person.LastName, Person.FirstName, pid, filename); Operators.Persons.Add(Person); SerializeXml sx = new SerializeXml(); sx.WriteXml(Operators); if (string.IsNullOrEmpty(Person.MiddleName)) MessageBox.Show(string.Format("{0}, {1}'s information has been saved.", txtLastName.Text, txtFirstName.Text)); else MessageBox.Show(string.Format("{0}, {1} {2}'s information has been saved.", txtLastName.Text, txtFirstName.Text, txtMiddleName.Text)); GetOperators(); } else { MessageBox.Show("You should agree with the privacy information policy"); cbxPolicyAgreement.Background = Brushes.Red; } } catch (Exception ex) { if (string.IsNullOrEmpty(Person.MiddleName)) MessageBox.Show(string.Format("{0}, {1}'s information couldn't saved. /n{2}", txtLastName.Text, txtFirstName.Text, ex.ToString())); else MessageBox.Show(string.Format("{0}, {1} {2}'s information couldn't saved. /n{3}", txtLastName.Text, txtFirstName.Text, txtMiddleName.Text, ex.ToString())); } finally { DeserializeXml dx = new DeserializeXml(); Operators = dx.DeserializePersons(); } }
private void InitializeComboBox() { DeserializeXml dx = new DeserializeXml(); OtherOptions otherOptions = dx.DeserializeOtherOptions(); CountriesNameOptions cnOptions = dx.DeserializeCountry(); RankServiceOptions rsOptions = dx.DeserializeRank(); PersonalInfoOptions piOptions = dx.DeserialzeObject(); InstallationNameOptions inOptions = dx.DeserializeInstallation(); Operators = dx.DeserializePersons(); EmailList = otherOptions.EmailServerOptions; ; cbxService.ItemsSource = rsOptions.RankOptions.Select(ro => ro.Service).Distinct(); cbxTypeOfPID.ItemsSource = piOptions.IDTypeOptions; cbxTypeOfPID.DisplayMemberPath = "IDType"; cbxTypeOfPID.SelectedValuePath = "Value"; cbxNationality.ItemsSource = cnOptions.CountriesOptions; cbxNationality.DisplayMemberPath = "Name"; cbxNationality.SelectedValuePath = "Code"; cbxGender.ItemsSource = piOptions.GenderOptions; cbxGender.DisplayMemberPath = "Gender"; cbxGender.SelectedValuePath = "Value"; //cbxService.ItemsSource = rsOptions.RankOptions.Select(ro => ro.Service).Distinct(); cbxOperatorType.ItemsSource = otherOptions.OperatorOptions; cbxOperatorType.DisplayMemberPath = "Operator"; cbxOperatorType.SelectedValuePath = "Value"; cbxEmailServer.ItemsSource = otherOptions.EmailServerOptions; cbxEmailServer.DisplayMemberPath = "EmailServer"; cbxEmailServer.SelectedValuePath = "Value"; cbxMobilePhoneArea.ItemsSource = piOptions.MobilePhoneCodes; cbxMobilePhoneArea.DisplayMemberPath = "MobilePhone"; cbxMobilePhoneArea.SelectedValuePath = "Value"; cbxOfficePhoneArea.ItemsSource = piOptions.PhoneAreaCodes; cbxOfficePhoneArea.DisplayMemberPath = "PhoneArea"; cbxOfficePhoneArea.SelectedValuePath = "Value"; //cbxFaxArea.ItemsSource = piOptions.PhoneAreaCodes; //cbxFaxArea.DisplayMemberPath = "PhoneArea"; //cbxFaxArea.SelectedValuePath = "Value"; cbxInstallation.ItemsSource = inOptions.InstallationOptions.OrderBy(i => i.InstallationName); cbxInstallation.DisplayMemberPath = "InstallationName"; cbxInstallation.SelectedValuePath = "InstallationCode"; // Set the Default value of the combo box cbxService.SelectedValue = "KSG"; cbxNationality.SelectedValue = "KR"; cbxGender.SelectedIndex = 0; cbxOperatorType.SelectedIndex = 1; cbxEmailServer.SelectedIndex = 7; cbxMobilePhoneArea.SelectedIndex = 0; cbxOfficePhoneArea.SelectedIndex = 0; cbxTypeOfPID.SelectedIndex = 0; //cbxFaxArea.SelectedIndex = 0; cbxInstallation.SelectedIndex = 11; dpkDateOfBirth.DisplayDate = DateTime.Now.AddYears(-25); imgDBIDSOperator.Source = ShowPhoto(@"XMLData\Photos.png"); GetOffices(); }
private void ShowTraineesList(object sender) { var dates = ((ComboBox)sender).SelectedItem; DeserializeXml dx = new DeserializeXml(); PersonAndDbidsOperators allTrainees = dx.DeserializePersons(); DateTreeView dv = new DateTreeView(); if (dates != null) { TrainingDate traningDate = dates as TrainingDate; if (traningDate != null) { var traineesByDate = allTrainees.Persons.Where(p => p.LastTrainedDate.Equals(traningDate.DateOfTraining)).Select(p => p).ToList(); GetTrainees(traineesByDate); //lbxTraineeList.ItemsSource = TraineeBySelectedDate; dgdFindPersonList.ItemsSource = TraineeBySelectedDate; txbNoOfTrainees.Text = traineesByDate.Count.ToString(); } } }
// Get Operators private void GetOperators() { DeserializeXml dx = new DeserializeXml(); Operators = dx.DeserializePersons(); DateTreeView dv = new DateTreeView(); if (Operators != null) { var dateList = dv.GetDates(Operators); BindTree(dateList); } }