/// <summary> /// 新增序号管理 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Init() { DataTable table = this.Sequence.GetTables(); if (table != null && table.Rows.Count > 0) { foreach (DataRow row in table.Rows) { string TabName = row["name"] != null ? row["name"].ToString() : string.Empty; if (!TabName.IsEmpty()) { SequenceEntity entity = new SequenceEntity(); entity.Where(a => a.TabName == TabName) .And(a => a.CompanyID == this.CompanyID) ; if (this.Sequence.GetCount(entity) == 0) { entity = new SequenceEntity(); entity.SN = TNumProvider.CreateGUID(); entity.TabName = TabName; entity.FirstType = (int)ESequence.Sequence; entity.FirstRule = ""; entity.FirstLength = 7; entity.JoinChar = ""; entity.CompanyID = this.CompanyID; entity.IncludeAll(); this.Sequence.Add(entity); } } } } return(0); }
/// <summary> /// 根据SN号获得序列 /// </summary> /// <param name="SN"></param> /// <returns></returns> public SequenceEntity Get(string SN) { SequenceEntity entity = new SequenceEntity(); entity.IncludeAll(); entity.Where(a => a.SN == SN).And(a => a.CompanyID == this.CompanyID); entity = this.Sequence.GetSingle(entity); return(entity); }
/// <summary> /// 根据表名序列 /// </summary> /// <param name="TabName"></param> /// <returns></returns> public SequenceEntity GetSingle(string TabName) { SequenceEntity entity = new SequenceEntity(); entity.IncludeAll(); entity.Where(a => a.TabName == TabName); entity = this.Sequence.GetSingle(entity); return(entity); }
/// <summary> /// 查询序列分页 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List <SequenceEntity> GetList(SequenceEntity entity, ref PageInfo pageInfo) { entity.IncludeAll(); entity.OrderBy(a => a.ID, EOrderBy.ASC); int rowCount = 0; List <SequenceEntity> listResult = this.Sequence.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; return(listResult); }
/// <summary> /// 查询序列分页 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List <SequenceEntity> GetList(SequenceEntity entity, ref PageInfo pageInfo) { entity.IncludeAll(); entity.Where(a => a.CompanyID == this.CompanyID); entity.OrderBy(a => a.ID, EOrderBy.ASC); if (!entity.TabName.IsEmpty()) { entity.And("TabName", ECondition.Like, "%" + entity.TabName + "%"); } int rowCount = 0; List <SequenceEntity> listResult = this.Sequence.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); if (listResult.IsNullOrEmpty()) { this.Init(); listResult = this.Sequence.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); } pageInfo.RowCount = rowCount; return(listResult); }