Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends,


i want to generate a number with reference to previous number(ex: i want to generate 4 and if previous value is 3) n this should happen in one time button click, if i click the button again it should not generate the next value (ex: i got the number 4 on button click, if i click second time the value must remain 4 it should not generate 5)
Posted
Comments
Vivek Krishnamurthy 2-Dec-11 1:04am    
What is the question ? You can disable the button after first click.
Manoj K Bhoir 2-Dec-11 1:28am    
You have to retrive Max no present in database after that increment it by one or if DataBase is empty assign it 1.

This is for reference...
C#
int n=0;

protected void button1_Click(....)
{
/*
code related to number ..
*/

n++;
button1.Enabled = false;
}
 
Share this answer
 
Code similar to the one below will do it for you


C#
.....

public class Form1()
{
     private bool incremented;
     private int numToIncrement;

........


     public Form1()
     {
          numToIncrement=0;
          incremented = false;
     }

     private void button1_Click(.......)
     {
           numToIncrement = //Get number from database here
          if(!incremented)
          {
              numToIncrement++;
              // put code her to show a messagebox to indicate that the number 
              //has already been incremented or whatever other way you want to 
              //do it
              //save to database here

          }
          else
          {
              
                // put code her to show a messagebox to indicate that the number 
                //has already been incremented or whatever other way you want to 
                //do it
          }

          incremented = true;

     }

     ........
}
 
Share this answer
 
v5
Comments
Vivek Shankar 2-Dec-11 4:01am    
it should check for the previous number from database and it should generate with respect to dat value
sucram 2-Dec-11 5:34am    
Update the code. You really could have figured that part out yourself

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900