예제 #1
0
파일: DAL_IMP.cs 프로젝트: acerosen/Final
        public IEnumerable <Trainee> GetAllTrainees(Func <Trainee, bool> predicat = null)
        {
            IEnumerable <Trainee> Trainees;

            try
            {
                Trainees = from p in TraineeRoot.Elements()
                           select new Trainee()
                {
                    ID          = Convert.ToInt32(p.Element("TraineeID").Value),
                    FirstName   = p.Element("FamilyName").Value,
                    FamilyName  = p.Element("FamilyName").Value,
                    Gender      = p.Element("Gender").Value,
                    PhoneNum    = Convert.ToInt32(p.Element("PhoneNum").Value),
                    Address     = p.Element("Address").Value,
                    Birthday    = DateTime.Parse(p.Element("Birthday").Value),
                    Model       = p.Element("Model").Value,
                    GearType    = p.Element("Geartype").Value,
                    School      = p.Element("School").Value,
                    TeacherName = p.Element("TeacherName").Value,
                    LessonAMT   = Convert.ToInt32(p.Element("LessonAmt").Value),
                };

                if (predicat != null)
                {
                    Trainees = Trainees.Where(predicat);
                }
            }
            catch
            {
                Trainees = null;
            }
            return(Trainees);
        }
예제 #2
0
        public BlockTraineeListViewModel(BlockTraineeBussiness bussiness)
        {
            _bussiness = bussiness;
            _bussiness.LoadTraineesEvnet += trainees =>
            {
                Trainees.Clear();
                if (trainees != null)
                {
                    trainees.ForEach(t =>
                    {
                        Trainees.Add(new TraineeViewModel(t, false));
                        Trainees.Last().OperateTraineeEvent += OnOperateTrainee;
                    });
                }
            };

            _bussiness.TraineeChangedEvent += (operation, trainee, newIndex) =>
            {
                switch (operation)
                {
                case OperationType.Add:
                    Trainees.Add(new TraineeViewModel(trainee, false));
                    Trainees.Last().OperateTraineeEvent += OnOperateTrainee;
                    break;

                case OperationType.Update:
                    Trainees.Where(t => t.TraineeID == trainee.TraineeIDForShown).First().TraineeName = trainee.TraineeName;
                    break;

                case OperationType.Delete:
                    Trainees.Remove(Trainees.Where(t => t.TraineeID == trainee.TraineeIDForShown).First());
                    break;
                }
            };
        }
예제 #3
0
 public void AddTrainee(ITrainee trainee)
 {
     if (!Trainees.Contains(trainee))
     {
         Trainees.Add(trainee);
     }
 }
예제 #4
0
        public IEnumerable <Trainee> getAllTrainees(Func <Trainee, bool> predicat = null)
        {
            IEnumerable <Trainee> Trainees;

            try
            {
                Trainees = from p in TraineeRoot.Elements()
                           // where predicat
                           select new Trainee()
                {
                    id           = Convert.ToInt32(p.Element("branchNumber").Value),
                    firstName    = p.Element("First Name").Value,
                    lastName     = p.Element("last Name").Value,
                    phoneNum     = p.Element("PhoneNumber").Value,
                    Adress       = p.Element("Address").Value,
                    birthday     = Convert.ToDateTime(p.Element("Birthday").Value),
                    school       = p.Element("School name").Value,
                    teacher      = p.Element("Teacher name").Value,
                    numOfLessons = Convert.ToInt32(p.Element("number of lessons").Value),
                    transmission = (BE.Transmission)Enum.Parse(typeof(Transmission), p.Element("Transmission").Value),
                    Gender       = (BE.gender)Enum.Parse(typeof(gender), p.Element("Gender").Value)
                };
                if (predicat != null)
                {
                    Trainees = Trainees.Where(predicat);
                }
            }
            catch
            {
                Trainees = null;
            }
            return(Trainees);
        }
