You must Sign In to post a response.
  • Category: ASP.NET

    Avoiding Duplication in Invoice No

    Hello Team,

    I am working on a small project where there are 2 table

    Table 1 : TransactionMaster
    Table 2 : TransactionDetail

    I have a page where the user selects customer and product and then adds quantity, price and clicks on Add.
    After clicking on Add the data is stored in data table which is dynamically created and then the data table is stored in session,
    The data table which is stored in session is used as a data source to bind it to grid view.

    The same the user will add multiple products. After adding all products the user will click on Save. On the save event the data table stored in session and other records stored in textbox will be saved to sql table.

    My worry is that if multiple user are using the page the bill number shouldn't be duplicated and the bill number should be same in the master and detail table but duplication should not happen.

    So should i insert the data first in master table or detail table and how to get the Invoice number to be same for both table for the master and detail transaction.

    Thanks and regards
  • #762405
    Hi Raj,

    My suggestion is keep the Bill Number should be auto generated column, so that you can avoid duplicate, and whenever you are trying to add records in to table lock that table and insert records to avoid duplicates.

    Hope this will helpful to you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #762409
    Hi

    If you need check duplicate record means try this code


    DataTable dt1 = new DataTable();
    SqlDataAdapter sqladp = new SqlDataAdapter("Select count(*) from tblEmplist Where Regno="+ TxtRegno.Text +"", con);
    sqladp.Fill(dt1);

    if (Convert.ToInt32(dt.DefaultView[0][0]) == 0)
    {
    //Insert new
    }

    else
    {
    // Duplicate Records.
    }


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


Sign In to post your comments