tx
2025-04-10 2538101febc78f525945da72c7cdcb2589f9e6ea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
 
namespace TProduct.BLL
{
    public partial class TestProjectItem
    {
        //编号键
        private const string _key_no = "TestItemCode";
 
        //创建编号
        public string CreateNO()
        {
            var service_soft_setting = new SoftSetting();
            var no_model = service_soft_setting.GetByCodeSetting(_key_no);
            if (no_model == null)
            {
                no_model = new Model.SoftSetting();
                no_model.Type = "Code";
                no_model.Name = _key_no;
                no_model.Value = "0";
                no_model.ID = service_soft_setting.Insert(no_model);
            }
            var setValue = Convert.ToInt64(no_model.Value);
            setValue++;
            var code = $"PI-{setValue.ToString("000000000")}";
            no_model.Value = setValue.ToString();
            service_soft_setting.Update(no_model);
            return code;
        }
 
        public List<string> CreateNO(int count)
        {
            var service_soft_setting = new SoftSetting();
            var no_model = service_soft_setting.GetByCodeSetting(_key_no);
            if (no_model == null)
            {
                no_model = new Model.SoftSetting();
                no_model.Type = "Code";
                no_model.Name = _key_no;
                no_model.Value = "0";
                no_model.ID = service_soft_setting.Insert(no_model);
            }
            var originValue = Convert.ToInt64(no_model.Value);
            var newSetValue = originValue + count;
            no_model.Value = newSetValue.ToString();
            service_soft_setting.Update(no_model);
 
            List<string> codes = new List<string>();
            for (var i = originValue + 1; i <= newSetValue; i++)
            {
                var code = $"PI-{i.ToString("000000000")}";
                codes.Add(code);
            }
 
            return codes;
        }
    }
}