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);
        }
    }
Ejemplo n.º 2
0
    public void CreateChild(string vBrand, string vVehicle, string vYear, string vLength, string vHeight)
    {
        try
        {
            EpiDataView         edvPartRev    = ((EpiDataView)(this.oTrans.EpiDataViews["PartRev"]));
            System.Data.DataRow edvPartRevRow = edvPartRev.CurrentDataRow;

            if ((edvPartRevRow != null))
            {
                string vPartNum     = edvPartRevRow["PartNum"].ToString();
                string vRevisionNum = edvPartRevRow["RevisionNum"].ToString();

                //MessageBox.Show("vPartNum: " + vPartNum + "  vRevisionNum: " + vRevisionNum);

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

                //ud100AdapterN.GetNewUD100A(vBrand, vVehicle, vYear, vLength, vHeight, vPartNum, vRevisionNum, "");
                ud100AdapterN.GetByID(vBrand, vVehicle, vYear, vLength, vHeight);

                ud100AdapterN.GetaNewUD100a(vBrand, vVehicle, vYear, vLength, vHeight);
                int newRow = ud100AdapterN.UD100Data.UD100A.Rows.Count - 1;
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["ChildKey1"]     = vPartNum;
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["ChildKey2"]     = vRevisionNum;
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["ChildKey3"]     = "";
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["ChildKey4"]     = "";
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["ChildKey5"]     = "";
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["Brand_c"]       = vBrand;
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["Model_c"]       = vVehicle;
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["Year_c"]        = vYear;
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["Length_c"]      = vLength;
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["Height_c"]      = vHeight;
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["PartNum_c"]     = vPartNum;
                ud100AdapterN.UD100Data.UD100A.Rows[newRow]["RevisionNum_c"] = vRevisionNum;

                ud100AdapterN.Update();

                ud100AdapterN.Dispose();

                FillVehicleGrid(vPartNum, vRevisionNum);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }
Ejemplo n.º 3
0
    public void DeleteChild(string vBrand, string vVehicle, string vYear, string vLength, string vHeight)
    {
        try
        {
            EpiDataView         edvPartRev    = ((EpiDataView)(this.oTrans.EpiDataViews["PartRev"]));
            System.Data.DataRow edvPartRevRow = edvPartRev.CurrentDataRow;

            if ((edvPartRevRow != null))
            {
                string vPartNum     = edvPartRevRow["PartNum"].ToString();
                string vRevisionNum = edvPartRevRow["RevisionNum"].ToString();

                //MessageBox.Show("vPartNum: " + vPartNum + "  vRevisionNum: " + vRevisionNum);

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

                ud100AdapterN.GetByID(vBrand, vVehicle, vYear, vLength, vHeight);

                DataRow[] drsDeleted = ud100AdapterN.UD100Data.UD100A.Select("ChildKey1 = \'" + vPartNum + "\' and ChildKey2 = \'" + vRevisionNum + "\'");
                for (int i = 0; (i < drsDeleted.Length); i = (i + 1))
                {
                    ud100AdapterN.Delete(drsDeleted[i]);
                }

                ud100AdapterN.Update();

                ud100AdapterN.Dispose();

                FillVehicleGrid(vPartNum, vRevisionNum);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }
Ejemplo n.º 4
0
    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());
                    }
                }
            }
        }
    }