Header Ads

AUTO GENAERATION

public void codegeneration(string SqlQry)
{
con.Close();
con.Open();
try
{

cmd = new SqlCommand(SqlQry, con);
int code = Convert.ToInt32(cmd.ExecuteScalar().ToString());
if (code < 9)
{

txtorderno.Text = "00000000" + Convert.ToString(code + 1);
}
else if (code < 99)
{

txtorderno.Text = "0000000" + Convert.ToString(code + 1);
}
else
{

txtorderno.Text = Convert.ToString(code + 1);
}
}
catch
{
txtorderno.Text = ("000000001");
}
con.Close();
}


THEN..................
You can call page load

codegeneration("select max(orderno)from table");

No comments:



Powered by Blogger.