/// <summary> /// 采番 /// </summary> /// <returns></returns> public string GetSeqNo(string key) { SeqRule ack = GetKeyValues(key); string date = ""; switch (ack.date_type) { //年 采番 case 1: date = DateTime.Now.ToString("yy"); break; //年 月 采番 case 2: date = DateTime.Now.ToString("yyMM"); break; //年 月 日 采番 case 3: date = DateTime.Now.ToString("yyMMdd"); break; default: break; } return(ack.pre_fix + date + ack.key_values); }
/// <summary> /// 获取采番值 /// </summary> /// <param name="key">采番键值</param> /// <returns></returns> public SeqRule GetKeyValues(string key) { SeqRule ack = new SeqRule(); string sSql = "SELECT * FROM SeqNo WHERE SeqKey='" + key + "'"; DataSet ds = DbHelperMySQL.Query(sSql); SeqNo model = new SeqNo(); if (ds.Tables.Count > 0) { model = DataRowToModel(ds.Tables[0].Rows[0]); ack.date_type = model.DateType; ack.pre_fix = model.PreFix; //清零 ClearZero(model); if (model.NowNumber < model.MaxNumber) { model.NowNumber += model.IncreNumber; int length = (model.MaxNumber.ToString()).Length - (model.NowNumber.ToString()).Length; for (int i = 0; i < length; i++) { ack.key_values += "0"; } ack.key_values = ack.key_values + model.NowNumber.ToString(); EditSeqNo(model); } } return(ack); }
IEnumerable <int> MatchSeq(string input, SeqRule seq, int pos, int index) { if (index == seq.Seq.Count) { yield return(pos); yield break; } foreach (var end in Match(input, seq.Seq[index], pos)) { foreach (var end2 in MatchSeq(input, seq, end, index + 1)) { yield return(end2); } } }