Example #1
0
        /// <summary>
        /// 自动分配学员
        /// </summary>
        /// <returns></returns>
        public string AutoDistributeStudents(string operater)
        {
            //根据教练数量,学员数量平均分配
            //比如:111个学员,10个教练。则每个教练分配:111/10=12(个)学员
            try
            {
                RegistrationBLL bllStu   = new RegistrationBLL();
                CoachBLL        bllCoach = new CoachBLL();

                //得到有效的教练个数
                int coachCount = this.GetRecordCount(" CoachStatus=1");

                //得到还未分配教练的学员个数
                int studentsCount = bllStu.GetDistributeStuRecordCount(@" flag=1  and PeriodsID = (SELECT TOP 1 CurrentPeroidID FROM tb_CurrentPeroid)
                and DistributeStuStatus=0 ");

                int yushu = 0;
                int shoudDistributeCount = Math.DivRem(studentsCount, coachCount, out yushu);
                if (yushu != 0)
                {
                    shoudDistributeCount += 1;
                }
                //int shoudDistributeCount = (studentsCount / coachCount) + 1;

                DataTable dtCoach    = this.GetList(" CoachStatus=1");
                int       startIndex = 0;
                int       endIndex   = shoudDistributeCount;

                for (int i = 0; i < dtCoach.Rows.Count; i++)
                {
                    DataTable dtStudents = bllStu.GetDistributeStuListByPage(@"  flag=1  and PeriodsID = (SELECT TOP 1 CurrentPeroidID FROM tb_CurrentPeroid)
                    and DistributeStuStatus=0 ", "ID", startIndex, endIndex);

                    int  coachID = Int32.Parse(dtCoach.Rows[i]["ID"].ToString());
                    bool result  = AddDistributeStu(coachID, dtStudents, operater);
                }

                return("共有学员" + studentsCount + "个;教练" + coachCount + "个;每个教练分得学员" + shoudDistributeCount + "个.");
            }
            catch
            {
                return("自动分配学员出错,请检查!");
            }
        }
Example #2
0
        /// <summary>
        /// 记录分配车辆情况
        /// </summary>
        /// <param name="vehicleID"></param>
        /// <param name="dtStudents"></param>
        /// <param name="operater"></param>
        /// <returns></returns>
        public string AddDistributeVehicle(int subjectId, string operater)
        {
            //根据车辆数量,学员数量平均分配
            //比如:111个学员,10个车辆。则每个车辆分配:111/10=12(个)学员
            try
            {
                RegistrationBLL bllStu = new RegistrationBLL();

                int vehicleCount = this.GetRecordCount(" Status = 0 and DeleteMark = 0");

                //获得未分车的学员个数

                int studentsCount        = bllStu.GetRecordCount(@" flag=1  and PeriodsID = (SELECT TOP 1 CurrentPeroidID FROM tb_CurrentPeroid) 
                                 and A.DistributeVihicleStatus=0 and SubjectID='" + subjectId + "'");
                int yushu                = 0;
                int shoudDistributeCount = Math.DivRem(studentsCount, vehicleCount, out yushu);
                if (yushu != 0)
                {
                    shoudDistributeCount += 1;
                }
                //int shoudDistributeCount = (studentsCount / coachCount) + 1;

                //获得未分车的学员
                DataTable dtVehicle  = this.GetList(" Status = 0 and DeleteMark = 0"); //0为启用
                int       startIndex = 0;
                int       endIndex   = shoudDistributeCount;
                for (int i = 0; i < dtVehicle.Rows.Count; i++)
                {
                    DataTable dtStudents = bllStu.GetListByPage(@"  flag=1  and PeriodsID = (SELECT TOP 1 CurrentPeroidID FROM tb_CurrentPeroid)
                                      and DistributeVihicleStatus=0  and SubjectID='" + subjectId + "' ", "ID", startIndex, endIndex);

                    int  vehicleID = Int32.Parse(dtVehicle.Rows[i]["Id"].ToString());
                    bool result    = AddDistributeVehicle(vehicleID, subjectId, dtStudents, operater);
                }

                return("共有学员" + studentsCount + "个;车辆" + vehicleCount + "个;每个车辆分得学员" + shoudDistributeCount + "个.");
            }
            catch
            {
                return("自动分配车辆出错,请检查!");
            }
        }