如何使用C#窗口应用程序生成序列号?请帮忙!!!!!!! [英] how to generate sequence number using C# window application? please help!!!!!!!

查看:73
本文介绍了如何使用C#窗口应用程序生成序列号?请帮忙!!!!!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在C#窗口应用程序中生成序列号,我在Google中有一个链接为
在此先感谢: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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