コード例 #1
0
        private void OnAutomaticPlacement(object obj)
        {
            List<BanJiSummaryModel> banjiSummary = new List<BanJiSummaryModel>();
            List<BanJiSummaryModel> currencybanjiSummary = new List<BanJiSummaryModel>();
            Services.BanJiServicesClient service = new Services.BanJiServicesClient();
            string result = service.BanJiSummary(SystemConfig.CurrentYear);
            banjiSummary = JsonConvert.DeserializeObject<List<BanJiSummaryModel>>(result);
            foreach (DataRow dr in DataList.Rows)
            {
                if (!string.IsNullOrEmpty(dr["班级编号"].ToString()))
                {
                    string ksh = dr["考生号"].ToString();
                    int zyId = int.Parse(dr["录取专业ID"].ToString());
                    string xbdm = dr["性别代码"].ToString();
                    string mzdm = dr["民族代码"].ToString();
                    string sfdm = dr["省份代码"].ToString();
                    double cj = 0;
                    double.TryParse(dr["省份代码"].ToString(), out cj);
                    currencybanjiSummary = banjiSummary.FindAll(r => r.Zyid == zyId);
                    if (currencybanjiSummary.Count == 0)
                    {
                        ModernDialog.ShowMessage(string.Format("没有找到 {0} 专业对应的班级信息", ksh), "消息", System.Windows.MessageBoxButton.OK);
                        break;
                    }
                    #region 开始分班
                    BanJiSummaryModel banji = new BanJiSummaryModel();
                    if (currencybanjiSummary.Count == 1)
                    {
                        //只有一个班级,直接分配
                        banji = currencybanjiSummary.First();
                    }
                    else
                    {
                        for (int i = 1; i <= 6; i++)
                        {
                            switch (i)
                            {
                                case 1:
                                    {
                                        ////分配到总人数最少的班级
                                        currencybanjiSummary = currencybanjiSummary.OrderBy(r => r.Zrs).ToList();
                                        //如果前两条记录总人数相同则所有班级总人数已相同,则进入下次循环
                                        if (currencybanjiSummary[0].Zrs == currencybanjiSummary[1].Zrs) continue;
                                        else
                                        {
                                            banji = currencybanjiSummary.First();
                                            break;
                                        }
                                    };
                                case 2:
                                    {
                                        if (xbdm == "1")
                                        {
                                            currencybanjiSummary = currencybanjiSummary.OrderBy(r => r.Nansrs).ToList();
                                            if (currencybanjiSummary[0].Nansrs == currencybanjiSummary[1].Nansrs) continue;
                                            else
                                            {
                                                banji = currencybanjiSummary.First();
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            currencybanjiSummary = currencybanjiSummary.OrderBy(r => r.Nsrs).ToList();
                                            if (currencybanjiSummary[0].Nsrs == currencybanjiSummary[1].Nsrs) continue;
                                            else
                                            {
                                                banji = currencybanjiSummary.First();
                                                break;
                                            }
                                        }

                                    };
                                case 3:
                                    {
                                        if (mzdm != "01")
                                        {
                                            ////分配到少数民族人数最少的班级
                                            currencybanjiSummary = currencybanjiSummary.OrderBy(r => r.Ssmzrs).ToList();
                                            //如果前两条记录总人数相同则所有班级总人数已相同,则进入下次循环
                                            if (currencybanjiSummary[0].Ssmzrs == currencybanjiSummary[1].Ssmzrs) continue;
                                            else
                                            {
                                                banji = currencybanjiSummary.First();
                                                break;
                                            }
                                        }
                                        else continue;
                                    };
                                case 4:
                                    {
                                        if (sfdm != "51")
                                        {
                                            ////分配到省外人数最少的班级
                                            currencybanjiSummary = currencybanjiSummary.OrderBy(r => r.Swrs).ToList();
                                            //如果前两条记录总人数相同则所有班级总人数已相同,则进入下次循环
                                            if (currencybanjiSummary[0].Swrs == currencybanjiSummary[1].Swrs) continue;
                                            else
                                            {
                                                banji = currencybanjiSummary.First();
                                                break;
                                            }
                                        }
                                        else continue;
                                    };
                                case 5:
                                    {
                                        ////分配到总成绩人数最少的班级
                                        currencybanjiSummary = currencybanjiSummary.OrderBy(r => r.Zfs).ToList();
                                        //如果前两条记录总人数相同则所有班级总人数已相同,则进入下次循环
                                        if (currencybanjiSummary[0].Zfs == currencybanjiSummary[1].Zfs) continue;
                                        else
                                        {
                                            banji = currencybanjiSummary.First();
                                            break;
                                        }
                                    };
                                case 6:
                                    {
                                        //到最后一步 直接分到第一个班级
                                        banji = currencybanjiSummary.First();
                                    }; break;
                            }
                        }
                    }
                    //写入到界面
                    dr["班级编号"] = banji.Bjbh;
                    dr["班级名称"] = banji.Bjmc;
                    dr["是否修改"] = true;
                    banji.Zfs++;
                    if (xbdm == "1") banji.Nansrs++; else banji.Nsrs++;
                    if (mzdm != "01") banji.Ssmzrs++;
                    if (sfdm != "51") banji.Swrs++;
                    banji.Zfs += cj;
                    #endregion
                }
            }


        }
コード例 #2
0
 private void RefreshBanJi()
 {
     Services.BanJiServicesClient service = new Services.BanJiServicesClient();
     string banji = service.BanJiSummary(SystemConfig.CurrentYear);
     BanJiList = JsonConvert.DeserializeObject<List<BanJiSummaryModel>>(banji);
     service.Close();
 }