/// <summary> /// Constructor takes the datagridview to show changes implemented in this class /// </summary> /// <param name="dgv">datasheet grid reference</param> /// <param name="dt">datasource for the grid</param> public frmMissingValues(DataGridView dgv, DataTable dt) { InitializeComponent(); _tu = new Utilities.TableUtils(dt); _dtRI = dtRowInformation.getdtRI(_dt, false); _dtCI = dtColumnInformation.getdtCI(dt, false); //get a working copy of the dataset _dt = dt.Copy(); _dgv = dgv; cboCols.DataSource = strArrDdlReplaceWith; btnReturn.Enabled = false; }
//event handler for packing state to save project public IDictionary<string, object> PackState() { //save packed state to a dictionary IDictionary<string, object> dictPackedState = new Dictionary<string, object>(); /*//check to see if this is the first time going to modeling if (this.State == VBCommon.Controls.DatasheetControl.dtState.dirty) { DialogResult dlgr = MessageBox.Show("Changes in data and/or data attributes have occurred.\nPrevious modeling results will be erased. Proceed?", "Proceed to Modeling.", MessageBoxButtons.OKCancel); if (dlgr == DialogResult.OK) { correlationData = this.DT; dataSheetData = this.DT; this.State = VBCommon.Controls.DatasheetControl.dtState.clean; } else { return null; } } else if (boolInitialPass) { correlationData = this.DT; modelData = this.DT; this.State = VBCommon.Controls.DatasheetControl.dtState.clean; boolInitialPass = false; }*/ dictPackedState.Add("CorrelationDataTable", this.DT); //for Modeling to use dictPackedState.Add("ModelDataTable", this.DT); //for Modeling to use dictPackedState.Add("DT", this.DT); //pack up mainEffect columns for Prediction dictPackedState.Add("CurrentColIndex", this.SelectedColIndex); dictPackedState.Add("DepVarColName", this.ResponseVarColName); dictPackedState.Add("DTColInfo", this.DTCI.DTColInfo); dictPackedState.Add("DTRowInfo", this.DTRI.DTRowInfo); dictPackedState.Add("DSValidated", boolValidated); //pack up listInfo for model datasheet int intNumCols = this.DT.Columns.Count; int intNumRows = this.DT.Rows.Count; string strDateName = this.DT.Columns[0].ColumnName.ToString(); string strResponseVar = this.DT.Columns[1].ColumnName.ToString(); dictPackedState.Add("ColCount", intNumCols); dictPackedState.Add("RowCount", intNumRows); dictPackedState.Add("DateIndex", strDateName); dictPackedState.Add("ResponseVar", strResponseVar); dictPackedState.Add("DisabledRwCt", this.DisabledRows); dictPackedState.Add("DisabledColCt", this.DisabledCols); dictPackedState.Add("HiddenColCt", this.HiddenCols); dictPackedState.Add("IndVarCt", this.NumberIVs); dictPackedState.Add("fileName", this.FileName); StringWriter sw = null; //Save Datasheet info as xml string for serialization sw = null; if (this.DT != null) { this.DT.TableName = "DataSheetData"; sw = new StringWriter(); this.DT.WriteXml(sw, XmlWriteMode.WriteSchema, false); string strXmlDataTable = sw.ToString(); sw.Close(); sw = null; dictPackedState.Add("XmlDataTable", strXmlDataTable); } if (this.State == VBCommon.Controls.DatasheetControl.dtState.clean) { bool boolClean = true; dictPackedState.Add("Clean", boolClean); } else { bool boolClean = false; dictPackedState.Add("Clean", boolClean); } //model expects this change to the dt first DataTable tempDt = (DataTable)dictPackedState["DT"]; tempDt.Columns[this.ResponseVarColName].SetOrdinal(1); //filter diabled rows and columns tempDt = this.filterDataTableRows(tempDt); Utilities.TableUtils tableutils = new Utilities.TableUtils(tempDt); tempDt = tableutils.filterRVHcols(tempDt); dictPackedState.Add("DataSheetDatatable", tempDt); //for modeling to use return dictPackedState; }