public UpdateStudentViewModel(NewStudentIdModel model)
 {
     Student = model;
     SaveCommand = new DelegateCommand() { ExecuteCommand = new Action<object>(OnSave) };
 }
Пример #2
0
 /// <summary>
 /// 增添数据
 /// </summary>
 /// <param name="model"></param>
 /// <param name="importType">1 完全覆盖,0 只覆盖录取基础数据</param>
 /// <returns></returns>
 public int Add(NewStudentNameModel model, int importType = 0)
 {
     model.DRSJ = DateTime.Now;
     //广东考生考生号为10位
     if (string.IsNullOrEmpty(model.SFDM))
         model.SFDM = model.KSH.Trim().Length > 10 ? model.KSH.Substring(0, 4) : string.Concat(DateTime.Now.Year.ToString().Substring(2, 2), "44");
     //获取专业名称
     List<ZhuanYeModel> zhuanyeList = zhuanyeData.DataList().Where(r => r.Sfdm == model.SFDM.Substring(0, 2) && r.Pcdm == model.PCDM
          && r.Kldm == model.KLDM && r.Jhxz == model.JHXZ && r.Tddw == model.TDDW).ToList();
     if (zhuanyeList != null)
     {
         ZhuanYeModel zhuanyeModel = zhuanyeList.Where(r => r.Zydh == model.LQZY).FirstOrDefault();
         model.ZYID = zhuanyeModel == null ? 0 : zhuanyeModel.Id;
         model.ZYMC = zhuanyeModel == null ? "" : zhuanyeModel.Zymc;
         zhuanyeModel = zhuanyeList.Where(r => r.Zydh == model.ZYDH1).FirstOrDefault();
         model.TDZYMC1 = zhuanyeModel == null ? "" : zhuanyeModel.Zymc;
         zhuanyeModel = zhuanyeList.Where(r => r.Zydh == model.ZYDH2).FirstOrDefault();
         model.TDZYMC2 = zhuanyeModel == null ? "" : zhuanyeModel.Zymc;
         zhuanyeModel = zhuanyeList.Where(r => r.Zydh == model.ZYDH3).FirstOrDefault();
         model.TDZYMC3 = zhuanyeModel == null ? "" : zhuanyeModel.Zymc;
         zhuanyeModel = zhuanyeList.Where(r => r.Zydh == model.ZYDH4).FirstOrDefault();
         model.TDZYMC4 = zhuanyeModel == null ? "" : zhuanyeModel.Zymc;
         zhuanyeModel = zhuanyeList.Where(r => r.Zydh == model.ZYDH5).FirstOrDefault();
         model.TDZYMC5 = zhuanyeModel == null ? "" : zhuanyeModel.Zymc;
         zhuanyeModel = zhuanyeList.Where(r => r.Zydh == model.ZYDH6).FirstOrDefault();
         model.TDZYMC6 = zhuanyeModel == null ? "" : zhuanyeModel.Zymc;
     }
     //构建NewStudentOnlyNameModel对象
     NewStudentOnlyNameModel onlyName = new NewStudentOnlyNameModel()
     {
         KSH = model.KSH,
         XBMC = model.XBMC,
         ZZMMMC = model.ZZMMMC,
         MZMC = model.MZMC,
         KSLBMC = model.KSLBMC,
         DQMC = model.DQMC,
         KLMC = model.KLMC,
         PCMC = model.PCMC,
         LQZYMC = model.ZYMC,
         TDZYMC1 = model.TDZYMC1,
         TDZYMC2 = model.TDZYMC2,
         TDZYMC3 = model.TDZYMC3,
         TDZYMC4 = model.TDZYMC4,
         TDZYMC5 = model.TDZYMC5,
         TDZYMC6 = model.TDZYMC6
     };
     //删除NewStudentName表原数据
     NewStudentNameData newstudentNameData = new NewStudentNameData();
     var newstudent = newstudentNameData.Exist(onlyName);
     foreach (NewStudentOnlyNameModel item in newstudent)
     {
         newstudentNameData.Delete(item.ID);
     }
     newstudentNameData.Add(onlyName);
     //新增新生数据
     var stu = newStudentId.Exist(model);
     if (stu != null && stu.Count > 0)
     {
         //完全覆盖
         if (importType == 1)
         {
             foreach (NewStudentIdModel item in stu)
             {
                 Delete(item);
             }
             NewStudentIdModel idmodel = new NewStudentIdModel();
             foreach (System.Reflection.PropertyInfo property in idmodel.GetType().GetProperties())
             {
                 property.SetValue(idmodel, property.GetValue(model, null), null);
             }
             return newStudentId.Add(idmodel);
         }
         else
         {
             NewStudentIdModel stuModel = stu[0];
             foreach (System.Reflection.PropertyInfo property in stuModel.GetType().GetProperties())
             {
                 if(!notUpdateFields.Contains(property.Name.ToUpper()))
                     property.SetValue(stuModel, property.GetValue(model, null), null);
             }
             return newStudentId.Update(stuModel);
         }
     }
     else
     {
         NewStudentIdModel idmodel = new NewStudentIdModel();
         foreach (System.Reflection.PropertyInfo property in idmodel.GetType().GetProperties())
         {
             property.SetValue(idmodel, property.GetValue(model, null), null);
         }
         return newStudentId.Add(idmodel);
     }
 }
Пример #3
0
 /// <summary>
 /// 删除数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Delete(NewStudentIdModel model)
 {
     return newStudentId.Delete(model.Id);
 }
Пример #4
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(NewStudentIdModel model)
 {
     return newStudentId.Update(model);
 }
 public UpdateNewStudent(NewStudentIdModel model)
 {
     InitializeComponent();
     this.DataContext =new UpdateStudentViewModel(model);
 }