Пример #1
0
        public bool UpdateDbidsOperator(Trainee trainee)
        {
            // update dbids operator
            try
            {
                secdivDataContext db = new secdivDataContext();
                var dbidsOperators = db.DbidsOperators.Where(d => d.PID.Equals(trainee.PID));

                if (dbidsOperators.Count() > 0)
                {
                    DbidsOperator dbidsOperator = dbidsOperators.First();
                    dbidsOperator.OperatorType = trainee.OperatorType;
                    dbidsOperator.LastTrainedDate = trainee.LastTrainedDate;

                    db.SubmitChanges();
                    return true;
                }
                else
                    return false;
            }
            catch
            {
                return false;
            }
        }
Пример #2
0
        public bool UpdatePerson(Trainee trainee)
        {
            // update person
            try
            {
                secdivDataContext db = new secdivDataContext();
                var persons = db.Persons.Where(p => p.PID.Equals(trainee.PID));

                if (persons.Count() > 0)
                {
                    Person person = persons.First();
                    person.LastName = trainee.LastName;
                    person.FirstName = trainee.FirstName;
                    person.MiddleName = trainee.MiddleName;
                    person.TypeOfPID = trainee.TypeOfPID;
                    person.EMail = trainee.Email;
                    person.JobTitle = trainee.JobTitle;
                    person.OFFICECODE = trainee.OfficeCode;
                    person.HomePhone = trainee.HomePhone;
                    person.MobilePhone = trainee.MobilePhone;
                    person.Gender = trainee.Gender;
                    person.DateOfBirth = trainee.DateOfBirth;
                    person.PersonStatus = "Current";
                    person.OfficePhone = trainee.OfficePhone;
                    person.Fax = trainee.Fax;
                    person.Photo = trainee.Photo;
                    person.RankID = trainee.RankID;

                    db.SubmitChanges();
                    return true;
                }
                else
                    return false;
            }
            catch
            {
                return false;
            }
        }
Пример #3
0
        public bool UpdatePersonDetail(Trainee trainee)
        {
            // update person details
            try
            {
                secdivDataContext db = new secdivDataContext();
                var personDetails = db.PersonDetails.Where(pd => pd.PID.Equals(trainee.PID));

                if (personDetails.Count() > 0)
                {
                    PersonDetail detailPerson = personDetails.First();
                    detailPerson.CountryCode = trainee.Nationality;

                    db.SubmitChanges();
                    return true;
                }
                else
                    return false;
            }
            catch
            {
                return false;
            }
        }
Пример #4
0
        public bool UpdateUserAccount(Trainee trainee)
        {
            // update user account
            try
            {
                string userName = string.Format("{0}{1}{2}", trainee.LastName, trainee.FirstName.Substring(0, 1), trainee.PID.Substring(trainee.PID.Length - 4, 4));
                string password = string.Format("{0}{1}", trainee.LastName, trainee.PID.Substring(trainee.PID.Length - 4, 4));
                byte[] passwd = DataHash.GetHashData(password, "SHA1");

                secdivDataContext db = new secdivDataContext();
                var userAccounts = db.UserAccounts.Where(u => u.PID.Equals(trainee.PID));

                if (userAccounts.Count() > 0)
                {
                    UserAccount userAccount = userAccounts.First();
                    if (userAccount.UserName == userName)
                    {
                        userAccount.Password = passwd;
                        userAccount.PID = trainee.PID;
                        userAccount.TypeOfUser = trainee.OperatorType;
                        userAccount.UAStatus = "Current";

                        db.SubmitChanges();
                        return true;
                    }
                    else
                    {
                        UserAccount ua = new UserAccount
                        {
                            UserName = userName,
                            Password = passwd,
                            PID = trainee.PID,
                            TypeOfUser = trainee.OperatorType,
                            UAStatus = "Current"
                        };

                        db.UserAccounts.InsertOnSubmit(ua);
                        db.SubmitChanges();
                        return true;
                    }
                }
                else
                    return false;
            }
            catch
            {
                return false;
            }
        }
Пример #5
0
        public bool UpdateDbidsCertificate(Trainee trainee)
        {
            try
            {
                secdivDataContext db = new secdivDataContext();
                var dbidsCertificates = db.DbidsCertificates.Where(d => d.OperatorPID.Equals(trainee.PID));
                string remarks = string.Format("{0}. - Update thru trainee registration program", trainee.PersonRemarks);

                if (dbidsCertificates.Count() > 0)
                {
                    DbidsCertificate dbidsCertificate = dbidsCertificates.First();
                    dbidsCertificate.CertificateStatus = "Current";
                    dbidsCertificate.CertificateRemarks = remarks;
                    dbidsCertificate.CertificateUpdatedDate = trainee.LastTrainedDate;
                    dbidsCertificate.CertificateExpiredDate = trainee.LastTrainedDate.AddYears(1);

                    db.SubmitChanges();
                    return true;
                }
                else
                    return false;
            }
            catch
            {
                return false;
            }
        }
Пример #6
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);
            }
        }
Пример #7
0
 // Remove trainee data from XML
 private void RemoveTraineeFromXML(Trainee trainee, bool isSuccess)
 {
     var trainedPerson = Trainees.Persons.Where(p => p.PID.Equals(trainee.PID)).Select(p => p).First();
     if (File.Exists(trainedPerson.Photo))
     {
         try
         {
             File.Delete(trainedPerson.Photo);
         }
         catch
         {
             MessageBox.Show(string.Format("{0}'s photo couldn't remove.", trainedPerson.LastName), "Image File Delete", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     Trainees.Persons.Remove(trainedPerson);
     TraineeToUpload.Remove(trainee);
 }
Пример #8
0
 public void RemoveTraineeFromXML(object sender, Trainee trainee, bool isSuccess)
 {
     Dispatcher.Invoke(new RemoveTraineeFromXMLDelegate(RemoveTraineeFromXML), trainee, isSuccess);
 }