Example #1
0
        public string GetOrCreateAutoCode(Type targetType, string defaultFormat = null, string beiZhu = null)
        {
            var    vm   = UIModel.Views.CreateBaseView(targetType);
            string name = vm.Label + "-自动编码规则";

            var item = this.FetchFirst(name);

            if (item == null)
            {
                item = new AutoCodeInfo
                {
                    MingCheng = name,
                    CanShuZhi = defaultFormat ?? "<YEAR><MONTH><DAY>-***",
                    BeiZhu    = beiZhu ??
                                @"自动编码填写规则
***表示自动编号
<YEAR> 表示当前年份
<MONTH> 表示当前月份
<DAY> 表示当前日号
如要编写 年+月+日+自动编号
则值为:<YEAR><MONTH><DAY>-***"
                };
                this.Save(item);
            }

            var format = item.CanShuZhi;

            var t    = DateTime.Today;
            var code = format.Replace("<YEAR>", t.Year.ToString("0000"))
                       .Replace("<MONTH>", t.Month.ToString("00"))
                       .Replace("<DAY>", t.Day.ToString("00"));

            if (code.Contains("***"))
            {
                var count = RF.Find(targetType).CountAll() + 1;
                code = code.Replace("***", count.ToString("0000"));
            }

            return(code);
        }
Example #2
0
 public void Insert(int index, AutoCodeInfo entity)
 {
     base.Insert(index, entity);
 }
Example #3
0
 public int IndexOf(AutoCodeInfo entity)
 {
     return(base.IndexOf(entity));
 }
Example #4
0
 public bool Contains(AutoCodeInfo entity)
 {
     return(base.Contains(entity));
 }
Example #5
0
 public void Add(AutoCodeInfo entity)
 {
     base.Add(entity);
 }
Example #6
0
 public bool Remove(AutoCodeInfo entity)
 {
     return(base.Remove(entity));
 }