UnitOfWork

Posts   
 
    
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 15-Jul-2010 13:57:09   

Hi, LLBLGEN V 3.0 .NET Framework 2.0 Oracle 9i/10g LLBLGen Runtime Framework

Here is my code. Problem: The grid has 3 rows, but only one row is being inserted in DB. Please HELP !

private void btnsave_Click(object sender, EventArgs e) {

        //dgridtaxgroup


        var Taxgroup = new TaxgroupEntity();
        string message;

        var SECTION_ID = "";
        Int32 Slno = 0;
        var RowCount =
                        Convert.ToInt32(dgridtaxgroup.Rows.GetRowCount(DataGridViewElementStates.None)) - 1;
        if (RowCount > 0)
        {


            SECTION_ID = "1";
            if (string.IsNullOrEmpty(SECTION_ID)) return;
            var TaxgroupBulkInsert = new UnitOfWork2();
            var taxgroupadapter = new DataAccessAdapter();
            for (var i = 0; i < RowCount; i++)


            {
                var TaxDescriptionID = "";
                var FormulaName = "";
                var Formula = "";


                Slno = Slno + 1;

                if (!string.IsNullOrEmpty(Convert.ToString(dgridtaxgroup.Rows[i].Cells[1].Value).Trim()))
                    TaxDescriptionID = Convert.ToString(dgridtaxgroup.Rows[i].Cells[4].Value).Trim();

                if (!string.IsNullOrEmpty(Convert.ToString(dgridtaxgroup.Rows[i].Cells[2].Value).Trim()))
                    FormulaName = Convert.ToString(dgridtaxgroup.Rows[i].Cells[2].Value).Trim();

                if (!string.IsNullOrEmpty(Convert.ToString(dgridtaxgroup.Rows[i].Cells[3].Value).Trim()))
                    Formula = Convert.ToString(dgridtaxgroup.Rows[i].Cells[3].Value).Trim();

                Taxgroup.Description = Convert.ToString(tbxdescription.Text);
                Taxgroup.Taxgroupserialno = Convert.ToInt32(1);
                Taxgroup.Formulaname = Convert.ToString(FormulaName);
                Taxgroup.Formula = Convert.ToString(Formula);
                Taxgroup.TaxId = Convert.ToInt32(TaxDescriptionID);
                Taxgroup.Serialno = Convert.ToInt32(Slno);
                Taxgroup.Effectivedatefrom = Convert.ToDateTime(dateeffectivedatefrom.Text);
                Taxgroup.Effectivedateto = Convert.ToDateTime(dateeffectivedateto.Text);



                TaxgroupBulkInsert.AddForSave(Taxgroup,true);




            }
            TaxgroupBulkInsert.Commit(taxgroupadapter, true);
        }

        MessageBox.Show(StandardMessage.datasavesuccess);
        DoRefresh();
    }
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 15-Jul-2010 14:31:18   

Did you debug your code to see how many entities were added? Did you check whether there was new data in them? Just dumping some code here and hope we will fix it for you is not going to work.

For the past weeks you've asked a lot of questions here, and we know the learning curve is steep sometimes, and therefore we're here to help out. However that doesn't mean we'll jump in whenever something in your code is not working like it should: we ask from you and everyone else to check first whether their own code is bug free. Also we ask from the people posting here to provide information they've gathered during the debug session so we don't have to spend that time again and also get information about other elements at play, as we don't have your code in front of you nor are we part of your team.

Frans Bouma | Lead developer LLBLGen Pro
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 15-Jul-2010 14:41:34   

Otis wrote:

Did you debug your code to see how many entities were added? Did you check whether there was new data in them? Just dumping some code here and hope we will fix it for you is not going to work.

For the past weeks you've asked a lot of questions here, and we know the learning curve is steep sometimes, and therefore we're here to help out. However that doesn't mean we'll jump in whenever something in your code is not working like it should: we ask from you and everyone else to check first whether their own code is bug free. Also we ask from the people posting here to provide information they've gathered during the debug session so we don't have to spend that time again and also get information about other elements at play, as we don't have your code in front of you nor are we part of your team.

Ok Sir. I will follow your suggestion and check before we post question.

Sir, I do agree I have posted lot of question but with all your help, am happy to say we have achieved lot of things in LLBLGEN which we never thought would be possible.

Will check on your suggestions and revert back soon with specific problem

shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 15-Jul-2010 17:42:48   

shekar wrote:

Otis wrote:

Did you debug your code to see how many entities were added? Did you check whether there was new data in them? Just dumping some code here and hope we will fix it for you is not going to work.

For the past weeks you've asked a lot of questions here, and we know the learning curve is steep sometimes, and therefore we're here to help out. However that doesn't mean we'll jump in whenever something in your code is not working like it should: we ask from you and everyone else to check first whether their own code is bug free. Also we ask from the people posting here to provide information they've gathered during the debug session so we don't have to spend that time again and also get information about other elements at play, as we don't have your code in front of you nor are we part of your team.

Ok Sir. I will follow your suggestion and check before we post question.

Sir, I do agree I have posted lot of question but with all your help, am happy to say we have achieved lot of things in LLBLGEN which we never thought would be possible.

Will check on your suggestions and revert back soon with specific problem

Sir, Apologies am back again.

What i noticed is it is inserting one row and updating same row for second time instead of adding a new row.

I do agree that I am a beginner and LLBLGen has a steep learning curve.

But with all your help am halfway through my project and now in critical stage of transaction entries by users of application. Looking forward for solution.

Thanks in advance.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 16-Jul-2010 01:20:26   

You need to move the line

var Taxgroup = new TaxgroupEntity();

inside the foreach loop, otherwise you are reusing the same entity over again, which is why the same row is being updated

Matt

shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 16-Jul-2010 06:14:06   

MTrinder wrote:

You need to move the line

var Taxgroup = new TaxgroupEntity();

inside the foreach loop, otherwise you are reusing the same entity over again, which is why the same row is being updated

Matt

Thanks MTrinder.