Ejemplo n.º 1
0
        //--------------------------------------------------------------------------------------
        void LoadScenario()
        {
            bool   iserror    = false;
            string ErrMessage = "";

            if (WSDB_Open)
            {
                TablenameDialog tableDialog = new TablenameDialog();
                string          tablename   = "";
                DataTable       DT          = new DataTable();
                // get the table name
                if (tableDialog.ShowDialog(WSim.DbConnection, false, true) == System.Windows.Forms.DialogResult.OK)
                {
                    tablename = tableDialog.Tablename;
                    if (tablename != "")
                    {
                        try
                        {
                            DT = dbTool.LoadTable(WSim.DbConnection, "Select * from " + dbTool.BracketIt(WSim.DbConnection.SQLServerType, tablename) + ";", ref iserror, ref ErrMessage);
                            //OleDbDataAdapter TableAdapter = new OleDbDataAdapter("Select * from " + '[' + tablename + ']', WSim.DbConnection);
                            //TableAdapter.Fill(DT);
                            //TableAdapter.Dispose();
                            if (!iserror)
                            {
                                SimulationInputs SI = WSim.ParamManager.GetSimulationInputs();
                                if (WSim.LoadScenario_DB("", 0, DT, ref SI))
                                {
                                    if (WSim.ParamManager.SetSimulationInputs(SI))
                                    {
                                        WS_InputPanel.Refresh_Inputs();
                                    }
                                }
                            }
                            else
                            {
                                throw new Exception(ErrMessage);
                            }
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("Whoops " + e.Message);
                        }
                    }
                }
            }
            else
            {
            }
        }
Ejemplo n.º 2
0
        //--------------------------------------------------------------------------------------
        void LoadScenario()
        {
            if (WSDB_Open)
            {
                TablenameDialog tableDialog = new TablenameDialog();
                string          tablename   = "";
                DataTable       DT          = new DataTable();
                // get the table name
                if (tableDialog.ShowDialog(WSim.DbConnection, false, true) == System.Windows.Forms.DialogResult.OK)
                {
                    tablename = tableDialog.Tablename;
                    if (tablename != "")
                    {
                        try
                        {
                            OleDbDataAdapter TableAdapter = new OleDbDataAdapter("Select * from " + '[' + tablename + ']', WSim.DbConnection);
                            TableAdapter.Fill(DT);
                            TableAdapter.Dispose();

                            SimulationInputs SI = WSim.ParamManager.GetSimulationInputs();
                            if (WSim.LoadScenario_DB("", 0, DT, ref SI))
                            {
                                if (WSim.ParamManager.SetSimulationInputs(SI))
                                {
                                    WS_InputPanel.Refresh_Inputs();
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("Whoops " + e.Message);
                        }
                    }
                }
            }
            else
            {
            }
        }
Ejemplo n.º 3
0
 //-------------------------------------------------------------------------------------------------------
 private void Refresh_Inputs()
 {
     WS_InputPanel.Refresh_Inputs();
 }