Monday 16 September 2013

To Increase Bill No. Automatically

To increase Billno. Automatically through database 
just make a function same as below and call it on Page load 
public void billno()
        {
            try
            {

                da = new SqlDataAdapter("select MAX(Id) from CustomerDetails", con);
                dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    string id = dt.Rows[0][0].ToString();
                    if (id == "")
                    {
                       TextBox1.Text = "1000";
                    }
                    else
                    {
                        int id1 = Convert.ToInt32(id.ToString());
                        id1 = id1 + 1;
                        TextBox1.Text = id1.ToString();
                    }
                }
                else
                {
                    TextBox1.Text = "1000";
                }
                //TextBox1.Text = sb + TextBox45.Text;
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }

No comments:

Post a Comment