private void mnuEditBrowse_Click(object sender, System.EventArgs e) { //instantiate the datasource class //FIA_Biosum_Manager.Datasource p_datasource = new Datasource(((frmDialog)this.ParentForm).m_frmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim()); FIA_Biosum_Manager.Datasource p_datasource = new Datasource(); p_datasource.LoadTableColumnNamesAndDataTypes = false; p_datasource.LoadTableRecordCount = false; p_datasource.m_strDataSourceMDBFile = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() + "\\db\\project.mdb"; p_datasource.m_strDataSourceTableName = "datasource"; p_datasource.m_strScenarioId = ""; p_datasource.populate_datasource_array(); int intPlot = p_datasource.getTableNameRow("PLOT"); //see if datasource found the PLOT table type if (intPlot >= 0) { string strFile = p_datasource.m_strDataSource[intPlot, PATH].Trim() + "\\" + p_datasource.m_strDataSource[intPlot, MDBFILE].Trim(); ado_data_access oAdo = new ado_data_access(); string strConn = oAdo.getMDBConnString(strFile, "", ""); oAdo.OpenConnection(strConn); if (oAdo.m_intError == 0) { //see if the MDB file is found and the plot table is found if (p_datasource.m_strDataSource[intPlot, FILESTATUS].Trim() == "F" && p_datasource.m_strDataSource[intPlot, TABLESTATUS].Trim() == "F") { //see if there are records in the plot table if (Convert.ToInt32(oAdo.getRecordCount(oAdo.m_OleDbConnection, "SELECT COUNT(*) FROM " + p_datasource.m_strDataSource[intPlot, TABLE].Trim(), "temp")) > 0) { //string strConn=""; oAdo.CloseConnection(oAdo.m_OleDbConnection); FIA_Biosum_Manager.frmGridView frmGV = new frmGridView(); frmGV.strProjectDirectory = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim(); //frmGV.MdiParent = (frmMain)this.ParentForm.ParentForm; frmGV.Text = "Database: Browse And Delete Plot Records"; frmGV.LoadDataSetToDeleteOnly(strConn, "select * from " + p_datasource.m_strDataSource[intPlot, TABLE].Trim() + ";", p_datasource.m_strDataSource[intPlot, TABLE].Trim()); frmMain.g_oFrmMain.Enabled = false; frmGV.MinimizeMainForm = true; frmGV.Show(); //frmGV.Show(); //frmGV.Focus(); } else { oAdo.CloseConnection(oAdo.m_OleDbConnection); MessageBox.Show("!!No Records In The PLOT table!!", "BROWSE AND DELETE PLOT RECORDS", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } } else { oAdo.CloseConnection(oAdo.m_OleDbConnection); MessageBox.Show("!!Could not find either the MDB File named \n" + p_datasource.m_strDataSource[intPlot, MDBFILE] + "\n" + " or the plot table named \n" + p_datasource.m_strDataSource[intPlot, TABLE].Trim() + "!!", "BROWSE AND DELETE PLOT RECORDS", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } } } else { MessageBox.Show("!!Could not find the table type PLOT in the datasource table!!", "BROWSE AND DELETE PLOT RECORDS", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } }
private void button2_Click(object sender, EventArgs e) { frmGridView f = new frmGridView(); f.ShowDialog(); }
private void tlbPlotAddEdit_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { switch (e.Button.Text.Trim().ToUpper()) { case "ADD PLOT DATA": frmDialog frmTemp = new frmDialog(((frmDialog)this.ParentForm).m_frmMain); frmTemp.Visible = false; //FIA_Biosum_Manager.uc_plot_input uc_plot_input1 = new uc_plot_input(); //frmTemp.Controls.Add(uc_plot_input1); frmTemp.Initialize_Plot_Input_User_Control(); frmTemp.MaximizeBox = false; frmTemp.MinimizeBox = true; frmTemp.Width = frmTemp.uc_plot_input1.m_DialogWd; frmTemp.Height = frmTemp.uc_plot_input1.m_DialogHt; frmTemp.Text = "Database: Add Plot Data"; frmTemp.uc_plot_input1.Dock = System.Windows.Forms.DockStyle.Fill; frmTemp.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; frmTemp.uc_plot_input1.Visible = true; frmTemp.DisposeOfFormWhenClosing = true; frmTemp.uc_plot_input1.ReferenceFormDialog = frmTemp; frmTemp.MinimizeMainForm = true; frmTemp.ParentControl = frmMain.g_oFrmMain; frmTemp.ParentControl.Enabled = false; frmTemp.Show(); break; case "DELETE CONDITIONS": frmDialog frmTemp2 = new frmDialog(((frmDialog)this.ParentForm).m_frmMain); frmTemp2.Visible = false; frmTemp2.Initialize_Delete_Conditions_User_Control(); frmTemp2.MaximizeBox = false; frmTemp2.MinimizeBox = true; frmTemp2.Width = frmTemp2.uc_delete_conditions.m_DialogWd; frmTemp2.Height = frmTemp2.uc_delete_conditions.m_DialogHt; frmTemp2.Text = "Database: Delete Conditions"; frmTemp2.uc_delete_conditions.Dock = System.Windows.Forms.DockStyle.Fill; frmTemp2.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; frmTemp2.uc_delete_conditions.Visible = true; frmTemp2.DisposeOfFormWhenClosing = true; frmTemp2.uc_delete_conditions.ReferenceFormDialog = frmTemp2; frmTemp2.MinimizeMainForm = true; frmTemp2.ParentControl = frmMain.g_oFrmMain; frmTemp2.ParentControl.Enabled = false; frmTemp2.Show(); break; case "BROWSE AND DELETE SELECTED PLOT RECORDS": //instantiate the datasource class FIA_Biosum_Manager.Datasource p_datasource = new Datasource(((frmDialog)this.ParentForm).m_frmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim()); int intPlot = p_datasource.getTableNameRow("PLOT"); //see if datasource found the PLOT table type if (intPlot >= 0) { //see if the MDB file is found and the plot table is found if (p_datasource.m_strDataSource[intPlot, FILESTATUS].Trim() == "F" && p_datasource.m_strDataSource[intPlot, TABLESTATUS].Trim() == "F") { //see if there are records in the plot table if (p_datasource.m_strDataSource[intPlot, RECORDCOUNT].Trim() != "0") { string strConn = ""; string strFile = p_datasource.m_strDataSource[intPlot, MDBFILE].Trim(); if (strFile.Substring(strFile.Trim().Length - 6, 6).ToUpper() == ".ACCDB") { strConn = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" + strFile + ";User Id=admin;Password=;"; } else { strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFile + ";User Id=admin;Password=;"; } //string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + // p_datasource.m_strDataSource[intPlot,MDBFILE].Trim() + // ";User Id=admin;Password=;"; FIA_Biosum_Manager.frmGridView frmGV = new frmGridView(); frmGV.Text = "Database: Browse And Delete Plot Records"; frmGV.LoadDataSetToDeleteOnly(strConn, "select * from " + p_datasource.m_strDataSource[intPlot, TABLE].Trim() + ";", p_datasource.m_strDataSource[intPlot, TABLE].Trim()); frmGV.Show(); frmGV.Focus(); } else { MessageBox.Show("!!No Records In The PLOT table!!", "BROWSE AND DELETE PLOT RECORDS", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } } else { MessageBox.Show("!!Could not find either the MDB File named \n" + p_datasource.m_strDataSource[intPlot, MDBFILE] + "\n" + " or the plot table named \n" + p_datasource.m_strDataSource[intPlot, TABLE].Trim() + "!!", "BROWSE AND DELETE PLOT RECORDS", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } } else { MessageBox.Show("!!Could not find the table type PLOT in the datasource table!!", "BROWSE AND DELETE PLOT RECORDS", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } break; case "EDIT PLOT DATA": break; case "DELETE ALL PLOT RECORDS": this.DeleteAllPlotRecords(); break; case "HELP": if (m_oHelp == null) { m_oHelp = new Help(m_xpsFile, m_oEnv); } m_oHelp.ShowHelp(new string[] { "DATABASE", "PLOT_DATA_MENU" }); break; } }