private void worker_DoWork(object sender, DoWorkEventArgs e)
    {
        //sender is BackgoundWorker
        //this is where the background operation goes
        using (UD100Adapter adapterUD100 = new UD100Adapter(oTrans))
        {
            adapterUD100.BOConnect();
            builder.Append("Start Process...").AppendLine();

            //foreach(DataRow dr in dtInput.Rows)
            for (int i = 0; i < dtInput.Rows.Count; i++)
            {
                var    dr          = dtInput.Rows[i];
                string whereClause = string.Format("Key1 like '{0}-%'", dr["Donor"].ToString());
                //start log
                builder.Append(string.Format("Looking up Donor {0}...", dr["Donor"].ToString())).AppendLine();

                //the Hashtable stores the runtime search criteria
                System.Collections.Hashtable wcs = new Hashtable(1);
                wcs.Clear();
                wcs.Add("UD100", whereClause);
                Ice.Lib.Searches.SearchOptions opts = Ice.Lib.Searches.SearchOptions.CreateRuntimeSearch(wcs, Ice.Lib.Searches.DataSetMode.RowsDataSet);
                adapterUD100.InvokeSearch(opts);

                int rowCount = adapterUD100.UD100Data.UD100.Rows.Count;
                if (rowCount > 0)
                {
                    foreach (DataRow udRow in adapterUD100.UD100Data.UD100.Rows)
                    {
                        //modify here
                        udRow.BeginEdit();
                        udRow["Character04"] = dr["OPO Name"];
                        udRow["Character05"] = dr["OPO Donor Number"];
                        udRow["RowMod"]      = "U";
                        udRow.EndEdit();
                        //update log
                        builder.Append(string.Format("{0}: Success!", udRow["Key1"].ToString())).AppendLine();
                        totalRecCount++;
                    }
                    //update
                    adapterUD100.Update();
                    worker.ReportProgress(i);
                }

                else
                {
                    //update log
                    builder.Append(string.Format("******Failed to find UD100 recs for {0}******", dr["Donor"].ToString())).AppendLine();
                }
                txtProgress.Text = builder.ToString();
            }
            adapterUD100.Dispose();
            worker.ReportProgress(100);
        }
    }
    private void btnCopyVehicles_Click(object sender, System.EventArgs args)
    {
        txtCopyPart = ((EpiTextBox)csm.GetNativeControlReference("d74c3905-a49e-42f4-a48d-e2a6a8b79379"));
        txtCopyRev  = ((EpiTextBox)csm.GetNativeControlReference("31cbeabb-4107-4626-ae5d-66897b75a8d8"));
        EpiDataView epiViewPartRev = ((EpiDataView)(this.oTrans.EpiDataViews["PartRev"]));
        DataRow     dataRowPartRev = epiViewPartRev.CurrentDataRow;
        string      partNum;
        string      revisionNum;

        if ((dataRowPartRev != null))
        {
            partNum     = dataRowPartRev["PartNum"].ToString();
            revisionNum = dataRowPartRev["RevisionNum"].ToString();


            if (txtCopyPart.Text == partNum && txtCopyRev.Text == revisionNum)
            {
                MessageBox.Show("Cannot copy from same Part Revision");
            }
            else if (txtCopyPart.Text == "" || txtCopyRev.Text == "")
            {
                MessageBox.Show("Choose a Part Revision");
            }
            else
            {
                DialogResult dialogResult = EpiMessageBox.Show("Are you sure you want to copy vehicles?", "Cancel", MessageBoxButtons.YesNo);
                if ((dialogResult == DialogResult.Yes))
                {
                    try {
                        // Set UD100Adapter

                        UD100Adapter ud100Adapter = new UD100Adapter(PartForm);
                        ud100Adapter.BOConnect();

                        Hashtable whereClauses = new Hashtable(1);
                        string    whereClause  = "ChildKey1 <> '' AND ChildKey2 <> ''";
                        whereClauses.Add("UD100A", whereClause);

                        SearchOptions searchOptions = SearchOptions.CreateRuntimeSearch(whereClauses, DataSetMode.RowsDataSet);
                        ud100Adapter.InvokeSearch(searchOptions);

                        // Delete all current PartRev's vehicles
                        DataRow[] deleteRows = ud100Adapter.UD100Data.UD100A.Select("ChildKey1 = \'" + partNum + "\' and ChildKey2 = \'" + revisionNum + "\'");
                        for (int i = 0; (i < deleteRows.Length); i++)
                        {
                            ud100Adapter.Delete(deleteRows[i]);
                        }

                        // Copy all selected PartRev's vehicles
                        DataRow[] copyRows = ud100Adapter.UD100Data.UD100A.Select("ChildKey1 = \'" + txtCopyPart.Text + "\' and ChildKey2 = \'" + txtCopyRev.Text + "\'");
                        for (int i = 0; (i < copyRows.Length); i++)
                        {
                            CreateChild(copyRows[i]["Brand_c"].ToString(), copyRows[i]["Model_c"].ToString(), copyRows[i]["Year_c"].ToString(), copyRows[i]["Length_c"].ToString(), copyRows[i]["Height_c"].ToString());
                        }
                        ud100Adapter.Update();
                        ud100Adapter.Dispose();
                        MessageBox.Show("Completed");
                    } catch (Exception e) {
                        MessageBox.Show(e.ToString());
                    }
                }
            }
        }
    }