TeachingMaterialPoolView.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ComponentModel;
  6. using System.ComponentModel.DataAnnotations;
  7. using EMIS.Entities;
  8. using EMIS.ViewModel.CacheManage;
  9. namespace EMIS.ViewModel.TeachingMaterial
  10. {
  11. [Serializable]
  12. public class TeachingMaterialPoolView
  13. {
  14. /// <summary>
  15. /// 教材ID
  16. /// </summary>
  17. [DisplayName("教材ID")]
  18. public Guid TeachingMaterialPoolID { get; set; }
  19. /// <summary>
  20. /// 教材编号
  21. /// </summary>
  22. /// [Required]
  23. [DisplayName("教材编号")]
  24. [Required]
  25. public string TeachingMaterialCode { get; set; }
  26. /// <summary>
  27. /// 教材名称
  28. /// </summary>
  29. [DisplayName("教材名称")]
  30. [Required]
  31. public string TeachingMaterialName { get; set; }
  32. /// <summary>
  33. /// 教材名称
  34. /// </summary>
  35. [DisplayName("教材简称")]
  36. //[Required]
  37. public string TeachingMaterialShorName { get; set; }
  38. /// <summary>
  39. /// 课程ID
  40. /// </summary>
  41. [DisplayName("课程")]
  42. //[Required]
  43. public HashSet<EM_Coursematerial> CoursematerialEntityList { get; set; }
  44. /// <summary>
  45. /// 课程名称
  46. /// </summary>
  47. [DisplayName("课程名称")]
  48. //[Required]
  49. public string CoursematerialName
  50. {
  51. get
  52. {
  53. return string.Join(",", CoursematerialEntityList.Select(x => x.CourseName));
  54. }
  55. }
  56. /// <summary>
  57. /// 课程代码
  58. /// </summary>
  59. [DisplayName("课程代码")]
  60. //[Required]
  61. public string CoursematerialCode
  62. {
  63. get
  64. {
  65. return string.Join(",", CoursematerialEntityList.Select(x => x.CourseCode));
  66. }
  67. }
  68. /// <summary>
  69. /// ISBN
  70. /// </summary>
  71. [DisplayName("ISBN")]
  72. [Required]
  73. public string ISBN { get; set; }
  74. private string isbnPre1Field;
  75. [Required]
  76. [DisplayName("国家编号")]
  77. [StringLength(3, MinimumLength = 3, ErrorMessage = "请输入3位国家编号")]
  78. public string ISBNPre1
  79. {
  80. get
  81. {
  82. var trimISBN = (ISBN ?? "").Trim().Replace("-", "");
  83. if (trimISBN.Length >= 3)
  84. {
  85. return trimISBN.Substring(0, 3);
  86. }
  87. else if (trimISBN.Length > 0)
  88. {
  89. return trimISBN;
  90. }
  91. else
  92. {
  93. return "978";
  94. }
  95. }
  96. set
  97. {
  98. isbnPre1Field = value;
  99. ISBN = isbnPre1Field + "-" + isbnPre2Field + "-" + isbnPre3Field + "-" + isbnPre4Field + "-" + isbnPre5Field;
  100. }
  101. }
  102. private string isbnPre2Field;
  103. [Required]
  104. [DisplayName("国代号")]
  105. [StringLength(1, MinimumLength = 1, ErrorMessage = "请输入1位国代号")]
  106. public string ISBNPre2
  107. {
  108. get
  109. {
  110. var trimISBN = (ISBN ?? "").Trim().Replace("-", "");
  111. if (trimISBN.Length >= 4)
  112. {
  113. return trimISBN.Substring(3, 1);
  114. }
  115. else
  116. {
  117. return "7";
  118. }
  119. }
  120. set
  121. {
  122. isbnPre2Field = value;
  123. ISBN = isbnPre1Field + "-" + isbnPre2Field + "-" + isbnPre3Field + "-" + isbnPre4Field + "-" + isbnPre5Field;
  124. }
  125. }
  126. private string isbnPre3Field;
  127. [Required]
  128. [DisplayName("出版社代号")]
  129. [StringLength(6, MinimumLength = 2, ErrorMessage = "请输入2-6位出版社代号")]
  130. [TotalLength(8, "ISBNPre4", ErrorMessage = "出版社代号和出版序号加起来应该有8位")]
  131. public string ISBNPre3
  132. {
  133. get
  134. {
  135. var isbnGroup = ISBN.Split('-');
  136. var subString = "";
  137. if (isbnGroup.Length >= 3 && isbnGroup[2].Length >= 2 && isbnGroup[2].Length <= 6)
  138. {
  139. return isbnGroup[2];
  140. }
  141. if (isbnGroup.Length >= 3)
  142. {
  143. subString = isbnGroup[2];
  144. }
  145. else
  146. {
  147. var trimISBN = (ISBN ?? "").Trim().Replace("-", "");
  148. if (trimISBN.Length > 4)
  149. {
  150. subString = trimISBN.Substring(4);
  151. }
  152. else
  153. {
  154. subString = "";
  155. }
  156. }
  157. if (subString.Length >= 6)
  158. {
  159. return subString.Substring(0, 6);
  160. }
  161. else
  162. {
  163. return subString;
  164. }
  165. }
  166. set
  167. {
  168. isbnPre3Field = value;
  169. ISBN = isbnPre1Field + "-" + isbnPre2Field + "-" + isbnPre3Field + "-" + isbnPre4Field + "-" + isbnPre5Field;
  170. }
  171. }
  172. private string isbnPre4Field;
  173. [Required]
  174. [DisplayName("出版序号")]
  175. [StringLength(6, MinimumLength = 2, ErrorMessage = "请输入2-6位出版序号")]
  176. [TotalLength(8, "ISBNPre3", ErrorMessage = "出版社代号和出版序号加起来应该有8位")]
  177. public string ISBNPre4
  178. {
  179. get
  180. {
  181. var isbnGroup = ISBN.Split('-');
  182. var subString = "";
  183. if (isbnGroup.Length >= 4 && isbnGroup[3].Length >= 2 && isbnGroup[3].Length <= 6)
  184. {
  185. return isbnGroup[3];
  186. }
  187. if (isbnGroup.Length >= 4)
  188. {
  189. subString = isbnGroup[3];
  190. }
  191. else
  192. {
  193. var trimISBN = (ISBN ?? "").Trim().Replace("-", "");
  194. var pre3Length = this.ISBNPre3.Length;
  195. if (trimISBN.Length > (4 + pre3Length))
  196. {
  197. subString = trimISBN.Substring(4 + pre3Length);
  198. }
  199. else
  200. {
  201. subString = "";
  202. }
  203. }
  204. return subString;
  205. }
  206. set
  207. {
  208. isbnPre4Field = value;
  209. ISBN = isbnPre1Field + "-" + isbnPre2Field + "-" + isbnPre3Field + "-" + isbnPre4Field + "-" + isbnPre5Field;
  210. }
  211. }
  212. private string isbnPre5Field;
  213. [Required]
  214. [DisplayName("校验位")]
  215. [StringLength(1, MinimumLength = 1, ErrorMessage = "请输入1位校验位")]
  216. public string ISBNPre5
  217. {
  218. get
  219. {
  220. var isbnGroup = ISBN.Split('-');
  221. if (isbnGroup.Length >= 5)
  222. {
  223. return isbnGroup[4];
  224. }
  225. else
  226. {
  227. return "";
  228. }
  229. }
  230. set
  231. {
  232. isbnPre5Field = value;
  233. ISBN = isbnPre1Field + "-" + isbnPre2Field + "-" + isbnPre3Field + "-" + isbnPre4Field + "-" + isbnPre5Field;
  234. }
  235. }
  236. /// <summary>
  237. ///教材类型
  238. /// </summary>
  239. [DisplayName("教材类型")]
  240. [Required]
  241. public int? TeachingMaterialTypeID { get; set; }
  242. /// <summary>
  243. ///教材类型
  244. /// </summary>
  245. [DisplayName("教材类型")]
  246. public string TeachingMaterialTypeName
  247. {
  248. get
  249. {
  250. return IdNameExt.GetDictionaryItem(DictionaryItem.CF_TeachingMaterialType.ToString())
  251. .Where(x => x.Value == TeachingMaterialTypeID)
  252. .Select(x => x.Name).FirstOrDefault();
  253. }
  254. }
  255. /// <summary>
  256. /// 获奖级别
  257. /// </summary>
  258. [DisplayName("获奖级别")]
  259. public int? WnningLevel { get; set; }
  260. /// <summary>
  261. /// 获奖级别
  262. /// </summary>
  263. [DisplayName("获奖级别")]
  264. public string WnningLevelName { get; set; }
  265. /// <summary>
  266. /// 版本时间
  267. /// </summary>
  268. [DisplayName("版本时间")]
  269. //[Required]
  270. public string PublishTime { get; set; }
  271. /// <summary>
  272. /// 出版单位ID
  273. /// </summary>
  274. [DisplayName("出版单位ID")]
  275. [Required]
  276. public Guid? PublishID { get; set; }
  277. /// <summary>
  278. /// 出版单位
  279. /// </summary>
  280. [DisplayName("出版单位")]
  281. [Required]
  282. public string PublishName { get; set; }
  283. /// <summary>
  284. /// 作者
  285. /// </summary>
  286. [DisplayName("作者")]
  287. [Required]
  288. public string Author { get; set; }
  289. /// <summary>
  290. /// 单价
  291. /// </summary>
  292. [DisplayName("单价")]
  293. [Required]
  294. [RegularExpression(@"^\d+(\.\d{1,2})?$", ErrorMessage = "必须填写有效的价格")]
  295. public decimal? Price { get; set; }
  296. /// <summary>
  297. /// 折合价
  298. /// </summary>
  299. [DisplayName("折合价")]
  300. public decimal? DiscountPrice { get; set; }
  301. /// <summary>
  302. /// 是否过期
  303. /// </summary>
  304. [DisplayName("是否过期")]
  305. [Required]
  306. public bool IsLate { get; set; }
  307. /// <summary>
  308. /// 是否过期
  309. /// </summary>
  310. public string IsLateName { get; set; }
  311. /// <summary>
  312. /// 备注
  313. /// </summary>
  314. [DisplayName("备注")]
  315. public string Desc { get; set; }
  316. /// <summary>
  317. /// 错误信息
  318. /// </summary>
  319. [DisplayName("错误信息")]
  320. public string ErrorMessage { get; set; }
  321. /// <summary>
  322. /// 创建时间
  323. /// </summary>
  324. [DisplayName("创建时间")]
  325. public DateTime? CreateTime { get; set; }
  326. /// <summary>
  327. /// 创建人
  328. /// </summary>
  329. [DisplayName("创建人")]
  330. public string CreateUserName { get; set; }
  331. /// <summary>
  332. /// 修改时间
  333. /// </summary>
  334. [DisplayName("修改时间")]
  335. public DateTime? ModifyTime { get; set; }
  336. /// <summary>
  337. /// 修改人
  338. /// </summary>
  339. [DisplayName("修改人")]
  340. public string ModifyUserName { get; set; }
  341. /// <summary>
  342. /// 征订数量(用于教师征订)
  343. /// </summary>
  344. [DisplayName("征订数量")]
  345. public int? OrderQty { get; set; }
  346. /// <summary>
  347. /// 课程级别(用于学生征订)
  348. /// </summary>
  349. [DisplayName("课程级别")]
  350. public string CourseLevelName { get; set; }
  351. /// <summary>
  352. /// 课程科类(用于学生征订)
  353. /// </summary>
  354. [DisplayName("课程科类")]
  355. public string CourseScienceName { get; set; }
  356. /// <summary>
  357. /// 折扣率
  358. /// </summary>
  359. [DisplayName("折扣率")]
  360. public decimal? Discount { get; set; }
  361. /// <summary>
  362. /// 最小库存量
  363. /// </summary>
  364. [DisplayName("最小库存量")]
  365. [Required]
  366. [RegularExpression(@"^[1-9]\d*$", ErrorMessage = "必须填写正整数")]
  367. public int? MinInventory { get; set; }
  368. /// <summary>
  369. /// 当前库存量
  370. /// </summary>
  371. [DisplayName("当前库存量")]
  372. public int? PresentInventory { get; set; }
  373. /// <summary>
  374. /// 总价
  375. /// </summary>
  376. [DisplayName("总价")]
  377. public decimal? ZongJia { get; set; }
  378. /// <summary>
  379. /// 码洋
  380. /// </summary>
  381. [DisplayName("码洋")]
  382. public decimal? MaYang { get; set; }
  383. private bool _isExcelVaildateOK = true;
  384. /// <summary>
  385. /// Excel验证是否通过,默认为true
  386. /// <para>true:通过;false:不通过</para>
  387. /// </summary>
  388. public bool IsExcelVaildateOK
  389. {
  390. get { return _isExcelVaildateOK; }
  391. set { _isExcelVaildateOK = value; }
  392. }
  393. }
  394. }