예제 #1
0
파일: AutoCodeInfo.cs 프로젝트: yungtau/oea
        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);
        }
예제 #2
0
 public void Insert(int index, AutoCodeInfo entity)
 {
     base.Insert(index, entity);
 }
예제 #3
0
 public int IndexOf(AutoCodeInfo entity)
 {
     return(base.IndexOf(entity));
 }
예제 #4
0
 public bool Contains(AutoCodeInfo entity)
 {
     return(base.Contains(entity));
 }
예제 #5
0
 public void Add(AutoCodeInfo entity)
 {
     base.Add(entity);
 }
예제 #6
0
 public bool Remove(AutoCodeInfo entity)
 {
     return(base.Remove(entity));
 }