hi
this my code . iam auto generating the PO Number which is in format PO-OOO1.
I want to auto generate. By this code iam getting PO-1 like this. iwant it PO-0001.
suggestions required in code
Name = "PO-"; SqlCommand cmd = new SqlCommand("Select top 1 * from Purordr order by purordr_pur_ordno desc ", con); con.Open(); SqlDataReader d = cmd.ExecuteReader(); if (d.Read() == true) { str = d["purordr_pur_ordno"].ToString();//it is String } for (int index = 0; index < str.Length; index++) { c[index] = str[index]; } con.Close(); int x = Convert.ToInt32(c[3].ToString()); int y = Convert.ToInt32(c[4].ToString()); int z = Convert.ToInt32(c[5].ToString()); int A = Convert.ToInt32(c[6].ToString());
int PNo = Convert.ToInt32(x * Math.Pow(10, 3)) + Convert.ToInt32(y * Math.Pow(10, 2)) + Convert.ToInt32(z * Math.Pow(10, 1)) + Convert.ToInt32(A * Math.Pow(10, 0)); int PN = PNo + 1; tb_ordrno.Text = Name + PN.ToString();
|
| Author: Anil Chalasani 04 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
use like this tb_ordrno.Text = Name + PN.ToString("0000");
Thanks & Regards Anil Chalasani.
|
| Author: Manigandan 04 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
Hi,
Instead of giving the 0001 as integer, Give it as a Nvarchar.
Thanks, Mani http://manicse85.blogspot.com/
|
| Author: Devendra 04 Jul 2009 | Member Level: Gold | Rating:  Points: 2 |
Dear,
Why you are not using Stuff instead of Writing procedure just use stuff formula to write these.
See How to write stuff in Sql Server and use that it would be better generate auto no.
thanks devendra
|
| Author: Sucharitha 07 Jul 2009 | Member Level: Silver | Rating:  Points: 2 |
dim num as integer dim s1 as string
c.cmd = New SqlCommand("select IsNull(Max(po_id),0)+1 from purorder_tbl ", c.con) c.con.Open() num = c.cmd.ExecuteScalar() c.con.Close()
s1 = "000" textbo1.text= s1 & num
|