using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using EMIS.Entities;
using EMIS.ViewModel.CacheManage;
namespace EMIS.ViewModel.TeachingMaterial
{
[Serializable]
public class TeachingMaterialPoolView
{
///
/// 教材ID
///
[DisplayName("教材ID")]
public Guid TeachingMaterialPoolID { get; set; }
///
/// 教材编号
///
/// [Required]
[DisplayName("教材编号")]
[Required]
public string TeachingMaterialCode { get; set; }
///
/// 教材名称
///
[DisplayName("教材名称")]
[Required]
public string TeachingMaterialName { get; set; }
///
/// 教材名称
///
[DisplayName("教材简称")]
//[Required]
public string TeachingMaterialShorName { get; set; }
///
/// 课程ID
///
[DisplayName("课程")]
//[Required]
public HashSet CoursematerialEntityList { get; set; }
///
/// 课程名称
///
[DisplayName("课程名称")]
//[Required]
public string CoursematerialName
{
get
{
return string.Join(",", CoursematerialEntityList.Select(x => x.CourseName));
}
}
///
/// 课程代码
///
[DisplayName("课程代码")]
//[Required]
public string CoursematerialCode
{
get
{
return string.Join(",", CoursematerialEntityList.Select(x => x.CourseCode));
}
}
///
/// ISBN
///
[DisplayName("ISBN")]
[Required]
public string ISBN { get; set; }
private string isbnPre1Field;
[Required]
[DisplayName("国家编号")]
[StringLength(3, MinimumLength = 3, ErrorMessage = "请输入3位国家编号")]
public string ISBNPre1
{
get
{
var trimISBN = (ISBN ?? "").Trim().Replace("-", "");
if (trimISBN.Length >= 3)
{
return trimISBN.Substring(0, 3);
}
else if (trimISBN.Length > 0)
{
return trimISBN;
}
else
{
return "978";
}
}
set
{
isbnPre1Field = value;
ISBN = isbnPre1Field + "-" + isbnPre2Field + "-" + isbnPre3Field + "-" + isbnPre4Field + "-" + isbnPre5Field;
}
}
private string isbnPre2Field;
[Required]
[DisplayName("国代号")]
[StringLength(1, MinimumLength = 1, ErrorMessage = "请输入1位国代号")]
public string ISBNPre2
{
get
{
var trimISBN = (ISBN ?? "").Trim().Replace("-", "");
if (trimISBN.Length >= 4)
{
return trimISBN.Substring(3, 1);
}
else
{
return "7";
}
}
set
{
isbnPre2Field = value;
ISBN = isbnPre1Field + "-" + isbnPre2Field + "-" + isbnPre3Field + "-" + isbnPre4Field + "-" + isbnPre5Field;
}
}
private string isbnPre3Field;
[Required]
[DisplayName("出版社代号")]
[StringLength(6, MinimumLength = 2, ErrorMessage = "请输入2-6位出版社代号")]
[TotalLength(8, "ISBNPre4", ErrorMessage = "出版社代号和出版序号加起来应该有8位")]
public string ISBNPre3
{
get
{
var isbnGroup = ISBN.Split('-');
var subString = "";
if (isbnGroup.Length >= 3 && isbnGroup[2].Length >= 2 && isbnGroup[2].Length <= 6)
{
return isbnGroup[2];
}
if (isbnGroup.Length >= 3)
{
subString = isbnGroup[2];
}
else
{
var trimISBN = (ISBN ?? "").Trim().Replace("-", "");
if (trimISBN.Length > 4)
{
subString = trimISBN.Substring(4);
}
else
{
subString = "";
}
}
if (subString.Length >= 6)
{
return subString.Substring(0, 6);
}
else
{
return subString;
}
}
set
{
isbnPre3Field = value;
ISBN = isbnPre1Field + "-" + isbnPre2Field + "-" + isbnPre3Field + "-" + isbnPre4Field + "-" + isbnPre5Field;
}
}
private string isbnPre4Field;
[Required]
[DisplayName("出版序号")]
[StringLength(6, MinimumLength = 2, ErrorMessage = "请输入2-6位出版序号")]
[TotalLength(8, "ISBNPre3", ErrorMessage = "出版社代号和出版序号加起来应该有8位")]
public string ISBNPre4
{
get
{
var isbnGroup = ISBN.Split('-');
var subString = "";
if (isbnGroup.Length >= 4 && isbnGroup[3].Length >= 2 && isbnGroup[3].Length <= 6)
{
return isbnGroup[3];
}
if (isbnGroup.Length >= 4)
{
subString = isbnGroup[3];
}
else
{
var trimISBN = (ISBN ?? "").Trim().Replace("-", "");
var pre3Length = this.ISBNPre3.Length;
if (trimISBN.Length > (4 + pre3Length))
{
subString = trimISBN.Substring(4 + pre3Length);
}
else
{
subString = "";
}
}
return subString;
}
set
{
isbnPre4Field = value;
ISBN = isbnPre1Field + "-" + isbnPre2Field + "-" + isbnPre3Field + "-" + isbnPre4Field + "-" + isbnPre5Field;
}
}
private string isbnPre5Field;
[Required]
[DisplayName("校验位")]
[StringLength(1, MinimumLength = 1, ErrorMessage = "请输入1位校验位")]
public string ISBNPre5
{
get
{
var isbnGroup = ISBN.Split('-');
if (isbnGroup.Length >= 5)
{
return isbnGroup[4];
}
else
{
return "";
}
}
set
{
isbnPre5Field = value;
ISBN = isbnPre1Field + "-" + isbnPre2Field + "-" + isbnPre3Field + "-" + isbnPre4Field + "-" + isbnPre5Field;
}
}
///
///教材类型
///
[DisplayName("教材类型")]
[Required]
public int? TeachingMaterialTypeID { get; set; }
///
///教材类型
///
[DisplayName("教材类型")]
public string TeachingMaterialTypeName
{
get
{
return IdNameExt.GetDictionaryItem(DictionaryItem.CF_TeachingMaterialType.ToString())
.Where(x => x.Value == TeachingMaterialTypeID)
.Select(x => x.Name).FirstOrDefault();
}
}
///
/// 获奖级别
///
[DisplayName("获奖级别")]
public int? WnningLevel { get; set; }
///
/// 获奖级别
///
[DisplayName("获奖级别")]
public string WnningLevelName { get; set; }
///
/// 版本时间
///
[DisplayName("版本时间")]
//[Required]
public string PublishTime { get; set; }
///
/// 出版单位ID
///
[DisplayName("出版单位ID")]
[Required]
public Guid? PublishID { get; set; }
///
/// 出版单位
///
[DisplayName("出版单位")]
[Required]
public string PublishName { get; set; }
///
/// 作者
///
[DisplayName("作者")]
[Required]
public string Author { get; set; }
///
/// 单价
///
[DisplayName("单价")]
[Required]
[RegularExpression(@"^\d+(\.\d{1,2})?$", ErrorMessage = "必须填写有效的价格")]
public decimal? Price { get; set; }
///
/// 折合价
///
[DisplayName("折合价")]
public decimal? DiscountPrice { get; set; }
///
/// 是否过期
///
[DisplayName("是否过期")]
[Required]
public bool IsLate { get; set; }
///
/// 是否过期
///
public string IsLateName { get; set; }
///
/// 备注
///
[DisplayName("备注")]
public string Desc { get; set; }
///
/// 错误信息
///
[DisplayName("错误信息")]
public string ErrorMessage { get; set; }
///
/// 创建时间
///
[DisplayName("创建时间")]
public DateTime? CreateTime { get; set; }
///
/// 创建人
///
[DisplayName("创建人")]
public string CreateUserName { get; set; }
///
/// 修改时间
///
[DisplayName("修改时间")]
public DateTime? ModifyTime { get; set; }
///
/// 修改人
///
[DisplayName("修改人")]
public string ModifyUserName { get; set; }
///
/// 征订数量(用于教师征订)
///
[DisplayName("征订数量")]
public int? OrderQty { get; set; }
///
/// 课程级别(用于学生征订)
///
[DisplayName("课程级别")]
public string CourseLevelName { get; set; }
///
/// 课程科类(用于学生征订)
///
[DisplayName("课程科类")]
public string CourseScienceName { get; set; }
///
/// 折扣率
///
[DisplayName("折扣率")]
public decimal? Discount { get; set; }
///
/// 最小库存量
///
[DisplayName("最小库存量")]
[Required]
[RegularExpression(@"^[1-9]\d*$", ErrorMessage = "必须填写正整数")]
public int? MinInventory { get; set; }
///
/// 当前库存量
///
[DisplayName("当前库存量")]
public int? PresentInventory { get; set; }
///
/// 总价
///
[DisplayName("总价")]
public decimal? ZongJia { get; set; }
///
/// 码洋
///
[DisplayName("码洋")]
public decimal? MaYang { get; set; }
private bool _isExcelVaildateOK = true;
///
/// Excel验证是否通过,默认为true
/// true:通过;false:不通过
///
public bool IsExcelVaildateOK
{
get { return _isExcelVaildateOK; }
set { _isExcelVaildateOK = value; }
}
}
}