使用c#自动增加字母数字 [英] Auto Increment Of Alphanumeric number using c#
本文介绍了使用c#自动增加字母数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在文本框中添加ID。它应该是自动生成的& Alphanumaric。
我写了下面的代码&它用于获取下一个id,但是当表有一些记录时,它会自动从表&中获取最后一个id。然后递增一,ID格式应该是LEL5-1,LEL5-2,LEL5-3 ....等等。
I am trying to add ID in text box. it should be auto-generated & Alphanumaric.
I have written below code & its working for taking next id but when table has some records it automatically take last id from table & then increment by one and ID format should be LEL5-1,LEL5-2,LEL5-3....so on.
static int EJDS_id = 1;
string code;
private void JDF_Load(object sender, EventArgs e)
{
EJDS_id = EJDS_id + 1;
txtjobno.Text = "LEL5-" + EJDS_id.ToString();
}
请帮助
Please help
推荐答案
检查一下:向您的数据库询问该唯一ID [ ^ ]
如果您的数据库列是您插入的自动增量值,例如。 LEL5-1,LEL5-2,LEL5-3等。然后从数据库中读取记录,用字符' - '拆分并将nuber值存储到数组并排序到desc并从顶部读取第一个值。它将是最高ID值。现在增加一个,显示值到文本框你的格式。
If your database column is auto increment value inserted by you Eg. LEL5-1,LEL5-2,LEL5-3 and so on. Then Read the record from database split it with character '-' and store nuber value to array and sort to desc and read the 1st value from top.It will be Highest ID value .Now increment with one , show the value to text box with your format.
这篇关于使用c#自动增加字母数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文