///<summary>
        ///</summary>
        ///<param name="TraineeApplicationID"></param>
        ///<returns></returns>
        public TraineeApplication GetTraineeApplicationByTraineeApplicationID(int TraineeApplicationID)
        {
            TraineeApplication app = new TraineeApplication();
            SqlCommand         cmd = new SqlCommand();

            cmd.Parameters.Add(_PKID, SqlDbType.Int).Value = TraineeApplicationID;
            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetTrainApplicationByPKID", cmd))
            {
                while (sdr.Read())
                {
                    app.PKID                         = TraineeApplicationID;
                    app.CourseName                   = (sdr[_DBCourseName]).ToString();
                    app.Applicant                    = new Account();
                    app.Applicant.Id                 = Convert.ToInt32(sdr[_DBApplicationId]);
                    app.TrainType                    = TrainScopeType.GetById(Convert.ToInt32(sdr[_DBTrainType]));
                    app.Trainer                      = (sdr[_DBTrainer]).ToString();
                    app.Skills                       = (sdr[_DBSkills]).ToString();
                    app.StratTime                    = Convert.ToDateTime(sdr[_DBStratTime]);
                    app.EndTime                      = Convert.ToDateTime(sdr[_DBEndTime]);
                    app.TrainPlace                   = (sdr[_DBTrianPlace]).ToString();
                    app.TrainOrgnatiaon              = (sdr[_DBTrainOrgnatiaon]).ToString();
                    app.TrainHour                    = Convert.ToInt32(sdr[_DBTrainHour]);
                    app.TrainCost                    = Convert.ToInt32(sdr[_DBTrainCost]);
                    app.EduSpuCost                   = HrmisUtility.ConvertToDecimal(sdr[_DbEduSpuCost]);
                    app.HasCertifacation             = (Convert.ToInt32(sdr[_DBHasCertification])).Equals(1);
                    app.NextStep                     = new DiyStep(Convert.ToInt32(sdr[_DBNextStepIndex]));
                    app.TraineeApplicationStatuss    = TraineeApplicationStatus.FindTraineeApplicationStatus(Convert.ToInt32(sdr[_DBApplicationStatus]));
                    app.TraineeApplicationDiyProcess = DiyProcessDal.ConvertToObject(sdr[_DbDiyProcess].ToString());
                    app.StudentList                  = GetAppTrainee(TraineeApplicationID);
                    app.TraineeApplicationFlowList   = GetApplicationFlows(TraineeApplicationID);
                }
                return(app);
            }
        }
        /// <summary>
        /// 新增考核活动
        /// </summary>
        public int InsertAssessActivity(AssessActivity obj)
        {
            InitializeTranscation();

            int activityId;

            //insert to main table
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Parameters.Add(_PKID, SqlDbType.Int).Direction                    = ParameterDirection.Output;
                cmd.Parameters.Add(_AssessEmployeeID, SqlDbType.Int).Value            = obj.ItsEmployee.Account.Id;
                cmd.Parameters.Add(_AssessCharacter, SqlDbType.Int).Value             = obj.AssessCharacterType;
                cmd.Parameters.Add(_AssessActivityStatus, SqlDbType.Int).Value        = obj.ItsAssessStatus;
                cmd.Parameters.Add(_ScopeFrom, SqlDbType.DateTime).Value              = obj.ScopeFrom;
                cmd.Parameters.Add(_ScopeTo, SqlDbType.DateTime).Value                = obj.ScopeTo;
                cmd.Parameters.Add(_PersonalGoal, SqlDbType.Text).Value               = obj.PersonalGoal;
                cmd.Parameters.Add(_AssessProposerName, SqlDbType.NVarChar, 50).Value = obj.AssessProposerName;
                cmd.Parameters.Add(_Reason, SqlDbType.Text).Value                     = obj.Reason;
                cmd.Parameters.Add(_Intention, SqlDbType.NVarChar, 50).Value          = obj.Intention;
                cmd.Parameters.Add(_HRConfirmerName, SqlDbType.NVarChar, 50).Value    = obj.HRConfirmerName;
                cmd.Parameters.Add(_PersonalExpectedFinish, SqlDbType.DateTime).Value = obj.PersonalExpectedFinish;
                cmd.Parameters.Add(_ManagerExpectedFinish, SqlDbType.DateTime).Value  = obj.ManagerExpectedFinish;
                cmd.Parameters.Add(_PaperName, SqlDbType.NVarChar, 50).Value          = obj.ItsAssessActivityPaper.PaperName;
                cmd.Parameters.Add(_Score, SqlDbType.Decimal).Value                   = obj.ItsAssessActivityPaper.Score;
                cmd.Parameters.Add(_EmployeeDept, SqlDbType.NVarChar, 50).Value       = obj.EmployeeDept;
                cmd.Parameters.Add(_Responsibility, SqlDbType.NVarChar, 255).Value    = obj.Responsibility;

                cmd.Parameters.Add(_ParmDiyProcess, SqlDbType.Text).Value   = DiyProcessDal.ConvertToString(obj.DiyProcess);
                cmd.Parameters.Add(_ParmNextStepIndex, SqlDbType.Int).Value = obj.NextStepIndex;
                cmd.Parameters.Add(_IfEmployeeVisible, SqlDbType.Int).Value = obj.IfEmployeeVisible;

                SqlHelper.TransExecuteNonQueryReturnPKID("InsertAssessActivity", cmd, _Conn, _Trans, out activityId);
                obj.AssessActivityID = activityId;
                //insert to paper table
                InsertPaperTable(obj);

                _Trans.Commit();
            }
            catch
            {
                _Trans.Rollback();
                throw;
            }
            finally
            {
                _Conn.Close();
            }

            return(activityId);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="accountID"></param>
        /// <returns></returns>
        public DiyProcess GetDiyProcessByProcessTypeAndAccountID(ProcessType type, int accountID)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(_Type, SqlDbType.Int).Value      = type.Id;
            cmd.Parameters.Add(_AccountID, SqlDbType.Int).Value = accountID;
            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetEmployeeDiyProcessByEmployeeIDAndTypeID", cmd))
            {
                while (sdr.Read())
                {
                    DiyProcessDal diyProcessDal = new DiyProcessDal();
                    return(diyProcessDal.GetDiyProcessByPKID((int)sdr[_DBDiyProcessID]));
                }
                return(null);
            }
        }
        /// <summary>
        /// 通过AssessActivity的PKID查找AssessActivity
        /// </summary>
        public AssessActivity GetAssessActivityById(int id)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(_PKID, SqlDbType.Int).Value = id;
            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetAssessActivityById", cmd))
            {
                while (sdr.Read())
                {
                    AssessActivity assessActivity = new AssessActivity();

                    //rechieve from its main table
                    assessActivity.AssessActivityID    = Convert.ToInt32(sdr[_DbPKID]);
                    assessActivity.ItsEmployee         = RechieveEmployee((int)sdr[_DbEmployeeID]);
                    assessActivity.AssessCharacterType = (AssessCharacterType)sdr[_DbAssessCharacter];
                    assessActivity.ItsAssessStatus     = (AssessStatus)sdr[_DbAssessStatus];
                    assessActivity.ScopeFrom           = Convert.ToDateTime(sdr[_DbScopeFrom]);
                    assessActivity.ScopeTo             = Convert.ToDateTime(sdr[_DbScopeTo]);
                    assessActivity.PersonalGoal        = sdr[_DbPersonalGoal].ToString();
                    assessActivity.AssessProposerName  = sdr[_DbAssessProposerName].ToString();
                    assessActivity.Intention           = sdr[_DbIntention].ToString();// RechieveIntention(sdr[_DbIntention].ToString());
                    assessActivity.Reason                 = sdr[_DbReason].ToString();
                    assessActivity.HRConfirmerName        = sdr[_DbHRConfirmerName].ToString();
                    assessActivity.PersonalExpectedFinish = Convert.ToDateTime(sdr[_DbPersonalExpectedFinish]);
                    assessActivity.ManagerExpectedFinish  = Convert.ToDateTime(sdr[_DbManagerExpectedFinish]);
                    assessActivity.ItsAssessActivityPaper = RechievePaper(sdr[_DbPaperName].ToString(), (decimal)sdr[_DbScore]);
                    assessActivity.EmployeeDept           = sdr[_DbEmployeeDept].ToString();
                    assessActivity.Responsibility         = sdr[_DbResponsibility].ToString();
                    assessActivity.NextStepIndex          = Convert.ToInt32(sdr[_DBNextStepIndex]);
                    assessActivity.DiyProcess             = DiyProcessDal.ConvertToObject(sdr[_DbDiyProcess].ToString());
                    if (sdr[_DbIfEmployeeVisible].ToString() == "1")
                    {
                        assessActivity.IfEmployeeVisible = true;
                    }
                    //rechieve from its paper table
                    RechieveItsPaper(assessActivity);
                    //rechieve from tis item table
                    RechieveItsItem(assessActivity.ItsAssessActivityPaper.PaperName, assessActivity);

                    return(assessActivity);
                }
            }
            return(null);
        }
        ///<summary>
        ///</summary>
        ///<param name="traineeName"></param>
        ///<param name="courseName"></param>
        ///<param name="traineeFrom"></param>
        ///<param name="traineeTo"></param>
        ///<param name="hasCertifacation"></param>
        ///<param name="trainScopeEnum"></param>
        ///<param name="statusEnum"></param>
        ///<returns></returns>
        public List <TraineeApplication> GetTraineeApplicationByCondition(string traineeName, string courseName, DateTime?traineeFrom, DateTime?traineeTo, int hasCertifacation, TrainScopeType trainScopeEnum, TraineeApplicationStatus statusEnum)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(_CourseName, SqlDbType.NVarChar, 200).Value = courseName;
            cmd.Parameters.Add(_Trainer, SqlDbType.NVarChar, 50).Value     = traineeName;
            cmd.Parameters.Add(_StratTime, SqlDbType.DateTime).Value       = traineeFrom;
            cmd.Parameters.Add(_EndTime, SqlDbType.DateTime).Value         = traineeTo;
            cmd.Parameters.Add(_TrainType, SqlDbType.Int).Value            = trainScopeEnum.Id;
            cmd.Parameters.Add(_HasCertification, SqlDbType.Int).Value     = hasCertifacation;
            cmd.Parameters.Add(_ApplicationStatus, SqlDbType.Int).Value    = statusEnum.Id;
            using (
                SqlDataReader sdr =
                    SqlHelper.ExecuteReader("GetTrainApplicationByCondition", cmd))
            {
                List <TraineeApplication> apps = new List <TraineeApplication>();
                while (sdr.Read())
                {
                    TraineeApplication app =
                        new TraineeApplication();
                    app.PKID                      = Convert.ToInt32(sdr[_DBPKID]);
                    app.CourseName                = (sdr[_DBCourseName]).ToString();
                    app.Applicant                 = new Account();
                    app.Applicant.Id              = Convert.ToInt32(sdr[_DBApplicationId]);
                    app.TrainType                 = TrainScopeType.GetById(Convert.ToInt32(sdr[_DBTrainType]));
                    app.Trainer                   = (sdr[_DBTrainer]).ToString();
                    app.Skills                    = (sdr[_DBSkills]).ToString();
                    app.StratTime                 = Convert.ToDateTime(sdr[_DBStratTime]);
                    app.EndTime                   = Convert.ToDateTime(sdr[_DBEndTime]);
                    app.TrainPlace                = (sdr[_DBTrianPlace]).ToString();
                    app.TrainOrgnatiaon           = (sdr[_DBTrainOrgnatiaon]).ToString();
                    app.TrainHour                 = Convert.ToInt32(sdr[_DBTrainHour]);
                    app.TrainCost                 = Convert.ToInt32(sdr[_DBTrainCost]);
                    app.EduSpuCost                = HrmisUtility.ConvertToDecimal(sdr[_DbEduSpuCost]);
                    app.HasCertifacation          = (Convert.ToInt32(sdr[_DBHasCertification])).Equals(1);
                    app.NextStep                  = new DiyStep(Convert.ToInt32(sdr[_DBNextStepIndex]));
                    app.TraineeApplicationStatuss =
                        TraineeApplicationStatus.FindTraineeApplicationStatus(Convert.ToInt32(sdr[_DBApplicationStatus]));
                    app.TraineeApplicationDiyProcess = DiyProcessDal.ConvertToObject(sdr[_DbDiyProcess].ToString());
                    apps.Add(app);
                }
                return(apps);
            }
        }
        /// <summary>
        /// »ñÈ¡´ýÉóºËµÄÅàѵÉêÇë
        /// </summary>
        /// <returns></returns>
        public List <TraineeApplication> GetConfimingTraineeApplications()
        {
            SqlCommand cmd = new SqlCommand();

            using (
                SqlDataReader sdr =
                    SqlHelper.ExecuteReader("GetConfirmingTrainApplication", cmd))
            {
                List <TraineeApplication> apps = new List <TraineeApplication>();
                while (sdr.Read())
                {
                    TraineeApplication app =
                        new TraineeApplication();
                    app.PKID                      = Convert.ToInt32(sdr[_DBPKID]);
                    app.CourseName                = (sdr[_DBCourseName]).ToString();
                    app.Applicant                 = new Account();
                    app.Applicant.Id              = Convert.ToInt32(sdr[_DBApplicationId]);
                    app.TrainType                 = TrainScopeType.GetById(Convert.ToInt32(sdr[_DBTrainType]));
                    app.Trainer                   = (sdr[_DBTrainer]).ToString();
                    app.Skills                    = (sdr[_DBSkills]).ToString();
                    app.StratTime                 = Convert.ToDateTime(sdr[_DBStratTime]);
                    app.EndTime                   = Convert.ToDateTime(sdr[_DBEndTime]);
                    app.TrainPlace                = (sdr[_DBTrianPlace]).ToString();
                    app.TrainOrgnatiaon           = (sdr[_DBTrainOrgnatiaon]).ToString();
                    app.TrainHour                 = Convert.ToInt32(sdr[_DBTrainHour]);
                    app.TrainCost                 = Convert.ToInt32(sdr[_DBTrainCost]);
                    app.EduSpuCost                = HrmisUtility.ConvertToDecimal(sdr[_DbEduSpuCost]);
                    app.HasCertifacation          = (Convert.ToInt32(sdr[_DBHasCertification])).Equals(1);
                    app.NextStep                  = new DiyStep(Convert.ToInt32(sdr[_DBNextStepIndex]));
                    app.TraineeApplicationStatuss =
                        TraineeApplicationStatus.FindTraineeApplicationStatus(Convert.ToInt32(sdr[_DBApplicationStatus]));
                    app.TraineeApplicationDiyProcess = DiyProcessDal.ConvertToObject(sdr[_DbDiyProcess].ToString());

                    if (app.TraineeApplicationDiyProcess != null)
                    {
                        app.CurrentStep = app.TraineeApplicationDiyProcess.FindStep(app.NextStep.DiyStepID);
                    }
                    apps.Add(app);
                }
                return(apps);
            }
        }