Пример #1
0
 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 InitializeComboBox()
        {
            DeserializeXml dx = new DeserializeXml();
            var sortInstallation = dx.DeserializeInstallation().InstallationOptions.OrderBy(si => si.InstallationName);

            cbxInstallationName.ItemsSource = sortInstallation;
            cbxInstallationName.DisplayMemberPath = "InstallationName";
            cbxInstallationName.SelectedValuePath = "InstallationCode";

            cbxInstallationName.SelectedIndex = 0;
            rdbSOSearchByName.IsChecked = true;
        }
Пример #3
0
        private void GetTrainees(List<PersonAndDbidsOperators.Person> operators)
        {
            TraineeByDate = new List<Trainee>();
            Trainee trainee;
            DeserializeXml dx = new DeserializeXml();

            foreach (PersonAndDbidsOperators.Person person in operators)
            {
                DateTime dateOfBirth;
                if (!string.IsNullOrEmpty(person.DateOfBirth))
                    dateOfBirth = DateTime.Parse(person.DateOfBirth);
                else
                    dateOfBirth = DateTime.Now;

                DateTime regDate = DateTime.Parse(person.RegDate);
                DateTime lastTrainedDate = DateTime.Parse(person.LastTrainedDate);
                Byte[] buffer = null;
                ImageConverter ic = new ImageConverter();
                buffer = ic.FromFileToByte(person.Photo);
                var installation = dx.DeserializeInstallation().InstallationOptions.Where(i => i.InstallationCode.Equals(person.Installation)).Select(i => i.InstallationName).First();

                trainee = new Trainee
                {
                    PID = person.PID,
                    LastName = person.LastName,
                    HomePhone = person.HomePhone,
                    MobilePhone = person.MobilePhone,
                    FirstName = person.FirstName,
                    MiddleName = person.MiddleName,
                    DateOfBirth = dateOfBirth,
                    Gender = person.Gender,
                    OfficePhone = person.OfficePhone,
                    Fax = person.Fax,
                    Photo = buffer,
                    Email = person.Email,
                    RankID = int.Parse(person.RankID),
                    OfficeCode = person.OfficeCode,
                    TypeOfPID = person.TypeOfPID,
                    RegDate = regDate,
                    JobTitle = person.JobTitle,
                    PersonRemarks = person.PersonRemarks,
                    OperatorType = person.OperatorType,
                    Installation = person.Installation,
                    InstallationName = installation.ToString(),
                    LastTrainedDate = lastTrainedDate,
                    Nationality = person.Nationality
                };
                TraineeByDate.Add(trainee);
            }
        }
Пример #4
0
        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;
                }
            }
        }
        //Get the information of the installation and put it into the TextBlock
        private void GetInstallationInformation(string installatioName)
        {
            DeserializeXml dx = new DeserializeXml();
            var installtion = dx.DeserializeInstallation().InstallationOptions.Where(i => i.InstallationCode == installatioName);

            foreach (InstallationNameOptions.InstallationNameOption inst in installtion)
            {
                txbInstallationCode.Text = inst.InstallationCode;
                txbArea.Text = inst.Area;
                txbCity.Text = inst.City;
            }
        }
        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();
            }

        }
        // Fill the Rank Combo Box When select a service
        private void ChangeRankComboBox(string typeService)
        {
            DeserializeXml dx = new DeserializeXml();
            var rsServices = dx.DeserializeRank().RankOptions.Where(rs => rs.Service == typeService);

            cbxRank.ItemsSource = rsServices;
            cbxRank.DisplayMemberPath = "RankGrade";
            cbxRank.SelectedValuePath = "RankID";
            cbxRank.SelectedIndex = 0;
        }
        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);
            }
        }