本文介绍了如何每天生成账单编号从1开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用c#2010 windows应用程序创建Windows应用程序,在我的应用程序中我使用下面的代码生成帐单编号,但在这里我想知道如何从每天开始我的帐单编号1.给我任何一个想法。
i am creating windows application using c# 2010 windows application, in my application i am using below code for bill number generation, but here i want how to my bill number every day starts from 1. give me any one some ideas.
public void AutoNumber()
{
SqlConnection con = new SqlConnection(db.Connectionstring());
con.Open();
SqlCommand cmd = new SqlCommand("SELECT max(billno) +1 FROM billing", con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
lblbillno.Text = dr[0].ToString();
if (lblbillno.Text == "")
{
lblbillno.Text = "1";
}
}
}
else
{
lblbillno.Text = "1";
}
con.Close();
}
我的尝试:
What I have tried:
How to generate bill number every day starts from 1
推荐答案
SELECT ROW_NUMBER() OVER (PARTITION BY EnterDate ORDER BY RowIDValueColumn ASC) AS DailyNumber, *
FROM MyTable
WHERE EnterDate >= '2016-02-02'
ORDER BY RowIDValueColumn ASC
这篇关于如何每天生成账单编号从1开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!