private void ctlStatus(frmStatus fs) { //if (fs == frmStatus.load) //{ // btn_open.Enabled = true; // btn_create.Enabled = false; // btn_export.Enabled = false; //} }
private void mStatus_Click(object sender, EventArgs e) { try { if (!FormularioExiste("frmStatus")) { var formulario = new frmStatus(Dominio.Enumeracao.EnStatus.Todos); formulario.MdiParent = this; Tela.AbrirFormulario(formulario); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// GUI Main function /// </summary> public static void GUIMain(string[] args) { //ConsoleUtilities.HideConsoleWindow(); frmStatus statusWindow = new frmStatus(); // Process the command-line options (allows settings overrides to be specified on the command line) ParseCommandLineVars(Environment.CommandLine); if (Start(statusWindow, statusWindow)) { statusWindow.Run(); Stop(); } //ConsoleUtilities.ShowConsoleWindow(); }
public void ProcessSocketDataArrival(int socketId) { string msg = null; string msg2 = null; frmStatus form = default(frmStatus); //FIX! try { form = lStatus.GetObject(lStatus.ActiveIndex).sWindow; msg = Strings.Trim(lStatus.StatusSocketLocalPort(socketId).ToString()) + ", " + Strings.Trim(lStatus.ReturnRemotePort(lStatus.ActiveIndex).ToString()) + " : USERID : " + lSettings.lIRC.iIdent.iUserID; msg2 = Strings.Trim(lStatus.StatusSocketLocalPort(lStatus.ActiveIndex).ToString()) + ", " + Strings.Trim(lStatus.ReturnRemotePort(lStatus.ActiveIndex).ToString()) + " : SYSTEM : " + lSettings.lIRC.iIdent.iSystem; _clientSocket.SendSocket(msg + Environment.NewLine); _clientSocket.SendSocket(msg2 + Environment.NewLine); _clientSocket.CloseSocket(); } catch (Exception ex) { throw ex; } }
private void LoadData() { string strConnection = SQL_CONNECTION_STRING; // Display a status message saying that we're attempting to connect to SQL Server. // This only needs to be done the very first time a connection is // attempted. After we've determined that MSDE or SQL Server is // installed, this message no longer needs to be displayed. frmStatus frmStatusMessage = new frmStatus(); frmStatusMessage.Show("Connecting to SQL Server"); // Attempt to connect first to the local SQL server instance, // if that is not successful try a local // MSDE installation (with the Northwind DB). bool IsConnecting = true; while (IsConnecting) { try { // The SqlConnection class allows you to communicate with SQL Server. // The constructor accepts a connection string an argument. This // connection string uses Integrated Security, which means that you // must have a login in to SQL Server, or be part of the Administrators // group on your local machine for this to work. No password or user id is // included in this type of string. SqlConnection northwindConnection = new SqlConnection(strConnection); // The SqlDataAdapter is used to populate a Dataset SqlDataAdapter ProductAdapter = new SqlDataAdapter( "SELECT * " + "FROM products", northwindConnection); // Populate the Dataset with the information from the products // table. Since a Dataset can hold multiple result sets, it's // a good idea to "name" the result set when you populate the // DataSet. In this case, the result set is named "Products". ProductAdapter.Fill(dsProducts, PRODUCT_TABLE_NAME); //create the dataview; use a constructor to specify // the sort, filter criteria for performance purposes dvProducts = new DataView(dsProducts.Tables["products"], "", DEFAULT_SORT, DataViewRowState.OriginalRows); // Data has been retrieved successfully // Signal to break out of the loop by setting isConnecting to false. IsConnecting = false; //Handle the situation where a connection attempt has failed } catch { if (strConnection == SQL_CONNECTION_STRING) { // Couldn't connect to SQL Server. Now try MSDE. strConnection = MSDE_CONNECTION_STRING; frmStatusMessage.Show("Connecting to MSDE"); } else { // Unable to connect to SQL Server or MSDE frmStatusMessage.Close(); MessageBox.Show("To run this sample, you must have SQL " + "or MSDE with the Northwind database installed. For " + "instructions on installing MSDE, view Readthis.", CAPTION_TITLE, CAPTION_BUTTON, CAPTION_ICON); //quit the program; could not connect to either SQL Server Application.Exit(); } } } frmStatusMessage.Close(); }
// Show frmStatus to display connection status. private void m_DAL_ConnectionStatusChange(string status) { frmStatusMessage = new frmStatus(); frmStatusMessage.Show(status); }
private void InitDataSets() { // Display a status message box saying that we are attempting to connect. // This only needs to be done the first time a connection is attempted. // After we have determined that MSDE or SQL Server is installed, this // message no longer needs to be displayed frmStatus frmStatusMessage = new frmStatus(); if (HasConnected == false) { frmStatusMessage.Show("Connecting to SQL Server"); } // Attempt to connect to SQL server or MSDE bool IsConnecting = true; while (IsConnecting) { try { SqlConnection con = new SqlConnection(Connectionstring); con.Open(); // Connection successful IsConnecting = false; HasConnected = true; frmStatusMessage.Close(); // Since this the first time a conection is made // The table being used for this How-To must be created // Instantiate Command Object to execute SQL Statements SqlCommand cmInitSQL = new SqlCommand(); // Attach the command to the connection cmInitSQL.Connection = con; // Set the command type to Text cmInitSQL.CommandType = CommandType.Text; // Drop ProductsDS table if it exists. cmInitSQL.CommandText = "IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[ProductsDS]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " + "DROP TABLE [dbo].[ProductsDS] "; // Execute the statement cmInitSQL.ExecuteNonQuery(); // Drop ProductsTDS table if it exists. cmInitSQL.CommandText = "IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[ProductsTDS]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) " + "DROP TABLE [dbo].[ProductsTDS] "; // Execute the statement cmInitSQL.ExecuteNonQuery(); // Create ProductsDS Table cmInitSQL.CommandText = "CREATE TABLE [dbo].[ProductsDS] ( " + "[ProductID] [int] IDENTITY (1, 1) PRIMARY KEY ," + "[ProductName] [nvarchar] (40) NOT NULL , " + "[SupplierID] [int] NULL , " + "[CategoryID] [int] NULL , " + "[QuantityPerUnit] [nvarchar] (20) NULL , " + "[UnitPrice] [money] NULL , " + "[UnitsInStock] [smallint] NULL , " + "[UnitsOnOrder] [smallint] NULL , " + "[ReorderLevel] [smallint] NULL , " + "[Discontinued] [bit] NOT NULL )"; // Execute the statement cmInitSQL.ExecuteNonQuery(); // Create ProductsTDS Table cmInitSQL.CommandText = "CREATE TABLE [dbo].[ProductsTDS] ( " + "[ProductID] [int] IDENTITY (1, 1) PRIMARY KEY ," + "[ProductName] [nvarchar] (40) NOT NULL , " + "[SupplierID] [int] NULL , " + "[CategoryID] [int] NULL , " + "[QuantityPerUnit] [nvarchar] (20) NULL , " + "[UnitPrice] [money] NULL , " + "[UnitsInStock] [smallint] NULL , " + "[UnitsOnOrder] [smallint] NULL , " + "[ReorderLevel] [smallint] NULL , " + "[Discontinued] [bit] NOT NULL )"; // Execute the statement cmInitSQL.ExecuteNonQuery(); // Insert data into new table from products table in northwind cmInitSQL.CommandText = "INSERT INTO ProductsDS " + "(ProductName,SupplierID,CategoryID," + "QuantityPerUnit,UnitPrice,UnitsInStock," + "UnitsOnOrder,ReorderLevel, Discontinued) " + "SELECT ProductName,SupplierID,CategoryID," + "QuantityPerUnit,UnitPrice,UnitsInStock," + "UnitsOnOrder,ReorderLevel, Discontinued FROM Products"; cmInitSQL.ExecuteNonQuery(); // Insert data into new table from products table in northwind cmInitSQL.CommandText = "INSERT INTO ProductsTDS " + "(ProductName,SupplierID,CategoryID," + "QuantityPerUnit,UnitPrice,UnitsInStock," + "UnitsOnOrder,ReorderLevel, Discontinued) " + "SELECT ProductName,SupplierID,CategoryID," + "QuantityPerUnit,UnitPrice,UnitsInStock," + "UnitsOnOrder,ReorderLevel, Discontinued FROM Products"; cmInitSQL.ExecuteNonQuery(); cmInitSQL.Dispose(); // Create command object to pull data for datasets SqlCommand cmdProductsDS = new SqlCommand("SELECT * FROM ProductsDS", con); SqlCommand cmdProductsTDS = new SqlCommand("SELECT * FROM ProductsTDS", con); // create instances of the dataset and typed dataset tdsNorthwind = new Northwind(); dsNorthwind = new DataSet(); // Use the sqldataadapter to fill datasets SqlDataAdapter daLocal = new SqlDataAdapter(); // Select command for Typed Dataset daLocal.SelectCommand = cmdProductsTDS; // Fill typed Dataset daLocal.Fill(tdsNorthwind, "ProductsTDS"); // Select command for Untyped Dataset daLocal.SelectCommand = cmdProductsDS; // Fill untyped Dataset daLocal.Fill(dsNorthwind, "ProductsDS"); con.Close(); } catch (SqlException e) { if (Connectionstring == SQL_CONNECTION_STRING) { // Couldn't connect to SQL server. Now try MSDE Connectionstring = MSDE_CONNECTION_STRING; frmStatusMessage.Show("Connecting to MSDE"); } else { // Unable to connect to SQL Server or MSDE frmStatusMessage.Close(); MessageBox.Show("To run this sample you must have SQL Server ot MSDE with " + "the Northwind database installed. For instructions on " + "installing MSDE, view the Readme file.", "SQL Server/MSDE not found"); // Quit program if neither connection method was successful. Application.Exit(); } } catch (Exception e) { MessageBox.Show(e.Message, "General Error"); } } }
// This routine creates the XML data document used for the hash comparison. void CreateOriginalProductsList() { // Display a status message saying that the user is attempting to connect. // This only needs to be done the very first time a connection is // attempted. After we've determined that MSDE or SQL Server is // installed, this message no longer needs to be displayed. frmStatus frmStatusMessage = new frmStatus(); if (!DidPreviouslyConnect) { frmStatusMessage.Show("Connecting to SQL Server"); } // Attempt to connect to the local SQL server instance, and a local // MSDE installation (with Northwind). bool IsConnecting = true; while (IsConnecting) { try { // The SqlConnection class allows you to communicate with SQL Server. // The constructor accepts a connection string an argument. This // connection string uses Integrated Security, which means that you // must have a login in SQL Server, or be part of the Administrators // group for this to work. SqlConnection scnnNW = new SqlConnection(strConn); string strSQL = "SELECT ProductID, ProductName, UnitPrice " + "FROM Products"; // A SqlCommand object is used to execute the SQL commands. SqlCommand scmd = new SqlCommand(strSQL, scnnNW); // A SqlDataAdapter uses the SqlCommand object to fill a DataSet. SqlDataAdapter sda = new SqlDataAdapter(scmd); // Create a new Dataset and fill its first DataTable. DataSet dsProducts = new DataSet(); sda.Fill(dsProducts); // Persist the Dataset to XML. try { dsProducts.WriteXml(@"..\products.xml"); } catch (Exception exp) { MessageBox.Show(exp.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } // The data has been successfully retrieved, so break out of the loop // and close the status form. IsConnecting = false; DidPreviouslyConnect = true; frmStatusMessage.Close(); } catch (SqlException expSql) { MessageBox.Show(expSql.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } catch { if (strConn == SQL_CONNECTION_STRING) { // Couldn't connect to SQL Server. Now try MSDE. strConn = MSDE_CONNECTION_STRING; frmStatusMessage.Show("Connecting to MSDE"); } else { // Unable to connect to SQL Server or MSDE frmStatusMessage.Close(); MessageBox.Show(CONNECTION_ERROR_MSG, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit(); } } } }
private void BindDataGrid() { // Display a status message saying that we're attempting to connect. // This only needs to be done the very first time a connection is // attempted. After we've determined that MSDE or SQL Server is // installed, this message no longer needs to be displayed. frmStatus frmStatusMessage = new frmStatus(); if (!DidPreviouslyConnect) { frmStatusMessage.Show("Connecting to SQL Server"); } // Attempt to connect to the local SQL server instance, and a local // MSDE installation (with Northwind). bool IsConnecting = true; while (IsConnecting) { try { // The SqlConnection class allows you to communicate with SQL Server. // The constructor accepts a connection string an argument. This // connection string uses Integrated Security, which means that you // must have a login in SQL Server, or be part of the Administrators // group for this to work. SqlConnection northwindConnection = new SqlConnection(Connectionstring); // The SqlDataAdapter is used to move data between SQL Server, // and a DataSet. SqlDataAdapter ProductAdapter = new SqlDataAdapter( "SELECT ProductID, ProductName, UnitPrice, UnitsInStock FROM products", northwindConnection); // Populate the Dataset with the information from the products // table. Since a Dataset can hold multiple result sets, it's // a good idea to "name" the result set when you populate the // DataSet. In this case, the result set is named "Products". ProductAdapter.Fill(ProductData, PRODUCT_TABLE_NAME); // Data has been successfully retrieved, so break out of the loop. IsConnecting = false; DidPreviouslyConnect = true; } catch { if (Connectionstring == SQL_CONNECTION_STRING) { // Couldn't connect to SQL Server. Now try MSDE. Connectionstring = MSDE_CONNECTION_STRING; frmStatusMessage.Show("Connecting to MSDE"); } else { // Unable to connect to SQL Server or MSDE frmStatusMessage.Close(); MessageBox.Show("To run this sample, you must have SQL " + "or MSDE with the Northwind database installed. For " + "instructions on installing MSDE, view the ReadMe file."); Application.Exit(); } } } frmStatusMessage.Close(); // Bind the DataGrid to the desired table in the DataSet. This // will cause the product information to display. grdProducts.DataSource = ProductData.Tables[PRODUCT_TABLE_NAME]; }
private void btnLoad_Click(object sender, System.EventArgs e) { frmStatus frmStatusMessage = new frmStatus(); if (!didPreviouslyConnect) { frmStatusMessage.Show("Connecting to SQL Server"); } bool isConnecting = true; while (isConnecting) { try { // The SqlConnection class allows you to communicate with SQL Server. // The constructor accepts a connection string an argument. This // connection string uses Integrated Security, which means that you // must have a login in SQL Server, or be part of the Administrators // group for this to work. You must also have Nortiwind installed // in either SQL Server, or the MSDE sample database. See the // readme for details. SqlConnection northwindConnection = new SqlConnection(connectionstring); // The SqlDataAdapter is used to move data between SQL Server, // and a DataSet. SqlDataAdapter ProductAdapter = new SqlDataAdapter( "select * from products", northwindConnection); // Clear out any old data that has been previously loaded into // the DataSet ProductData.Clear(); // Populate the Dataset with the information from the products // table. Since a Dataset can hold multiple result sets, it's // a good idea to "name" the result set when you populate the // DataSet. In this case, the result set is named "Products". ProductAdapter.Fill(ProductData, PRODUCT_TABLE_NAME); // Bind the DataGrid to the desired table in the DataSet. This // will cause the product information to display. grdProducts.DataSource = ProductData.Tables[PRODUCT_TABLE_NAME]; // Now that the grid is populated, let the user filter the results. btnFilter.Enabled = true; isConnecting = false; } catch { if (connectionstring == SQL_CONNECTION_STRING) { // Couldn't connect to SQL Server. Now try MSDE. connectionstring = MSDE_CONNECTION_STRING; frmStatusMessage.Show("Connecting to MSDE"); } else { // Unable to connect to SQL Server or MSDE MessageBox.Show(CONNECTION_ERROR_MSG, "Connection Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } } frmStatusMessage.Close(); }
public StatusViewModel Pesquisar(int codigo, string descricao, TipoPesquisa tipoPesquisa, EnStatus enStatus) { if (codigo == 0 && tipoPesquisa == TipoPesquisa.Id) { return(null); } if (string.IsNullOrEmpty(descricao) && tipoPesquisa == TipoPesquisa.Descricao) { return(null); } if (tipoPesquisa == TipoPesquisa.Tela) { frmStatus formulario = new frmStatus("", enStatus); if (Tela.AbrirFormularioModal(formulario)) { if (Funcoes.IdSelecionado == 0) { return(null); } return(_statusApp.ObterPorId(Funcoes.IdSelecionado)); } } if (tipoPesquisa == TipoPesquisa.Id && codigo > 0) { var model = _statusApp.ObterPorCodigo(codigo, enStatus); if (model == null || model.Codigo == 0) { throw new Exception("Registro não encontrado!"); } return(model); } if (tipoPesquisa == TipoPesquisa.Descricao && descricao.Length > 0) { var model = _statusApp.Filtrar("Sta_Nome", descricao, enStatus); if (model == null) { frmStatus formulario = new frmStatus(enStatus); if (Tela.AbrirFormularioModal(formulario)) { return(_statusApp.ObterPorId(Funcoes.IdSelecionado)); } return(null); } else { if (model.Count() == 1) { return(_statusApp.ObterPorId(model.First().Id)); } else { frmStatus formulario = new frmStatus(descricao, enStatus); if (Tela.AbrirFormularioModal(formulario)) { return(_statusApp.ObterPorId(Funcoes.IdSelecionado)); } } return(null); } } else { return(null); } }
public void main() { //===================================================================== // Procedure Name : Main // Parameters Passed : None // Returns : None // Purpose : Start of the software // Description : // Assumptions : // Dependencies : // Author : Deepak B. // Created : 05.09.06 // Revisions : //===================================================================== //'note: //'this is first starting point of software //'this is a function which called first. //'do some software initialisation step here. //'like checking for user, checking for dependencies etc. frmSplash objfrmSplashScreen = new frmSplash(); frmAASInitialisation objfrmAASInitialisation; bool blnResetCmd = false; string strPath; clsTimer objTimeDelay = new clsTimer(null, 5000); bool blnIsUpgradeSessionID; try { //---Initialize error handler subErrorHandlerInitialization(gobjErrorHandler); //'Added by pankaj on 29 Jan 08 INI_SETTINGS_PATH = Application.StartupPath + "\\AAS.ini"; //---Initialize database settings if (funcInitializeAppDatabaseSettings() == true) { //---read configuration settings if (!gobjHardwareLock.gfuncGetConfigurationSetting()) { //display msg -error in configuration settings initialization gobjMessageAdapter.ShowMessage(constConfigurationError); Application.DoEvents(); //'allow application to perfrom its panding work. System.Environment.Exit(0); } } else { //---display msg -error in database initialization gobjMessageAdapter.ShowMessage("AAS ini Error", "Error", MessageHandler.clsMessageHandler.enumMessageType.ErrorMessage); Application.DoEvents(); System.Environment.Exit(0); } //'--------- //---Display Splash screen objfrmSplashScreen.Show(); //'put a delay of 3000 for splash screen. //Call objTimeDelay.subTime_Delay(2000) Application.DoEvents(); //'now allow application to perfrom its panding work ////----- Added by Sachin Dokhale //objTimeDelay = Nothing ////----- //'--- Check for the previous instance of the application if (PrevInstance()) { //'this function will find that ,is there any other instance of software is running //'or not.If running then prompt a message. gobjMessageAdapter.ShowMessage("Application Busy", "One instance of the application is already running" + vbCrLf + "Please close the previous instance", EnumMessageType.Information); System.Environment.Exit(0); } objTimeDelay.subTime_Delay(2000); objTimeDelay = null; Application.DoEvents(); //--------------- //INI_SETTINGS_PATH = Application.StartupPath & "\AAS.ini" //'---Initialize database settings //If funcInitializeAppDatabaseSettings() = True Then // '---read configuration settings // If Not gobjHardwareLock.gfuncGetConfigurationSetting() Then // 'display msg -error in configuration settings initialization // Call gobjMessageAdapter.ShowMessage(constConfigurationError) // Call Application.DoEvents() // ''allow application to perfrom its panding work. // End // End If //Else // '---display msg -error in database initialization // Call gobjMessageAdapter.ShowMessage("AAS ini Error", "Error", MessageHandler.clsMessageHandler.enumMessageType.ErrorMessage) // Call Application.DoEvents() // End //End If //--------- //--path of AAS.ini file //INI_SETTINGS_PATH = Application.StartupPath & "\AAS.ini" //---Initialize database settings //If funcInitializeAppDatabaseSettings() = True Then // '---read configuration settings // If Not gobjHardwareLock.gfuncGetConfigurationSetting() Then // 'display msg -error in configuration settings initialization // Call gobjMessageAdapter.ShowMessage(constConfigurationError) // Call Application.DoEvents() // ''allow application to perfrom its panding work. // End // End If //Else // '---display msg -error in database initialization // Call gobjMessageAdapter.ShowMessage("AAS ini Error", "Error", MessageHandler.clsMessageHandler.enumMessageType.ErrorMessage) // Call Application.DoEvents() // End //End If //---read hardware lock settings if (gobjHardwareLock.gfuncReadHardwareLockSetting() == false) { if (!IsNothing(objfrmSplashScreen)) { objfrmSplashScreen.Close(); objfrmSplashScreen.Dispose(); objfrmSplashScreen = null; } gobjMessageAdapter.ShowMessage("Hardware Lock Error", "Error", MessageHandler.clsMessageHandler.enumMessageType.ErrorMessage); //'prompt a error message if hardware lock failed. System.Environment.Exit(0); } //==========*********Modified by Saurabh**********========= if (gstructSettings.AppMode == EnumAppMode.DemoMode) { //--- To Get A New session ID and write it back to INI file. funcGetSessionID(); //--- To Create Service LogBook Database Connection. gfuncCreateLogBookConnection(); //--- To Create Userinfo Database Connection. gfuncCreateUserInfoConnection(); //---Insert new row with new sessionsID and //---insert current Date , time and day funcInsertLogData(gstructUserDetails.SessionID); } else { //--- To Get A New session ID and write it back to INI file. funcGetSessionID(); gfuncCreateLogBookConnection(); gfuncCreateUserInfoConnection(); gSetInstrumentStartTime = System.DateTime.Now; gSetWStartTime = System.DateTime.Now; gSetD2StartTime = System.DateTime.Now; } //========================================================= //--close and dispose splash screen if (!IsNothing(objfrmSplashScreen)) { objfrmSplashScreen.Close(); Application.DoEvents(); objfrmSplashScreen.Dispose(); objfrmSplashScreen = null; } //Saurabh 31.07.07 to Check for Hydride Mode //---if application is already in hydride mode then display message box. if (gstructSettings.HydrideMode == 1) { gobjMessageAdapter.ShowMessage("HYDRIDE MODE", "CONFIGURATION", MessageHandler.clsMessageHandler.enumMessageType.InformativeMessage); Application.DoEvents(); } //Saurabh 31.07.07 to Check for Hydride Mode if (gstructSettings.Enable21CFR == true) { //'check for 21 CFR frmLogin objfrmLogin = new frmLogin(); if (objfrmLogin.ShowDialog() == DialogResult.OK) { Application.DoEvents(); //If objfrmLogin.DialogResult = DialogResult.OK Then if (!objfrmLogin.LoginSuccessfull) { return; } } else { System.Environment.Exit(0); } Application.DoEvents(); } //'get a application path string strConfigPath; strConfigPath = Application.ExecutablePath; strConfigPath = Right(strConfigPath, Len("AAS_Service.exe")); //---check which executable file to run if (UCase(strConfigPath) == UCase("AAS_Service.exe")) { //'for normal application gstructSettings.EnableServiceUtility = true; gstructSettings.ExeToRun = EnumApplicationMode.ServiceUtility; } else { //'for service utility gstructSettings.EnableServiceUtility = false; gstructSettings.ExeToRun = EnumApplicationMode.AAS; } //---Initialize all global Variable here gobjCommProtocol = new clsCommProtocolFunctions(); gobjfrmStatus = new frmStatus(); //--- Get the global variables from AAS.ini file gFuncLoadGlobals(); //---Initialize gobjinst object if (funcInitInstrumentSettings() == true) { if (gstructSettings.AppMode == EnumAppMode.DemoMode | gstructSettings.AppMode == EnumAppMode.DemoMode_201 | gstructSettings.AppMode == EnumAppMode.DemoMode_203D) { //---if demo mode then load gobjinst object from serialized file funcLoadInstStatus(); } } string strAANameVersion; bool blnFlag; if (gstructSettings.ExeToRun == EnumApplicationMode.ServiceUtility) { //blnFlag = gobjCommProtocol.funcInitInstrument() blnFlag = true; } else { if (gstructSettings.AppMode == EnumAppMode.FullVersion_203 | gstructSettings.AppMode == EnumAppMode.FullVersion_203D | gstructSettings.AppMode == EnumAppMode.FullVersion_201) { //'check for the real mode of application //If Not gstructSettings.EnableServiceUtility Then 'ToChange objfrmAASInitialisation = new frmAASInitialisation(); //'show the initialization form and start the initialization here objfrmAASInitialisation.Show(); if (objfrmAASInitialisation.funcInstrumentInitialization()) { //'start the initialization //objfrmAASInitialisation.Close() //objfrmAASInitialisation.Dispose() } else { objfrmAASInitialisation.Close(); objfrmAASInitialisation.Dispose(); System.Environment.Exit(0); return; } //Else //End If } } Application.DoEvents(); //---Load the Methods from serialized file. if (!funcLoadMethods()) { //---display Msg -error in loading methods //---commented on 10.04.09 for ver 4.85 //Call gobjMessageAdapter.ShowMessage("Error in loading method settings file.", "Error", MessageHandler.clsMessageHandler.enumMessageType.ErrorMessage) //Call Application.DoEvents() //---------------- //End } //---commented on 19.06.07 //'check for the demo mode of application. if (gstructSettings.AppMode == EnumAppMode.DemoMode) { gintInstrumentBeamType = AAS203Library.Instrument.enumInstrumentBeamType.SingleBeam; } else if (gstructSettings.AppMode == EnumAppMode.DemoMode_203D) { gintInstrumentBeamType = AAS203Library.Instrument.enumInstrumentBeamType.DoubleBeam; } else if (gstructSettings.AppMode == EnumAppMode.DemoMode_201) { } //Saurabh 28.07.07 To set Instrument title //'set the instrument title as par application mode. //--4.85 14.04.09 if (gstructSettings.NewModelName == false) { if (gstructSettings.AppMode == EnumAppMode.FullVersion_203) { gstrTitleInstrumentType = CONST_AA203_FullVersion; } else if (gstructSettings.AppMode == EnumAppMode.FullVersion_203D) { gstrTitleInstrumentType = CONST_AA203D_FullVersion; } else if (gstructSettings.AppMode == EnumAppMode.FullVersion_201) { gstrTitleInstrumentType = CONST_AA201_FullVersion; } else if (gstructSettings.AppMode == EnumAppMode.DemoMode) { gstrTitleInstrumentType = CONST_AA203_DemoVersion; } else if (gstructSettings.AppMode == EnumAppMode.DemoMode_203D) { gstrTitleInstrumentType = CONST_AA203D_DemoVersion; } else if (gstructSettings.AppMode == EnumAppMode.DemoMode_201) { gstrTitleInstrumentType = CONST_AA201_DemoVersion; } else { gstrTitleInstrumentType = CONST_AA203; } } else { if (gstructSettings.AppMode == EnumAppMode.FullVersion_203) { gstrTitleInstrumentType = CONST_AA303_FullVersion; } else if (gstructSettings.AppMode == EnumAppMode.FullVersion_203D) { gstrTitleInstrumentType = CONST_AA303D_FullVersion; } else if (gstructSettings.AppMode == EnumAppMode.FullVersion_201) { gstrTitleInstrumentType = CONST_AA301_FullVersion; } else if (gstructSettings.AppMode == EnumAppMode.DemoMode) { gstrTitleInstrumentType = CONST_AA303_DemoVersion; } else if (gstructSettings.AppMode == EnumAppMode.DemoMode_203D) { gstrTitleInstrumentType = CONST_AA303D_DemoVersion; } else if (gstructSettings.AppMode == EnumAppMode.DemoMode_201) { gstrTitleInstrumentType = CONST_AA301_DemoVersion; } else { gstrTitleInstrumentType = CONST_AA303_FullVersion; } } //--4.85 14.04.09 //Saurabh 28.07.07 To set Instrument title if (gstructSettings.EnableServiceUtility) { //'this will check which EXE to be run. either main exe or service exe. gobjMainService = new frmMDIMainService(); Application.Run(gobjMainService); } else { gobjMain = new frmMDIMain(); if (!objfrmAASInitialisation == null) { objfrmAASInitialisation.Close(); objfrmAASInitialisation.Dispose(); } Application.DoEvents(); Application.Run(gobjMain); } funcExitApplicationSettings(); //'fir deinitialise the application setting //'It Exit Application parameters gIntMethodID = 0; //---added by deepak on 19.07.07 to reset the instrument ////----- Modified by Sachin Dokhale if (gobjCommProtocol.mobjCommdll.gFuncIsPortOpen()) { ////----- gobjCommProtocol.funcResetInstrument(); //'serial communication function to Reset the Instrument } System.Environment.Exit(0); } catch (Exception ex) { //--------------------------------------------------------- //Error Handling and logging gobjErrorHandler.ErrorDescription = ex.Message; gobjErrorHandler.ErrorMessage = ex.Message; gobjErrorHandler.WriteErrorLog(ex); //--------------------------------------------------------- } finally { //--------------------------------------------------------- //Writing Execution log if (CONST_CREATE_EXECUTION_LOG == 1) { gobjErrorHandler.WriteExecutionLog(); } Application.DoEvents(); //--------------------------------------------------------- } }
// Creates a connection to the database and uses a SqlDataAdapter // object to fill a DataSet. protected DataSet GetDataSource() { // Display a status message saying that we're attempting to connect. // This only needs to be done the very first time a connection is // attempted. After we've determined that MSDE or SQL Server is // installed, this message no longer needs to be displayed. frmStatus frmStatusMessage = new frmStatus(); DataSet dsProducts = null; if (!DidPreviouslyConnect) { frmStatusMessage.Show("Connecting to SQL Server"); } // Attempt to connect to the local SQL server instance, and a local // MSDE installation (with Northwind). bool IsConnecting = true; while (IsConnecting) { try { // The SqlConnection class allows you to communicate with SQL Server. // The constructor accepts a connection string an argument. This // connection string uses Integrated Security, which means that you // must have a login in SQL Server, or be part of the Administrators // group for this to work. SqlConnection cnNorthwind = new SqlConnection(connectionstring); // The SqlDataAdapter is used to move data between SQL Server, // and a DataSet. SqlDataAdapter da = new SqlDataAdapter( "SELECT ProductID, ProductName, UnitPrice, UnitsInStock " + "FROM products", cnNorthwind); dsProducts = new DataSet(); // Populate the Dataset with the information from the products // table. Since a Dataset can hold multiple result sets, it's // a good idea to "name" the result set when you populate the // DataSet. In this case, the result set is named "Products". da.Fill(dsProducts, "Products"); // Data has been successfully retrieved, so break out of the loop // and close the status form. IsConnecting = false; DidPreviouslyConnect = true; frmStatusMessage.Close(); } catch { if (connectionstring == SQL_CONNECTION_STRING) { // Couldn't connect to SQL Server. Now try MSDE. connectionstring = MSDE_CONNECTION_STRING; frmStatusMessage.Show("Connecting to MSDE"); } else { // Unable to connect to SQL Server or MSDE frmStatusMessage.Close(); MessageBox.Show("To run this sample, you must have SQL " + "or MSDE with the Northwind database installed. For " + "instructions on installing MSDE, view the ReadMe file.", "Connection Problem", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } } frmStatusMessage.Close(); return(dsProducts); }
private void frmMain_Load(object sender, System.EventArgs e) { string strConnection = SQL_CONNECTION_STRING; // Display a status message saying that we're attempting to connect to SQL Server. // This only needs to be done the very first time a connection is // attempted. After we've determined that MSDE or SQL Server is // installed, this message no longer needs to be displayed. frmStatus frmStatusMessage = new frmStatus(); frmStatusMessage.Show("Connecting to SQL Server"); // Attempt to connect first to the local SQL server instance, // if that is not successful try a local // MSDE installation (with the Northwind DB). bool IsConnecting = true; while (IsConnecting) { try { // The SqlConnection class allows you to communicate with SQL Server. // The constructor accepts a connection string an argument. This // connection string uses Integrated Security, which means that you // must have a login in to SQL Server, or be part of the Administrators // group on your local machine for this to work. No password or user id is // included in this type of string. SqlConnection northwindConnection = new SqlConnection(strConnection); // The SqlDataAdapter is used to populate a Dataset SqlDataAdapter ProductAdapter = new SqlDataAdapter("SELECT ProductName,UnitPrice, UnitsInStock, UnitsOnOrder FROM products", northwindConnection); // Populate the Dataset with the information from the products // table. Since a Dataset can hold multiple result sets, it's // a good idea to "name" the result set when you populate the // DataSet. In this case, the result set is named "Products". ProductAdapter.Fill(dsProducts, PRODUCT_TABLE_NAME); //create the dataview; use a constructor to specify // the sort, filter criteria for performance purposes dvProducts = new DataView(dsProducts.Tables["products"], DEFAULT_FILTER, DEFAULT_SORT, DataViewRowState.OriginalRows); // Data has been retrieved successfully // Signal to break out of the loop by setting isConnecting to false. IsConnecting = false; //Handle the situation where a connection attempt has failed } catch (Exception exc) { if (strConnection == SQL_CONNECTION_STRING) { // Couldn't connect to SQL Server. Now try MSDE. strConnection = MSDE_CONNECTION_STRING; frmStatusMessage.Show("Connecting to MSDE"); } else { // Unable to connect to SQL Server or MSDE frmStatusMessage.Close(); MessageBox.Show("To run this sample, you must have SQL " + "or MSDE with the Northwind database installed. For " + "instructions on installing MSDE, view Readthis.", CAPTION_TITLE); //quit the program; could not connect to either SQL Server Application.Exit(); } } } frmStatusMessage.Close(); // Bind the DataGrid to the dataview created above grdProducts.DataSource = dvProducts; //Populate the combo box for productName filtering. // Allow a user to select the first letter of products that they wish to view cboProducts.Items.AddRange(new Object[] { "<ALL>", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }); cboProducts.Text = "<ALL>"; //Populate the combo box for UnitsInStock filtering // Allow the usual arithmetic comparision operators cboCompare.Items.AddRange(new Object[] { "<", "<=", "=", ">=", ">" }); cboCompare.Text = "<"; //Display labeling status information lblRecords.Text = STATUS_MESSAGE + this.dsProducts.Tables[PRODUCT_TABLE_NAME].Rows.Count.ToString(); grdProducts.CaptionText = CAPTION_MESSAGE_ORIG; lblSort.Text = DEFAULT_SORT; lblFilter.Text = DEFAULT_FILTER; }