Exemplo n.º 1
0
        /// <summary>
        /// 获取专业信息
        /// </summary>
        private void GetZhuanYe()
        {
            Services.ZhuanYeServicesClient service = new Services.ZhuanYeServicesClient();
            string result = service.ZhuanYeTableQuery();
            var query = JsonConvert.DeserializeObject<List<ZhuanYeModel>>(result);
            service.Close();

            var value = from l in query
                        select new
                        {
                            Code = l.Zdydm,
                            Name = l.Zymc
                        };
            value = value.ToList().Distinct();
            DataTable dt = new DataTable();
            dt.Columns.Add("Code");
            dt.Columns.Add("Name");
            foreach (var item in value)
            {
                DataRow dr = dt.NewRow();
                dr[0] = item.Code;
                dr[1] = item.Name;
                dt.Rows.Add(dr);
            }
            ZhuanYe = dt;
        }
Exemplo n.º 2
0
 protected override void Refresh(object o)
 {
     Services.ZhuanYeServicesClient service = new Services.ZhuanYeServicesClient();
     string result = service.ZhuanYeQuery();
     DataList = JsonConvert.DeserializeObject<DataTable>(result);
     service.Close();
 }
Exemplo n.º 3
0
 public List<ZhuanYeModel> ZhuanYeTableQuery()
 {
     Services.ZhuanYeServicesClient service = new Services.ZhuanYeServicesClient();
     string result = service.ZhuanYeTableQuery();
     service.Close();
     return JsonConvert.DeserializeObject<List<ZhuanYeModel>>(result);
 }
Exemplo n.º 4
0
 protected override void Save(object model)
 {
     if (_ZhuanYe != null)
     {
         if (string.IsNullOrEmpty(_ZhuanYe.YxCode))
         {
             ModernDialog.ShowMessage("专业所属院系不能为空", "消息", MessageBoxButton.OK);
             return;
         }
         if (string.IsNullOrEmpty(_ZhuanYe.Zymc))
         {
             ModernDialog.ShowMessage("专业名称不能为空", "消息", MessageBoxButton.OK);
             return;
         }
         Services.ZhuanYeServicesClient service = new Services.ZhuanYeServicesClient();
         //新增
         if (_ZhuanYe.Id == 0)
         {
             //string result = service.ZhuanYeAdd(_ZhuanYe);
             //ResultEx ex = JsonConvert.DeserializeObject<ResultEx>(result);
             //if (ex.Result)
             //{
             //    ModernDialog.ShowMessage("    新增成功  ", "消息", MessageBoxButton.OK);
             //    BorderVisibility = Visibility.Collapsed;
             //    RefreshCommand.Execute(new object());
             //}
             //else ModernDialog.ShowMessage(ex.Message, "消息", MessageBoxButton.OK);
         }
         //修改
         else
         {
             int i = service.ZhuanYeUpdate(_ZhuanYe);
             if (i > 0)
             {
                 ModernDialog.ShowMessage("    修改成功  ", "消息", MessageBoxButton.OK);
                 BorderVisibility = Visibility.Collapsed;
                 RefreshCommand.Execute(new object());
             }
             else
                 ModernDialog.ShowMessage("    修改失败  ", "消息", MessageBoxButton.OK);
         }
         service.Close();
     }
 }
 /// <summary>
 /// 插入专业信息表
 /// </summary>
 /// <returns></returns>
 private bool InsertZhuanYe()
 {
     try
     {
         SetErrorMsg("正在导入基础专业信息");
         List<ZhuanYeModel> list = DbfHelper.GetList<ZhuanYeModel>(DbfSql.ZhuanYeSql);
         if (list != null)
         {
             //广东考生号只有10位
             string ksh = NewStudents.First().KSH.Trim();
             string year = ksh.Length > 10 ? ksh.Substring(0, 2) : DateTime.Now.Year.ToString().Substring(2, 2);
             Services.ZhuanYeServicesClient zhuanye = new Services.ZhuanYeServicesClient();
             string result = zhuanye.ZhuanYeQuery();
             List<ZhuanYeModel> zhuanyeList = JsonConvert.DeserializeObject<List<ZhuanYeModel>>(result);
             const string pattern = @"(.*?)\((.*?)\)";
             foreach (var item in list)
             {
                 //生成专业方向
                 item.Zymc = item.Zymc.Replace("(", "(").Replace(")", ")");
                 Match match = Regex.Match(item.Zymc, pattern, RegexOptions.IgnoreCase);
                 if (match.Success)
                 {
                     item.Zymc = match.Groups[1].Value;
                     item.Zyfx = match.Groups[2].Value;
                 }
                 item.Sfdm = year;
                 var query = zhuanyeList.Where(r => r.Sfdm == item.Sfdm && r.Pcdm == item.Pcdm && r.Kldm == item.Kldm
                          && r.Jhxz == item.Jhxz && r.Tddw == item.Tddw && r.Zydh == item.Zydh);
                 //如果专业存在就不在添加
                 if (query == null || query.Count() == 0)
                     zhuanye.ZhuanYeAdd(item);
             }
             zhuanye.Close();
             return true;
         }
         else
         {
             ErrorMsg = "没有争取获取录取专业信息";
             return false;
         }
     }
     catch (Exception ex)
     {
         ErrorMsg = ex.Message;
         return false;
     }
 }