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); }
public void Insert(int index, AutoCodeInfo entity) { base.Insert(index, entity); }
public int IndexOf(AutoCodeInfo entity) { return(base.IndexOf(entity)); }
public bool Contains(AutoCodeInfo entity) { return(base.Contains(entity)); }
public void Add(AutoCodeInfo entity) { base.Add(entity); }
public bool Remove(AutoCodeInfo entity) { return(base.Remove(entity)); }