You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1968 lines
75 KiB

  1. using Dapper;
  2. using Learun.Application.Base.AuthorizeModule;
  3. using Learun.Application.Base.SystemModule;
  4. using Learun.Application.Organization;
  5. using Learun.Application.TwoDevelopment.LogisticsManagement;
  6. using Learun.DataBase.Repository;
  7. using Learun.Util;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Text;
  14. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  15. {
  16. /// <summary>
  17. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  18. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  19. /// 创 建:超级管理员
  20. /// 日 期:2019-08-08 17:21
  21. /// 描 述:新生信息管理
  22. /// </summary>
  23. public class StuInfoFreshService : RepositoryFactory
  24. {
  25. #region 构造函数和属性
  26. private string fieldSql;
  27. public StuInfoFreshService()
  28. {
  29. fieldSql = @"
  30. t.ID,
  31. t.NoticeNo,
  32. t.ksh,
  33. t.zkzh,
  34. t.StuNo,
  35. t.StuName,
  36. t.DeptNo,
  37. t.GenderNo,
  38. t.MajorNo,
  39. t.MajorDetailNok,
  40. t.MajorDetailName,
  41. t.Birthday,
  42. t.PartyFaceNo,
  43. t.FamilyOriginNo,
  44. t.NationalityNo,
  45. t.ResidenceNo,
  46. t.TestStuSortNo,
  47. t.HealthStatusNo,
  48. t.WillNo,
  49. t.TestStuSubjectNo,
  50. t.GraduateNo,
  51. t.PlanFormNo,
  52. t.HighTestSortNo,
  53. t.HighAmountScore,
  54. t.PoliticsScore,
  55. t.ChineseScore,
  56. t.MathScore,
  57. t.PhysicsScore,
  58. t.ChemScore,
  59. t.BiologyScore,
  60. t.ForeignLangScore,
  61. t.ForeignLangOralScore,
  62. t.ComprehensiveScore,
  63. t.ForeignLangSpecies,
  64. t.IsThreeGood,
  65. t.IsExcellent,
  66. t.IsNormalCadre,
  67. t.IsProvinceFirstThree,
  68. t.OverseasChineseNo,
  69. t.MatriculateSort,
  70. t.ProvinceNo,
  71. t.HighSchoolNo,
  72. t.RegionNo,
  73. t.Remark,
  74. t.RecruitYearDate,
  75. t.ClassNo,
  76. t.IdentityCardNo,
  77. t.HighSchoolName,
  78. t.GoodAt,
  79. t.ArriveDate,
  80. t.ArchivesNo,
  81. t.telephone,
  82. t.FamilyAddress,
  83. t.RegisterStatus,
  84. t.MailAddress,
  85. t.PostalCode,
  86. t.TransMark,
  87. t.LogIp,
  88. t.LogNum,
  89. t.Logtime,
  90. t.RecruitDeptNo,
  91. t.RecruitMajorNo,
  92. t.RegisterEmpNo,
  93. t.RegisterEmpName,
  94. t.ApprovedLeader,
  95. t.ChangeReason,
  96. t.ChangeDate,
  97. t.TextNo,
  98. t.SignUpTime,
  99. t.OriginAddress,
  100. t.IsAccommodate,
  101. t.HeightWeight,
  102. t.CreateUserId,
  103. t.UpdateUserId,
  104. t.IsPayUniform,
  105. t.IsGetUniform,
  106. t.Grade
  107. ";
  108. }
  109. #endregion
  110. #region 获取数据
  111. /// <summary>
  112. /// 获取列表数据
  113. /// <summary>
  114. /// <returns></returns>
  115. public void SynchronousList()
  116. {
  117. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  118. try
  119. {
  120. List<StuInfoFreshEntity> ListStuInfo = new List<StuInfoFreshEntity>();
  121. List<StuInfoFreshEntity> Model = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>().ToList();
  122. if (Model != null)
  123. {
  124. for (int i = 0; i < Model.Count(); i++)
  125. {
  126. //var IspayList = this.BaseRepository("IsPay").ExecuteBySql($" select * from View_JFdd WHERE XH ='{Model[i].StuNo}' ").ToString().ToList();
  127. //if (IspayList.Count > 0)
  128. //{
  129. // Model[i].PayFeeStatus = "1";
  130. // ListStuInfo.Add(Model[i]);
  131. //}
  132. var IspayList = this.BaseRepository("IsPay").FindTable($" select * from View_JFdd WHERE XH ='{Model[i].StuNo}' ");
  133. if (IspayList.Rows.Count > 0)
  134. {
  135. Model[i].PayFeeStatus = "1";
  136. ListStuInfo.Add(Model[i]);
  137. }
  138. else
  139. {
  140. Model[i].PayFeeStatus = "0";
  141. ListStuInfo.Add(Model[i]);
  142. }
  143. }
  144. this.BaseRepository("CollegeMIS").Update(ListStuInfo);
  145. }
  146. db.Commit();
  147. }
  148. catch (Exception ex)
  149. {
  150. db.Rollback();
  151. if (ex is ExceptionEx)
  152. {
  153. throw;
  154. }
  155. else
  156. {
  157. throw ExceptionEx.ThrowServiceException(ex);
  158. }
  159. }
  160. }
  161. /// <summary>
  162. /// 获取列表数据
  163. /// <summary>
  164. /// <returns></returns>
  165. public IEnumerable<StuInfoFreshEntity> GetList(string queryJson)
  166. {
  167. try
  168. {
  169. //参考写法
  170. var queryParam = queryJson.ToJObject();
  171. //虚拟参数
  172. var dp = new DynamicParameters(new { });
  173. var strSql = new StringBuilder();
  174. strSql.Append("SELECT t.*,d.DeptName,m.MajorName,c.ClassName,b.Name as Bed,r.Name as Room,f.Name as floor,u.Name as Unit,build.Name as Build ");
  175. strSql.Append(" FROM StuInfoFresh t ");
  176. strSql.Append(" left join CdDept d on t.DeptNo=d.DeptNo ");
  177. strSql.Append(" left join CdMajor m on t.MajorNo=m.MajorNo ");
  178. strSql.Append(" left join ClassInfo c on t.ClassNo=c.ClassNo ");
  179. strSql.Append(" left join Acc_DormitoryBuild b on t.DormitoryNo=b.ID ");
  180. strSql.Append(" left join Acc_DormitoryBuild r on b.ParentID=r.ID ");
  181. strSql.Append(" left join Acc_DormitoryBuild f on r.ParentID=f.ID ");
  182. strSql.Append(" left join Acc_DormitoryBuild u on f.ParentID=u.ID ");
  183. strSql.Append(" left join Acc_DormitoryBuild build on u.ParentID=build.ID ");
  184. strSql.Append(" where 1=1 ");
  185. if (!queryParam["DeptNo"].IsEmpty())
  186. {
  187. strSql.Append(" and t.DeptNo = @DeptNo ");
  188. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  189. }
  190. if (!queryParam["MajorNo"].IsEmpty())
  191. {
  192. strSql.Append(" and t.MajorNo = @MajorNo ");
  193. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  194. }
  195. if (!queryParam["ClassNo"].IsEmpty())
  196. {
  197. strSql.Append(" and t.ClassNo = @ClassNo ");
  198. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  199. }
  200. if (!queryParam["Grade"].IsEmpty())
  201. {
  202. strSql.Append(" and t.Grade = @Grade ");
  203. dp.Add("Grade", queryParam["Grade"].ToString(), DbType.String);
  204. }
  205. var data = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>(strSql.ToString(), dp);
  206. return data;
  207. }
  208. catch (Exception ex)
  209. {
  210. if (ex is ExceptionEx)
  211. {
  212. throw;
  213. }
  214. else
  215. {
  216. throw ExceptionEx.ThrowServiceException(ex);
  217. }
  218. }
  219. }
  220. /// <summary>
  221. /// 获取列表数据
  222. /// <summary>
  223. /// <returns></returns>
  224. public IEnumerable<StuInfoFreshEntity> GetList2(string queryJson)
  225. {
  226. try
  227. {
  228. //参考写法
  229. var queryParam = queryJson.ToJObject();
  230. //虚拟参数
  231. var dp = new DynamicParameters(new { });
  232. var strSql = new StringBuilder();
  233. strSql.Append("SELECT t.*,d.DeptName,m.MajorName,c.ClassName ");
  234. strSql.Append(" FROM StuInfoFresh t ");
  235. strSql.Append(" left join CdDept d on t.DeptNo=d.DeptNo ");
  236. strSql.Append(" left join CdMajor m on t.MajorNo=m.MajorNo ");
  237. strSql.Append(" left join ClassInfo c on t.ClassNo=c.ClassNo ");
  238. strSql.Append(" where 1=1 ");
  239. if (!queryParam["DeptNo"].IsEmpty())
  240. {
  241. strSql.Append(" and t.DeptNo = @DeptNo ");
  242. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  243. }
  244. if (!queryParam["MajorNo"].IsEmpty())
  245. {
  246. strSql.Append(" and t.MajorNo = @MajorNo ");
  247. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  248. }
  249. if (!queryParam["ClassNo"].IsEmpty())
  250. {
  251. strSql.Append(" and t.ClassNo = @ClassNo ");
  252. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  253. }
  254. if (!queryParam["Grade"].IsEmpty())
  255. {
  256. strSql.Append(" and t.Grade = @Grade ");
  257. dp.Add("Grade", queryParam["Grade"].ToString(), DbType.String);
  258. }
  259. var data = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>(strSql.ToString(), dp);
  260. foreach (var item in data)
  261. {
  262. var familyList = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshFamilyEntity>(x => x.StuInfoFreshId == item.ID);
  263. if (familyList.Any())
  264. {
  265. item.IsStudentEdit = true;
  266. }
  267. else
  268. {
  269. item.IsStudentEdit = false;
  270. }
  271. }
  272. return data;
  273. }
  274. catch (Exception ex)
  275. {
  276. if (ex is ExceptionEx)
  277. {
  278. throw;
  279. }
  280. else
  281. {
  282. throw ExceptionEx.ThrowServiceException(ex);
  283. }
  284. }
  285. }
  286. /// <summary>
  287. /// 获取列表分页数据
  288. /// <param name="pagination">分页参数</param>
  289. /// <summary>
  290. /// <returns></returns>
  291. public IEnumerable<StuInfoFreshEntity> GetPageList(Pagination pagination, string queryJson)
  292. {
  293. try
  294. {
  295. var strSql = new StringBuilder();
  296. strSql.Append("SELECT t.*,c.ClassName,c.ClassDiredctorNo,c.ClassTutorNo,b.Name as Bed,r.Name as Room,f.Name as floor,u.Name as Unit,build.Name as Build FROM StuInfoFresh t left join ClassInfo c on t.ClassNo=c.ClassNo ");
  297. strSql.Append(" left join Acc_DormitoryBuild b on t.DormitoryNo=b.ID ");
  298. strSql.Append(" left join Acc_DormitoryBuild r on b.ParentID=r.ID ");
  299. strSql.Append(" left join Acc_DormitoryBuild f on r.ParentID=f.ID ");
  300. strSql.Append(" left join Acc_DormitoryBuild u on f.ParentID=u.ID ");
  301. strSql.Append(" left join Acc_DormitoryBuild build on u.ParentID=build.ID ");
  302. strSql.Append(" where 1=1 ");
  303. var queryParam = queryJson.ToJObject();
  304. var dp = new DynamicParameters(new { });
  305. if (!queryParam["keyword"].IsEmpty())
  306. {
  307. strSql.Append(" and (t.ksh like @keyword or t.zkzh like @keyword or t.StuName like @keyword or t.IdentityCardNo like @keyword )");
  308. dp.Add("keyword", "%" + queryParam["keyword"].ToString() + "%", DbType.String);
  309. }
  310. if (!queryParam["StuNo"].IsEmpty())
  311. {
  312. strSql.Append(" and t.StuNo = @StuNo ");
  313. dp.Add("StuNo", queryParam["StuNo"].ToString(), DbType.String);
  314. }
  315. if (!queryParam["StuName"].IsEmpty())
  316. {
  317. strSql.Append(" and t.StuName like @StuName ");
  318. dp.Add("StuName", '%' + queryParam["StuName"].ToString() + '%', DbType.String);
  319. }
  320. if (!queryParam["Grade"].IsEmpty())
  321. {
  322. strSql.Append(" and t.Grade like @Grade ");
  323. dp.Add("Grade", '%' + queryParam["Grade"].ToString() + '%', DbType.String);
  324. }
  325. //分配班级
  326. if (!queryParam["MajorNo"].IsEmpty())
  327. {
  328. strSql.Append(" and t.MajorNo = @MajorNo ");
  329. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  330. }
  331. if (!queryParam["EducationalSystem"].IsEmpty())
  332. {
  333. strSql.Append(" and t.EducationalSystem = @EducationalSystem ");
  334. dp.Add("EducationalSystem", queryParam["EducationalSystem"].ToString(), DbType.String);
  335. }
  336. if (!queryParam["IDCard"].IsEmpty())
  337. {
  338. strSql.Append(" and t.IdentityCardNo like @IDCard ");
  339. dp.Add("IDCard", '%' + queryParam["IDCard"].ToString() + '%', DbType.String);
  340. }
  341. if (!queryParam["IsAllocation"].IsEmpty())
  342. {
  343. var IsAllocation = Convert.ToBoolean(queryParam["IsAllocation"].ToString());
  344. if (IsAllocation)//未分配
  345. {
  346. strSql.Append(" AND (t.ClassNo IS NULL OR t.ClassNo='') ");
  347. }
  348. else
  349. {
  350. strSql.Append(" AND (t.ClassNo IS NOT NULL AND t.ClassNo<>'') ");
  351. }
  352. }
  353. //分配床位
  354. if (!queryParam["ClassNo"].IsEmpty())
  355. {
  356. strSql.Append(" and t.ClassNo = @ClassNo ");
  357. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  358. }
  359. //完善信息
  360. if (!queryParam["PerfectStatus"].IsEmpty())
  361. {
  362. if (queryParam["PerfectStatus"].ToString() == "1")
  363. {
  364. strSql.Append(" AND t.ID in (select StuInfoFreshId from StuInfoFreshFamily) ");
  365. }
  366. else
  367. {
  368. strSql.Append(" AND t.ID not in (select StuInfoFreshId from StuInfoFreshFamily) ");
  369. }
  370. }
  371. //报到状态
  372. if (!queryParam["RegisterStatus"].IsEmpty())
  373. {
  374. if (queryParam["RegisterStatus"].ToString() == "1")
  375. {
  376. strSql.Append(" AND t.RegisterStatus = @RegisterStatus ");
  377. }
  378. else
  379. {
  380. strSql.Append(" AND (t.RegisterStatus <> 1 or t.RegisterStatus is null)");
  381. }
  382. dp.Add("RegisterStatus", queryParam["RegisterStatus"].ToString(), DbType.String);
  383. }
  384. //缴费状态
  385. if (!queryParam["PayStatus"].IsEmpty())
  386. {
  387. if (queryParam["PayStatus"].ToString() == "1")
  388. {
  389. strSql.Append(" AND t.PayFeeStatus = @PayFeeStatus ");
  390. }
  391. else
  392. {
  393. strSql.Append(" AND (t.PayFeeStatus <> 1 or t.PayFeeStatus is null)");
  394. }
  395. dp.Add("PayFeeStatus", queryParam["PayStatus"].ToString(), DbType.String);
  396. }
  397. //领取状态
  398. if (!queryParam["GetKeyStatus"].IsEmpty())
  399. {
  400. if (queryParam["GetKeyStatus"].ToString() == "1")
  401. {
  402. strSql.Append(" AND t.GetKeyStatus = @GetKeyStatus ");
  403. }
  404. else
  405. {
  406. strSql.Append(" AND (t.GetKeyStatus <> 1 or t.GetKeyStatus is null)");
  407. }
  408. dp.Add("GetKeyStatus", queryParam["GetKeyStatus"].ToString(), DbType.String);
  409. }
  410. if (!queryParam["Gender"].IsEmpty())
  411. {
  412. if (queryParam["Gender"].ToString() == "1")
  413. {
  414. strSql.Append(" AND t.GenderNo = @Gender ");
  415. }
  416. else
  417. {
  418. strSql.Append(" AND t.GenderNo <> 1 ");
  419. }
  420. dp.Add("Gender", queryParam["Gender"].ToString(), DbType.String);
  421. }
  422. if (!queryParam["IsAllocationDormitory"].IsEmpty())
  423. {
  424. var IsAllocation = Convert.ToBoolean(queryParam["IsAllocationDormitory"].ToString());
  425. if (IsAllocation)
  426. {
  427. strSql.Append(" AND (t.DormitoryNo IS NULL OR t.DormitoryNo='')");
  428. }
  429. else
  430. {
  431. strSql.Append(" AND (t.DormitoryNo IS NOT NULL AND t.DormitoryNo<>'')");
  432. }
  433. }
  434. //班主任/辅导员
  435. if (!queryParam["EmpNo"].IsEmpty())
  436. {
  437. strSql.Append(" and (c.ClassDiredctorNo = @EmpNo or c.ClassTutorNo = @EmpNo) ");
  438. dp.Add("EmpNo", queryParam["EmpNo"].ToString(), DbType.String);
  439. }
  440. return this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>(strSql.ToString(), dp, pagination);
  441. }
  442. catch (Exception ex)
  443. {
  444. if (ex is ExceptionEx)
  445. {
  446. throw;
  447. }
  448. else
  449. {
  450. throw ExceptionEx.ThrowServiceException(ex);
  451. }
  452. }
  453. }
  454. /// <summary>
  455. /// 获取StuInfoFreshFamily表数据
  456. /// <summary>
  457. /// <returns></returns>
  458. public IEnumerable<StuInfoFreshFamilyEntity> GetStuInfoFreshFamilyList(string keyValue)
  459. {
  460. try
  461. {
  462. return this.BaseRepository("CollegeMIS").FindList<StuInfoFreshFamilyEntity>(t => t.StuInfoFreshId == keyValue);
  463. }
  464. catch (Exception ex)
  465. {
  466. if (ex is ExceptionEx)
  467. {
  468. throw;
  469. }
  470. else
  471. {
  472. throw ExceptionEx.ThrowServiceException(ex);
  473. }
  474. }
  475. }
  476. /// <summary>
  477. /// 获取StuInfoFreshEmergePeople表数据
  478. /// <summary>
  479. /// <returns></returns>
  480. public IEnumerable<StuInfoFreshEmergePeopleEntity> GetStuInfoFreshEmergePeopleList(string keyValue)
  481. {
  482. try
  483. {
  484. return this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEmergePeopleEntity>(t => t.StuInfoFreshId == keyValue);
  485. }
  486. catch (Exception ex)
  487. {
  488. if (ex is ExceptionEx)
  489. {
  490. throw;
  491. }
  492. else
  493. {
  494. throw ExceptionEx.ThrowServiceException(ex);
  495. }
  496. }
  497. }
  498. /// <summary>
  499. /// 获取StuInfoFresh表实体数据
  500. /// <param name="keyValue">主键</param>
  501. /// <summary>
  502. /// <returns></returns>
  503. public StuInfoFreshEntity GetStuInfoFreshEntity(string keyValue)
  504. {
  505. try
  506. {
  507. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshEntity>(keyValue);
  508. }
  509. catch (Exception ex)
  510. {
  511. if (ex is ExceptionEx)
  512. {
  513. throw;
  514. }
  515. else
  516. {
  517. throw ExceptionEx.ThrowServiceException(ex);
  518. }
  519. }
  520. }
  521. /// <summary>
  522. /// 获取StuInfoFresh表实体数据
  523. /// <param name="keyValue">主键</param>
  524. /// <summary>
  525. /// <returns></returns>
  526. public StuInfoFreshEntity GetStuInfoFreshEntityByStuNo(string stuNo)
  527. {
  528. try
  529. {
  530. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshEntity>(x => x.StuNo == stuNo);
  531. }
  532. catch (Exception ex)
  533. {
  534. if (ex is ExceptionEx)
  535. {
  536. throw;
  537. }
  538. else
  539. {
  540. throw ExceptionEx.ThrowServiceException(ex);
  541. }
  542. }
  543. }
  544. /// <summary>
  545. /// 获取StuInfoFreshEmergePeople表实体数据
  546. /// <param name="keyValue">主键</param>
  547. /// <summary>
  548. /// <returns></returns>
  549. public StuInfoFreshEmergePeopleEntity GetStuInfoFreshEmergePeopleEntity(string keyValue)
  550. {
  551. try
  552. {
  553. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshEmergePeopleEntity>(t => t.StuInfoFreshId == keyValue);
  554. }
  555. catch (Exception ex)
  556. {
  557. if (ex is ExceptionEx)
  558. {
  559. throw;
  560. }
  561. else
  562. {
  563. throw ExceptionEx.ThrowServiceException(ex);
  564. }
  565. }
  566. }
  567. /// <summary>
  568. /// 获取StuInfoFreshFamily表实体数据
  569. /// <param name="keyValue">主键</param>
  570. /// <summary>
  571. /// <returns></returns>
  572. public StuInfoFreshFamilyEntity GetStuInfoFreshFamilyEntity(string keyValue)
  573. {
  574. try
  575. {
  576. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshFamilyEntity>(t => t.StuInfoFreshId == keyValue);
  577. }
  578. catch (Exception ex)
  579. {
  580. if (ex is ExceptionEx)
  581. {
  582. throw;
  583. }
  584. else
  585. {
  586. throw ExceptionEx.ThrowServiceException(ex);
  587. }
  588. }
  589. }
  590. /// <summary>
  591. /// 获取列表分页数据
  592. /// <param name="pagination">分页参数</param>
  593. /// <summary>
  594. /// <returns></returns>
  595. public IEnumerable<StuInfoFreshEntity> GetStuInfoFreshListByClassNo(string classNo)
  596. {
  597. try
  598. {
  599. var strSql = new StringBuilder();
  600. strSql.Append("SELECT t.* FROM StuInfoFresh t where 1=1 and t.ClassNo='" + classNo + "' ");
  601. return this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>(strSql.ToString());
  602. }
  603. catch (Exception ex)
  604. {
  605. if (ex is ExceptionEx)
  606. {
  607. throw;
  608. }
  609. else
  610. {
  611. throw ExceptionEx.ThrowServiceException(ex);
  612. }
  613. }
  614. }
  615. /// <summary>
  616. /// 获取分配宿舍列表
  617. /// </summary>
  618. /// <param name="pagination"></param>
  619. /// <param name="queryJson"></param>
  620. /// <returns></returns>
  621. public IEnumerable<Acc_DormitoryBuildEntity> GetDormitorys(Pagination pagination, string queryJson)
  622. {
  623. try
  624. {
  625. var strSql = new StringBuilder();
  626. strSql.Append("SELECT t.* FROM Acc_DormitoryBuild t ");
  627. strSql.Append(" WHERE 1=1 ");
  628. var queryParam = queryJson.ToJObject();
  629. // 虚拟参数
  630. var dp = new DynamicParameters(new { });
  631. if (!queryParam["BuildType"].IsEmpty())
  632. {
  633. dp.Add("BuildType", queryParam["BuildType"].ToString(), DbType.String);
  634. strSql.Append(" AND t.BuildType =@BuildType ");
  635. }
  636. if (!queryParam["ParentID"].IsEmpty())
  637. {
  638. dp.Add("ParentID", queryParam["ParentID"].ToString(), DbType.String);
  639. strSql.Append(" AND t.ParentID =@ParentID ");
  640. }
  641. if (!queryParam["Sex"].IsEmpty())
  642. {
  643. dp.Add("Sex", queryParam["Sex"].ToString(), DbType.String);
  644. strSql.Append(" AND t.Sex = @Sex ");
  645. }
  646. //if (!queryParam["IsAllocationDormitory"].IsEmpty())
  647. //{
  648. // if (queryParam["IsAllocationDormitory"].ToString() == "false")
  649. // {
  650. // strSql.Append(" AND t.PlanClassNo is not null ");
  651. // }
  652. // else
  653. // {
  654. // strSql.Append(" AND t.PlanClassNo is null ");
  655. // }
  656. //}
  657. if (!queryParam["PlanClassNo"].IsEmpty())
  658. {
  659. //dp.Add("PlanClassNo", queryParam["PlanClassNo"].ToString(), DbType.String);
  660. //strSql.Append(" AND t.PlanClassNo =@PlanClassNo ");
  661. dp.Add("PlanClassNo", "%" + queryParam["PlanClassNo"].ToString() + "%", DbType.String);
  662. strSql.Append(" AND t.PlanClassNo like @PlanClassNo ");
  663. }
  664. var data = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(strSql.ToString(), dp, pagination).OrderBy(a => a.Name).ToList();
  665. foreach (var item in data)
  666. {
  667. //总床位
  668. item.ChildCount = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(a => a.ParentID == item.ID).Count();
  669. //可分配床位=总床位-预分床位
  670. int remainBedNum = item.ChildCount - (item.PlanBedNum.HasValue ? item.PlanBedNum.Value : 0);
  671. item.PlanBedNum = remainBedNum;
  672. item.RemainBedNum = remainBedNum;
  673. }
  674. if (!queryParam["IsAllocationDormitory"].IsEmpty())
  675. {
  676. if (queryParam["IsAllocationDormitory"].ToString() == "false")//不可分配
  677. {
  678. data = data.Where(x => x.RemainBedNum == 0).ToList();
  679. }
  680. else//可分配
  681. {
  682. data = data.Where(x => x.RemainBedNum > 0).ToList();
  683. }
  684. }
  685. return data;
  686. }
  687. catch (Exception ex)
  688. {
  689. if (ex is ExceptionEx)
  690. {
  691. throw;
  692. }
  693. else
  694. {
  695. throw ExceptionEx.ThrowServiceException(ex);
  696. }
  697. }
  698. }
  699. /// <summary>
  700. /// 获取分配宿舍列表
  701. /// </summary>
  702. /// <param name="pagination"></param>
  703. /// <param name="queryJson"></param>
  704. /// <returns></returns>
  705. public IEnumerable<Acc_DormitoryBuildEntity> GetDormitorys2(Pagination pagination, string queryJson)
  706. {
  707. try
  708. {
  709. var strSql = new StringBuilder();
  710. strSql.Append("SELECT t.* FROM Acc_DormitoryBuild t ");
  711. strSql.Append(" WHERE 1=1 ");
  712. var queryParam = queryJson.ToJObject();
  713. // 虚拟参数
  714. var dp = new DynamicParameters(new { });
  715. if (!queryParam["BuildType"].IsEmpty())
  716. {
  717. dp.Add("BuildType", queryParam["BuildType"].ToString(), DbType.String);
  718. strSql.Append(" AND t.BuildType =@BuildType ");
  719. }
  720. if (!queryParam["PlanClassNo"].IsEmpty())
  721. {
  722. dp.Add("PlanClassNo", "%" + queryParam["PlanClassNo"].ToString() + "%", DbType.String);
  723. strSql.Append(" AND t.PlanClassNo like @PlanClassNo ");
  724. }
  725. var data = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(strSql.ToString(), dp, pagination).OrderBy(a => a.Name).ToList();
  726. foreach (var item in data)
  727. {
  728. var bedList = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(a => a.ParentID == item.ID);
  729. //总床位
  730. item.ChildCount = bedList.Count();
  731. //已分配床位
  732. item.UseBedNum = bedList.Where(x => x.PlanClassNo == queryParam["PlanClassNo"].ToString()).Count();
  733. item.CancelUseBedNum = item.UseBedNum;
  734. }
  735. return data;
  736. }
  737. catch (Exception ex)
  738. {
  739. if (ex is ExceptionEx)
  740. {
  741. throw;
  742. }
  743. else
  744. {
  745. throw ExceptionEx.ThrowServiceException(ex);
  746. }
  747. }
  748. }
  749. /// <summary>
  750. /// 获取分配宿舍树
  751. /// </summary>
  752. /// <returns></returns>
  753. internal List<Tuple<int, int, string, string>> GetTree()
  754. {
  755. try
  756. {
  757. var data = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>(a => !string.IsNullOrEmpty(a.ClassNo)).ToList();
  758. var classInfos = this.BaseRepository("CollegeMIS").FindList<ClassInfoEntity>().ToList();
  759. var classes = data.GroupBy(a => a.ClassNo).Select(a => a.Key).ToList();
  760. List<Tuple<int, int, string, string>> list = new List<Tuple<int, int, string, string>>();
  761. foreach (var classNo in classes)
  762. {
  763. var boy = data.Count(a => a.ClassNo == classNo && a.GenderNo == "1");
  764. var girl = data.Count(a => a.ClassNo == classNo && a.GenderNo != "1");
  765. var className = classInfos.FirstOrDefault(a => a.ClassNo == classNo)?.ClassName;
  766. Tuple<int, int, string, string> tuple = new Tuple<int, int, string, string>(boy, girl, classNo, className);
  767. list.Add(tuple);
  768. }
  769. return list;
  770. }
  771. catch (Exception ex)
  772. {
  773. if (ex is ExceptionEx)
  774. {
  775. throw;
  776. }
  777. else
  778. {
  779. throw ExceptionEx.ThrowServiceException(ex);
  780. }
  781. }
  782. }
  783. /// <summary>
  784. /// 获取分配床位树
  785. /// </summary>
  786. /// <param name="classNo"></param>
  787. /// <param name="gender"></param>
  788. /// <returns></returns>
  789. internal List<Acc_DormitoryBuildEntity> GetBedTree(string classNo, string gender)
  790. {
  791. try
  792. {
  793. List<Acc_DormitoryBuildEntity> list = new List<Acc_DormitoryBuildEntity>();
  794. var data = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(a => a.PlanClassNo.Contains(classNo) && a.Sex == gender && a.BuildType == "4").ToList();
  795. var bb = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>().ToList();
  796. foreach (var item in data)
  797. {
  798. list.Add(item);
  799. var beds = this.BaseRepository("CollegeMIS").FindList<Acc_DormitoryBuildEntity>(a => a.ParentID == item.ID && a.PlanClassNo == classNo).ToList();
  800. foreach (var bed in beds)
  801. {
  802. var stuName = bb.FirstOrDefault(a => a.DormitoryNo == bed.ID)?.StuName;
  803. if (!string.IsNullOrEmpty(stuName))
  804. {
  805. bed.Name = $"{bed.Name}({stuName})";
  806. }
  807. list.Add(bed);
  808. }
  809. }
  810. return list;
  811. }
  812. catch (Exception ex)
  813. {
  814. if (ex is ExceptionEx)
  815. {
  816. throw;
  817. }
  818. else
  819. {
  820. throw ExceptionEx.ThrowServiceException(ex);
  821. }
  822. }
  823. }
  824. public IEnumerable<StuInfoFreshEntity> GetNewStudentList(string queryJson)
  825. {
  826. try
  827. {
  828. //虚拟参数
  829. var dp = new DynamicParameters(new { });
  830. var strSql = new StringBuilder();
  831. strSql.Append("SELECT t.*,d.DeptName,m.MajorName,c.ClassName ");
  832. strSql.Append(" FROM StuInfoFresh t ");
  833. strSql.Append(" left join CdDept d on t.DeptNo=d.DeptNo ");
  834. strSql.Append(" left join CdMajor m on t.MajorNo=m.MajorNo ");
  835. strSql.Append(" left join ClassInfo c on t.ClassNo=c.ClassNo ");
  836. strSql.Append(" where 1=1 ");
  837. strSql.Append(" AND t.Grade ='21' ");
  838. if (!string.IsNullOrEmpty(queryJson))
  839. {
  840. dp.Add("DeptNo", queryJson, DbType.String);
  841. strSql.Append(" AND t.DeptNo =@DeptNo ");
  842. }
  843. var data = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshEntity>(strSql.ToString(), dp);
  844. foreach (var item in data)
  845. {
  846. var familyList = this.BaseRepository("CollegeMIS").FindList<StuInfoFreshFamilyEntity>(x => x.StuInfoFreshId == item.ID);
  847. if (familyList.Any())
  848. {
  849. item.IsStudentEdit = true;
  850. }
  851. else
  852. {
  853. item.IsStudentEdit = false;
  854. }
  855. }
  856. return data;
  857. }
  858. catch (Exception ex)
  859. {
  860. if (ex is ExceptionEx)
  861. {
  862. throw;
  863. }
  864. else
  865. {
  866. throw ExceptionEx.ThrowServiceException(ex);
  867. }
  868. }
  869. }
  870. #endregion
  871. #region 提交数据
  872. /// <summary>
  873. /// 删除实体数据
  874. /// <param name="keyValue">主键</param>
  875. /// <summary>
  876. /// <returns></returns>
  877. public void DeleteEntity(string keyValue)
  878. {
  879. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  880. try
  881. {
  882. var stuInfoFreshEntity = GetStuInfoFreshEntity(keyValue);
  883. db.Delete<StuInfoFreshEntity>(t => t.ID == keyValue);
  884. db.Delete<StuInfoFreshEmergePeopleEntity>(t => t.StuInfoFreshId == stuInfoFreshEntity.ID);
  885. db.Delete<StuInfoFreshFamilyEntity>(t => t.StuInfoFreshId == stuInfoFreshEntity.ID);
  886. db.Commit();
  887. }
  888. catch (Exception ex)
  889. {
  890. db.Rollback();
  891. if (ex is ExceptionEx)
  892. {
  893. throw;
  894. }
  895. else
  896. {
  897. throw ExceptionEx.ThrowServiceException(ex);
  898. }
  899. }
  900. }
  901. /// <summary>
  902. /// 保存实体数据(新增、修改)
  903. /// <param name="keyValue">主键</param>
  904. /// <summary>
  905. /// <returns></returns>
  906. public void SaveEntity(string keyValue, StuInfoFreshEntity entity, List<StuInfoFreshEmergePeopleEntity> stuInfoFreshEmergePeopleList, List<StuInfoFreshFamilyEntity> stuInfoFreshFamilyList)
  907. {
  908. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  909. try
  910. {
  911. if (!string.IsNullOrEmpty(keyValue))
  912. {
  913. var stuInfoFreshEntityTmp = GetStuInfoFreshEntity(keyValue);
  914. entity.Modify(keyValue);
  915. db.Update(entity);
  916. db.Delete<StuInfoFreshEmergePeopleEntity>(t => t.StuInfoFreshId == stuInfoFreshEntityTmp.ID);
  917. if (null != stuInfoFreshEmergePeopleList && null != stuInfoFreshFamilyList)
  918. {
  919. foreach (StuInfoFreshEmergePeopleEntity item in stuInfoFreshEmergePeopleList)
  920. {
  921. item.Create();
  922. item.StuInfoFreshId = stuInfoFreshEntityTmp.ID;
  923. db.Insert(item);
  924. }
  925. db.Delete<StuInfoFreshFamilyEntity>(t => t.StuInfoFreshId == stuInfoFreshEntityTmp.ID);
  926. foreach (StuInfoFreshFamilyEntity item in stuInfoFreshFamilyList)
  927. {
  928. item.Create();
  929. item.StuInfoFreshId = stuInfoFreshEntityTmp.ID;
  930. db.Insert(item);
  931. }
  932. }
  933. }
  934. else
  935. {
  936. entity.Create();
  937. db.Insert(entity);
  938. if (null != stuInfoFreshEmergePeopleList && null != stuInfoFreshFamilyList)
  939. {
  940. foreach (StuInfoFreshEmergePeopleEntity item in stuInfoFreshEmergePeopleList)
  941. {
  942. item.Create();
  943. item.StuInfoFreshId = entity.ID;
  944. db.Insert(item);
  945. }
  946. foreach (StuInfoFreshFamilyEntity item in stuInfoFreshFamilyList)
  947. {
  948. item.Create();
  949. item.StuInfoFreshId = entity.ID;
  950. db.Insert(item);
  951. }
  952. }
  953. }
  954. db.Commit();
  955. }
  956. catch (Exception ex)
  957. {
  958. db.Rollback();
  959. if (ex is ExceptionEx)
  960. {
  961. throw;
  962. }
  963. else
  964. {
  965. throw ExceptionEx.ThrowServiceException(ex);
  966. }
  967. }
  968. }
  969. /// <summary>
  970. /// 保存实体数据(新增、修改)
  971. /// <param name="keyValue">主键</param>
  972. /// <summary>
  973. /// <returns></returns>
  974. public void SaveEntity(string keyValue, StuInfoFreshEntity entity)
  975. {
  976. try
  977. {
  978. if (!string.IsNullOrEmpty(keyValue))
  979. {
  980. entity.Modify(keyValue);
  981. this.BaseRepository("CollegeMIS").Update(entity);
  982. }
  983. else
  984. {
  985. entity.Create();
  986. this.BaseRepository("CollegeMIS").Insert(entity);
  987. }
  988. }
  989. catch (Exception ex)
  990. {
  991. if (ex is ExceptionEx)
  992. {
  993. throw;
  994. }
  995. else
  996. {
  997. throw ExceptionEx.ThrowServiceException(ex);
  998. }
  999. }
  1000. }
  1001. #endregion
  1002. #region 扩展数据
  1003. /// <summary>
  1004. /// 确认报到、取消报到
  1005. /// <param name="keyValue">主键</param>
  1006. /// <summary>
  1007. /// <returns></returns>
  1008. public void IsRegister(string keyValue, string status)
  1009. {
  1010. try
  1011. {
  1012. if (status == "1")//报到
  1013. {
  1014. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set RegisterStatus='1',ArriveDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
  1015. }
  1016. else
  1017. {
  1018. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set RegisterStatus='0',ArriveDate=null where ID='" + keyValue + "' ");
  1019. }
  1020. }
  1021. catch (Exception ex)
  1022. {
  1023. if (ex is ExceptionEx)
  1024. {
  1025. throw;
  1026. }
  1027. else
  1028. {
  1029. throw ExceptionEx.ThrowServiceException(ex);
  1030. }
  1031. }
  1032. }
  1033. /// <summary>
  1034. /// 收取学生档案
  1035. /// <param name="keyValue">主键</param>
  1036. /// <summary>
  1037. /// <returns></returns>
  1038. public void IsCollectFile(string keyValue, string status)
  1039. {
  1040. try
  1041. {
  1042. if (status == "1")//收取
  1043. {
  1044. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set CollectFileStatus='1',CollectFileDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
  1045. }
  1046. else
  1047. {
  1048. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set CollectFileStatus='0',CollectFileDate=null where ID='" + keyValue + "' ");
  1049. }
  1050. }
  1051. catch (Exception ex)
  1052. {
  1053. if (ex is ExceptionEx)
  1054. {
  1055. throw;
  1056. }
  1057. else
  1058. {
  1059. throw ExceptionEx.ThrowServiceException(ex);
  1060. }
  1061. }
  1062. }
  1063. /// <summary>
  1064. /// 领取钥匙
  1065. /// <param name="keyValue">主键</param>
  1066. /// <summary>
  1067. /// <returns></returns>
  1068. public void IsGetKey(string keyValue, string status)
  1069. {
  1070. try
  1071. {
  1072. if (status == "1")//领取
  1073. {
  1074. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set GetKeyStatus='1',GetKeyDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
  1075. }
  1076. else
  1077. {
  1078. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set GetKeyStatus='0',GetKeyDate=null where ID='" + keyValue + "' ");
  1079. }
  1080. }
  1081. catch (Exception ex)
  1082. {
  1083. if (ex is ExceptionEx)
  1084. {
  1085. throw;
  1086. }
  1087. else
  1088. {
  1089. throw ExceptionEx.ThrowServiceException(ex);
  1090. }
  1091. }
  1092. }
  1093. /// <summary>
  1094. /// 领取校园卡
  1095. /// <param name="keyValue">主键</param>
  1096. /// <summary>
  1097. /// <returns></returns>
  1098. public void IsGetCard(string keyValue, string status)
  1099. {
  1100. try
  1101. {
  1102. if (status == "1")//领取
  1103. {
  1104. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set GetCardStatus='1',GetCardDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
  1105. }
  1106. else
  1107. {
  1108. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set GetCardStatus='0',GetCardDate=null where ID='" + keyValue + "' ");
  1109. }
  1110. }
  1111. catch (Exception ex)
  1112. {
  1113. if (ex is ExceptionEx)
  1114. {
  1115. throw;
  1116. }
  1117. else
  1118. {
  1119. throw ExceptionEx.ThrowServiceException(ex);
  1120. }
  1121. }
  1122. }
  1123. /// <summary>
  1124. /// 缴费
  1125. /// <param name="keyValue">主键</param>
  1126. /// <summary>
  1127. /// <returns></returns>
  1128. public void IsPayFee(string keyValue, string status)
  1129. {
  1130. try
  1131. {
  1132. if (status == "1")//缴费
  1133. {
  1134. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set PayFeeStatus='1',PayFeeDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
  1135. }
  1136. else
  1137. {
  1138. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set PayFeeStatus='0',PayFeeDate=null where ID='" + keyValue + "' ");
  1139. }
  1140. }
  1141. catch (Exception ex)
  1142. {
  1143. if (ex is ExceptionEx)
  1144. {
  1145. throw;
  1146. }
  1147. else
  1148. {
  1149. throw ExceptionEx.ThrowServiceException(ex);
  1150. }
  1151. }
  1152. }
  1153. /// <summary>
  1154. /// 其他费用缴费
  1155. /// <param name="keyValue">主键</param>
  1156. /// <summary>
  1157. /// <returns></returns>
  1158. public void IsOtherPayFee(string keyValue, string status)
  1159. {
  1160. try
  1161. {
  1162. if (status == "1")//缴费
  1163. {
  1164. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set OtherPayFeeStatus='1',OtherPayFeeDate='" + DateTime.Now + "' where ID='" + keyValue + "' ");
  1165. }
  1166. else
  1167. {
  1168. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set OtherPayFeeStatus='0',OtherPayFeeDate=null where ID='" + keyValue + "' ");
  1169. }
  1170. }
  1171. catch (Exception ex)
  1172. {
  1173. if (ex is ExceptionEx)
  1174. {
  1175. throw;
  1176. }
  1177. else
  1178. {
  1179. throw ExceptionEx.ThrowServiceException(ex);
  1180. }
  1181. }
  1182. }
  1183. /// <summary>
  1184. /// 审核助学贷款
  1185. /// <param name="keyValue">主键</param>
  1186. /// <summary>
  1187. /// <returns></returns>
  1188. public void DoCheckLoan(string keyValue, string status)
  1189. {
  1190. try
  1191. {
  1192. //if (status == "1")//通过
  1193. //{
  1194. // this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set StudentLoanStatus='1' where ID='" + keyValue + "' ");
  1195. //}
  1196. //else
  1197. //{
  1198. // this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set StudentLoanStatus='0' where ID='" + keyValue + "' ");
  1199. //}
  1200. if (status == "1")//已办理
  1201. {
  1202. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set StudentLoanBLStatus='1' where ID='" + keyValue + "' ");
  1203. }
  1204. else
  1205. {
  1206. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set StudentLoanBLStatus='2' where ID='" + keyValue + "' ");
  1207. }
  1208. }
  1209. catch (Exception ex)
  1210. {
  1211. if (ex is ExceptionEx)
  1212. {
  1213. throw;
  1214. }
  1215. else
  1216. {
  1217. throw ExceptionEx.ThrowServiceException(ex);
  1218. }
  1219. }
  1220. }
  1221. /// <summary>
  1222. /// 分配班级
  1223. /// <param name="keyValue">主键</param>
  1224. /// <summary>
  1225. /// <returns></returns>
  1226. public void DoAllocationClass(List<StuInfoFreshEntity> stuInfoFreshEntities)
  1227. {
  1228. UserRelationIBLL userRelationIBLL = new UserRelationBLL();
  1229. UserIBLL userIBLL = new UserBLL();
  1230. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  1231. try
  1232. {
  1233. foreach (var entity in stuInfoFreshEntities)
  1234. {
  1235. //新生信息
  1236. entity.Modify(entity.ID);
  1237. db.Update(entity);
  1238. //自动生成学生账号默认为学生角色,方便登录移动端
  1239. //判断User是否存在
  1240. var userModel = userIBLL.GetEntityByAccount(entity.StuNo);
  1241. if (userModel == null)
  1242. {
  1243. //User
  1244. var annexesFileEntity = this.BaseRepository().FindEntity<AnnexesFileEntity>(a => a.F_Id == entity.Photo);
  1245. var url = "";
  1246. if (annexesFileEntity != null)
  1247. {
  1248. url = annexesFileEntity.F_FilePath;
  1249. url = "/" + url.Substring(url.IndexOf("Resource"));
  1250. }
  1251. var userEntity = new UserEntity()
  1252. {
  1253. F_Account = entity.StuNo,
  1254. F_RealName = entity.StuName,
  1255. F_EnCode = entity.StuNo,
  1256. F_Password = Md5Helper.Encrypt(Config.GetValue("defaultpwd"), 32).ToLower(),
  1257. F_HeadIcon = string.IsNullOrEmpty(url) ? Config.GetValue("defaultheadimg") : url,
  1258. F_Gender = entity.GenderNo == "1" ? 1 : 0,
  1259. F_DeleteMark = 0,
  1260. F_EnabledMark = 1,
  1261. F_Mobile = entity.telephone,
  1262. F_Description = "学生",
  1263. F_CompanyId = this.BaseRepository("CollegeMIS").FindEntity<CdMajorEntity>(x => x.MajorNo == entity.MajorNo)?.F_SchoolId,
  1264. F_DepartmentId = entity.DeptNo
  1265. };
  1266. userIBLL.SaveEntity(null, userEntity);
  1267. //UserRelation
  1268. var roleId = Config.GetValue("GenerateStudentsRoleId");
  1269. //判断User是否添加成功
  1270. var user = userIBLL.GetEntityByAccount(entity.StuNo);
  1271. if (user != null)
  1272. {
  1273. var userRelationEntity = new UserRelationEntity();
  1274. userRelationEntity.Create();
  1275. userRelationEntity.F_UserId = user.F_UserId;
  1276. userRelationEntity.F_Category = 1;
  1277. userRelationEntity.F_ObjectId = roleId;
  1278. this.BaseRepository().Insert(userRelationEntity);
  1279. }
  1280. }
  1281. }
  1282. db.Commit();
  1283. }
  1284. catch (Exception ex)
  1285. {
  1286. db.Rollback();
  1287. if (ex is ExceptionEx)
  1288. {
  1289. throw;
  1290. }
  1291. else
  1292. {
  1293. throw ExceptionEx.ThrowServiceException(ex);
  1294. }
  1295. }
  1296. }
  1297. /// <summary>
  1298. /// 分配宿舍
  1299. /// <param name="keyValue">主键</param>
  1300. /// <summary>
  1301. /// <returns></returns>
  1302. public void DoAllocationDormitory(List<Acc_DormitoryBuildEntity> acc_DormitoryBuildEntities)
  1303. {
  1304. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  1305. try
  1306. {
  1307. foreach (var entity in acc_DormitoryBuildEntities)
  1308. {
  1309. //修改房间:预分床位数量增加;预分班级判断是否需要增加;
  1310. var model = db.FindEntity<Acc_DormitoryBuildEntity>(entity.ID);
  1311. model.PlanBedNum = (model.PlanBedNum.HasValue ? model.PlanBedNum.Value : 0) + entity.PlanBedNum;
  1312. if (!string.IsNullOrEmpty(model.PlanClassNo) && model.PlanClassNo.Contains(entity.PlanClassNo))
  1313. {
  1314. }
  1315. else
  1316. {
  1317. model.PlanClassNo = model.PlanClassNo + entity.PlanClassNo + ',';
  1318. }
  1319. db.Update(model);
  1320. //修改房间下的床位:预分班级增加;
  1321. var redList = db.FindList<Acc_DormitoryBuildEntity>(x => x.ParentID == entity.ID && string.IsNullOrEmpty(x.PlanClassNo)).OrderBy(x => x.Name).ToList();
  1322. foreach (var redItem in redList)
  1323. {
  1324. var index = redList.IndexOf(redItem);
  1325. if (index == entity.PlanBedNum)
  1326. {
  1327. break;
  1328. }
  1329. redItem.PlanClassNo = entity.PlanClassNo;
  1330. db.Update(redItem);
  1331. }
  1332. }
  1333. db.Commit();
  1334. }
  1335. catch (Exception ex)
  1336. {
  1337. db.Rollback();
  1338. if (ex is ExceptionEx)
  1339. {
  1340. throw;
  1341. }
  1342. else
  1343. {
  1344. throw ExceptionEx.ThrowServiceException(ex);
  1345. }
  1346. }
  1347. }
  1348. /// <summary>
  1349. /// 导入宿舍
  1350. /// <param name="keyValue">主键</param>
  1351. /// <summary>
  1352. /// <returns></returns>
  1353. public void ImportDormitory(List<Acc_DormitoryBuildEntity> acc_DormitoryBuildEntities)
  1354. {
  1355. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  1356. try
  1357. {
  1358. foreach (var entity in acc_DormitoryBuildEntities)
  1359. {
  1360. //修改房间:预分床位数量增加;预分班级判断是否需要增加;
  1361. var model = db.FindEntity<Acc_DormitoryBuildEntity>(entity.ID);
  1362. model.PlanBedNum = (model.PlanBedNum.HasValue ? model.PlanBedNum.Value : 0) + entity.PlanBedNum;
  1363. if (!string.IsNullOrEmpty(model.PlanClassNo) && model.PlanClassNo.Contains(entity.PlanClassNo))
  1364. {
  1365. }
  1366. else
  1367. {
  1368. model.PlanClassNo = model.PlanClassNo + entity.PlanClassNo + ',';
  1369. }
  1370. db.Update(model);
  1371. //修改房间下的床位:预分班级增加;
  1372. var redList = db.FindList<Acc_DormitoryBuildEntity>(x => x.ID == entity.bedId).ToList();
  1373. foreach (var redItem in redList)
  1374. {
  1375. var index = redList.IndexOf(redItem);
  1376. if (index == entity.PlanBedNum)
  1377. {
  1378. break;
  1379. }
  1380. redItem.PlanClassNo = entity.PlanClassNo;
  1381. db.Update(redItem);
  1382. }
  1383. }
  1384. db.Commit();
  1385. }
  1386. catch (Exception ex)
  1387. {
  1388. db.Rollback();
  1389. if (ex is ExceptionEx)
  1390. {
  1391. throw;
  1392. }
  1393. else
  1394. {
  1395. throw ExceptionEx.ThrowServiceException(ex);
  1396. }
  1397. }
  1398. }
  1399. /// <summary>
  1400. /// 取消分配宿舍
  1401. /// <param name="keyValue">主键</param>
  1402. /// <summary>
  1403. /// <returns></returns>
  1404. public void CancelAllocationDormitory(List<Acc_DormitoryBuildEntity> acc_DormitoryBuildEntities)
  1405. {
  1406. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  1407. try
  1408. {
  1409. foreach (var entity in acc_DormitoryBuildEntities)
  1410. {
  1411. //修改房间:预分床位数量减少;预分班级判断是否需要清除;
  1412. var model = db.FindEntity<Acc_DormitoryBuildEntity>(entity.ID);
  1413. model.PlanBedNum = model.PlanBedNum - entity.CancelUseBedNum;
  1414. if (!string.IsNullOrEmpty(model.PlanClassNo))
  1415. {
  1416. var planclassnotemp = entity.PlanClassNo + ',';
  1417. if (model.PlanClassNo == planclassnotemp) //一个班
  1418. {
  1419. if (model.PlanBedNum <= 0)
  1420. {
  1421. model.PlanClassNo = "";
  1422. }
  1423. }
  1424. else //多个班
  1425. {
  1426. var bedNumSelf = db.FindList<Acc_DormitoryBuildEntity>(x => x.ParentID == entity.ID && x.PlanClassNo == entity.PlanClassNo).Count();
  1427. if (bedNumSelf == entity.CancelUseBedNum)
  1428. {
  1429. model.PlanClassNo = model.PlanClassNo.Replace(planclassnotemp, "");
  1430. }
  1431. }
  1432. }
  1433. db.Update(model);
  1434. //修改房间下的床位:预分班级清除;
  1435. var redList = db.FindList<Acc_DormitoryBuildEntity>(x => x.ParentID == entity.ID && x.PlanClassNo == entity.PlanClassNo).OrderBy(x => x.PlanStudentID).ThenBy(x => x.Name).ToList();
  1436. foreach (var redItem in redList)
  1437. {
  1438. var index = redList.IndexOf(redItem);
  1439. if (index == entity.CancelUseBedNum)
  1440. {
  1441. break;
  1442. }
  1443. redItem.PlanClassNo = "";
  1444. //判断床位是否被占用;
  1445. if (!string.IsNullOrEmpty(redItem.PlanStudentID))
  1446. {
  1447. redItem.PlanStudentID = "";
  1448. var stuInfoFreshEntity = db.FindEntity<StuInfoFreshEntity>(x => x.DormitoryNo == redItem.ID);
  1449. if (stuInfoFreshEntity != null)
  1450. {
  1451. stuInfoFreshEntity.DormitoryNo = "";
  1452. stuInfoFreshEntity.DormitoryName = "";
  1453. }
  1454. db.Update(stuInfoFreshEntity);
  1455. }
  1456. db.Update(redItem);
  1457. }
  1458. }
  1459. db.Commit();
  1460. }
  1461. catch (Exception ex)
  1462. {
  1463. db.Rollback();
  1464. if (ex is ExceptionEx)
  1465. {
  1466. throw;
  1467. }
  1468. else
  1469. {
  1470. throw ExceptionEx.ThrowServiceException(ex);
  1471. }
  1472. }
  1473. }
  1474. /// <summary>
  1475. /// 分配床位
  1476. /// </summary>
  1477. /// <param name="dormitoryNo"></param>
  1478. /// <param name="stuId"></param>
  1479. /// <param name="dormitoryName"></param>
  1480. public void DoAllocationBed(string dormitoryNo, string keyValue)
  1481. {
  1482. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  1483. try
  1484. {
  1485. //清除StuInfoFresh
  1486. db.ExecuteBySql("update StuInfoFresh set DormitoryNo=null,DormitoryName=null where DormitoryNo='" + dormitoryNo + "' ");
  1487. //清除Acc_DormitoryBuild
  1488. db.ExecuteBySql("update Acc_DormitoryBuild set PlanStudentID=null where PlanStudentID='" + keyValue + "' ");
  1489. //更新Acc_DormitoryBuild
  1490. var newAcc_DormitoryBuildEntity = db.FindEntity<Acc_DormitoryBuildEntity>(x => x.ID == dormitoryNo);
  1491. if (newAcc_DormitoryBuildEntity != null)
  1492. {
  1493. newAcc_DormitoryBuildEntity.PlanStudentID = keyValue;
  1494. db.Update(newAcc_DormitoryBuildEntity);
  1495. //更新StuInfoFresh
  1496. var newStuInfoFreshEntity = db.FindEntity<StuInfoFreshEntity>(x => x.ID == keyValue);
  1497. if (newStuInfoFreshEntity != null)
  1498. {
  1499. newStuInfoFreshEntity.DormitoryNo = dormitoryNo;
  1500. newStuInfoFreshEntity.DormitoryName = db.FindEntity<Acc_DormitoryBuildEntity>(x => x.ID == newAcc_DormitoryBuildEntity.ParentID)?.Name + newAcc_DormitoryBuildEntity.Name;
  1501. db.Update(newStuInfoFreshEntity);
  1502. }
  1503. }
  1504. db.Commit();
  1505. }
  1506. catch (Exception ex)
  1507. {
  1508. db.Rollback();
  1509. if (ex is ExceptionEx)
  1510. {
  1511. throw;
  1512. }
  1513. else
  1514. {
  1515. throw ExceptionEx.ThrowServiceException(ex);
  1516. }
  1517. }
  1518. }
  1519. /// <summary>
  1520. /// 自动分配床位
  1521. /// </summary>
  1522. /// <param name="classNo">班级编号</param>
  1523. /// <param name="stuId"></param>
  1524. /// <param name="dormitoryName"></param>
  1525. public void DoAllocationBedOfAuto(string classNo)
  1526. {
  1527. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  1528. try
  1529. {
  1530. //区分性别:男1,女0;
  1531. //班级里未分配床位的学生;班级里的空床位;
  1532. //修改StuInfoFresh;修改Acc_DormitoryBuild;
  1533. #region 随机分配
  1534. for (int i = 0; i <= 1; i++)
  1535. {
  1536. var studentList = new List<StuInfoFreshEntity>();
  1537. var bedList = new List<Acc_DormitoryBuildEntity>();
  1538. string sexTemp = "1";
  1539. if (i == 0)
  1540. {
  1541. studentList = db.FindList<StuInfoFreshEntity>(x => x.ClassNo == classNo && x.GenderNo != sexTemp && string.IsNullOrEmpty(x.DormitoryNo)).ToList();
  1542. bedList = db.FindList<Acc_DormitoryBuildEntity>(x => x.PlanClassNo == classNo && x.Sex != sexTemp && string.IsNullOrEmpty(x.PlanStudentID)).ToList();
  1543. }
  1544. else
  1545. {
  1546. studentList = db.FindList<StuInfoFreshEntity>(x => x.ClassNo == classNo && x.GenderNo == sexTemp && string.IsNullOrEmpty(x.DormitoryNo)).ToList();
  1547. bedList = db.FindList<Acc_DormitoryBuildEntity>(x => x.PlanClassNo == classNo && x.Sex == sexTemp && string.IsNullOrEmpty(x.PlanStudentID)).ToList();
  1548. }
  1549. var studentTempList = new List<StuInfoFreshEntity>();
  1550. var bedTempList = new List<Acc_DormitoryBuildEntity>();
  1551. foreach (var bedItem in bedList)
  1552. {
  1553. if (studentList.Count() == studentTempList.Count())
  1554. {
  1555. break;
  1556. }
  1557. var index = bedList.IndexOf(bedItem);
  1558. var studentItem = studentList[index];
  1559. bedItem.PlanStudentID = studentItem.ID;
  1560. bedTempList.Add(bedItem);
  1561. studentItem.DormitoryNo = bedItem.ID;
  1562. studentItem.DormitoryName = db.FindEntity<Acc_DormitoryBuildEntity>(x => x.ID == bedItem.ParentID)?.Name + bedItem.Name;
  1563. studentTempList.Add(studentItem);
  1564. }
  1565. db.Update(bedTempList);
  1566. db.Update(studentTempList);
  1567. }
  1568. #endregion
  1569. db.Commit();
  1570. }
  1571. catch (Exception ex)
  1572. {
  1573. db.Rollback();
  1574. if (ex is ExceptionEx)
  1575. {
  1576. throw;
  1577. }
  1578. else
  1579. {
  1580. throw ExceptionEx.ThrowServiceException(ex);
  1581. }
  1582. }
  1583. }
  1584. public void ConfirmDormitory()
  1585. {
  1586. try
  1587. {
  1588. var nostuBed = this.BaseRepository("CollegeMIS")
  1589. .FindList<Acc_DormitoryBuildEntity>(a => a.StudentID == null || a.StudentID == "").Where(a => a.PlanStudentID != null);
  1590. foreach (var bed in nostuBed)
  1591. {
  1592. var stuFreshInfo = this.BaseRepository("CollegeMIS")
  1593. .FindEntity<StuInfoFreshEntity>(a => a.ID == bed.PlanStudentID);
  1594. if (stuFreshInfo != null)
  1595. {
  1596. var stuInfo = this.BaseRepository("CollegeMIS")
  1597. .FindEntity<StuInfoBasicEntity>(a => a.StuNo == stuFreshInfo.StuNo);
  1598. if (stuInfo != null)
  1599. {
  1600. bed.Dept = stuInfo.DeptNo;
  1601. bed.Major = stuInfo.MajorNo;
  1602. bed.Class = stuInfo.ClassNo;
  1603. bed.StudentID = stuInfo.StuId;
  1604. this.BaseRepository("CollegeMIS").Update(bed);
  1605. }
  1606. }
  1607. }
  1608. }
  1609. catch (Exception ex)
  1610. {
  1611. if (ex is ExceptionEx)
  1612. {
  1613. throw;
  1614. }
  1615. else
  1616. {
  1617. throw ExceptionEx.ThrowServiceException(ex);
  1618. }
  1619. }
  1620. }
  1621. public void ConfirmDormitoryTwo()
  1622. {
  1623. try
  1624. {
  1625. var nostuBed = this.BaseRepository("CollegeMIS")
  1626. .FindList<Acc_DormitoryBuildEntity>(a => a.StudentID == null || a.StudentID == "").Where(a => a.PlanStudentID != null);
  1627. foreach (var bed in nostuBed)
  1628. {
  1629. var stuFreshInfo = this.BaseRepository("CollegeMIS")
  1630. .FindEntity<StuEnrollEntity>(a => a.StuId == bed.PlanStudentID);
  1631. if (stuFreshInfo != null)
  1632. {
  1633. var stuInfo = this.BaseRepository("CollegeMIS")
  1634. .FindEntity<StuInfoBasicEntity>(a => a.StuNo == stuFreshInfo.StuNo);
  1635. if (stuInfo != null)
  1636. {
  1637. bed.Dept = stuInfo.DeptNo;
  1638. bed.Major = stuInfo.MajorNo;
  1639. bed.Class = stuInfo.ClassNo;
  1640. bed.StudentID = stuInfo.StuId;
  1641. this.BaseRepository("CollegeMIS").Update(bed);
  1642. }
  1643. }
  1644. }
  1645. }
  1646. catch (Exception ex)
  1647. {
  1648. if (ex is ExceptionEx)
  1649. {
  1650. throw;
  1651. }
  1652. else
  1653. {
  1654. throw ExceptionEx.ThrowServiceException(ex);
  1655. }
  1656. }
  1657. }
  1658. public void GetUniform(string keyValue, bool Status)
  1659. {
  1660. try
  1661. {
  1662. var sql = "";
  1663. if (Status)
  1664. {
  1665. sql = $"UPDATE dbo.StuInfoFresh SET IsGetUniform =1 WHERE ID='{keyValue}'";
  1666. }
  1667. else
  1668. {
  1669. sql = $"UPDATE dbo.StuInfoFresh SET IsGetUniform =0 WHERE ID='{keyValue}'";
  1670. }
  1671. this.BaseRepository("CollegeMIS").ExecuteBySql(sql);
  1672. }
  1673. catch (Exception ex)
  1674. {
  1675. if (ex is ExceptionEx)
  1676. {
  1677. throw;
  1678. }
  1679. else
  1680. {
  1681. throw ExceptionEx.ThrowServiceException(ex);
  1682. }
  1683. }
  1684. }
  1685. public void PayUniform(string keyValue, bool Status)
  1686. {
  1687. try
  1688. {
  1689. var sql = "";
  1690. if (Status)
  1691. {
  1692. sql = $"UPDATE dbo.StuInfoFresh SET IsPayUniform =1 WHERE ID='{keyValue}'";
  1693. }
  1694. else
  1695. {
  1696. sql = $"UPDATE dbo.StuInfoFresh SET IsPayUniform =0 WHERE ID='{keyValue}'";
  1697. }
  1698. this.BaseRepository("CollegeMIS").ExecuteBySql(sql);
  1699. }
  1700. catch (Exception ex)
  1701. {
  1702. if (ex is ExceptionEx)
  1703. {
  1704. throw;
  1705. }
  1706. else
  1707. {
  1708. throw ExceptionEx.ThrowServiceException(ex);
  1709. }
  1710. }
  1711. }
  1712. /// <summary>
  1713. /// 导入学籍信息
  1714. /// </summary>
  1715. public void ImportStuInfoBasic()
  1716. {
  1717. try
  1718. {
  1719. //学籍表增加数据
  1720. var strSql = new StringBuilder();
  1721. strSql.Append(@"insert into StuInfoBasic
  1722. (StuId, StuNo, StuCode, NoticeNo, GraduateYear, ksh, DeptNo, MajorNo, MajorDetailNo, MajorDetailName,
  1723. Grade, ClassNo, StuName, SpellFull, SpellBrief, GenderNo, Birthday, PartyFaceNo, FamilyOriginNo, NationalityNo,
  1724. ProvinceNo, RegionNo, ResidenceNo, TestStuSortNo, HealthStatusNo, WillNo, TestStuSubjectNo, GraduateNo,
  1725. PlanFormNo, IsThreeGood, IsExcellent, IsNormalCadre, IsProvinceFirstThree, OverseasChineseNo, MatriculateSort,
  1726. ComeProvinceNo, HighSchoolNo, HighSchoolName, EntranceDate, Religion, GoodAt, IdentityCardNo, JoinPartyDate,
  1727. JoinLeagueDate, InSchoolAddress, InSchoolTelephone, AbmormityMoveMark, AwardMark, PunishMark, LinkmanMark,
  1728. StuNoChangeMark, FinishSchoolMark, CurrentRegisterMark, FinishSchoolDate, DiplomaNo, DiplomaRemark, Remark,
  1729. RegisterDate, Photo, TeachPlanNo, CheckMark, mobile, EMail, QQ, FatherUnit, FatherName, FatherPhone, MatherName,
  1730. MatherUnit, MatherPhone, username, password, MailAddress, PostalCode, InSchoolStatus, TransMark, ClassTutorNo,
  1731. ResumeCheck, PracStatus, RegisterStatus, PunishmentDate, F_CityId, F_CountyId, F_ProvinceId, F_SchoolId,
  1732. EduSystem, StudyModality, SyncFlag)
  1733. select NEWID(),StuNo,null,NoticeNo,null,ksh,DeptNo,MajorNo,MajorDetailNok as MajorDetailNo,MajorDetailName,Grade,ClassNo,StuName,null,null,case when GenderNo ='1' then 1 else 0 end,Birthday,PartyFaceNo,FamilyOriginNo,NationalityNo,ProvinceNo,RegionNo,ResidenceNo,TestStuSortNo,HealthStatusNo,WillNo,TestStuSubjectNo,GraduateNo,PlanFormNo,IsThreeGood,IsExcellent,IsNormalCadre,IsProvinceFirstThree,OverseasChineseNo,MatriculateSort,null,HighSchoolNo,HighSchoolName,null,null,GoodAt,IdentityCardNo,null,null,null,null,null,null,null,null,null,null,null,null,null,null,Remark,ArriveDate as RegisterDate,Photo,null,null,telephone as mobile,null,null,null,null,null,null,null,null,StuNo as username,null,MailAddress,PostalCode,null,TransMark,null,null,null,RegisterStatus,null,null,null,null,F_SchoolId,null,null,0 from
  1734. (select f.*,m.F_SchoolId from StuInfoFresh f left join CdMajor m on f.MajorNo=m.MajorNo where f.StuNo is not null ) as bb
  1735. where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo) ");
  1736. this.BaseRepository("CollegeMIS").ExecuteBySql(strSql.ToString());
  1737. //新生表修改“是否生成学籍”的状态
  1738. var strSql2 = new StringBuilder();
  1739. strSql2.Append("update StuInfoFresh set IsInBasic=1 where StuNo is not null and (IsInBasic is null or IsInBasic=0) and StuNo in (select t.StuNo from StuInfoBasic t where t.StuNo=StuNo)");
  1740. this.BaseRepository("CollegeMIS").ExecuteBySql(strSql2.ToString());
  1741. }
  1742. catch (Exception ex)
  1743. {
  1744. if (ex is ExceptionEx)
  1745. {
  1746. throw;
  1747. }
  1748. else
  1749. {
  1750. throw ExceptionEx.ThrowServiceException(ex);
  1751. }
  1752. }
  1753. }
  1754. /// <summary>
  1755. /// 删除宿舍信息
  1756. /// </summary>
  1757. public void DeleteBed(string keyValue)
  1758. {
  1759. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  1760. try
  1761. {
  1762. var stuInfoFreshEntity = db.FindEntity<StuInfoFreshEntity>(x => x.ID == keyValue);
  1763. if (stuInfoFreshEntity != null && !string.IsNullOrEmpty(stuInfoFreshEntity.DormitoryNo))
  1764. {
  1765. var dormitoryBuildEntity = db.FindEntity<Acc_DormitoryBuildEntity>(x => x.ID == stuInfoFreshEntity.DormitoryNo);
  1766. if (dormitoryBuildEntity != null)
  1767. {
  1768. //判断是否清除宿舍中预分班级
  1769. var roomEntity = db.FindEntity<Acc_DormitoryBuildEntity>(x => x.ID == dormitoryBuildEntity.ParentID);
  1770. if (roomEntity != null)
  1771. {
  1772. roomEntity.PlanBedNum = roomEntity.PlanBedNum - 1;
  1773. var aa = db.FindList<Acc_DormitoryBuildEntity>(x => x.ParentID == roomEntity.ID && x.PlanClassNo == dormitoryBuildEntity.PlanClassNo && x.ID != dormitoryBuildEntity.ID);
  1774. if (!aa.Any()) //宿舍不存在同班学生
  1775. {
  1776. var tempClass = dormitoryBuildEntity.PlanClassNo + ",";
  1777. roomEntity.PlanClassNo = roomEntity.PlanClassNo.Replace(tempClass, "");
  1778. }
  1779. db.Update(roomEntity);
  1780. }
  1781. //清除Acc_DormitoryBuild
  1782. db.ExecuteBySql("update Acc_DormitoryBuild set PlanStudentID=null,PlanClassNo=null where ID='" + dormitoryBuildEntity.ID + "' ");
  1783. }
  1784. //清除StuInfoFresh
  1785. db.ExecuteBySql("update StuInfoFresh set DormitoryNo=null,DormitoryName=null where ID='" + stuInfoFreshEntity.ID + "' ");
  1786. }
  1787. db.Commit();
  1788. }
  1789. catch (Exception ex)
  1790. {
  1791. db.Rollback();
  1792. if (ex is ExceptionEx)
  1793. {
  1794. throw;
  1795. }
  1796. else
  1797. {
  1798. throw ExceptionEx.ThrowServiceException(ex);
  1799. }
  1800. }
  1801. }
  1802. public class InAndOutList
  1803. {
  1804. public string X { get; set; }
  1805. public string Y { get; set; }
  1806. public string Sum { get; set; }
  1807. }
  1808. #endregion
  1809. #region 上传图片
  1810. internal (bool, string) IsPhoto(string stuId, bool status, string fileGuid)
  1811. {
  1812. try
  1813. {
  1814. string result = "";
  1815. bool resultBool = false;
  1816. var model = this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshEntity>(a => a.ID == stuId);
  1817. if (model != null)
  1818. {
  1819. model.Photo = fileGuid;
  1820. resultBool = true;
  1821. result = "操作成功!";
  1822. this.BaseRepository("CollegeMIS").Update(model);
  1823. }
  1824. else
  1825. {
  1826. result = "错误";
  1827. }
  1828. return (resultBool, result);
  1829. }
  1830. catch (Exception ex)
  1831. {
  1832. if (ex is ExceptionEx)
  1833. {
  1834. throw;
  1835. }
  1836. else
  1837. {
  1838. throw ExceptionEx.ThrowServiceException(ex);
  1839. }
  1840. }
  1841. }
  1842. #endregion
  1843. }
  1844. }