Thanks for the tip.
--- In vantage@yahoogroups.com, Jose Gomez <jose@...> wrote:
>
> You can use a name instead of an index makes it easier :)
>
> *Jose C Gomez*
> *Software Engineer*
> *
> *
> *
> *T: 904.469.1524 mobile
> E: jose@...
> http://www.josecgomez.com
> <http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
> <http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
> <http://www.josecgomez.com/professional-resume/>
> <http://www.josecgomez.com/feed/>
> <http://www.usdoingstuff.com>
>
> *Quis custodiet ipsos custodes?*
>
>
>
> On Tue, Oct 16, 2012 at 4:19 PM, yzou79 <yzou79@...> wrote:
>
> > **
> >
> >
> > I figured it out
> >
> > The UD100A table is the third table in UD101DataSet, not the second
> >
> > Changing these two lines of code fix the problem:
> >
> >
> > myUD101.GetaNewUD101A(ds,"Z5","","","","")
> > dr = ds.tables(2).rows(0)
> >
> >
> > --- In vantage@yahoogroups.com, "yzou79" <yzou79@> wrote:
> > >
> > > I tried to move the code to Carrier Maintenance form just for a test. My
> > ultimate goal is to use it on End Activity Goal. It looks that I cannot
> > GetNewChild once the code is not on UD100 Maintenace form. So I wrote the
> > following code from your example and some other code.
> > >
> > > The following code works ok for adding new record in UD100.But the code
> > for adding new record in UD100A failed on the line of
> > >
> > > dr![ChildKey1] = "Z5Sub1"
> > >
> > > The error indicates that ChildKey1 is not a valid field.
> > >
> > > Here is the code:
> > > ==========================
> > > Dim dr as system.data.DataRow
> > > Dim mySession As Epicor.Mfg.Core.Session
> > > Dim myUD101 As Epicor.Mfg.BO.UD101
> > > Dim ds as New Epicor.Mfg.BO.UD101DataSet
> > >
> > > mySession = CarrierForm.Session
> > > myUD101 = New Epicor.Mfg.BO.UD101(mySession.ConnectionPool)
> > > myUD101.GetaNewUD101(ds)
> > >
> > > dr = ds.tables(0).rows(0)
> > > dr.BeginEdit
> > > dr![Company] = "EPIC06"
> > > dr![Key1] = "Z5"
> > > dr.EndEdit
> > >
> > > myUD101.Update(ds)
> > >
> > > myUD101.GetaNewUD101A(ds,"Z5","","","","")
> > > dr = ds.tables(0).rows(0)
> > >
> > > 'Tried to use tables(1) or use a different ds, all failed
> > >
> > > dr.BeginEdit
> > > dr![Company] = "EPIC06"
> > > dr![Key1] = "Z5"
> > > dr![ChildKey1] = "Z5Sub1"
> > > dr.EndEdit
> > >
> > > myUD101.Update(ds)
> > > ==========================
> > >
> > > --- In vantage@yahoogroups.com, "yzou79" <yzou79@> wrote:
> > > >
> > > > Thank you very much! Your code works great!
> > > >
> > > > I will try to see if I can get it to work on another form.
> > > >
> > > > --- In vantage@yahoogroups.com, "mmcwilliams22" <mmcwilliams22@>
> > wrote:
> > > > >
> > > > > Here is an example of creating the parent. I am assigning a
> > sequential ID from the company record. Below this code is a sample of
> > creating a new child.
> > > > >
> > > > > Dim compAdapter As CompanyAdapter = New CompanyAdapter(UD102Form)
> > > > > compAdapter.BOConnect()
> > > > > Dim company As string = "TBT"
> > > > > Dim CompAd As Boolean = compAdapter.GetByID(company)
> > > > > Dim CurQuoteID As Integer =
> > compAdapter.CompanyData.Tables("Company").Rows(0)("Number03")
> > > > > Dim assignQuoteId As Integer = CurQuoteID + 1
> > > > > compAdapter.CompanyData.Tables("Company").Rows(0)("Number03") =
> > assignQuoteId
> > > > > compAdapter.Update()
> > > > > compAdapter.Dispose()
> > > > >
> > > > > oTrans.GetNew()
> > > > > Dim UD102 As EpiDataView =
> > Ctype(oTrans.EpiDataViews("UD102"),EpiDataView)
> > > > >
> > > > > UD102.dataView(UD102.Row).BeginEdit
> > > > > UD102.DataView(UD102.Row)("Key1") = CurQuoteID
> > > > > UD102.DataView(UD102.Row)("Date01") = Today
> > > > > UD102.DataView(UD102.Row)("ShortChar02") = UD102Form.Session.UserID
> > > > >
> > > > > UD102.dataView(UD102.Row).EndEdit
> > > > >
> > > > > oTrans.update()
> > > > >
> > > > > '// New Child
> > > > > Dim i As Decimal = 1
> > > > > Dim RowCount as decimal = '//Number of children wanted
> > > > > Do Until i - 1 = RowCount
> > > > > Otrans.GetNewChild()
> > > > > Dim UD102dv As EpiDataView =
> > Ctype(oTrans.EpiDataViews("UD102A"),EpiDataView)
> > > > > UD102dv.dataView(UD102dv.Row).BeginEdit()
> > > > > UD102dv.dataView(UD102dv.Row)("ChildKey1") = UD102dv.Row + 1
> > > > > UD102dv.dataView(UD102dv.Row).EndEdit()
> > > > >
> > > > > oTrans.Update()
> > > > > i = i + 1
> > > > >
> > > > > Loop
> > > > > UD102Adapt.Dispose()
> > > > >
> > > > > --- In vantage@yahoogroups.com, "yzou79" <yzou79@> wrote:
> > > > > >
> > > > > > I have customization project that requires using code to create a
> > new record in UD100 as parent table and two or more records in UD100A as
> > child table. Has anyone done this before? Could you please give me a sample
> > code.
> > > > > >
> > > > > > The following is the code I tried. The code can run through
> > without error, but no record was created in UD100 or UD100A.
> > > > > >
> > > > > > private void epiButtonC1_Click(object sender, System.EventArgs
> > args)
> > > > > > {
> > > > > > try
> > > > > > {
> > > > > > UD101Adapter adapterUD101 = new UD101Adapter(this.oTrans);
> > > > > > adapterUD101.BOConnect();
> > > > > >
> > > > > > string parentKey1 = "TestPK1";
> > > > > > string parentKey2 = string.Empty;
> > > > > > string parentKey3 = string.Empty;
> > > > > > string parentKey4 = string.Empty;
> > > > > > string parentKey5 = string.Empty;
> > > > > >
> > > > > > bool result = adapterUD101.GetaNewUD101();
> > > > > >
> > > > > > int rowCount = adapterUD101.UD101Data.UD101.Rows.Count;
> > > > > >
> > > > > >
> > > > > > DataRow edvUD101Row =
> > adapterUD101.UD101Data.UD101.Rows[(rowCount-1)];
> > > > > >
> > > > > > edvUD101Row.BeginEdit();
> > > > > > edvUD101Row["Company"] = "EPIC06";
> > > > > > edvUD101Row["Key1"] = parentKey1;
> > > > > > edvUD101Row["Key2"] = parentKey2;
> > > > > > edvUD101Row["Key3"] = parentKey3;
> > > > > > edvUD101Row["Key4"] = parentKey4;
> > > > > > edvUD101Row["Key5"] = parentKey5;
> > > > > > edvUD101Row.EndEdit();
> > > > > >
> > > > > > edvUD101Row.AcceptChanges();
> > > > > >
> > > > > > adapterUD101.Update();
> > > > > >
> > > > > > result = adapterUD101.GetaNewUD101A(parentKey1, parentKey2,
> > parentKey3, parentKey4, parentKey5);
> > > > > >
> > > > > > rowCount =dapterUD101.UD101Data.UD101A.Rows.Count;
> > > > > >
> > > > > > DataRow edvUD101ARow =
> > adapterUD101.UD101Data.UD101A.Rows[(rowCount-1)];
> > > > > >
> > > > > >
> > > > > > edvUD101ARow.BeginEdit();
> > > > > > edvUD101ARow["Company"] = "EPIC06";
> > > > > > edvUD101ARow["Key1"] = parentKey1;
> > > > > > edvUD101ARow["Key2"] = parentKey2;
> > > > > > edvUD101ARow["Key3"] = parentKey3;
> > > > > > edvUD101ARow["Key4"] = parentKey4;
> > > > > > edvUD101ARow["Key5"] = parentKey5;
> > > > > > edvUD101ARow["ChildKey1"] = "PartNum";
> > > > > > edvUD101ARow["ChildKey2"] = "JobNum";
> > > > > > edvUD101ARow["ChildKey3"] = "ASM";
> > > > > > edvUD101ARow["ChildKey4"] = string.Empty;
> > > > > > edvUD101ARow["ChildKey5"] = string.Empty;
> > > > > > edvUD101ARow["RowIdent"] = "A";
> > > > > > edvUD101ARow.EndEdit();
> > > > > >
> > > > > > edvUD101ARow.AcceptChanges();
> > > > > >
> > > > > > adapterUD101.UD101Data.AcceptChanges();
> > > > > >
> > > > > > adapterUD101.Update();
> > > > > >
> > > > > > oTrans.Update();
> > > > > >
> > > > > >
> > > > > >
> > > > > > // Cleanup Adapter Reference
> > > > > > adapterUD101.Dispose();
> > > > > >
> > > > > > } catch (System.Exception ex)
> > > > > >
> > > > > > {
> > > > > > ExceptionBox.Show(ex);
> > > > > > } //End of Try
> > > > > >
> > > > > > } //End of button click
> > > > > >
> > > > >
> > > >
> > >
> >
> >
> >
>
>
> [Non-text portions of this message have been removed]
>