Exemple #1
0
        //Import OB datatable
        public void btnImportObs_Click(object sender, EventArgs e)
        {
            VBCommon.IO.ImportExport import = new ImportExport();
            DataTable dt = import.Input;
            if (dt == null)
                return;

            string[] strArrHeaderCaptions = { "Obs IDs", "Obs" };
            string[] strArrObsColumns = { "ID", "Observation" };

            frmColumnMapper colMapper = new frmColumnMapper(strArrObsColumns, dt, strArrHeaderCaptions, true);
            DialogResult dr = colMapper.ShowDialog();

            if (dr == DialogResult.OK)
            {
                dt = colMapper.MappedTable;
                dgvObs.DataSource = dt;
            }
            else
                return;

            foreach (DataGridViewColumn dvgCol in dgvObs.Columns)
                dvgCol.SortMode = DataGridViewColumnSortMode.NotSortable;

            setViewOnGrid(dgvObs);
        }
Exemple #2
0
        //import IV datatable
        public void btnImportIVs_Click(object sender, EventArgs e)
        {
            VBCommon.IO.ImportExport import = new ImportExport();
            DataTable dt = import.Input;
            if (dt == null)
                return;

            string[] strArrHeaderCaptions = { "Model Variables", "Imported Variables" };
            Dictionary<string, string> dictFields = new Dictionary<string, string>(dictMainEffects);
            frmColumnMapper colMapper = new frmColumnMapper(strArrReferencedVars, dt, strArrHeaderCaptions, true);
            DialogResult dr = colMapper.ShowDialog();

            if (dr == DialogResult.OK)
            {
                dt = colMapper.MappedTable;

                int errndx = 0;
                if (!recordIndexUnique(dt, out errndx))
                {
                    MessageBox.Show("Unable to import datasets with non-unique record identifiers.\n" +
                                    "Fix your datatable by assuring unique record identifier values\n" +
                                    "in the ID column and try importing again.\n\n" +
                                    "Record Identifier values cannot be blank or duplicated;\nencountered " +
                                    "error near row " + errndx.ToString(), "Import Data Error - Cannot Import This Dataset", MessageBoxButtons.OK);
                    return;
                }
                dgvVariables.DataSource = dt;
            }
            else
                return;

            foreach (DataGridViewColumn dvgCol in dgvVariables.Columns)
            {
                dvgCol.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            setViewOnGrid(dgvVariables);
            btnMakePredictions.Enabled = false;
        }