Beispiel #1
0
        /// <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);
        }
        public ActionResult SN()
        {
            string           TabName   = WebUtil.GetFormValue <string>("TabName", string.Empty);
            int              PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int              PageSize  = WebUtil.GetFormValue <int>("PageSize", 10);
            SequenceProvider provider  = new SequenceProvider();
            SequenceEntity   entity    = new SequenceEntity();

            if (!TabName.IsEmpty())
            {
                entity.Where("TabName", ECondition.Like, "%" + TabName + "%");
            }

            PageInfo pageInfo = new PageInfo()
            {
                PageIndex = PageIndex, PageSize = PageSize
            };
            List <SequenceEntity> listResult = provider.GetList(entity, ref pageInfo);

            listResult = listResult.IsNull() ? new List <SequenceEntity>() : listResult;
            string json = JsonConvert.SerializeObject(listResult);

            this.ReturnJson.AddProperty("Data", json);
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return(Content(this.ReturnJson.ToString()));
        }
Beispiel #3
0
        /// <summary>
        /// 修改序号
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(SequenceEntity entity)
        {
            entity.Include(a => new { a.FirstType, a.FirstRule, a.FirstLength, a.SecondType, a.SecondRule, a.SecondLength, a.ThirdType, a.ThirdRule, a.ThirdLength, a.FourType, a.FourRule, a.FourLength, a.JoinChar, a.Sample, a.CurrentValue, a.Remark });
            entity.Where(a => a.SN == entity.SN).Where(a => a.CompanyID == this.CompanyID);
            int line = this.Sequence.Update(entity);

            return(line);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        /// <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);
        }
Beispiel #6
0
        /// <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);
        }