如何使用C#窗口应用程序生成序列号?请帮忙!!!!!!! [英] how to generate sequence number using C# window application? please help!!!!!!!
本文介绍了如何使用C#窗口应用程序生成序列号?请帮忙!!!!!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我想在C#窗口应用程序中生成序列号,我在Google中有一个链接为 ^ ],但我不想像这样我希望单击添加按钮后,应该生成一个订单序列号并将其存储在SQL数据库中,并且可以基于订单号在数据网格视图"中查看
在此先感谢:rose :: rose:
Hi
I want to generate sequence number in C# window application I have got one link in Google which is this[^], but I don''t want like this way. I want that on click to add button an order sequence number should generate and stored in SQL Database and on base of order number i can view in "Data Grid View"
Thank in Advance :rose::rose:
推荐答案
如果您想要一个可靠的序列号,则必须在数据库中而不是在应用程序中创建它-考虑一下多个用户同时使用...
If you want a reliable sequence numbering, you have to create it in the database, not in the app - think about multiple users at the same time ...
您可以使用文本文件来生成和存储号码.
You can use a text file to generate and store the number.
using System.IO;
private int GenerateSequenceNumber()
{
string file2 = "test.txt";
FileInfo fiRead = new FileInfo(file2);
string input = string.Empty;
int num = 1;
if (fiRead.Exists)
{
input = File.ReadAllText(file2);
}
if (input != string.Empty)
{
num = Convert.ToInt32(input);
}
File.WriteAllText(file2, (num + 1).ToString());
return num;
}
这篇关于如何使用C#窗口应用程序生成序列号?请帮忙!!!!!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文