예제 #5
0
        public Trainees GetRegisteredTrainees(string training_id)
        {
            Trainees trainees = new Trainees();

            try
            {
                string query = $"select dsto_questionaire.* from dsto_questionaire inner join dsto_Trainee " +
                               $"on dsto_questionaire.guid = dsto_trainee.yref_questionaire " +
                               $"where dsto_Trainee.yref_training ='{training_id}'";
                var table = DbInfo.ExecuteSelectQuery(query);
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        Trainee trainee = trainees.Add();
                        trainee.Questionaire           = new Questionaires().Add();
                        trainee.Questionaire.Key       = row["guid"].ToString();
                        trainee.Questionaire.CreatedBy = row["created_by"].ToString();
                        trainee.Questionaire.OID       = int.Parse(row["OID"].ToString());
                        trainee.Questionaire.Deleted   = bool.Parse(row["deleted"].ToString());
                        trainee.Questionaire.Name      = new SectionProvider(DbInfo).QuestionaireIdentification(row["yref_template"].ToString(), row["guid"].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(trainees);
        }
예제 #6
0
        public Trainees GetTrainees(string training_id)
        {
            Trainees trainees = new Trainees();

            try
            {
                string query = $"select * from dsto_Trainee where yref_training = '{training_id}' and Deleted=0";
                var    table = DbInfo.ExecuteSelectQuery(query);
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        Trainee trainee = trainees.Add();
                        trainee.Key        = Convert.ToString(row["guid"]);
                        trainee.OID        = Convert.ToInt32(row["OID"]);
                        trainee.FarmerKey  = Convert.ToString(row["yref_questionaire"]);
                        trainee.Deleted    = bool.Parse(row["deleted"].ToString());
                        trainee.CreatedBy  = Convert.ToString(row["created_by"]);
                        trainee.TrainingId = Convert.ToString(row["yref_training"]);
                    }
                }
                return(trainees);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #7
0
 private void OnOperateTrainee(OperationType operation, TraineeModel trainee)
 {
     if (operation == OperationType.Select)
     {
         foreach (TraineeViewModel item in Trainees.Where(t => t.TraineeID != trainee.TraineeIDForShown))
         {
             item.ConvertToUnselected();
         }
         return;
     }
     _bussiness.OperateTrainee(operation, trainee);
 }
예제 #8
0
        public RegularTraineeListViewModel(RegularTraineeBussiness bussiness) : base()
        {
            _bussiness = bussiness;
            _bussiness.LoadTraineesEvent += trainees =>
            {
                Trainees.Clear();
                if (trainees != null)
                {
                    trainees.ForEach(t =>
                    {
                        Trainees.Add(new TraineeViewModel(t, true));
                        Trainees.Last().OperateTraineeEvent += OnOperateTrainee;
                    });
                }
            };
            _bussiness.TraineeChangedEvent += (operation, trainee, newIndex) =>
            {
                switch (operation)
                {
                case OperationType.Add:
                    Trainees.Add(new TraineeViewModel(trainee, true));
                    Trainees.Last().OperateTraineeEvent += OnOperateTrainee;
                    break;

                case OperationType.Update:
                    if (newIndex == -1)
                    {    //只是更新信息
                        Trainees.Where(t => t.TraineeID == trainee.TraineeIDForShown).First().TraineeName = trainee.TraineeName;
                    }
                    else
                    {    //删除或者恢复
                        Trainees.Remove(Trainees.Where(t => t.TraineeID == trainee.TraineeIDForShown).First());
                        Trainees.Insert(newIndex, new TraineeViewModel(trainee, true));
                        Trainees[newIndex].OperateTraineeEvent += OnOperateTrainee;
                    }
                    break;

                case OperationType.Delete:
                    Trainees.Remove(Trainees.Where(t => t.TraineeID == trainee.TraineeIDForShown).First());
                    break;
                }
            };
        }