Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Add row to another table from within busines object
Message
De
05/11/2008 13:32:26
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 2.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01359912
Message ID:
01359923
Vues:
42
Hi Linda,

>When certain fields are updated in one table, I want to automatically create a row in a related table if that row does not already exist. I am trying to do that from within the business object for the first table. Everything acts like it's working but the record does not get saved. I am using a HookPostSave override method.
>
>I know when I add rows to a table using mmButtonNew, I have to set the table row to the newly added row by changing the binding context. This is not available from the business object, but I wonder if the problem is similar. I am having trouble figuring out how to fix this. Here's what I have so far. Thanks in advance for any help.
>
>
>        protected override void HookPostSave(DataTable dt)
>        {
>            base.HookPostSave(dt);
>            this.oLCCDate.GetLCCDateByPatientId(Entity.PatientId);
>            if (oLCCDate.DataSet.Tables[0].Rows.Count == 0)
>            {
>                oLCCDate.NewRow(oLCCDate.DefaultValues);
>                //oLCCDate.GetCurrentDataSet();
>                oLCCDate.Entity.PatientId = Entity.PatientId;
>                oLCCDate.Entity.BegDate = (DateTime)Entity.LCCBegin;
>                oLCCDate.Entity.EndDate = (DateTime)Entity.LCCEnd;
>                oLCCDate.Entity.EnterBy = mmAppBase.UserMgr.UserID;
>                oLCCDate.Entity.LCCMonths = 0;
>                oLCCDate.SaveRow();
>            }
>        }
>
First just a comment; the hook methods are for your code so there is no value in adding the call to the base method. Have you placed a breakpoint in this method to verify your "if" statement is executing? Also since you are not checking the rules on the SaveRow, you might want to step through that to verify the save isn't failing due to broken rules.
Tim
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform