如何在Windows应用程序中使用csharp自动增加顺序 [英] how to autoincrement the order no using csharp in windows application
问题描述
注意这是windows应用程序
MsAccess中的数据库结构如下
订单无文字
订单日期日期时间
设计如下;
订购无组合框
订单日期文本框(日历图片)
按钮如下
新保存清除。
运行模式如下;
订单号OR001
订购日期15/2/2013
,OROOl通过编码自动进入。
并输入日期并保存记录。 />
然后我放了另一条记录,当我点击下一个按钮OR002自动来编码。
怎么样自动增加订单编号
我正在使用ms访问数据库。
在新按钮中,wh在代码我必须打字。
请帮帮我。
问候和谢谢,
Narasiman p
Note It is windows application
Database structure as follows in MsAccess
Order No text
Order date datetime
Design as follows;
Order NO combobox
Order date textbox(Calendar image)
Button as follows
New Save Clear.
Run Mode as follows;
Order No OR001
Order Date 15/2/2013
in the run mode when i click the new button, OROOl autcomatically come by coding.
and enter the date and save the record.
then i put another record, when i click the next button OR002 automatically come by coding.
how to autoincrement the Order no.
I am using ms access database.
In the new button, what code i have to type.
please help me.
regards & Thanks,
Narasiman p
推荐答案
private void AddNewEmployeeDetails_Load(object sender,EventArgs e)
{
AutomaticID();
}
public void AutomaticID()
{
int a;
SqlConnection con = new SqlConnection(cnstr);
con.Open();
string query =从EmployeeDetails中选择count(*)作为EmployeeID;
SqlCommand cmd = new SqlCommand(query,con);
SqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
a = Convert.ToInt32(dr [0] .ToString());
int b = a + 1;
textBox1.Text =USP+ b.ToString();
}
else
{
}
con.Close();
}
private void AddNewEmployeeDetails_Load(object sender, EventArgs e)
{
AutomaticID();
}
public void AutomaticID()
{
int a;
SqlConnection con = new SqlConnection(cnstr);
con.Open();
string query = "Select count(*) as EmployeeID from EmployeeDetails";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
a = Convert.ToInt32(dr[0].ToString());
int b = a + 1;
textBox1.Text = "USP" + b.ToString();
}
else
{
}
con.Close();
}
这篇关于如何在Windows应用程序中使用csharp自动增加顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!