commit 79c0f9cd435c679b71b03c5cac980e892e8323e8 Author: XingCheng3 <1773407212@qq.com> Date: Mon May 11 11:09:04 2026 +0800 首次提交 diff --git a/DLL/BasicData.dll b/DLL/BasicData.dll new file mode 100644 index 0000000..5008ace Binary files /dev/null and b/DLL/BasicData.dll differ diff --git a/DLL/BouncyCastle.Crypto.dll b/DLL/BouncyCastle.Crypto.dll new file mode 100644 index 0000000..0310983 Binary files /dev/null and b/DLL/BouncyCastle.Crypto.dll differ diff --git a/DLL/ConLink.dll b/DLL/ConLink.dll new file mode 100644 index 0000000..fa95f29 Binary files /dev/null and b/DLL/ConLink.dll differ diff --git a/DLL/ConLink19.dll b/DLL/ConLink19.dll new file mode 100644 index 0000000..05a03cc Binary files /dev/null and b/DLL/ConLink19.dll differ diff --git a/DLL/DataLinkMesWork.dll b/DLL/DataLinkMesWork.dll new file mode 100644 index 0000000..57fcd25 Binary files /dev/null and b/DLL/DataLinkMesWork.dll differ diff --git a/DLL/DynamicExpresso.Core.dll b/DLL/DynamicExpresso.Core.dll new file mode 100644 index 0000000..e150894 Binary files /dev/null and b/DLL/DynamicExpresso.Core.dll differ diff --git a/DLL/EnBaseM.dll b/DLL/EnBaseM.dll new file mode 100644 index 0000000..ebdeaa2 Binary files /dev/null and b/DLL/EnBaseM.dll differ diff --git a/DLL/ICSharpCode.SharpZipLib.dll b/DLL/ICSharpCode.SharpZipLib.dll new file mode 100644 index 0000000..84e8c68 Binary files /dev/null and b/DLL/ICSharpCode.SharpZipLib.dll differ diff --git a/DLL/MQTTnet.Extensions.ManagedClient.dll b/DLL/MQTTnet.Extensions.ManagedClient.dll new file mode 100644 index 0000000..99035f6 Binary files /dev/null and b/DLL/MQTTnet.Extensions.ManagedClient.dll differ diff --git a/DLL/MQTTnet.dll b/DLL/MQTTnet.dll new file mode 100644 index 0000000..2951433 Binary files /dev/null and b/DLL/MQTTnet.dll differ diff --git a/DLL/MW_Log.dll b/DLL/MW_Log.dll new file mode 100644 index 0000000..22a3de8 Binary files /dev/null and b/DLL/MW_Log.dll differ diff --git a/DLL/MesWork.Control.dll b/DLL/MesWork.Control.dll new file mode 100644 index 0000000..b4d9de5 Binary files /dev/null and b/DLL/MesWork.Control.dll differ diff --git a/DLL/MesWork.DeviceDriver.dll b/DLL/MesWork.DeviceDriver.dll new file mode 100644 index 0000000..730f828 Binary files /dev/null and b/DLL/MesWork.DeviceDriver.dll differ diff --git a/DLL/Microsoft.Extensions.DependencyInjection.Abstractions.dll b/DLL/Microsoft.Extensions.DependencyInjection.Abstractions.dll new file mode 100644 index 0000000..5583517 Binary files /dev/null and b/DLL/Microsoft.Extensions.DependencyInjection.Abstractions.dll differ diff --git a/DLL/Microsoft.Extensions.Logging.Abstractions.dll b/DLL/Microsoft.Extensions.Logging.Abstractions.dll new file mode 100644 index 0000000..1580585 Binary files /dev/null and b/DLL/Microsoft.Extensions.Logging.Abstractions.dll differ diff --git a/DLL/Microsoft.Extensions.Logging.dll b/DLL/Microsoft.Extensions.Logging.dll new file mode 100644 index 0000000..fc7d689 Binary files /dev/null and b/DLL/Microsoft.Extensions.Logging.dll differ diff --git a/DLL/Microsoft.Extensions.Options.dll b/DLL/Microsoft.Extensions.Options.dll new file mode 100644 index 0000000..f56ff80 Binary files /dev/null and b/DLL/Microsoft.Extensions.Options.dll differ diff --git a/DLL/Microsoft.Extensions.Primitives.dll b/DLL/Microsoft.Extensions.Primitives.dll new file mode 100644 index 0000000..d6560c9 Binary files /dev/null and b/DLL/Microsoft.Extensions.Primitives.dll differ diff --git a/DLL/Microsoft.Win32.Primitives.dll b/DLL/Microsoft.Win32.Primitives.dll new file mode 100644 index 0000000..8b69a69 Binary files /dev/null and b/DLL/Microsoft.Win32.Primitives.dll differ diff --git a/DLL/MySql.Data.dll b/DLL/MySql.Data.dll new file mode 100644 index 0000000..a95e69e Binary files /dev/null and b/DLL/MySql.Data.dll differ diff --git a/DLL/MySql.Data.xml b/DLL/MySql.Data.xml new file mode 100644 index 0000000..f35ac41 --- /dev/null +++ b/DLL/MySql.Data.xml @@ -0,0 +1,17803 @@ + + + + MySql.Data + + + + + The implementation of the caching_sha2_password authentication plugin. + + + + + Generates a byte array set with the password of the user in the expected format based on the + SSL settings of the current connection. + + A byte array that contains the password of the user in the expected format. + + + + Defines the stage of the authentication. + + + + + Defines the default behavior for an authentication plugin. + + + + + Gets or sets the authentication data returned by the server. + + + + + This is a factory method that is used only internally. It creates an auth plugin based on the method type + + + + + + + + + Gets the connection option settings. + + + + + Gets the server version associated with this authentication plugin. + + + + + Gets the encoding assigned to the native driver. + + + + + Sets the authentication data required to encode, encrypt, or convert the password of the user. + + A byte array containing the authentication data provided by the server. + This method may be overriden based on the requirements by the implementing authentication plugin. + + + + Defines the behavior when checking for constraints. + + This method is intended to be overriden. + + + + Throws a that encapsulates the original exception. + + The exception to encapsulate. + + + + Defines the behavior when authentication is successful. + + This method is intended to be overriden. + + + + Defines the behavior when more data is required from the server. + + The data returned by the server. + The data to return to the server. + This method is intended to be overriden. + + + + Gets the plugin name based on the authentication plugin type defined during the creation of this object. + + + + + Gets the user name associated to the connection settings. + + The user name associated to the connection settings. + + + + Gets the encoded, encrypted, or converted password based on the authentication plugin type defined during the creation of this object. + This method is intended to be overriden. + + An object containing the encoded, encrypted, or converted password. + + + + Provides functionality to read, decode and convert PEM files to objects supported in .NET. + + + + + Converts the binary data of a PEM file to an object. + + A binary representation of the public key provided by the server. + An object containing the data found in the public key. + + + + Allows connections to a user account set with the mysql_native_password authentication plugin. + + + + + Returns a byte array containing the proper encryption of the + given password/seed according to the new 4.1.1 authentication scheme. + + + + + + + + The implementation of the sha256_password authentication plugin. + + + + + The byte array representation of the public key provided by the server. + + + + + Applies XOR to the byte arrays provided as input. + + A byte array that contains the results of the XOR operation. + + + + + + + + + Defines the type of the security buffer. + + + + + Defines a security handle. + + + + + Describes a buffer allocated by a transport to pass to a security package. + + + + + Specifies the size, in bytes, of the buffer. + + + + + Bit flags that indicate the type of the buffer. + + + + + Pointer to a buffer. + + + + + Hold a numeric value used in defining other data types. + + + + + Least significant digits. + + + + + Most significant digits. + + + + + Holds a pointer used to define a security handle. + + + + + Least significant digits. + + + + + Most significant digits. + + + + + Indicates the sizes of important structures used in the message support functions. + + + + + Specifies the maximum size of the security token used in the authentication changes. + + + + + Specifies the maximum size of the signature created by the MakeSignature function. + This member must be zero if integrity services are not requested or available. + + + + + Specifies the preferred integral size of the messages. + + + + + Size of the security trailer to be appended to messages. + This member should be zero if the relevant services are not requested or available. + + + + + Allows importing large amounts of data into a database with bulk loading. + + + + + Gets or sets the connection. + + The connection. + + + + Gets or sets the field terminator. + + The field terminator. + + + + Gets or sets the line terminator. + + The line terminator. + + + + Gets or sets the name of the table. + + The name of the table. + + + + Gets or sets the character set. + + The character set. + + + + Gets or sets the name of the file. + + The name of the file. + + + + Gets or sets the timeout. + + The timeout. + + + + Gets or sets a value indicating whether the file name that is to be loaded + is local to the client or not. The default value is false. + + true if local; otherwise, false. + + + + Gets or sets the number of lines to skip. + + The number of lines to skip. + + + + Gets or sets the line prefix. + + The line prefix. + + + + Gets or sets the field quotation character. + + The field quotation character. + + + + Gets or sets a value indicating whether [field quotation optional]. + + + true if [field quotation optional]; otherwise, false. + + + + + Gets or sets the escape character. + + The escape character. + + + + Gets or sets the conflict option. + + The conflict option. + + + + Gets or sets the priority. + + The priority. + + + + Gets the columns. + + The columns. + + + + Gets the expressions. + + The expressions. + + + + Executes the load operation. + + The number of rows inserted. + + + + Asynchronous version of the load operation. + + The number of rows inserted. + + + + Executes the load operation asynchronously while the cancellation isn't requested. + + The cancellation token. + The number of rows inserted. + + + + Represents the priority set for bulk loading operations. + + + + + This is the default and indicates normal priority + + + + + Low priority will cause the load operation to wait until all readers of the table + have finished. This only affects storage engines that use only table-level locking + such as MyISAM, Memory, and Merge. + + + + + Concurrent priority is only relevant for MyISAM tables and signals that if the table + has no free blocks in the middle that other readers can retrieve data from the table + while the load operation is happening. + + + + + Represents the behavior when conflicts arise during bulk loading operations. + + + + + This is the default and indicates normal operation. In the event of a LOCAL load, this + is the same as ignore. When the data file is on the server, then a key conflict will + cause an error to be thrown and the rest of the data file ignored. + + + + + Replace column values when a key conflict occurs. + + + + + Ignore any rows where the primary key conflicts. + + + + + Summary description for CharSetMap. + + + + + Returns the text encoding for a given MySQL character set name + + Version of the connection requesting the encoding + Name of the character set to get the encoding for + Encoding object for the given character set name + + + + Initializes the mapping. + + + + Represents a SQL statement to execute against a MySQL database. This class cannot be inherited. + MySqlCommand features the following methods for executing commands at a MySQL database: + + + Item + Description + + + + ExecuteReader + + Executes commands that return rows. + + + + ExecuteNonQuery + + Executes commands such as SQL INSERT, DELETE, and UPDATE statements. + + + + ExecuteScalar + + Retrieves a single value (for example, an aggregate value) from a database. + + + + You can reset the CommandText property and reuse the MySqlCommand + object. However, you must close the MySqlDataReader + before you can execute a new or previous command. + + If a MySqlException is + generated by the method executing a MySqlCommand, the MySqlConnection + remains open. It is the responsibility of the programmer to close the connection. + + + Using the '@' symbol for paramters is now the preferred approach although the old pattern of using + '?' is still supported. Please be aware though that using '@' can cause conflicts when user variables + are also used. To help with this situation please see the documentation on the 'allow user variables' + connection string option. The 'old syntax' connection string option has now been deprecated. + + + The following example creates a MySqlCommand and + a MySqlConnection. The MySqlConnection is opened and set as the Connection + for the MySqlCommand. The example then calls ExecuteNonQuery, + and closes the connection. To accomplish this, the ExecuteNonQuery is + passed a connection string and a query string that is a SQL INSERT + statement. + + Public Sub InsertRow(myConnectionString As String) + " If the connection string is null, use a default. + If myConnectionString = "" Then + myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass" + End If + Dim myConnection As New MySqlConnection(myConnectionString) + Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)" + Dim myCommand As New MySqlCommand(myInsertQuery) + myCommand.Connection = myConnection + myConnection.Open() + myCommand.ExecuteNonQuery() + myCommand.Connection.Close() + End Sub + + + public void InsertRow(string myConnectionString) + { + // If the connection string is null, use a default. + if(myConnectionString == "") + { + myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"; + } + MySqlConnection myConnection = new MySqlConnection(myConnectionString); + string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"; + MySqlCommand myCommand = new MySqlCommand(myInsertQuery); + myCommand.Connection = myConnection; + myConnection.Open(); + myCommand.ExecuteNonQuery(); + myCommand.Connection.Close(); + } + + + + + + + Initializes a new instance of the MySqlCommand class. + + + The following example creates a MySqlCommand and sets some of its properties. + + + This example shows how to use one of the overloaded + versions of the MySqlCommand constructor. For other examples that might be available, + see the individual overload topics. + + + + Public Sub CreateMySqlCommand() + Dim myConnection As New MySqlConnection _ + ("Persist Security Info=False;database=test;server=myServer") + myConnection.Open() + Dim myTrans As MySqlTransaction = myConnection.BeginTransaction() + Dim mySelectQuery As String = "SELECT * FROM MyTable" + Dim myCommand As New MySqlCommand(mySelectQuery, myConnection, myTrans) + myCommand.CommandTimeout = 20 + End Sub + + + public void CreateMySqlCommand() + { + MySqlConnection myConnection = new MySqlConnection("Persist Security Info=False; + database=test;server=myServer"); + myConnection.Open(); + MySqlTransaction myTrans = myConnection.BeginTransaction(); + string mySelectQuery = "SELECT * FROM myTable"; + MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection,myTrans); + myCommand.CommandTimeout = 20; + } + + + public: + void CreateMySqlCommand() + { + MySqlConnection* myConnection = new MySqlConnection(S"Persist Security Info=False; + database=test;server=myServer"); + myConnection->Open(); + MySqlTransaction* myTrans = myConnection->BeginTransaction(); + String* mySelectQuery = S"SELECT * FROM myTable"; + MySqlCommand* myCommand = new MySqlCommand(mySelectQuery, myConnection, myTrans); + myCommand->CommandTimeout = 20; + }; + + + + Initializes a new instance of the MySqlCommand class. + + The base constructor initializes all fields to their default values. The + following table shows initial property values for an instance of . + + + Properties + Initial Value + + + + + + empty string ("") + + + + + + 0 + + + + + + CommandType.Text + + + + + + Null + + + + You can change the value for any of these properties through a separate call to + the property. + + + The following example creates a and + sets some of its properties. + + + Public Sub CreateMySqlCommand() + Dim myCommand As New MySqlCommand() + myCommand.CommandType = CommandType.Text + End Sub + + + public void CreateMySqlCommand() + { + MySqlCommand myCommand = new MySqlCommand(); + myCommand.CommandType = CommandType.Text; + } + + + + + + Initializes a new instance of the class with the text of the query. + The text of the query. + When an instance of is created, + the following read/write properties are set to initial values. + + + + Properties + Initial Value + + + + + + + cmdText + + + + + + + 0 + + + + + + CommandType.Text + + + + + + Null + + + + You can change the value for any of these properties through a separate call to + the property. + + + The following example creates a and + sets some of its properties. + + + Public Sub CreateMySqlCommand() + Dim sql as String = "SELECT * FROM mytable" + Dim myCommand As New MySqlCommand(sql) + myCommand.CommandType = CommandType.Text + End Sub + + + public void CreateMySqlCommand() + { + string sql = "SELECT * FROM mytable"; + MySqlCommand myCommand = new MySqlCommand(sql); + myCommand.CommandType = CommandType.Text; + } + + + + + + Initializes a new instance of the class + with the text of the query and a . + The text of the query. + A that represents the + connection to an instance of SQL Server. + + When an instance of is created, + the following read/write properties are set to initial values. + + + + Properties + Initial Value + + + + + + + cmdText + + + + + + + 0 + + + + + + CommandType.Text + + + + + + + connection + + + + + You can change the value for any of these properties through a separate call to + the property. + + + The following example creates a and + sets some of its properties. + + + Public Sub CreateMySqlCommand() + Dim conn as new MySqlConnection("server=myServer") + Dim sql as String = "SELECT * FROM mytable" + Dim myCommand As New MySqlCommand(sql, conn) + myCommand.CommandType = CommandType.Text + End Sub + + + public void CreateMySqlCommand() + { + MySqlConnection conn = new MySqlConnection("server=myserver") + string sql = "SELECT * FROM mytable"; + MySqlCommand myCommand = new MySqlCommand(sql, conn); + myCommand.CommandType = CommandType.Text; + } + + + + + + Initializes a new instance of the class + with the text of the query, a , and the + . + The text of the query. + A that represents the + connection to an instance of SQL Server. + + The in which the executes. + + When an instance of is created, + the following read/write properties are set to initial values. + + + + Properties + Initial Value + + + + + + + cmdText + + + + + + + 0 + + + + + + CommandType.Text + + + + + + + connection + + + + + You can change the value for any of these properties through a separate call to + the property. + + + The following example creates a and + sets some of its properties. + + + Public Sub CreateMySqlCommand() + Dim conn as new MySqlConnection("server=myServer") + conn.Open(); + Dim txn as MySqlTransaction = conn.BeginTransaction() + Dim sql as String = "SELECT * FROM mytable" + Dim myCommand As New MySqlCommand(sql, conn, txn) + myCommand.CommandType = CommandType.Text + End Sub + + + public void CreateMySqlCommand() + { + MySqlConnection conn = new MySqlConnection("server=myserver") + conn.Open(); + MySqlTransaction txn = conn.BeginTransaction(); + string sql = "SELECT * FROM mytable"; + MySqlCommand myCommand = new MySqlCommand(sql, conn, txn); + myCommand.CommandType = CommandType.Text; + } + + + + + + Gets the last inserted id. + + + + + + Gets or sets the SQL statement to execute at the data source. + + The SQL statement or stored procedure to execute. The default is an empty string. + + + When the property is set to StoredProcedure, + the CommandText property should be set to the name of the stored procedure. + The user may be required to use escape character syntax if the stored procedure name + contains any special characters. The command executes this stored procedure when + you call one of the Execute methods. Starting with Connector/NET 5.0, having both a stored function + and stored procedure with the same name in the same database is not supported. It is + suggested that you provide unqiue names for your stored routines. + + + The following example creates a and sets some of its properties. + + Public Sub CreateMySqlCommand() + Dim myCommand As New MySqlCommand() + myCommand.CommandText = "SELECT * FROM Mytable ORDER BY id" + myCommand.CommandType = CommandType.Text + End Sub + + + public void CreateMySqlCommand() + { + MySqlCommand myCommand = new MySqlCommand(); + myCommand.CommandText = "SELECT * FROM mytable ORDER BY id"; + myCommand.CommandType = CommandType.Text; + } + + + + + + Gets or sets the wait time before terminating the attempt to execute a command + and generating an error. + + The time (in seconds) to wait for the command to execute. The default is 30 + seconds. + + CommandTimeout is dependent on the ability of MySQL to cancel an executing query. + Because of this, CommandTimeout is only supported when connected to MySQL + version 5.0.0 or higher. + + + + + Gets or sets a value indicating how the property is to be interpreted. + + One of the values. The default is Text. + + + When you set the CommandType property to StoredProcedure, you + should set the property to the name of the stored + procedure. The command executes this stored procedure when you call one of the + Execute methods. + + + The following example creates a and sets some of its properties. + + Public Sub CreateMySqlCommand() + Dim myCommand As New MySqlCommand() + myCommand.CommandType = CommandType.Text + End Sub + + + public void CreateMySqlCommand() + { + MySqlCommand myCommand = new MySqlCommand(); + myCommand.CommandType = CommandType.Text; + } + + + + + + Gets a boolean value that indicates whether the Prepared method has been called. + + + + + + Gets or sets the used by this instance of the + . + + The connection to a data source. The default value is a null reference + (Nothing in Visual Basic). + + + If you set Connection while a transaction is in progress and the + property is not null, an + is generated. If the Transaction property is not null and the transaction + has already been committed or rolled back, Transaction is set to + null. + + + The following example creates a and sets some of its properties. + + Public Sub CreateMySqlCommand() + Dim mySelectQuery As String = "SELECT * FROM mytable ORDER BY id" + Dim myConnectString As String = "Persist Security Info=False;database=test;server=myServer" + Dim myCommand As New MySqlCommand(mySelectQuery) + myCommand.Connection = New MySqlConnection(myConnectString) + myCommand.CommandType = CommandType.Text + End Sub + + + public void CreateMySqlCommand() + { + string mySelectQuery = "SELECT * FROM mytable ORDER BY id"; + string myConnectString = "Persist Security Info=False;database=test;server=myServer"; + MySqlCommand myCommand = new MySqlCommand(mySelectQuery); + myCommand.Connection = new MySqlConnection(myConnectString); + myCommand.CommandType = CommandType.Text; + } + + + + + + Get the + + The parameters of the SQL statement or stored procedure. The default is + an empty collection. + + Connector/NET does not support unnamed parameters. Every parameter added to the collection must + have an associated name. + + The following example creates a and displays its parameters. + To accomplish this, the method is passed a , a query string + that is a SQL SELECT statement, and an array of objects. + + Public Sub CreateMySqlCommand(myConnection As MySqlConnection, _ + mySelectQuery As String, myParamArray() As MySqlParameter) + Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) + myCommand.CommandText = "SELECT id, name FROM mytable WHERE age=@age" + myCommand.UpdatedRowSource = UpdateRowSource.Both + myCommand.Parameters.Add(myParamArray) + Dim j As Integer + For j = 0 To myCommand.Parameters.Count - 1 + myCommand.Parameters.Add(myParamArray(j)) + Next j + Dim myMessage As String = "" + Dim i As Integer + For i = 0 To myCommand.Parameters.Count - 1 + myMessage += myCommand.Parameters(i).ToString() & ControlChars.Cr + Next i + Console.WriteLine(myMessage) + End Sub + + + public void CreateMySqlCommand(MySqlConnection myConnection, string mySelectQuery, + MySqlParameter[] myParamArray) + { + MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection); + myCommand.CommandText = "SELECT id, name FROM mytable WHERE age=@age"; + myCommand.Parameters.Add(myParamArray); + for (int j=0; j<myParamArray.Length; j++) + { + myCommand.Parameters.Add(myParamArray[j]) ; + } + string myMessage = ""; + for (int i = 0; i < myCommand.Parameters.Count; i++) + { + myMessage += myCommand.Parameters[i].ToString() + "\n"; + } + MessageBox.Show(myMessage); + } + + + + + + Gets or sets the within which the executes. + + The . The default value is a null reference (Nothing in Visual Basic). + + You cannot set the Transaction property if it is already set to a + specific value, and the command is in the process of executing. If you set the + transaction property to a object that is not connected + to the same as the object, + an exception will be thrown the next time you attempt to execute a statement. + + + + + Gets or sets a boolean value that indicates whether caching is enabled. + + + + + Gets or sets the seconds for how long a TableDirect result should be cached. + + + + + Gets or sets how command results are applied to the DataRow when used by the + Update method of the DbDataAdapter. + + + + + Gets or sets a value indicating whether the command object should be visible in a Windows Form Designer control. + + + + + Attempts to cancel the execution of a currently active command + + + Cancelling a currently active query only works with MySQL versions 5.0.0 and higher. + + + + + Creates a new instance of a object. + + + This method is a strongly-typed version of . + + A object. + + + + + Check the connection to make sure + - it is open + - it is not currently being used by a reader + - and we have the right version of MySQL for the requested command type + + + + + Executes a SQL statement against the connection and returns the number of rows affected. + Number of rows affected + You can use ExecuteNonQuery to perform any type of database operation, + however any resultsets returned will not be available. Any output parameters + used in calling a stored procedure will be populated with data and can be + retrieved after execution is complete. + For UPDATE, INSERT, and DELETE statements, the return value is the number + of rows affected by the command. For all other types of statements, the return + value is -1. + + The following example creates a MySqlCommand and then + executes it using ExecuteNonQuery. The example is passed a string that is a + SQL statement (such as UPDATE, INSERT, or DELETE) and a string to use to + connect to the data source. + + Public Sub CreateMySqlCommand(myExecuteQuery As String, myConnection As MySqlConnection) + Dim myCommand As New MySqlCommand(myExecuteQuery, myConnection) + myCommand.Connection.Open() + myCommand.ExecuteNonQuery() + myConnection.Close() + End Sub + + + public void CreateMySqlCommand(string myExecuteQuery, MySqlConnection myConnection) + { + MySqlCommand myCommand = new MySqlCommand(myExecuteQuery, myConnection); + myCommand.Connection.Open(); + myCommand.ExecuteNonQuery(); + myConnection.Close(); + } + + + + + + Reset reader to null, to avoid "There is already an open data reader" + on the next ExecuteReader(). Used in error handling scenarios. + + + + + Reset SQL_SELECT_LIMIT that could have been modified by CommandBehavior. + + + + + Sends the to the Connection + and builds a . + + A object. + + + When the property is set to StoredProcedure, + the property should be set to the name of the stored + procedure. The command executes this stored procedure when you call + ExecuteReader. + + + While the is in use, the associated + is busy serving the MySqlDataReader. + While in this state, no other operations can be performed on the + MySqlConnection other than closing it. This is the case until the + method of the MySqlDataReader is called. + + + The following example creates a , then executes it by + passing a string that is a SQL SELECT statement, and a string to use to connect to the + data source. + + Public Sub CreateMySqlDataReader(mySelectQuery As String, myConnection As MySqlConnection) + Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) + myConnection.Open() + Dim myReader As MySqlDataReader + myReader = myCommand.ExecuteReader() + Try + While myReader.Read() + Console.WriteLine(myReader.GetString(0)) + End While + Finally + myReader.Close + myConnection.Close + End Try + End Sub + + + public void CreateMySqlDataReader(string mySelectQuery, MySqlConnection myConnection) + { + MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection); + myConnection.Open(); + MMySqlDataReader myReader; + myReader = myCommand.ExecuteReader(); + try + { + while(myReader.Read()) + { + Console.WriteLine(myReader.GetString(0)); + } + } + finally + { + myReader.Close(); + myConnection.Close(); + } + } + + + + + + Sends the to the Connection, + and builds a using one of the values. + + One of the values. + + + When the property is set to StoredProcedure, + the property should be set to the name of the stored + procedure. The command executes this stored procedure when you call + ExecuteReader. + + + The supports a special mode that enables large binary + values to be read efficiently. For more information, see the SequentialAccess + setting for . + + + While the is in use, the associated + is busy serving the MySqlDataReader. + While in this state, no other operations can be performed on the + MySqlConnection other than closing it. This is the case until the + method of the MySqlDataReader is called. + If the MySqlDataReader is created with CommandBehavior set to + CloseConnection, closing the MySqlDataReader closes the connection + automatically. + + + When calling ExecuteReader with the SingleRow behavior, you should be aware that using a limit + clause in your SQL will cause all rows (up to the limit given) to be retrieved by the client. The + method will still return false after the first row but pulling all rows of data + into the client will have a performance impact. If the limit clause is not necessary, it should + be avoided. + + + A object. + + + + + Executes the query, and returns the first column of the first row in the + result set returned by the query. Extra columns or rows are ignored. + + The first column of the first row in the result set, or a null reference if the + result set is empty + + + Use the ExecuteScalar method to retrieve a single value (for example, + an aggregate value) from a database. This requires less code than using the + method, and then performing the operations necessary + to generate the single value using the data returned by a + + + The following example creates a and then + executes it using ExecuteScalar. The example is passed a string that is a + SQL statement that returns an aggregate result, and a string to use to + connect to the data source. + + + Public Sub CreateMySqlCommand(myScalarQuery As String, myConnection As MySqlConnection) + Dim myCommand As New MySqlCommand(myScalarQuery, myConnection) + myCommand.Connection.Open() + myCommand.ExecuteScalar() + myConnection.Close() + End Sub + + + public void CreateMySqlCommand(string myScalarQuery, MySqlConnection myConnection) + { + MySqlCommand myCommand = new MySqlCommand(myScalarQuery, myConnection); + myCommand.Connection.Open(); + myCommand.ExecuteScalar(); + myConnection.Close(); + } + + + public: + void CreateMySqlCommand(String* myScalarQuery, MySqlConnection* myConnection) + { + MySqlCommand* myCommand = new MySqlCommand(myScalarQuery, myConnection); + myCommand->Connection->Open(); + myCommand->ExecuteScalar(); + myConnection->Close(); + } + + + + + + + + + + Creates a prepared version of the command on an instance of MySQL Server. + + + Prepared statements are only supported on MySQL version 4.1 and higher. Calling + prepare while connected to earlier versions of MySQL will succeed but will execute + the statement in the same way as unprepared. + + + The following example demonstrates the use of the Prepare method. + + public sub PrepareExample() + Dim cmd as New MySqlCommand("INSERT INTO mytable VALUES (@val)", myConnection) + cmd.Parameters.Add( "@val", 10 ) + cmd.Prepare() + cmd.ExecuteNonQuery() + + cmd.Parameters(0).Value = 20 + cmd.ExecuteNonQuery() + end sub + + + private void PrepareExample() + { + MySqlCommand cmd = new MySqlCommand("INSERT INTO mytable VALUES (@val)", myConnection); + cmd.Parameters.Add( "@val", 10 ); + cmd.Prepare(); + cmd.ExecuteNonQuery(); + + cmd.Parameters[0].Value = 20; + cmd.ExecuteNonQuery(); + } + + + + + + Initiates the asynchronous execution of the SQL statement or stored procedure + that is described by this , and retrieves one or more + result sets from the server. + + An that can be used to poll, wait for results, + or both; this value is also needed when invoking EndExecuteReader, + which returns a instance that can be used to retrieve + the returned rows. + + + + Initiates the asynchronous execution of the SQL statement or stored procedure + that is described by this using one of the + CommandBehavior values. + + One of the values, indicating + options for statement execution and data retrieval. + An that can be used to poll, wait for results, + or both; this value is also needed when invoking EndExecuteReader, + which returns a instance that can be used to retrieve + the returned rows. + + + + Finishes asynchronous execution of a SQL statement, returning the requested + . + + The returned by the call to + . + A MySqlDataReader object that can be used to retrieve the requested rows. + + + + Initiates the asynchronous execution of the SQL statement or stored procedure + that is described by this . + + + An delegate that is invoked when the command's + execution has completed. Pass a null reference (Nothing in Visual Basic) + to indicate that no callback is required. + A user-defined state object that is passed to the + callback procedure. Retrieve this object from within the callback procedure + using the property. + An that can be used to poll or wait for results, + or both; this value is also needed when invoking , + which returns the number of affected rows. + + + + Initiates the asynchronous execution of the SQL statement or stored procedure + that is described by this . + + An that can be used to poll or wait for results, + or both; this value is also needed when invoking , + which returns the number of affected rows. + + + + Finishes asynchronous execution of a SQL statement. + + The returned by the call + to . + + + + + Verifies if a query is valid even if it has not spaces or is a stored procedure call + + Query to validate + If it is necessary to add call statement + + + + Creates a clone of this object. CommandText, Connection, and Transaction properties + are included as well as the entire parameter list. + + The cloned object. + + + + Summary description for API. + + + + + Summary description for CompressedStream. + + + + + Represents an open connection to a MySQL Server database. This class cannot be inherited. + + + A MySqlConnection object represents a session to a MySQL Server + data source. When you create an instance of MySqlConnection, all + properties are set to their initial values. For a list of these values, see the + MySqlConnection constructor. + + + + If the MySqlConnection goes out of scope, it is not closed. Therefore, + you must explicitly close the connection by calling + or . + + + The following example creates a and + a MySqlConnection. The MySqlConnection is opened and set as the + for the MySqlCommand. The example then calls + , and closes the connection. To accomplish this, the ExecuteNonQuery is + passed a connection string and a query string that is a SQL INSERT + statement. + + + Public Sub InsertRow(myConnectionString As String) + ' If the connection string is null, use a default. + If myConnectionString = "" Then + myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass" + End If + Dim myConnection As New MySqlConnection(myConnectionString) + Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)" + Dim myCommand As New MySqlCommand(myInsertQuery) + myCommand.Connection = myConnection + myConnection.Open() + myCommand.ExecuteNonQuery() + myCommand.Connection.Close() + End Sub + + + + + public void InsertRow(string myConnectionString) + { + // If the connection string is null, use a default. + if(myConnectionString == "") + { + myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"; + } + MySqlConnection myConnection = new MySqlConnection(myConnectionString); + string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"; + MySqlCommand myCommand = new MySqlCommand(myInsertQuery); + myCommand.Connection = myConnection; + myConnection.Open(); + myCommand.ExecuteNonQuery(); + myCommand.Connection.Close(); + } + + + + + + + The client used to handle SSH connections. + + + + Occurs when MySQL returns warnings as a result of executing a command or query. + + + + + Initializes a new instance of the class. + + When a new instance of is created, the read/write + properties are set to the following initial values unless they are specifically + set using their associated keywords in the property. + + + + Properties + Initial Value + + + + + + empty string ("") + + + + + + 15 + + + + + + empty string ("") + + + + + + empty string ("") + + + + + + empty string ("") + + + + You can change the value for these properties only by using the ConnectionString property. + + + + Initializes a new instance of the class. + + + + + + Initializes a new instance of the class when given a string containing the connection string. + + When a new instance of is created, the read/write + properties are set to the following initial values unless they are specifically + set using their associated keywords in the property. + + + + Properties + Initial Value + + + + + + empty string ("") + + + + + + 15 + + + + + + empty string ("") + + + + + + empty string ("") + + + + + + empty string ("") + + + + You can change the value for these properties only by using the ConnectionString property. + + The connection properties used to open the MySQL database. + + + + Determines whether the connection is a clone of other connection. + + + + + Returns the id of the server thread this connection is executing on + + + + + Gets the name of the MySQL server to which to connect. + + + + + Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error. + The value set is less than 0. + A value of 0 indicates no limit, and should be avoided in a + because an attempt to connect + will wait indefinitely. + + The following example creates a MySqlConnection + and sets some of its properties in the connection string. + + Public Sub CreateSqlConnection() + Dim myConnection As New MySqlConnection() + myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30" + myConnection.Open() + End Sub + + + public void CreateSqlConnection() + { + MySqlConnection myConnection = new MySqlConnection(); + myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30"; + myConnection.Open(); + } + + + + + Gets the name of the current database or the database to be used after a connection is opened.The name of the current database or the name of the database to be used after a connection is opened. The default value is an empty string. + + The Database property does not update dynamically. + If you change the current database using a SQL statement, then this property + may reflect the wrong value. If you change the current database using the + method, this property is updated to reflect the new database. + + + The following example creates a and displays + some of its read-only properties. + + + Public Sub CreateMySqlConnection() + Dim myConnString As String = _ + "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass" + Dim myConnection As New MySqlConnection( myConnString ) + myConnection.Open() + MessageBox.Show( "Server Version: " + myConnection.ServerVersion _ + + ControlChars.NewLine + "Database: " + myConnection.Database ) + myConnection.ChangeDatabase( "test2" ) + MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _ + + ControlChars.NewLine + "Database: " + myConnection.Database ) + myConnection.Close() + End Sub + + + + public void CreateMySqlConnection() + { + string myConnString = + "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"; + MySqlConnection myConnection = new MySqlConnection( myConnString ); + myConnection.Open(); + MessageBox.Show( "Server Version: " + myConnection.ServerVersion + + "\nDatabase: " + myConnection.Database ); + myConnection.ChangeDatabase( "test2" ); + MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion + + "\nDatabase: " + myConnection.Database ); + myConnection.Close(); + } + + + + + + Indicates if this connection should use compression when communicating with the server. + + + + Gets the current state of the connection. + A bitwise combination of the values. The default is Closed. + + The allowed state changes are: + + + From Closed to Open, using the Open method of the connection object. + + + From Open to Closed, using either the Close method or the Dispose method of the connection object. + + + + The following example creates a , opens it, + displays some of its properties, then closes the connection. + + + Public Sub CreateMySqlConnection(myConnString As String) + Dim myConnection As New MySqlConnection(myConnString) + myConnection.Open() + MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ + + ControlChars.Cr + "State: " + myConnection.State.ToString()) + myConnection.Close() + End Sub + + + public void CreateMySqlConnection(string myConnString) + { + MySqlConnection myConnection = new MySqlConnection(myConnString); + myConnection.Open(); + MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + + "\nState: " + myConnection.State.ToString()); + myConnection.Close(); + } + + + + + Gets a string containing the version of the MySQL server to which the client is connected.The version of the instance of MySQL.The connection is closed. + The following example creates a , opens it, + displays some of its properties, then closes the connection. + + + Public Sub CreateMySqlConnection(myConnString As String) + Dim myConnection As New MySqlConnection(myConnString) + myConnection.Open() + MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ + + ControlChars.Cr + "State: " + myConnection.State.ToString()) + myConnection.Close() + End Sub + + + public void CreateMySqlConnection(string myConnString) + { + MySqlConnection myConnection = new MySqlConnection(myConnString); + myConnection.Open(); + MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + + "\nState: " + myConnection.State.ToString()); + myConnection.Close(); + } + + + + + + Gets or sets the string used to connect to a MySQL Server database. + + + The ConnectionString returned may not be exactly like what was originally + set but will be indentical in terms of keyword/value pairs. Security information + will not be included unless the Persist Security Info value is set to true. + + + You can use the ConnectionString property to connect to a database. + The following example illustrates a typical connection string. + + "Persist Security Info=False;database=MyDB;server=MySqlServer;user id=myUser;Password=myPass" + + The ConnectionString property can be set only when the connection is + closed. Many of the connection string values have corresponding read-only + properties. When the connection string is set, all of these properties are + updated, except when an error is detected. In this case, none of the properties + are updated. properties return only those settings contained in the + ConnectionString. + + + To connect to a local machine, specify "localhost" for the server. If you do not + specify a server, localhost is assumed. + + + Resetting the ConnectionString on a closed connection resets all + connection string values (and related properties) including the password. For + example, if you set a connection string that includes "Database= MyDb", and + then reset the connection string to "Data Source=myserver;User Id=myUser;Password=myPass", + the property is no longer set to MyDb. + + + The connection string is parsed immediately after being set. If errors in + syntax are found when parsing, a runtime exception, such as , + is generated. Other errors can be found only when an attempt is made to open the + connection. + + + The basic format of a connection string consists of a series of keyword/value + pairs separated by semicolons. The equal sign (=) connects each keyword and its + value. To include values that contain a semicolon, single-quote character, or + double-quote character, the value must be enclosed in double quotes. If the + value contains both a semicolon and a double-quote character, the value can be + enclosed in single quotes. The single quote is also useful if the value begins + with a double-quote character. Conversely, the double quote can be used if the + value begins with a single quote. If the value contains both single-quote and + double-quote characters, the quote character used to enclose the value must be + doubled each time it occurs within the value. + + + To include preceding or trailing spaces in the string value, the value must + be enclosed in either single quotes or double quotes. Any leading or trailing + spaces around integer, Boolean, or enumerated values are ignored, even if + enclosed in quotes. However, spaces within a string literal keyword or value are + preserved. Using .NET Framework version 1.1, single or double quotes may be used + within a connection string without using delimiters (for example, Data Source= + my'Server or Data Source= my"Server), unless a quote character is the first or + last character in the value. + + + To include an equal sign (=) in a keyword or value, it must be preceded by + another equal sign. For example, in the hypothetical connection string + + "key==word=value" + + the keyword is "key=word" and the value is "value". + + If a specific keyword in a keyword= value pair occurs multiple times in a + connection string, the last occurrence listed is used in the value set. + + Keywords are not case sensitive. + + The following table lists the valid names for keyword values within the + ConnectionString. + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDefaultDescription
+ Connect Timeout -or- Connection Timeout + 15 + The length of time (in seconds) to wait for a connection to the server before + terminating the attempt and generating an error. +
+ Host -or- Server -or- Data Source -or- + DataSource -or- Address -or- Addr -or- + Network Address + localhost + + The name or network address of the instance of MySQL to which to connect. Multiple hosts can be + specified separated by &. This can be useful where multiple MySQL servers are configured for replication + and you are not concerned about the precise server you are connecting to. No attempt is made by the provider to + synchronize writes to the database so care should be taken when using this option. + + + In Unix environment with Mono, this can be a fully qualified path to MySQL socket filename. With this configuration, the Unix socket will be used instead of TCP/IP socket. + Currently only a single socket name can be given so accessing MySQL in a replicated environment using Unix sockets is not currently supported. + +
Port3306 + The port MySQL is using to listen for connections. This value is ignored if the connection protocol + is anything but socket. +
Protocolsocket + Specifies the type of connection to make to the server.Values can be: + socket or tcp for a socket connection
+ pipe for a named pipe connection
+ unix for a Unix socket connection
+ memory to use MySQL shared memory +
+ CharSet -or Character Set + + + Specifies the character set that should be used to encode all queries sent to the server. + Resultsets are still returned in the character set of the data returned. +
LoggingfalseWhen true, various pieces of information is output to any configured TraceListeners.
Allow Batchtrue + When true, multiple SQL statements can be sent with one command execution.

+ -Note-
+ Starting with MySQL 4.1.1, batch statements should be separated by the server-defined seperator character.
+ Commands sent to earlier versions of MySQL should be seperated with ';'. +
Encryptfalse + When true, SSL/TLS encryption is used for all data sent between the + client and server if the server has a certificate installed. Recognized values + are true, false, yes, and no. +
+ Initial Catalog -or- Database + mysqlThe name of the database to use intially
+ Password -or- pwd + + The password for the MySQL account being used.
Persist Security Infofalse + When set to false or no (strongly recommended), security-sensitive + information, such as the password, is not returned as part of the connection if + the connection is open or has ever been in an open state. Resetting the + connection string resets all connection string values including the password. + Recognized values are true, false, yes, and no. +
+ User Id -or- Username -or- Uid -or- User name + + The MySQL login account being used.
Shared Memory NameMYSQLThe name of the shared memory object to use for communication if the connection protocol is set to memory.
Allow Zero Datetimefalse + True to have MySqlDataReader.GetValue() return a MySqlDateTime for date or datetime columns that have illegal values. + False will cause a DateTime object to be returned for legal values and an exception will be thrown for illegal values. +
Convert Zero Datetimefalse + True to have MySqlDataReader.GetValue() and MySqlDataReader.GetDateTime() + return DateTime.MinValue for date or datetime columns that have illegal values. +
+ Pipe Name -or- Pipe + mysql + When set to the name of a named pipe, the MySqlConnection will attempt to connect to MySQL + on that named pipe.

This settings only applies to the Windows platform. +
+ Use Performance Monitor -or- UsePerformanceMonitor + false + Posts performance data that can be tracked using perfmon +
+ Procedure Cache Size + 25 + How many stored procedure definitions can be held in the cache +
+ Ignore Prepare + true + Instructs the provider to ignore any attempts to prepare commands. This option + was added to allow a user to disable prepared statements in an entire application + without modifying the code. A user might want to do this if errors or bugs are + encountered with MySQL prepared statements. +
Use Procedure Bodiestrue + Instructs the provider to attempt to call the procedure without first resolving the metadata. This + is useful in situations where the calling user does not have access to the mysql.proc table. To + use this mode, the parameters for the procedure must be added to the command in the same order + as they appear in the procedure definition and their types must be explicitly set. +
Auto Enlisttrue + Indicates whether the connection should automatically enlist in the current transaction, + if there is one. +
Respect Binary Flagstrue + Indicates whether the connection should respect all binary flags sent to the client + as part of column metadata. False will cause the connector to behave like + Connector/NET 5.0 and earlier. +
BlobAsUTF8IncludePatternnull + Pattern that should be used to indicate which blob columns should be treated as UTF-8. +
BlobAsUTF8ExcludePatternnull + Pattern that should be used to indicate which blob columns should not be treated as UTF-8. +
Default Command Timeout30 + The default timeout that new MySqlCommand objects will use unless changed. +
Allow User Variablesfalse + Should the provider expect user variables in the SQL. +
Interactive -or- Interactive Sessionfalse + Should this session be considered interactive? +
Functions Return Stringfalse + Set this option to true to force the return value of SQL functions to be string. +
Use Affected Rowsfalse + Set this option to true to cause the affected rows reported to reflect only the + rows that are actually changed. By default, the number of rows that are matched + is returned. +
+
+ + The following table lists the valid names for connection pooling values within + the ConnectionString. For more information about connection pooling, see + Connection Pooling for the MySql Data Provider. + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDefaultDescription
Connection Lifetime0 + When a connection is returned to the pool, its creation time is compared with + the current time, and the connection is destroyed if that time span (in seconds) + exceeds the value specified by Connection Lifetime. This is useful in + clustered configurations to force load balancing between a running server and a + server just brought online. + + A value of zero (0) causes pooled connections to have the maximum connection + timeout. + +
Max Pool Size100The maximum number of connections allowed in the pool.
Min Pool Size0The minimum number of connections allowed in the pool.
Poolingtrue + When true, the MySqlConnection object is drawn from the appropriate + pool, or if necessary, is created and added to the appropriate pool. Recognized + values are true, false, yes, and no. +
Connection Resetfalse + Specifies whether the database connection should be reset when being + drawn from the pool. Leaving this as false will yeild much faster + connection opens but the user should understand the side effects + of doing this such as temporary tables and user variables from the previous + session not being cleared out. +
Cache Server Propertiesfalse + Specifies whether the server variables are cached between pooled connections. + On systems where the variables change infrequently and there are lots of + connection attempts, this can speed up things dramatically. +
+
+ + When setting keyword or connection pooling values that require a Boolean + value, you can use 'yes' instead of 'true', and 'no' instead of 'false'. + + + Note The MySql Data Provider uses the native socket protocol to + communicate with MySQL. Therefore, it does not support the use of an ODBC data source name (DSN) when + connecting to MySQL because it does not add an ODBC layer. + + + CAUTION In this release, the application should use caution when constructing a + connection string based on user input (for example when retrieving user ID and password information from a + dialog box, and appending it to the connection string). The application should + ensure that a user cannot embed extra connection string parameters in these + values (for example, entering a password as "validpassword;database=somedb" in + an attempt to attach to a different database). + +
+ The following example creates a and sets some of its properties + + Public Sub CreateConnection() + Dim myConnection As New MySqlConnection() + myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass" + myConnection.Open() + End Sub 'CreateConnection + + + public void CreateConnection() + { + MySqlConnection myConnection = new MySqlConnection(); + myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass"; + myConnection.Open(); + } + + + The following example creates a in Unix environment with Mono installed. MySQL socket filename used in this example is "/var/lib/mysql/mysql.sock". The actual filename depends on your MySQL configuration. + + Public Sub CreateConnection() + Dim myConnection As New MySqlConnection() + myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass" + myConnection.Open() + End Sub 'CreateConnection + + + public void CreateConnection() + { + MySqlConnection myConnection = new MySqlConnection(); + myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass"; + myConnection.Open(); + } + + +
+ + + Gets a boolean value that indicates whether the password associated to the connection is expired. + + + + Begins a database transaction.An object representing the new transaction.Parallel transactions are not supported. + This command is equivalent to the MySQL BEGIN TRANSACTION command. + + You must explicitly commit or roll back the transaction using the or + method. + + If you do not specify an isolation level, the default isolation level is used. To specify an isolation + level with the method, use the overload that takes the iso parameter. Also + note that any attempt to begin a transaction while a transaction is in progress will throw an exception on MySQL 4.1 and higher. + On MySQL 4.0, an exception will not be thrown because servers 4.0 and earlier did not report their transacation status. + + + + The following example creates a and a + . It also demonstrates how to use the BeginTransaction, a + , and methods. + + Public Sub RunTransaction(myConnString As String) + Dim myConnection As New MySqlConnection(myConnString) + myConnection.Open() + + Dim myCommand As MySqlCommand = myConnection.CreateCommand() + Dim myTrans As MySqlTransaction + + ' Start a local transaction + myTrans = myConnection.BeginTransaction() + ' Must assign both transaction object and connection + ' to Command object for a pending local transaction + myCommand.Connection = myConnection + myCommand.Transaction = myTrans + + Try + myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')" + myCommand.ExecuteNonQuery() + myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')" + myCommand.ExecuteNonQuery() + myTrans.Commit() + Console.WriteLine("Both records are written to database.") + Catch e As Exception + Try + myTrans.Rollback() + Catch ex As MySqlException + If Not myTrans.Connection Is Nothing Then + Console.WriteLine("An exception of type " + ex.GetType().ToString() + _ + " was encountered while attempting to roll back the transaction.") + End If + End Try + + Console.WriteLine("An exception of type " + e.GetType().ToString() + _ + "was encountered while inserting the data.") + Console.WriteLine("Neither record was written to database.") + Finally + myConnection.Close() + End Try + End Sub + + + public void RunTransaction(string myConnString) + { + MySqlConnection myConnection = new MySqlConnection(myConnString); + myConnection.Open(); + + MySqlCommand myCommand = myConnection.CreateCommand(); + MySqlTransaction myTrans; + + // Start a local transaction + myTrans = myConnection.BeginTransaction(); + // Must assign both transaction object and connection + // to Command object for a pending local transaction + myCommand.Connection = myConnection; + myCommand.Transaction = myTrans; + + try + { + myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')"; + myCommand.ExecuteNonQuery(); + myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')"; + myCommand.ExecuteNonQuery(); + myTrans.Commit(); + Console.WriteLine("Both records are written to database."); + } + catch(Exception e) + { + try + { + myTrans.Rollback(); + } + catch (SqlException ex) + { + if (myTrans.Connection != null) + { + Console.WriteLine("An exception of type " + ex.GetType() + + " was encountered while attempting to roll back the transaction."); + } + } + + Console.WriteLine("An exception of type " + e.GetType() + + " was encountered while inserting the data."); + Console.WriteLine("Neither record was written to database."); + } + finally + { + myConnection.Close(); + } + } + + + + + Begins a database transaction with the specified isolation level.The isolation level under which the transaction should run. An object representing the new transaction.Parallel exceptions are not supported. + This command is equivalent to the MySQL BEGIN TRANSACTION command. + + You must explicitly commit or roll back the transaction using the or + method. + + If you do not specify an isolation level, the default isolation level is used. To specify an isolation + level with the method, use the overload that takes the iso parameter. + Also note that any attempt to begin a transaction while a transaction is in progress will throw an exception on MySQL 4.1 and higher. + On MySQL 4.0, an exception will not be thrown because servers 4.0 and earlier did not report their transacation status. + + + + The following example creates a and a + . It also demonstrates how to use the BeginTransaction, a + , and methods. + + Public Sub RunTransaction(myConnString As String) + Dim myConnection As New MySqlConnection(myConnString) + myConnection.Open() + + Dim myCommand As MySqlCommand = myConnection.CreateCommand() + Dim myTrans As MySqlTransaction + + ' Start a local transaction + myTrans = myConnection.BeginTransaction() + ' Must assign both transaction object and connection + ' to Command object for a pending local transaction + myCommand.Connection = myConnection + myCommand.Transaction = myTrans + + Try + myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')" + myCommand.ExecuteNonQuery() + myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')" + myCommand.ExecuteNonQuery() + myTrans.Commit() + Console.WriteLine("Both records are written to database.") + Catch e As Exception + Try + myTrans.Rollback() + Catch ex As MySqlException + If Not myTrans.Connection Is Nothing Then + Console.WriteLine("An exception of type " + ex.GetType().ToString() + _ + " was encountered while attempting to roll back the transaction.") + End If + End Try + + Console.WriteLine("An exception of type " + e.GetType().ToString() + _ + "was encountered while inserting the data.") + Console.WriteLine("Neither record was written to database.") + Finally + myConnection.Close() + End Try + End Sub + + + public void RunTransaction(string myConnString) + { + MySqlConnection myConnection = new MySqlConnection(myConnString); + myConnection.Open(); + + MySqlCommand myCommand = myConnection.CreateCommand(); + MySqlTransaction myTrans; + + // Start a local transaction + myTrans = myConnection.BeginTransaction(); + // Must assign both transaction object and connection + // to Command object for a pending local transaction + myCommand.Connection = myConnection; + myCommand.Transaction = myTrans; + + try + { + myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')"; + myCommand.ExecuteNonQuery(); + myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')"; + myCommand.ExecuteNonQuery(); + myTrans.Commit(); + Console.WriteLine("Both records are written to database."); + } + catch(Exception e) + { + try + { + myTrans.Rollback(); + } + catch (SqlException ex) + { + if (myTrans.Connection != null) + { + Console.WriteLine("An exception of type " + ex.GetType() + + " was encountered while attempting to roll back the transaction."); + } + } + + Console.WriteLine("An exception of type " + e.GetType() + + " was encountered while inserting the data."); + Console.WriteLine("Neither record was written to database."); + } + finally + { + myConnection.Close(); + } + } + + + + + Changes the current database for an open MySqlConnection.The name of the database to use. + + The value supplied in the database parameter must be a valid database + name. The database parameter cannot contain a null value, an empty + string, or a string with only blank characters. + + + + When you are using connection pooling against MySQL, and you close + the connection, it is returned to the connection pool. The next time the + connection is retrieved from the pool, the reset connection request + executes before the user performs any operations. + + The database name is not valid.The connection is not open.Cannot change the database. + The following example creates a and displays + some of its read-only properties. + + + Public Sub CreateMySqlConnection() + Dim myConnString As String = _ + "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass" + Dim myConnection As New MySqlConnection( myConnString ) + myConnection.Open() + MessageBox.Show( "Server Version: " + myConnection.ServerVersion _ + + ControlChars.NewLine + "Database: " + myConnection.Database ) + myConnection.ChangeDatabase( "test2" ) + MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _ + + ControlChars.NewLine + "Database: " + myConnection.Database ) + myConnection.Close() + End Sub + + + + public void CreateMySqlConnection() + { + string myConnString = + "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"; + MySqlConnection myConnection = new MySqlConnection( myConnString ); + myConnection.Open(); + MessageBox.Show( "Server Version: " + myConnection.ServerVersion + + "\nDatabase: " + myConnection.Database ); + myConnection.ChangeDatabase( "test2" ); + MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion + + "\nDatabase: " + myConnection.Database ); + myConnection.Close(); + } + + + + + + Pings the server. + + true if the ping was successful; otherwise, false. + + + Opens a database connection with the property settings specified by the ConnectionString.Cannot open a connection without specifying a data source or server.A connection-level error occurred while opening the connection. + + The draws an open connection from the connection pool if one is available. + Otherwise, it establishes a new connection to an instance of MySQL. + + + The following example creates a , opens it, + displays some of its properties, then closes the connection. + + + Public Sub CreateMySqlConnection(myConnString As String) + Dim myConnection As New MySqlConnection(myConnString) + myConnection.Open() + MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ + + ControlChars.Cr + "State: " + myConnection.State.ToString()) + myConnection.Close() + End Sub + + + public void CreateMySqlConnection(string myConnString) + { + MySqlConnection myConnection = new MySqlConnection(myConnString); + myConnection.Open(); + MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + + "\nState: " + myConnection.State.ToString()); + myConnection.Close(); + } + + + + + + Initializes the if more than one host is found. + + A string containing an unparsed list of hosts. + true if the connection data is a URI; otherwise false. + The number of hosts found, -1 if an error was raised during parsing. + + + + Creates a object based on the provided parameters. + + The host string which can be a simple host name or a host name and port. + The priority of the host. + The port number of the host. + + + + + Creates and returns a object associated with the . + + A object. + + + + Closes the connection to the database. This is the preferred method of closing any open connection. + + The Close method rolls back any pending transactions. It then releases + the connection to the connection pool, or closes the connection if connection + pooling is disabled. + + + An application can call Close more than one time. No exception is + generated. + + + The following example creates a , opens it, + displays some of its properties, then closes the connection. + + + Public Sub CreateMySqlConnection(myConnString As String) + Dim myConnection As New MySqlConnection(myConnString) + myConnection.Open() + MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ + + ControlChars.Cr + "State: " + myConnection.State.ToString()) + myConnection.Close() + End Sub + + + public void CreateMySqlConnection(string myConnString) + { + MySqlConnection myConnection = new MySqlConnection(myConnString); + myConnection.Open(); + MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + + "\nState: " + myConnection.State.ToString()); + myConnection.Close(); + } + + + + + + Cancels the query after the specified time interval. + + The length of time (in seconds) to wait for the cancelation of the command execution. + + + + Sets query timeout. If timeout has been set prior and not + yet cleared ClearCommandTimeout(), it has no effect. + + timeout in seconds + true if + + + + Clears query timeout, allowing next SetCommandTimeout() to succeed. + + + + + Gets a schema collection based on the provided restriction values. + + The name of the collection. + The values to restrict. + A schema collection object. + + + Empties the connection pool associated with the specified connection. + The associated with the pool to be cleared. + + + ClearPool clears the connection pool that is associated with the connection. + If additional connections associated with connection are in use at the time of the call, + they are marked appropriately and are discarded (instead of being returned to the pool) + when Close is called on them. + + + + + Clears all connection pools. + + ClearAllPools essentially performs a on all current connection + pools. + + + + + + Initiates the asynchronous execution of a transaction. + + An object representing the new transaction. + + + + Asynchronous version of BeginTransaction. + + The cancellation token. + An object representing the new transaction. + + + + Asynchronous version of BeginTransaction. + + The isolation level under which the transaction should run. + An object representing the new transaction. + + + + Asynchronous version of BeginTransaction. + + The isolation level under which the transaction should run. + The cancellation token. + An object representing the new transaction. + + + + Asynchronous version of the ChangeDataBase method. + + The name of the database to use. + + + + + Asynchronous version of the ChangeDataBase method. + + The name of the database to use. + The cancellation token. + + + + + Asynchronous version of the Close method. + + + + + Asynchronous version of the Close method. + + The cancellation token. + + + + Asynchronous version of the ClearPool method. + + The connection associated with the pool to be cleared. + + + + Asynchronous version of the ClearPool method. + + The connection associated with the pool to be cleared. + The cancellation token. + + + + Asynchronous version of the ClearAllPools method. + + + + + Asynchronous version of the ClearAllPools method. + + The cancellation token. + + + + Asynchronous version of the GetSchemaCollection method. + + The name of the collection. + The values to restrict. + A collection of schema objects. + + + + Asynchronous version of the GetSchemaCollection method. + + The name of the collection. + The values to restrict. + The cancellation token. + A collection of schema objects. + + + + Returns schema information for the data source of this . + + A that contains schema information. + + + + Returns schema information for the data source of this + using the specified string for the schema name. + + Specifies the name of the schema to return. + A that contains schema information. + + + + Returns schema information for the data source of this + using the specified string for the schema name and the specified string array + for the restriction values. + + Specifies the name of the schema to return. + Specifies a set of restriction values for the requested schema. + A that contains schema information. + + + + Enlists in the specified transaction. + + + A reference to an existing in which to enlist. + + + + + Creates a new MySqlConnection object with the exact same ConnectionString value + + A cloned MySqlConnection object + + + + Represents the method that will handle the event of a + . + + + + + Provides data for the InfoMessage event. This class cannot be inherited. + + + + + Gets or sets an array of objects set with the errors found. + + + + + IDisposable wrapper around SetCommandTimeout and ClearCommandTimeout functionality. + + + + + Summary description for Crypt. + + + + + Simple XOR scramble + + Source array + Index inside source array + Destination array + Index inside destination array + Password used to xor the bits + Number of bytes to scramble + + + + Returns a byte array containing the proper encryption of the + given password/seed according to the new 4.1.1 authentication scheme. + + + + + + + + Encrypts a password using the MySql encryption scheme + + The password to encrypt + The encryption seed the server gave us + Indicates if we should use the old or new encryption scheme + + + + + Hashes a password using the algorithm from Monty's code. + The first element in the return is the result of the "old" hash. + The second element is the rest of the "new" hash. + + Password to be hashed + Two element array containing the hashed values + + + + Provides a means of reading a forward-only stream of rows from a MySQL database. This class cannot be inherited. + + + To create a MySQLDataReader, you must call the + method of the object, rather than directly using a constructor. + + + While the MySqlDataReader is in use, the associated + is busy serving the MySqlDataReader, and no other operations can be performed + on the MySqlConnection other than closing it. This is the case until the + method of the MySqlDataReader is called. + + + and + are the only properties that you can call after the MySqlDataReader is + closed. Though the RecordsAffected property may be accessed at any time + while the MySqlDataReader exists, always call Close before returning + the value of RecordsAffected to ensure an accurate return value. + + + For optimal performance, MySqlDataReader avoids creating + unnecessary objects or making unnecessary copies of data. As a result, multiple calls + to methods such as return a reference to the + same object. Use caution if you are modifying the underlying value of the objects + returned by methods such as GetValue. + + + The following example creates a , + a , and a MySqlDataReader. The example reads through + the data, writing it out to the console. Finally, the example closes the MySqlDataReader, then the + MySqlConnection. + + Public Sub ReadMyData(myConnString As String) + Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders" + Dim myConnection As New MySqlConnection(myConnString) + Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) + myConnection.Open() + Dim myReader As MySqlDataReader + myReader = myCommand.ExecuteReader() + ' Always call Read before accessing data. + While myReader.Read() + Console.WriteLine((myReader.GetInt32(0) & ", " & myReader.GetString(1))) + End While + ' always call Close when done reading. + myReader.Close() + ' Close the connection when done with it. + myConnection.Close() + End Sub 'ReadMyData + + + public void ReadMyData(string myConnString) { + string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders"; + MySqlConnection myConnection = new MySqlConnection(myConnString); + MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection); + myConnection.Open(); + MySqlDataReader myReader; + myReader = myCommand.ExecuteReader(); + // Always call Read before accessing data. + while (myReader.Read()) { + Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1)); + } + // always call Close when done reading. + myReader.Close(); + // Close the connection when done with it. + myConnection.Close(); + } + + + + + + Gets the number of columns in the current row. + + + + + Gets a value indicating whether the MySqlDataReader contains one or more rows. + + + + + Gets a value indicating whether the data reader is closed. + + + + + Gets the number of rows changed, inserted, or deleted by execution of the SQL statement. + + + + + Overloaded. Gets the value of a column in its native format. + In C#, this property is the indexer for the MySqlDataReader class. + + + + + Gets the value of a column in its native format. + [C#] In C#, this property is the indexer for the MySqlDataReader class. + + + + + Gets a value indicating the depth of nesting for the current row. This method is not + supported currently and always returns 0. + + + + + Closes the MySqlDataReader object. + + + + + Gets the value of the specified column as a Boolean. + + + + + + + Gets the value of the specified column as a Boolean. + + + + + + + Gets the value of the specified column as a byte. + + + + + + + Gets the value of the specified column as a byte. + + + + + + + Gets the value of the specified column as a sbyte. + + + + + + + Gets the value of the specified column as a sbyte. + + + + + + + Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset. + + The zero-based column ordinal. + The index within the field from which to begin the read operation. + The buffer into which to read the stream of bytes. + The index for buffer to begin the read operation. + The maximum length to copy into the buffer. + The actual number of bytes read. + + + + + Gets the value of the specified column as a single character. + + + + + + + Gets the value of the specified column as a single character. + + + + + + + Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset. + + + + + + + + + + + Gets the name of the source data type. + + + + + + + Gets the value of the specified column as a object. + + + No conversions are performed; therefore, the data retrieved must already be a DateTime object. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal or column name.The value of the specified column. + + + + Gets the value of the specified column as a object. + + + No conversions are performed; therefore, the data retrieved must already be a DateTime object. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal or column name.The value of the specified column. + + + + Gets the value of the specified column as a object. + + + No conversions are performed; therefore, the data retrieved must already be a DateTime object. + + + Call IsDBNull to check for null values before calling this method. + + + + MySql allows date columns to contain the value '0000-00-00' and datetime + columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain + or represent these values. To read a datetime value from a column that might + contain zero values, use . + + + The behavior of reading a zero datetime column using this method is defined by the + ZeroDateTimeBehavior connection string option. For more information on this option, + please refer to . + + + The column name.The value of the specified column. + + + + Gets the value of the specified column as a object. + + + No conversions are performed; therefore, the data retrieved must already be a DateTime object. + + + Call IsDBNull to check for null values before calling this method. + + + + MySql allows date columns to contain the value '0000-00-00' and datetime + columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain + or represent these values. To read a datetime value from a column that might + contain zero values, use . + + + The behavior of reading a zero datetime column using this method is defined by the + ZeroDateTimeBehavior connection string option. For more information on this option, + please refer to . + + + The zero-based column ordinal.The value of the specified column. + + + + Gets the value of the specified column as a . + + The name of the colum. + The value of the specified column as a . + + + + Gets the value of the specified column as a . + + The index of the colum. + The value of the specified column as a . + + + + Gets the value of the specified column as a object. + + + No conversions are performed; therefore, the data retrieved must already be a Decimal object. + + + Call IsDBNull to check for null values before calling this method. + + The column nameThe value of the specified column. + + + + Gets the value of the specified column as a object. + + + No conversions are performed; therefore, the data retrieved must already be a Decimal object. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinalThe value of the specified column. + + + Gets the value of the specified column as a double-precision floating point number. + + No conversions are performed; therefore, the data retrieved must already be a Double object. + + + Call IsDBNull to check for null values before calling this method. + + The column nameThe value of the specified column. + + + Gets the value of the specified column as a double-precision floating point number. + + No conversions are performed; therefore, the data retrieved must already be a Double object. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal.The value of the specified column. + + + + Gets the Type that is the data type of the object. + + + + + + + Gets the value of the specified column as a single-precision floating point number. + + + No conversions are performed; therefore, the data retrieved must already be a Float object. + + + Call IsDBNull to check for null values before calling this method. + + The column nameThe value of the specified column. + + + + Gets the value of the specified column as a single-precision floating point number. + + + No conversions are performed; therefore, the data retrieved must already be a Float object. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal.The value of the specified column. + + + + Gets the value of the specified column as a globally-unique identifier(GUID). + + The name of the column. + + + + + + + Gets the value of the specified column as a 16-bit signed integer. + + No conversions are performed; threfore, the data retrieved must already be a 16 bit integer value. + + + Call IsDBNull to check for null values before calling this method. + + The column nameThe value of the specified column. + + + Gets the value of the specified column as a 16-bit signed integer. + + No conversions are performed; therefore, the data retrieved must already be a 16 bit integer value. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal.The value of the specified column. + + + Gets the value of the specified column as a 32-bit signed integer. + + No conversions are performed; therefore, the data retrieved must already be a 32 bit integer value. + + + Call IsDBNull to check for null values before calling this method. + + The column name.The value of the specified column. + + + Gets the value of the specified column as a 32-bit signed integer. + + No conversions are performed; therefore, the data retrieved must already be a 32 bit integer value. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal.The value of the specified column. + + + Gets the value of the specified column as a 64-bit signed integer. + + No conversions are performed; therefore, the data retrieved must already be a 64 bit integer value. + + + Call IsDBNull to check for null values before calling this method. + + The column name.The value of the specified column. + + + Gets the value of the specified column as a 64-bit signed integer. + + No conversions are performed; therefore, the data retrieved must already be a 64 bit integer value. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal.The value of the specified column. + + + + Gets the name of the specified column. + + + + + + + Gets the column ordinal, given the name of the column. + + + + + + + Gets the value of the specified column as a object. + + + No conversions are performed; therefore, the data retrieved must already be a String object. + + + Call IsDBNull to check for null values before calling this method. + + The column name.The value of the specified column. + + + + Gets the value of the specified column as a object. + + + No conversions are performed; therefore, the data retrieved must already be a String object. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal.The value of the specified column. + + + + Gets the value of the specified column as a object. + + + No conversions are performed; therefore, the data retrieved must already be a Time value. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal or column name.The value of the specified column. + + + + Gets the value of the specified column as a object. + + + No conversions are performed; therefore, the data retrieved must already be a Time value. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal or column name.The value of the specified column. + + + + Gets the value of the specified column in its native format. + + + + + + + Gets all attribute columns in the collection for the current row. + + + + + + Gets the value of the specified column as a 16-bit unsigned integer. + + No conversions are performed; therefore, the data retrieved must already be a 16 bit unsigned integer value. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal or column name.The value of the specified column. + + + Gets the value of the specified column as a 16-bit unsigned integer. + + No conversions are performed; therefore, the data retrieved must already be a 16 bit unsigned integer value. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal or column name.The value of the specified column. + + + Gets the value of the specified column as a 32-bit unsigned integer. + + No conversions are performed; therefore, the data retrieved must already be a 32 bit unsigned integer value. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal or column name.The value of the specified column. + + + Gets the value of the specified column as a 32-bit unsigned integer. + + No conversions are performed; therefore, the data retrieved must already be a 32 bit unsigned integer value. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal or column name.The value of the specified column. + + + Gets the value of the specified column as a 64-bit unsigned integer. + + No conversions are performed; therefore, the data retrieved must already be a 64 bit unsigned integer value. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal or column name.The value of the specified column. + + + Gets the value of the specified column as a 64-bit unsigned integer. + + No conversions are performed; therefore, the data retrieved must already be a 64 bit unsigned integer value. + + + Call IsDBNull to check for null values before calling this method. + + The zero-based column ordinal or column name.The value of the specified column. + + + + Gets a value indicating whether the column contains non-existent or missing values. + + + + + + + Advances the data reader to the next result, when reading the results of batch SQL statements. + + + + + + Advances the MySqlDataReader to the next record. + + + + + + Gets the value of the specified column as a . + + The index of the colum. + The value of the specified column as a . + + + + Gets the value of the specified column as a . + + The name of the colum. + The value of the specified column as a . + + + + Returns an that iterates through the . + + + + + Returns a DataTable that describes the column metadata of the MySqlDataReader. + + + + + + Summary description for BaseDriver. + + + + + For pooled connections, time when the driver was + put into idle queue + + + + + Loads the properties from the connected server into a hashtable + + + + + + + Loads all the current character set names and ids for this server + into the charSets hashtable + + + + + The exception that is thrown when MySQL returns an error. This class cannot be inherited. + + + + This class is created whenever the MySql Data Provider encounters an error generated from the server. + + + Any open connections are not automatically closed when an exception is thrown. If + the client application determines that the exception is fatal, it should close any open + objects or objects. + + + The following example generates a MySqlException due to a missing server, + and then displays the exception. + + + Public Sub ShowException() + Dim mySelectQuery As String = "SELECT column1 FROM table1" + Dim myConnection As New MySqlConnection ("Data Source=localhost;Database=Sample;") + Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) + + Try + myCommand.Connection.Open() + Catch e As MySqlException + MessageBox.Show( e.Message ) + End Try + End Sub + + + public void ShowException() + { + string mySelectQuery = "SELECT column1 FROM table1"; + MySqlConnection myConnection = + new MySqlConnection("Data Source=localhost;Database=Sample;"); + MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection); + + try + { + myCommand.Connection.Open(); + } + catch (MySqlException e) + { + MessageBox.Show( e.Message ); + } + } + + + + + + Gets a number that identifies the type of error. + + + + + True if this exception was fatal and cause the closing of the connection, false otherwise. + + + + + Gets the SQL state. + + + + + Gets an integer that representes the MySQL error code. + + + + + Summary description for Field. + + + + + We are adding a custom installer class to our assembly so our installer + can make proper changes to the machine.config file. + + + + + We override Install so we can add our assembly to the proper + machine.config files. + + + + + + We override Uninstall so we can remove out assembly from the + machine.config files. + + + + + + Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated MySQL database. This class cannot be inherited. + + + The does not automatically generate the SQL statements required to + reconcile changes made to a DataSet with the associated instance of MySQL. + However, you can create a MySqlCommandBuilder object to automatically generate SQL statements for + single-table updates if you set the SelectCommand property + of the MySqlDataAdapter. Then, any additional SQL statements that you do not set are generated by the + MySqlCommandBuilder. + + + + The MySqlCommandBuilder registers itself as a listener for RowUpdating + events whenever you set the property. You can only associate one + MySqlDataAdapter or MySqlCommandBuilder object with each other at one time. + + + + To generate INSERT, UPDATE, or DELETE statements, the MySqlCommandBuilder uses the + SelectCommand property to retrieve a required set of metadata automatically. If you change + the SelectCommand after the metadata has is retrieved (for example, after the first update), you + should call the method to update the metadata. + + + + The SelectCommand must also return at least one primary key or unique + column. If none are present, an InvalidOperation exception is generated, + and the commands are not generated. + + + + The MySqlCommandBuilder also uses the Connection, + CommandTimeout, and Transaction + properties referenced by the SelectCommand. The user should call + RefreshSchema if any of these properties are modified, or if the + SelectCommand itself is replaced. Otherwise the InsertCommand, + UpdateCommand, and + DeleteCommand properties retain + their previous values. + + + + If you call Dispose, the MySqlCommandBuilder is disassociated + from the MySqlDataAdapter, and the generated commands are no longer used. + + + + Caution must be used when using MySqlCOmmandBuilder on MySql 4.0 systems. With MySql 4.0, + database/schema information is not provided to the connector for a query. This means that + a query that pulls columns from two identically named tables in two or more different databases + will not cause an exception to be thrown but will not work correctly. Even more dangerous + is the situation where your select statement references database X but is executed in + database Y and both databases have tables with similar layouts. This situation can cause + unwanted changes or deletes. + This note does not apply to MySQL versions 4.1 and later. + + + + The following example uses the , along + and , to + select rows from a data source. The example is passed an initialized + , a connection string, a + query string that is a SQL SELECT statement, and a string that is the + name of the database table. The example then creates a MySqlCommandBuilder. + + + Public Shared Function SelectRows(myConnection As String, mySelectQuery As String, myTableName As String) As DataSet + Dim myConn As New MySqlConnection(myConnection) + Dim myDataAdapter As New MySqlDataAdapter() + myDataAdapter.SelectCommand = New MySqlCommand(mySelectQuery, myConn) + Dim cb As SqlCommandBuilder = New MySqlCommandBuilder(myDataAdapter) + + myConn.Open() + + Dim ds As DataSet = New DataSet + myDataAdapter.Fill(ds, myTableName) + + ' Code to modify data in DataSet here + + ' Without the MySqlCommandBuilder this line would fail. + myDataAdapter.Update(ds, myTableName) + + myConn.Close() + End Function 'SelectRows + + + public static DataSet SelectRows(string myConnection, string mySelectQuery, string myTableName) + { + MySqlConnection myConn = new MySqlConnection(myConnection); + MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(); + myDataAdapter.SelectCommand = new MySqlCommand(mySelectQuery, myConn); + MySqlCommandBuilder cb = new MySqlCommandBuilder(myDataAdapter); + + myConn.Open(); + + DataSet ds = new DataSet(); + myDataAdapter.Fill(ds, myTableName); + + //code to modify data in DataSet here + + //Without the MySqlCommandBuilder this line would fail + myDataAdapter.Update(ds, myTableName); + + myConn.Close(); + + return ds; + } + + + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class + with the associated object. + + The to use. + + + The registers itself as a listener for + events that are generated by the + specified in this property. + + + When you create a new instance MySqlCommandBuilder, any existing + MySqlCommandBuilder associated with this MySqlDataAdapter + is released. + + + + + + Gets or sets a object for which SQL statements are automatically generated. + + A object. + + + The registers itself as a listener for + events that are generated by the + specified in this property. + + + When you create a new instance MySqlCommandBuilder, any existing + MySqlCommandBuilder associated with this MySqlDataAdapter + is released. + + + + + + Retrieves parameter information from the stored procedure specified + in the MySqlCommand and populates the Parameters collection of the + specified MySqlCommand object. + This method is not currently supported since stored procedures are + not available in MySql. + + The MySqlCommand referencing the stored + procedure from which the parameter information is to be derived. + The derived parameters are added to the Parameters collection of the + MySqlCommand. + The command text is not + a valid stored procedure name. + + + + Gets the delete command. + + + + + + Gets the update command. + + + + + + Gets the insert command. + + + + + + + + + + + + + Represents a set of data commands and a database connection that are used to fill a dataset and update a MySQL database. This class cannot be inherited. + + + The MySQLDataAdapter, serves as a bridge between a + and MySQL for retrieving and saving data. The MySQLDataAdapter provides this + bridge by mapping , which changes the data in the + DataSet to match the data in the data source, and , + which changes the data in the data source to match the data in the DataSet, + using the appropriate SQL statements against the data source. + + + When the MySQLDataAdapter fills a DataSet, it will create the necessary + tables and columns for the returned data if they do not already exist. However, primary + key information will not be included in the implicitly created schema unless the + property is set to . + You may also have the MySQLDataAdapter create the schema of the DataSet, + including primary key information, before filling it with data using . + + + MySQLDataAdapter is used in conjunction with + and to increase performance when connecting to a MySQL database. + + + The MySQLDataAdapter also includes the , + , , + , and + properties to facilitate the loading and updating of data. + + + When an instance of MySQLDataAdapter is created, the read/write properties + are set to initial values. For a list of these values, see the MySQLDataAdapter + constructor. + + + Please be aware that the class allows only + Int16, Int32, and Int64 to have the AutoIncrement property set. + If you plan to use autoincremement columns with MySQL, you should consider + using signed integer columns. + + + The following example creates a and a . + The MySqlConnection is opened and set as the for the + MySqlCommand. The example then calls , and closes + the connection. To accomplish this, the ExecuteNonQuery is + passed a connection string and a query string that is a SQL INSERT + statement. + + Public Function SelectRows(dataSet As DataSet, connection As String, query As String) As DataSet + Dim conn As New MySqlConnection(connection) + Dim adapter As New MySqlDataAdapter() + adapter.SelectCommand = new MySqlCommand(query, conn) + adapter.Fill(dataset) + Return dataset + End Function + + + public DataSet SelectRows(DataSet dataset,string connection,string query) + { + MySqlConnection conn = new MySqlConnection(connection); + MySqlDataAdapter adapter = new MySqlDataAdapter(); + adapter.SelectCommand = new MySqlCommand(query, conn); + adapter.Fill(dataset); + return dataset; + } + + + + + + Occurs during Update before a command is executed against the data source. The attempt to update is made, so the event fires. + + + + + Occurs during Update after a command is executed against the data source. The attempt to update is made, so the event fires. + + + + + Initializes a new instance of the MySqlDataAdapter class. + + + When an instance of is created, + the following read/write properties are set to the following initial + values. + + + + Properties + Initial Value + + + + + + + MissingMappingAction.Passthrough + + + + + + + + MissingSchemaAction.Add + + + + + You can change the value of any of these properties through a separate call + to the property. + + + The following example creates a and sets some of + its properties. + + Public Sub CreateSqlDataAdapter() + Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _ + "database=test") + Dim da As MySqlDataAdapter = New MySqlDataAdapter + da.MissingSchemaAction = MissingSchemaAction.AddWithKey + + da.SelectCommand = New MySqlCommand("SELECT id, name FROM mytable", conn) + da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ + "VALUES (@id, @name)", conn) + da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ + "WHERE id=@oldId", conn) + da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) + + da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") + da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") + + da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") + da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") + da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original + + da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original + End Sub + + + public static void CreateSqlDataAdapter() + { + MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test"); + MySqlDataAdapter da = new MySqlDataAdapter(); + da.MissingSchemaAction = MissingSchemaAction.AddWithKey; + + da.SelectCommand = new MySqlCommand("SELECT id, name FROM mytable", conn); + da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + + "VALUES (@id, @name)", conn); + da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + + "WHERE id=@oldId", conn); + da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); + + da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); + da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); + + da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); + da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); + da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; + + da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; + } + + + + + + Initializes a new instance of the class with + the specified as the + property. + + that is a SQL SELECT statement or stored procedure and is set + as the property of the . + + + When an instance of is created, + the following read/write properties are set to the following initial + values. + + + + Properties + Initial Value + + + + + + + MissingMappingAction.Passthrough + + + + + + + + MissingSchemaAction.Add + + + + + You can change the value of any of these properties through a separate call + to the property. + + + When SelectCommand (or any of the other command properties) is assigned + to a previously created , the MySqlCommand is not cloned. + The SelectCommand maintains a reference to the previously created MySqlCommand + object. + + + The following example creates a and sets some of + its properties. + + Public Sub CreateSqlDataAdapter() + Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _ + "database=test") + Dim cmd as new MySqlCommand("SELECT id, name FROM mytable", conn) + Dim da As MySqlDataAdapter = New MySqlDataAdapter(cmd) + da.MissingSchemaAction = MissingSchemaAction.AddWithKey + + da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ + "VALUES (@id, @name)", conn) + da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ + "WHERE id=@oldId", conn) + da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) + + da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") + da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") + + da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") + da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") + da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original + + da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original + End Sub + + + public static void CreateSqlDataAdapter() + { + MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test"); + MySqlCommand cmd = new MySqlCommand("SELECT id, name FROM mytable", conn); + MySqlDataAdapter da = new MySqlDataAdapter(cmd); + da.MissingSchemaAction = MissingSchemaAction.AddWithKey; + + da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + + "VALUES (@id, @name)", conn); + da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + + "WHERE id=@oldId", conn); + da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); + + da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); + da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); + + da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); + da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); + da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; + + da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; + } + + + + + + Initializes a new instance of the class with + a and a object. + + A String that is a SQL SELECT statement or stored procedure to be used by + the property of the . + + A that represents the connection. + + + This implementation of the opens and closes a + if it is not already open. This can be useful in a an application that must call the + method for two or more MySqlDataAdapter objects. + If the MySqlConnection is already open, you must explicitly call + or to close it. + + + When an instance of is created, + the following read/write properties are set to the following initial + values. + + + + Properties + Initial Value + + + + + + + MissingMappingAction.Passthrough + + + + + + + + MissingSchemaAction.Add + + + + + You can change the value of any of these properties through a separate call + to the property. + + + The following example creates a and sets some of + its properties. + + Public Sub CreateSqlDataAdapter() + Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _ + "database=test") + Dim da As MySqlDataAdapter = New MySqlDataAdapter("SELECT id, name FROM mytable", conn) + da.MissingSchemaAction = MissingSchemaAction.AddWithKey + + da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ + "VALUES (@id, @name)", conn) + da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ + "WHERE id=@oldId", conn) + da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) + + da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") + da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") + + da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") + da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") + da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original + + da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original + End Sub + + + public static void CreateSqlDataAdapter() + { + MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test"); + MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, name FROM mytable", conn); + da.MissingSchemaAction = MissingSchemaAction.AddWithKey; + + da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + + "VALUES (@id, @name)", conn); + da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + + "WHERE id=@oldId", conn); + da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); + + da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); + da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); + + da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); + da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); + da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; + + da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; + } + + + + + + Initializes a new instance of the class with + a and a connection string. + + A that is a SQL SELECT statement or stored procedure to + be used by the property of the . + The connection string + + When an instance of is created, + the following read/write properties are set to the following initial + values. + + + + Properties + Initial Value + + + + + + + MissingMappingAction.Passthrough + + + + + + + + MissingSchemaAction.Add + + + + + You can change the value of any of these properties through a separate call + to the property. + + + The following example creates a and sets some of + its properties. + + Public Sub CreateSqlDataAdapter() + Dim da As MySqlDataAdapter = New MySqlDataAdapter("SELECT id, name FROM mytable", "Data Source=localhost;database=test") + Dim conn As MySqlConnection = da.SelectCommand.Connection + da.MissingSchemaAction = MissingSchemaAction.AddWithKey + + da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ + "VALUES (@id, @name)", conn) + da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ + "WHERE id=@oldId", conn) + da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) + + da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") + da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") + + da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") + da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") + da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original + + da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original + End Sub + + + public static void CreateSqlDataAdapter() + { + MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, name FROM mytable", "Data Source=localhost;database=test"); + MySqlConnection conn = da.SelectCommand.Connection; + da.MissingSchemaAction = MissingSchemaAction.AddWithKey; + + da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + + "VALUES (@id, @name)", conn); + da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + + "WHERE id=@oldId", conn); + da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); + + da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); + da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); + + da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); + da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); + da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; + + da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; + } + + + + + + Gets or sets a SQL statement or stored procedure used to delete records from the data set. + + A used during to delete records in the + database that correspond to deleted rows in the . + + + During , if this property is not set and primary key information + is present in the , the DeleteCommand can be generated + automatically if you set the property and use the + . Then, any additional commands that you do not set are + generated by the MySqlCommandBuilder. This generation logic requires key column + information to be present in the DataSet. + + + When DeleteCommand is assigned to a previously created , + the MySqlCommand is not cloned. The DeleteCommand maintains a reference + to the previously created MySqlCommand object. + + + The following example creates a and sets the + and DeleteCommand properties. It assumes you have already + created a object. + + Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter + + Dim da As MySqlDataAdapter = New MySqlDataAdapter() + Dim cmd As MySqlCommand + Dim parm As MySqlParameter + + ' Create the SelectCommand. + cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) + + cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) + cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) + + da.SelectCommand = cmd + + ' Create the DeleteCommand. + cmd = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) + + parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") + parm.SourceVersion = DataRowVersion.Original + + da.DeleteCommand = cmd + + Return da + End Function + + + public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) + { + MySqlDataAdapter da = new MySqlDataAdapter(); + MySqlCommand cmd; + MySqlParameter parm; + + // Create the SelectCommand. + cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); + + cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); + cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); + + da.SelectCommand = cmd; + + // Create the DeleteCommand. + cmd = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); + + parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); + parm.SourceVersion = DataRowVersion.Original; + + da.DeleteCommand = cmd; + + return da; + } + + + + + + Gets or sets a SQL statement or stored procedure used to insert records into the data set. + + A used during to insert records into the + database that correspond to new rows in the . + + + During , if this property is not set and primary key information + is present in the , the InsertCommand can be generated + automatically if you set the property and use the + . Then, any additional commands that you do not set are + generated by the MySqlCommandBuilder. This generation logic requires key column + information to be present in the DataSet. + + + When InsertCommand is assigned to a previously created , + the MySqlCommand is not cloned. The InsertCommand maintains a reference + to the previously created MySqlCommand object. + + + If execution of this command returns rows, these rows may be added to the DataSet + depending on how you set the property of the MySqlCommand object. + + + The following example creates a and sets the + and InsertCommand properties. It assumes you have already + created a object. + + Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter + + Dim da As MySqlDataAdapter = New MySqlDataAdapter() + Dim cmd As MySqlCommand + Dim parm As MySqlParameter + + ' Create the SelectCommand. + cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) + + cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) + cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) + + da.SelectCommand = cmd + + ' Create the InsertCommand. + cmd = New MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id, @name)", conn) + + cmd.Parameters.Add( "@id", MySqlDbType.VarChar, 15, "id" ) + cmd.Parameters.Add( "@name", MySqlDbType.VarChar, 15, "name" ) + da.InsertCommand = cmd + + Return da + End Function + + + public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) + { + MySqlDataAdapter da = new MySqlDataAdapter(); + MySqlCommand cmd; + MySqlParameter parm; + + // Create the SelectCommand. + cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); + + cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); + cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); + + da.SelectCommand = cmd; + + // Create the InsertCommand. + cmd = new MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id,@name)", conn); + cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15, "id" ); + cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15, "name" ); + + da.InsertCommand = cmd; + + return da; + } + + + + + + Gets or sets a SQL statement or stored procedure used to select records in the data source. + + A used during to select records from the + database for placement in the . + + + When SelectCommand is assigned to a previously created , + the MySqlCommand is not cloned. The SelectCommand maintains a reference to the + previously created MySqlCommand object. + + + If the SelectCommand does not return any rows, no tables are added to the + , and no exception is raised. + + + The following example creates a and sets the + and InsertCommand properties. It assumes you have already + created a object. + + Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter + + Dim da As MySqlDataAdapter = New MySqlDataAdapter() + Dim cmd As MySqlCommand + Dim parm As MySqlParameter + + ' Create the SelectCommand. + cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) + + cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) + cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) + + da.SelectCommand = cmd + + ' Create the InsertCommand. + cmd = New MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id, @name)", conn) + + cmd.Parameters.Add( "@id", MySqlDbType.VarChar, 15, "id" ) + cmd.Parameters.Add( "@name", MySqlDbType.VarChar, 15, "name" ) + da.InsertCommand = cmd + + Return da + End Function + + + public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) + { + MySqlDataAdapter da = new MySqlDataAdapter(); + MySqlCommand cmd; + MySqlParameter parm; + + // Create the SelectCommand. + cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); + + cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); + cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); + + da.SelectCommand = cmd; + + // Create the InsertCommand. + cmd = new MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id,@name)", conn); + cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15, "id" ); + cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15, "name" ); + + da.InsertCommand = cmd; + + return da; + } + + + + + + Gets or sets a SQL statement or stored procedure used to updated records in the data source. + + A used during to update records in the + database with data from the . + + + During , if this property is not set and primary key information + is present in the , the UpdateCommand can be generated + automatically if you set the property and use the + . Then, any additional commands that you do not set are + generated by the MySqlCommandBuilder. This generation logic requires key column + information to be present in the DataSet. + + + When UpdateCommand is assigned to a previously created , + the MySqlCommand is not cloned. The UpdateCommand maintains a reference + to the previously created MySqlCommand object. + + + If execution of this command returns rows, these rows may be merged with the DataSet + depending on how you set the property of the MySqlCommand object. + + + The following example creates a and sets the + and UpdateCommand properties. It assumes you have already + created a object. + + Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter + + Dim da As MySqlDataAdapter = New MySqlDataAdapter() + Dim cmd As MySqlCommand + Dim parm As MySqlParameter + + ' Create the SelectCommand. + cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) + + cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) + cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) + + da.SelectCommand = cmd + + ' Create the UpdateCommand. + cmd = New MySqlCommand("UPDATE mytable SET id=@id, name=@name WHERE id=@oldId", conn) + + cmd.Parameters.Add( "@id", MySqlDbType.VarChar, 15, "id" ) + cmd.Parameters.Add( "@name", MySqlDbType.VarChar, 15, "name" ) + + parm = cmd.Parameters.Add("@oldId", MySqlDbType.VarChar, 15, "id") + parm.SourceVersion = DataRowVersion.Original + + da.UpdateCommand = cmd + + Return da + End Function + + + public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) + { + MySqlDataAdapter da = new MySqlDataAdapter(); + MySqlCommand cmd; + MySqlParameter parm; + + // Create the SelectCommand. + cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); + + cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); + cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); + + da.SelectCommand = cmd; + + // Create the UpdateCommand. + cmd = new MySqlCommand("UPDATE mytable SET id=@id, name=@name WHERE id=@oldId", conn); + cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15, "id" ); + cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15, "name" ); + + parm = cmd.Parameters.Add( "@oldId", MySqlDbType.VarChar, 15, "id" ); + parm.SourceVersion = DataRowVersion.Original; + + da.UpdateCommand = cmd; + + return da; + } + + + + + + Open connection if it was closed. + Necessary to workaround "connection must be open and valid" error + with batched updates. + + Row state + list of opened connections + If connection is opened by this function, the list is updated + + true if connection was opened + + + + Overridden. See . + + + + + + + + + + Overridden. See . + + + + + + + + + + Overridden. Raises the RowUpdating event. + + A MySqlRowUpdatingEventArgs that contains the event data. + + + + Overridden. Raises the RowUpdated event. + + A MySqlRowUpdatedEventArgs that contains the event data. + + + + Asynchronous version of the Fill method. + + The to fill records with. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill records with. + The cancellation token. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The name of the to use for table mapping. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The name of the to use for table mapping. + The cancellation token. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill with records. + The name of the source table to use for table mapping. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill with records. + The name of the source table to use for table mapping. + The cancellation token. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill with records. + An instance of . + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill with records. + An instance of . + The cancellation token. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill with records. + The SQL SELECT statement used to retrieve rows from the data source. + One of the values. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill with records. + The SQL SELECT statement used to retrieve rows from the data source. + One of the values. + The cancellation token. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The start record. + The max number of affected records. + The s to fill with records. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The start record. + The max number of affected records. + The cancellation token. + The s to fill with records. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill with records. + The start record. + The max number of affected records. + The name of the source table to use for table mapping. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill with records. + The start record. + The max number of affected records. + The name of the source table to use for table mapping. + The cancellation token. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill with records. + The name of the source table to use for table mapping. + An instance of . + The start record. + The max number of affected records. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill with records. + The name of the source table to use for table mapping. + An instance of . + The start record. + The max number of affected records. + The cancellation token. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The s to fill with records. + The start record. + The max number of affected records. + The SQL SELECT statement used to retrieve rows from the data source. + One of the values. + The number of rows successfully added to or refreshed in the s. + + + + Asynchronous version of the Fill method. + + The s to fill with records. + The start record. + The max number of affected records. + The SQL SELECT statement used to retrieve rows from the data source. + One of the values. + The cancellation token. + The number of rows successfully added to or refreshed in the s. + + + + Asynchronous version of the Fill method. + + The to fill with records. + The start record. + The max number of affected records. + The name of the source table to use for table mapping. + The SQL SELECT statement used to retrieve rows from the data source. + One of the values. + The number of rows successfully added to or refreshed in the . + + + + Asynchronous version of the Fill method. + + The to fill with records. + The start record. + The max number of affected records. + The name of the source table to use for table mapping. + The SQL SELECT statement used to retrieve rows from the data source. + One of the values. + The cancellation token. + The number of rows successfully added to or refreshed in the . + + + + Async version of FillSchema + + DataSet to use + Schema Type + DataTable[] + + + + Async version of FillSchema + + DataSet to use + Schema Type + Source Table + DataTable[] + + + + Async version of FillSchema + + DataSet to use + Schema Type + Source Table + DataReader to use + DataTable[] + + + + Async version of FillSchema + + DataSet to use + Schema Type + DBCommand to use + Source Table + Command Behavior + DataTable[] + + + + Async version of FillSchema + + DataTable to use + Schema Type + DataTable + + + + Async version of FillSchema + + DataTable to use + Schema Type + DataReader to use + DataTable + + + + Async version of FillSchema + + DataTable to use + Schema Type + DBCommand to use + Command Behavior + DataTable + + + + Async version of Update + + DataRow[] to use + int + + + + Async version of Update + + DataSet to use + int + + + + Async version of Update + + DataTable to use + int + + + + Async version of Update + + DataRow[] to use + Data Table Mapping + int + + + + Async version of Update + + DataSet to use + Source Table + + + + + Represents the method that will handle the event of a . + + + + + Represents the method that will handle the event of a . + + + + + Provides data for the RowUpdating event. This class cannot be inherited. + + + + + Initializes a new instance of the MySqlRowUpdatingEventArgs class. + + The to + . + The to execute during . + One of the values that specifies the type of query executed. + The sent through an . + + + + Gets or sets the MySqlCommand to execute when performing the Update. + + + + + Provides data for the RowUpdated event. This class cannot be inherited. + + + + + Initializes a new instance of the MySqlRowUpdatedEventArgs class. + + The sent through an . + The executed when is called. + One of the values that specifies the type of query executed. + The sent through an . + + + + Gets or sets the MySqlCommand executed when Update is called. + + + + + Enables the provider to help ensure that a user has a security level adequate for accessing data. + + + + + Adds a new connection string with set of restricted keywords to the MySqlClientPermission object + + Settings to be used for the connection + Keywords to define the restrictions + KeyRestrictionBehavior to be used + + + + Returns MySqlClientPermission as an IPermission + + + + + + Associates a security action with a custom security attribute. + + + + + Represents a section within a configuration file. + + + + + Gets the MySQL configuations associated to the current configuration. + + + + + Gets a collection of the exception interceptors available in the current configuration. + + + + + Gets a collection of the command interceptors available in the current configuration. + + + + + Gets a collection of the authentication plugins available in the current configuration. + + + + + Gets or sets the replication configurations. + + + + + Defines the configurations allowed for an authentication plugin. + + + + + Gets or sets the name of the authentication plugin. + + + + + Gets or sets the type of the authentication plugin. + + + + + Defines the configurations allowed for an interceptor. + + + + + Gets or sets the name of the interceptor. + + + + + Gets or sets the type of the interceptor. + + + + + Represents a generic configuration element. + + + + + + Gets an enumerator that iterates through the returned list. + + An enumerator that iterates through the returned list. + + + + Helper class that makes it easier to work with the provider. + + + + + Asynchronous version of ExecuteDataRow. + + The settings to be used for the connection. + The command to execute. + The parameters to use for the command. + The DataRow containing the first row of the resultset. + + + + Asynchronous version of ExecuteDataRow. + + The settings to be used for the connection. + The command to execute. + The cancellation token. + The parameters to use for the command. + The DataRow containing the first row of the resultset. + + + + Executes a single SQL command and returns the first row of the resultset. A new MySqlConnection object + is created, opened, and closed during this method. + + Settings to be used for the connection + Command to execute + Parameters to use for the command + DataRow containing the first row of the resultset + + + + Executes a single SQL command and returns the resultset in a . + A new MySqlConnection object is created, opened, and closed during this method. + + Settings to be used for the connection + Command to execute + containing the resultset + + + + Executes a single SQL command and returns the resultset in a . + A new MySqlConnection object is created, opened, and closed during this method. + + Settings to be used for the connection + Command to execute + Parameters to use for the command + containing the resultset + + + + Executes a single SQL command and returns the resultset in a . + The state of the object remains unchanged after execution + of this method. + + object to use + Command to execute + containing the resultset + + + + Executes a single SQL command and returns the resultset in a . + The state of the object remains unchanged after execution + of this method. + + object to use + Command to execute + Parameters to use for the command + containing the resultset + + + + Updates the given table with data from the given + + Settings to use for the update + Command text to use for the update + containing the new data to use in the update + Tablename in the dataset to update + + + + Async version of ExecuteDataset + + Settings to be used for the connection + Command to execute + containing the resultset + + + + Async version of ExecuteDataset + + Settings to be used for the connection + Command to execute + Parameters to use for the command + containing the resultset + + + + Async version of ExecuteDataset + + object to use + Command to execute + containing the resultset + + + + Async version of ExecuteDataset + + object to use + Command to execute + Parameters to use for the command + containing the resultset + + + + Async version of UpdateDataset + + Settings to use for the update + Command text to use for the update + containing the new data to use in the update + Tablename in the dataset to update + + + + Executes a single command against a MySQL database. The is assumed to be + open when the method is called and remains open after the method completes. + + The object to use + The SQL command to be executed. + An array of objects to use with the command. + The number of affected records. + + + + Executes a single command against a MySQL database. + + to use. + The SQL command to be executed. + An rray of objects to use with the command. + The number of affected records. + A new is created using the given. + + + + Executes a single command against a MySQL database, possibly inside an existing transaction. + + object to use for the command + object to use for the command + Command text to use + Array of objects to use with the command + True if the connection should be preserved, false if not + object ready to read the results of the command + + + + Executes a single command against a MySQL database. + + Settings to use for this command + Command text to use + object ready to read the results of the command + + + + Executes a single command against a MySQL database. + + object to use for the command + Command text to use + object ready to read the results of the command + + + + Executes a single command against a MySQL database. + + Settings to use for this command + Command text to use + Array of objects to use with the command + object ready to read the results of the command + + + + Executes a single command against a MySQL database. + + Connection to use for the command + Command text to use + Array of objects to use with the command + object ready to read the results of the command + + + + Execute a single command against a MySQL database. + + Settings to use for the update + Command text to use for the update + The first column of the first row in the result set, or a null reference if the result set is empty. + + + + Execute a single command against a MySQL database. + + Settings to use for the command + Command text to use for the command + Parameters to use for the command + The first column of the first row in the result set, or a null reference if the result set is empty. + + + + Execute a single command against a MySQL database. + + object to use + Command text to use for the command + The first column of the first row in the result set, or a null reference if the result set is empty. + + + + Execute a single command against a MySQL database. + + object to use + Command text to use for the command + Parameters to use for the command + The first column of the first row in the result set, or a null reference if the result set is empty. + + + + Escapes the string. + + The string to escape. + The string with all quotes escaped. + + + + Replaces quotes with double quotes. + + The string to modidify. + A string containing double quotes instead of single quotes. + + + + Async version of ExecuteNonQuery + + object to use + SQL command to be executed + Array of objects to use with the command. + Rows affected + + + + Asynchronous version of the ExecuteNonQuery method. + + to use. + The SQL command to be executed. + An array of objects to use with the command. + The number of rows affected. + + + + Asynchronous version of the ExecuteNonQuery method. + + to use. + The SQL command to be executed. + The cancellation token. + An array of objects to use with the command. + The number of rows affected. + + + + Async version of ExecuteReader + + object to use for the command + object to use for the command + Command text to use + Array of objects to use with the command + True if the connection should be preserved, false if not + object ready to read the results of the command + + + + Async version of ExecuteReader + + Settings to use for this command + Command text to use + object ready to read the results of the command + + + + Async version of ExecuteReader + + object to use for the command + Command text to use + object ready to read the results of the command + + + + Async version of ExecuteReader + + Settings to use for this command + Command text to use + Array of objects to use with the command + object ready to read the results of the command + + + + Async version of ExecuteReader + + Connection to use for the command + Command text to use + Array of objects to use with the command + object ready to read the results of the command + + + + Async version of ExecuteScalar + + Settings to use for the update + Command text to use for the update + The first column of the first row in the result set, or a null reference if the result set is empty. + + + + Async version of ExecuteScalar + + Settings to use for the command + Command text to use for the command + Parameters to use for the command + The first column of the first row in the result set, or a null reference if the result set is empty. + + + + Async version of ExecuteScalar + + object to use + Command text to use for the command + The first column of the first row in the result set, or a null reference if the result set is empty. + + + + Async version of ExecuteScalar + + object to use + Command text to use for the command + Parameters to use for the command + The first column of the first row in the result set, or a null reference if the result set is empty. + + + + Represents a parameter to a , This class cannot be inherited. + + + + + Gets or sets the to use when loading . + + + + + CLoses this object. + + An object that is a clone of this object. + + + + Initializes a new instance of the class with the parameter name, the , the size, and the source column name. + + The name of the parameter to map. + One of the values. + The length of the parameter. + The name of the source column. + + + + Initializes a new instance of the class with the parameter name and a value of the new MySqlParameter. + + The name of the parameter to map. + An that is the value of the . + + + + Initializes a new instance of the class with the parameter name and the data type. + + The name of the parameter to map. + One of the values. + + + + Initializes a new instance of the class with the parameter name, the , and the size. + + The name of the parameter to map. + One of the values. + The length of the parameter. + + + + Initializes a new instance of the class with the parameter name, the type of the parameter, the size of the parameter, a , the precision of the parameter, the scale of the parameter, the source column, a to use, and the value of the parameter. + + The name of the parameter to map. + One of the values. + The length of the parameter. + One of the values. + true if the value of the field can be null, otherwise false. + The total number of digits to the left and right of the decimal point to which is resolved. + The total number of decimal places to which is resolved. + The name of the source column. + One of the values. + An that is the value of the . + + + + + Gets or sets a value indicating whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter. + As of MySql version 4.1 and earlier, input-only is the only valid choice. + + + + + Gets or sets a value indicating whether the parameter accepts null values. + + + + + Gets or sets the of the parameter. + + + + + Gets or sets the maximum number of digits used to represent the property. + + + + + Gets or sets the number of decimal places to which is resolved. + + + + + Gets or sets the maximum size, in bytes, of the data within the column. + + + + + Gets or sets the value of the parameter. + + + + + Returns the possible values for this parameter if this parameter is of type + SET or ENUM. Returns null otherwise. + + + + + Gets or sets the name of the source column that is mapped to the and used for loading or returning the . + + + + + Sets or gets a value which indicates whether the source column is nullable. + This allows to correctly generate Update statements + for nullable columns. + + + + + Gets or sets the of the parameter. + + + + + Overridden. Gets a string containing the . + + + + + + Resets the DbType property to its original settings. + + + + + Represents a collection of parameters relevant to a as well as their respective mappings to columns in a . This class cannot be inherited. + + + The number of the parameters in the collection must be equal to the number of + parameter placeholders within the command text, or an exception will be generated. + + The following example creates multiple instances of + through the MySqlParameterCollection collection within the . + These parameters are used to select data within the data source and place the data in + the . This code assumes that a DataSet and a MySqlDataAdapter + have already been created with the appropriate schema, commands, and connection. + + Public Sub AddParameters() + ' ... + ' create myDataSet and myDataAdapter + ' ... + myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters" + myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239 + + myDataAdapter.Fill(myDataSet) + End Sub 'AddSqlParameters + + + public void AddSqlParameters() + { + // ... + // create myDataSet and myDataAdapter + // ... + + myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters"; + myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239; + myDataAdapter.Fill(myDataSet); + + } + + + + + + Gets a value that indicates whether the + has a fixed size. + + + + + Gets a value that indicates whether the + is read-only. + + + + + Gets a value that indicates whether the + is synchronized. + + + + + Gets the number of MySqlParameter objects in the collection. + + + + + Gets the at the specified index. + + Gets the with a specified attribute. + [C#] In C#, this property is the indexer for the class. + + + + + Gets the with the specified name. + + + + + Adds a to the with the parameter name, the data type, the column length, and the source column name. + + The name of the parameter. + One of the values. + The length of the column. + The name of the source column. + The newly added object. + + + + Adds the specified object to the . + + The to add to the collection. + The newly added object. + + + + Adds a parameter and its value. + + The name of the parameter. + The value of the parameter. + A object representing the provided values. + + + + Adds a to the given the parameter name and the data type. + + The name of the parameter. + One of the values. + The newly added object. + + + + Adds a to the with the parameter name, the data type, and the column length. + + The name of the parameter. + One of the values. + The length of the column. + The newly added object. + + + + Removes all items from the collection. + + + + + Gets the location of the in the collection with a specific parameter name. + + The name of the object to retrieve. + The zero-based location of the in the collection. + + + + Gets the location of a in the collection. + + The object to locate. + The zero-based location of the in the collection. + Gets the location of a in the collection. + + + + This method will update all the items in the index hashes when + we insert a parameter somewhere in the middle + + + + + + + Adds an array of values to the end of the . + + + + + + Retrieve the parameter with the given name. + + + + + + + Adds the specified object to the . + + The to add to the collection. + The index of the new object. + + + + Gets a value indicating whether a with the specified parameter name exists in the collection. + + The name of the object to find. + true if the collection contains the parameter; otherwise, false. + + + + Gets a value indicating whether a MySqlParameter exists in the collection. + + The value of the object to find. + true if the collection contains the object; otherwise, false. + Gets a value indicating whether a exists in the collection. + + + + Copies MySqlParameter objects from the MySqlParameterCollection to the specified array. + + + + + + + Returns an enumerator that iterates through the . + + + + + + Inserts a MySqlParameter into the collection at the specified index. + + + + + + + Removes the specified MySqlParameter from the collection. + + + + + + Removes the specified from the collection using the parameter name. + + The name of the object to retrieve. + + + + Removes the specified from the collection using a specific index. + + The zero-based index of the parameter. + Removes the specified from the collection. + + + + Gets an object that can be used to synchronize access to the + . + + + + + Represents a single(not nested) TransactionScope + + + + + Defines security permissions assigned to a MySQL object. + + + + + Creates a set of permissions. + + A flag indicating if the reflection permission should be included. + A object representing a collection of permissions. + + + + BaseCommandInterceptor is the base class that should be used for all userland + command interceptors + + + + + Gets the active connection. + + + + + Executes an SQL statements that returns a scalar value such as a calculation. + + The SQL statement to execute. + A scalar value that represents the result returned by the execution of the SQL statement. + false. + This method is intended to be overriden. + + + + Executes an SQL statement that returns the number of affected rows. + + The SQL statement to execute. + The number of affected rows. + false. + This method is intended to be overriden. + + + + Executes an SQL statement that will return a resultset. + + The SQL statement to execute. + A value that describes the results of the query and its effect on the database. + A object containing the result of the statement execution. + false. + This method is intended to be overriden. + + + + Sets the active connection. + + The active connection. + + + + CommandInterceptor is the "manager" class that keeps the list of registered interceptors + for the given connection. + + + + + BaseExceptionInterceptor is the base class that should be used for all userland + exception interceptors. + + + + + Returns the received exception. + + The exception to be returned. + The exception originally received. + + + + Gets the active connection. + + + + + Initilizes this object by setting the active connection. + + The connection to become active. + + + + StandardExceptionInterceptor is the standard interceptor that simply returns the exception. + It is the default action. + + + + + Returns the received exception, which is the default action + + The exception to be returned. + The exception originally received. + + + + ExceptionInterceptor is the "manager" class that keeps the list of registered interceptors + for the given connection. + + + + + Interceptor is the base class for the "manager" classes such as ExceptionInterceptor, + CommandInterceptor, etc + + + + + Return schema information about procedures and functions + Restrictions supported are: + schema, name, type + + + + + + + Return schema information about parameters for procedures and functions + Restrictions supported are: + schema, name, type, parameter name + + + + + Initializes a new row for the procedure parameters table. + + + + + Parses out the elements of a procedure parameter data type. + + + + + Implementation of memcached binary client protocol. + + According to http://code.google.com/p/memcached/wiki/BinaryProtocolRevamped + + + + Sends an store command (add, replace, set). + + + + + + + + + + + Sends a get command. + + + + + + + + + Sends a delete command. + + + + + + + + Sends a command without args (like flush). + + + + + + + + Sends a command with amount (INCR/DECR) + + + + + + + + + Encodes in the binary protocol the a command of the kind set, add or replace. + + + + + + + If true applies to set, add or replace commands; if false applies to append and prepend commands. + + + + + An interface of the client memcached protocol. This class is abstract for + implementation of the Memcached client interface see for the + text protocol version and for the binary protocol version. + + + + + The port used by the connection. + + + + + The server DNS or IP address used by the connection. + + + + + The network stream used by the connecition. + + + + + Factory method for creating instances of that implement a connection with the requested features. + The connection object returned must be explicitely opened see method . + + The Memcached server DNS or IP address. + The port for the Memcached server + A set of flags indicating characterestics requested. + An instance of a client connection ready to be used. + + + + Opens the client connection. + + + + + Closes the client connection. + + + + + Adds a new key/value pair with the given TimeSpan expiration. + + The key for identifying the entry. + The data to associate with the key. + The interval of timespan, use TimeSpan.Zero for no expiration. + + + + Appens the data to the existing data for the associated key. + + The key for identifying the entry. + The data to append with the data associated with the key. + + + + Executes the Check-and-set Memcached operation. + + The key for identifying the entry. + The data to use in the CAS. + The interval of timespan, use TimeSpan.Zero for no expiration. + The CAS unique value to use. + + + + + Decrements the value associated with a key by the given amount. + + The key associated with the value to decrement. + The amount to decrement the value. + + + + Removes they pair key/value given the specified key. + + + + + + Removes all entries from the storage, effectively invalidating the whole cache. + + The interval after which the cache will be cleaned. Can be TimeSpan.Zero for immediately. + + + + Get the key/value pair associated with a given key. + + The key for which to returm the key/value. + The key/value associated with the key or a MemcachedException if it does not exists. + + + + Increments the value associated with a key by the given amount. + + The key associated with the value to increment. + The amount to increment the value. + + + + Prepends the data to the existing data for the associated key. + + The key for identifying the entry. + The data to append with the data associated with the key. + + + + Replaces the value associated with the given key with another value. + + The key for identifying the entry. + The data to replace the value associated with the key. + The interval of timespan, use TimeSpan.Zero for no expiration. + + + + Set the value of a given key. + + The key for identifying the entry. + The data to associate with the given key. + The interval of timespan, use TimeSpan.Zero for no expiration. + + + + A set of flags for requesting new instances of connections + + + + + Requests a connection implememting the text protocol. + + + + + Requests a connection implementing the binary protocol. + + + + + Requests a TCP connection. Currently UDP is not supported. + + + + + The base exception class for all Memcached exceptions. + + + + + Implementation of the Memcached text client protocol. + + + + + Sends a command to the memcached server. + + + + + + + This version is for commands that take a key, data, expiration and casUnique. + + + + Sends a command to the memcached server. + + + + + + This version is for commands that take a key, data and expiration + + + + Send a command to memcached server. + + + + + This version is for commands that don't need flags neither expiration fields. + + + + Sends a command to the server. + + + + This version is for commands that only require a key + + + + Sends a command to the server. + + + + + This version is for commands that only require a key and an integer value. + + + + Sends a command to the server. + + + + This version is for commands that only require a key and expiration. + + + + Abstract class that provides common functionality for connection options that apply for all protocols. + + + + + Readonly field containing a collection of protocol shared connection options. + + + + + Gets or sets a flag indicating if the object has access to procedures. + + + + + Gets or sets a dictionary representing key-value pairs for each connection option. + + + + + Gets or sets the name of the server. + + The server. + + + + Gets or sets the name of the database for the initial connection. + + + + + Gets or sets the protocol that should be used for communicating + with MySQL. + + + + + Gets or sets the port number that is used when the socket + protocol is being used. + + + + + Gets or sets a boolean value that indicates whether this connection + should resolve DNS SRV records. + + + + + Gets or sets the user ID that should be used to connect with. + + + + + Gets or sets the password that should be used to make a connection. + + + + + Gets or sets the path to the certificate file to be used. + + + + + Gets or sets the password to be used in conjunction with the certificate file. + + + + + Gets or sets the location to a personal store where a certificate is held. + + + + + Gets or sets a certificate thumbprint to ensure correct identification of a certificate contained within a personal store. + + + + + Indicates whether to use SSL connections and how to handle server certificate errors. + + + + + Sets the TLS versions to use in a SSL connection to the server. + + + Tls version=TLSv1.1,TLSv1.2; + + + + + Gets or sets the path to a local key file in PEM format to use for establishing an encrypted connection. + + + + + Gets or sets the path to a local certificate file in PEM format to use for establishing an encrypted connection. + + + + + Gets or sets the name of the SSH server. + + + + + Gets or sets the port number to use when authenticating to the SSH server. + + + + + Gets or sets the user name to authenticate to the SSH server. + + + + + Gets or sets the password to authenticate to the SSH server. + + + + + Gets or sets the SSH key file to authenticate to the SSH server. + + + + + Gets or sets the passphrase of the key file to authenticate to the SSH server. + + + + + Gets or sets the idle connection time(seconds) for TCP connections. + + + + + Gets or sets the character set that should be used for sending queries to the server. + + + + + Analyzes the connection string for potential duplicated or invalid connection options. + + Connection string. + Flag that indicates if the connection is using X Protocol. + Flag that indicates if the default port is used. + + + + Represents a set of methods for creating instances of the MySQL client implementation of the data source classes. + + + + + Gets an instance of the . + This can be used to retrieve strongly typed data objects. + + + + + Returns a strongly typed instance. + + A new strongly typed instance of DbCommand. + + + + Returns a strongly typed instance. + + A new strongly typed instance of DbConnection. + + + + Returns a strongly typed instance. + + A new strongly typed instance of DbParameter. + + + + Returns a strongly typed instance. + + A new strongly typed instance of DbConnectionStringBuilder. + + + + Returns a strongly typed instance. + + A new strongly typed instance of DbCommandBuilder. + + + + Returns a strongly typed instance. + + A new strongly typed instance of DbDataAdapter. + + + + Provide a simple caching layer + + + + + Aids in the creation of connection strings by exposing the connection options as properties. + Contains connection options specific to the Classic protocol. + + + + + Main constructor. + + + + + Constructor accepting a connection string. + + The connection string. + + + + Readonly field containing a collection of classic protocol and protocol shared connection options. + + + + + Gets or sets the name of the named pipe that should be used + for communicating with MySQL. + + + + + Gets or sets a boolean value that indicates whether this connection + should use compression. + + + + + Gets or sets a boolean value that indicates whether this connection will allow + commands to send multiple SQL statements in one execution. + + + + + Gets or sets a boolean value that indicates whether logging is enabled. + + + + + Gets or sets the base name of the shared memory objects used to + communicate with MySQL when the shared memory protocol is being used. + + + + + Gets or sets the default command timeout. + + + + + Gets or sets the connection timeout. + + + + + Gets or sets a boolean value that indicates whether this connection will allow + to load data local infile. + + + + + Gets or sets a boolean value that indicates if the password should be persisted + in the connection string. + + + + + Gets or sets a boolean value that indicates if the connection should be encrypted. + + Obsolte. Use instead. + + + + Gets or sets a boolean value that indicates if RSA public keys should be retrieved from the server. + + This option is only relevant when SSL is disabled. Setting this option to true in + 8.0 servers that have the caching_sha2_password authentication plugin as the default plugin will + cause the connection attempt to fail if the user hasn't successfully connected to the server on a + previous occasion. + + + + Gets or sets a boolean value that indicates if zero date time values are supported. + + Default value is false. + + + + Gets or sets a boolean value that indicates if zero datetime values should be + converted to DateTime.MinValue. + + Default value is false. + + + + Gets or sets a boolean value that indicates if the Usage Advisor should be enabled. + + Default value is false. + + + + Gets or sets the size of the stored procedure cache. + + Default value is 25. + + + + Gets or sets a boolean value that indicates if the performance monitor hooks should be enabled. + + Default value is false. + + + + Gets or sets a boolean value that indicates if calls to the Prepare method should be ignored. + + Default value is false. + + + + Gets or sets a boolean value that indicates if an opened connection should particiapte in the current scope. + + Default value is true. + + + + Gets or sets a boolean value that indicates if security asserts must be included. + + Must be set to true when using the class in a partial trust environment, + with the library installed in the GAC of the hosting environment. Not supported in .NET Core. + Default value is false. + + + + Gets or sets a boolean value that indicates if column binary flags set by the server are ignored. + + Default value is true. + + + + Gets or sets a boolean value that indicates if TINYINT(1) shound be treated as a BOOLEAN. + + Default value is true. + + + + Gets or sets a boolean value that indicates if the provider expects user variables in the SQL. + + Default value is false. + + + + Gets or sets a boolean value that indicates if the session should be interactive. + + Default value is false. + + + + Gets or sets a boolean value that indicates if server functions should be treated as returning a string. + + Default value is false. + + + + Gets or sets a boolean value that indicates if the server should report affected rows instead of found rows. + + Default value is false. + + + + Gets or sets a boolean value that indicates if items of data type BINARY(16) should be treated as guids. + + Default value is false. + + + + Gets or sets a boolean value that indicates if SQL Server syntax should be allowed by supporting square brackets + around symbols instead of backticks. + + Default value is false. + + + + Gets or sets a boolean value that indicates if caching of TableDirect commands is enabled. + + Default value is false. + + + + Gets or sets the seconds for how long a TableDirect result should be cached. + + Default value is 0. + + + + Gets or sets a boolean value that indicates if stored routine parameters should be checked against the server. + + Default value is true. + + + + Gets or sets a boolean value that indicates if this connection will use replication. + + Default value is false. + + + + Gets or sets the list of interceptors that can triage thrown MySqlExceptions. + + + + + Gets or sets the list of interceptors that can intercept command operations. + + + + + Gets or sets the lifetime of a pooled connection. + + Default value is 0. + + + + Gets or sets a boolean value indicating if connection pooling is enabled. + + Default value is true. + + + + Gets the minimum connection pool size. + + Default value is 0. + + + + Gets or sets the maximum connection pool setting. + + Default value is 100. + + + + Gets or sets a boolean value that indicates if the connection should be reset when retrieved + from the pool. + + Default value is false. + + + + Gets or sets a boolean value that indicates whether the server variable settings are updated by a + SHOW VARIABLES command each time a pooled connection is returned. + + Default value is false. + + + + Indicates whether the driver should treat binary BLOBs as UTF8. + + Default value is false. + + + + Gets or sets the pattern to match for the columns that should be treated as UTF8. + + + + + Gets or sets the pattern to match for the columns that should not be treated as UTF8. + + + + + Gets or sets a connection option. + + The keyword that identifies the connection option to modify. + + + + Summary description for ClientParam. + + + + + DB Operations Code + + + + + Specifies MySQL specific data type of a field, property, for use in a . + + + + + + A fixed precision and scale numeric value between -1038 + -1 and 10 38 -1. + + + + + The signed range is -128 to 127. The unsigned + range is 0 to 255. + + + + + A 16-bit signed integer. The signed range is + -32768 to 32767. The unsigned range is 0 to 65535 + + + + + Specifies a 24 (3 byte) signed or unsigned value. + + + + + A 32-bit signed integer + + + + + A 64-bit signed integer. + + + + + A small (single-precision) floating-point + number. Allowable values are -3.402823466E+38 to -1.175494351E-38, + 0, and 1.175494351E-38 to 3.402823466E+38. + + + + + A normal-size (double-precision) + floating-point number. Allowable values are -1.7976931348623157E+308 + to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to + 1.7976931348623157E+308. + + + + + A timestamp. The range is '1970-01-01 00:00:00' to sometime in the + year 2037 + + + + + Date The supported range is '1000-01-01' to '9999-12-31'. + + + + + Time The range is '-838:59:59' to '838:59:59'. + + + + + DateTime The supported range is '1000-01-01 00:00:00' to + '9999-12-31 23:59:59'. + + + + + Datetime The supported range is '1000-01-01 00:00:00' to + '9999-12-31 23:59:59'. + + + + + A year in 2- or 4-digit format (default is 4-digit). The + allowable values are 1901 to 2155, 0000 in the 4-digit year + format, and 1970-2069 if you use the 2-digit format (70-69). + + + + + Obsolete Use Datetime or Date type + + + + + A variable-length string containing 0 to 65535 characters + + + + + Bit-field data type + + + + + JSON + + + + + New Decimal + + + + + An enumeration. A string object that can have only one value, + chosen from the list of values 'value1', 'value2', ..., NULL + or the special "" error value. An ENUM can have a maximum of + 65535 distinct values + + + + + A set. A string object that can have zero or more values, each + of which must be chosen from the list of values 'value1', 'value2', + ... A SET can have a maximum of 64 members. + + + + + A binary column with a maximum length of 255 (2^8 - 1) + characters + + + + + A binary column with a maximum length of 16777215 (2^24 - 1) bytes. + + + + + A binary column with a maximum length of 4294967295 or + 4G (2^32 - 1) bytes. + + + + + A binary column with a maximum length of 65535 (2^16 - 1) bytes. + + + + + A variable-length string containing 0 to 255 bytes. + + + + + A fixed-length string. + + + + + Geometric (GIS) data type. + + + + + Unsigned 8-bit value. + + + + + Unsigned 16-bit value. + + + + + Unsigned 24-bit value. + + + + + Unsigned 32-bit value. + + + + + Unsigned 64-bit value. + + + + + Fixed length binary string. + + + + + Variable length binary string. + + + + + A text column with a maximum length of 255 (2^8 - 1) characters. + + + + + A text column with a maximum length of 16777215 (2^24 - 1) characters. + + + + + A text column with a maximum length of 4294967295 or + 4G (2^32 - 1) characters. + + + + + A text column with a maximum length of 65535 (2^16 - 1) characters. + + + + + A guid column. + + + + + Allows the user to specify the type of connection that should + be used. + + + + + TCP/IP style connection. Works everywhere. + + + + + TCP/IP style connection. Works everywhere. + + + + + TCP/IP style connection. Works everywhere. + + + + + Named pipe connection. Works only on Windows systems. + + + + + Named pipe connection. Works only on Windows systems. + + + + + Unix domain socket connection. Works only with Unix systems. + + + + + Unix domain socket connection. Works only with Unix systems. + + + + + Shared memory connection. Currently works only with Windows systems. + + + + + Shared memory connection. Currently works only with Windows systems. + + + + + SSL options for connection. + + + + + Do not use SSL. + + + + + Use SSL, if server supports it. This option is only available for the classic protocol. + + + + + Always use SSL. Deny connection if server does not support SSL. + Do not perform server certificate validation. + This is the default SSL mode when the same isn't specified as part of the connection string. + + + + + Always use SSL. Validate server SSL certificate, but different host name mismatch. + + + + + Always use SSL and perform full certificate validation. + + + + + Specifies the connection types supported + + + + + Use TCP/IP sockets. + + + + + Use client library. + + + + + Use MySQL embedded server. + + + + + Defines the location of the certificate store. + + + + + Do not use certificate store. + + + + + Use certificate store for the current user. + + + + + User certificate store for the machine. + + + + + Specifies the authentication mechanism that should be used. + + + + + If SSL is enabled or Unix sockets are being used, sets PLAIN as the authentication mechanism; + otherwise, it tries to use MYSQL41 and then SHA256_MEMORY. + + + + + Authenticate using PLAIN. + + + + + Authenticate using MYSQL41. + + + + + Authenticate using EXTERNAL. + + + + + Authenticate using SHA256_MEMORY. + + + + + Defines waiting options that may be used with row locking options. + + + + + Waits until the blocking transaction releases the row lock. + + + + + Never waits to acquire a row lock. The query executes immediately, + failing with an error if a requested row is locked. + + + + + Never waits to acquire a row lock. The query executes immediately, + removing locked rows from the result set. + + + + + Defines the type of compression used when data is exchanged between client and server. + + + + + Uses compression if client and server are able to reach a concensus. Otherwise, compression + is not used. + + + + + Enforces the use of compression. If no concensus is reached, an error is raised. + + + + + Disables compression. + + + + + Collection of error codes that can be returned by the server + + + + + + + + + + + Error level + + + + + Error code + + + + + Error message + + + + + Provides a reference to error codes returned by MySQL. + + + + + ER_HASHCHK + + + + ER_NISAMCHK + + + + ER_NO + + + + ER_YES + + + The file couldn't be created. + ER_CANT_CREATE_FILE + + + The table couldn't be created. + ER_CANT_CREATE_TABLE + + + The database couldn't be created. + ER_CANT_CREATE_DB + + + The database couldn't be created, it already exists. + ER_DB_CREATE_EXISTS + + + The database couldn't be dropped, it doesn't exist. + ER_DB_DROP_EXISTS + + + The database couldn't be dropped, the file can't be deleted. + ER_DB_DROP_DELETE + + + The database couldn't be dropped, the directory can't be deleted. + ER_DB_DROP_RMDIR + + + The file couldn't be deleted. + ER_CANT_DELETE_FILE + + + The record couldn't be read from the system table. + ER_CANT_FIND_SYSTEM_REC + + + The status couldn't be retrieved. + ER_CANT_GET_STAT + + + The working directory couldn't be retrieved. + ER_CANT_GET_WD + + + The file couldn't be locked. + ER_CANT_LOCK + + + The file couldn't be opened. + ER_CANT_OPEN_FILE + + + The file couldn't be found. + ER_FILE_NOT_FOUND + + + The directory couldn't be read. + ER_CANT_READ_DIR + + + The working directory couldn't be entered. + ER_CANT_SET_WD + + + The record changed since it was last read. + ER_CHECKREAD + + + The disk is full. + ER_DISK_FULL + + + + There is already a key with the given values. + + + + An error occurred when closing the file. + ER_ERROR_ON_CLOSE + + + An error occurred when reading from the file. + ER_ERROR_ON_READ + + + An error occurred when renaming then file. + ER_ERROR_ON_RENAME + + + An error occurred when writing to the file. + ER_ERROR_ON_WRITE + + + The file is in use. + ER_FILE_USED + + + Sorting has been aborted. + ER_FILSORT_ABORT + + + The view doesn't exist. + ER_FORM_NOT_FOUND + + + Got the specified error from the table storage engine. + ER_GET_ERRNO + + + The table storage engine doesn't support the specified option. + ER_ILLEGAL_HA + + + + The specified key was not found. + + + + The file contains incorrect information. + ER_NOT_FORM_FILE + + + The key file is incorrect for the table, it should be repaired. + ER_NOT_KEYFILE + + + The key file is old for the table, it should be repaired. + ER_OLD_KEYFILE + + + The table is read-only + ER_OPEN_AS_READONLY + + + The server is out of memory, it should be restarted. + ER_OUTOFMEMORY + + + The server is out of sort-memory, the sort buffer size should be increased. + ER_OUT_OF_SORTMEMORY + + + An unexpected EOF was found when reading from the file. + ER_UNEXPECTED_EOF + + + Too many connections are open. + ER_CON_COUNT_ERROR + + + The server is out of resources, check if MySql or some other process is using all available memory. + ER_OUT_OF_RESOURCES + + + + Given when the connection is unable to successfully connect to host. + + + + The handshake was invalid. + ER_HANDSHAKE_ERROR + + + Access was denied for the specified user using the specified database. + ER_DBACCESS_DENIED_ERROR + + + + Normally returned when an incorrect password is given + + + + No database has been selected. + ER_NO_DB_ERROR + + + The command is unknown. + ER_UNKNOWN_COM_ERROR + + + The specified column cannot be NULL. + ER_BAD_NULL_ERROR + + + The specified database is not known. + + + The specified table already exists. + ER_TABLE_EXISTS_ERROR + + + The specified table is unknown. + ER_BAD_TABLE_ERROR + + + The specified column is ambiguous. + ER_NON_UNIQ_ERROR + + + The server is currently being shutdown. + ER_SERVER_SHUTDOWN + + + The specified columns is unknown. + ER_BAD_FIELD_ERROR + + + The specified column isn't in GROUP BY. + ER_WRONG_FIELD_WITH_GROUP + + + The specified columns cannot be grouped on. + ER_WRONG_GROUP_FIELD + + + There are sum functions and columns in the same statement. + ER_WRONG_SUM_SELECT + + + The column count doesn't match the value count. + ER_WRONG_VALUE_COUNT + + + The identifier name is too long. + ER_TOO_LONG_IDENT + + + The column name is duplicated. + ER_DUP_FIELDNAME + + + + Duplicate Key Name + + + + + Duplicate Key Entry + + + + The column specifier is incorrect. + ER_WRONG_FIELD_SPEC + + + An error occurred when parsing the statement. + ER_PARSE_ERROR + + + The statement is empty. + ER_EMPTY_QUERY + + + The table alias isn't unique. + ER_NONUNIQ_TABLE + + + The default value is invalid for the specified field. + ER_INVALID_DEFAULT + + + The table has multiple primary keys defined. + ER_MULTIPLE_PRI_KEY + + + Too many keys were defined for the table. + ER_TOO_MANY_KEYS + + + Too many parts to the keys were defined for the table. + ER_TOO_MANY_KEY_PARTS + + + The specified key is too long + ER_TOO_LONG_KEY + + + The specified key column doesn't exist in the table. + ER_KEY_COLUMN_DOES_NOT_EXITS + + + The BLOB column was used as a key, this can't be done. + ER_BLOB_USED_AS_KEY + + + The column length is too big for the specified column type. + ER_TOO_BIG_FIELDLENGTH + + + There can only be one auto-column, and it must be defined as a PK. + ER_WRONG_AUTO_KEY + + + The server is ready to accept connections. + ER_READY + + + + ER_NORMAL_SHUTDOWN + + + The server received the specified signal and is aborting. + ER_GOT_SIGNAL + + + The server shutdown is complete. + ER_SHUTDOWN_COMPLETE + + + The server is forcing close of the specified thread. + ER_FORCING_CLOSE + + + An error occurred when creating the IP socket. + ER_IPSOCK_ERROR + + + The table has no index like the one used in CREATE INDEX. + ER_NO_SUCH_INDEX + + + The field separator argument is not what is expected, check the manual. + ER_WRONG_FIELD_TERMINATORS + + + The BLOB columns must terminated, fixed row lengths cannot be used. + ER_BLOBS_AND_NO_TERMINATED + + + The text file cannot be read. + ER_TEXTFILE_NOT_READABLE + + + The specified file already exists. + ER_FILE_EXISTS_ERROR + + + Information returned by the LOAD statement. + ER_LOAD_INFO + + + Information returned by an UPDATE statement. + ER_ALTER_INFO + + + The prefix key is incorrect. + ER_WRONG_SUB_KEY + + + All columns cannot be removed from a table, use DROP TABLE instead. + ER_CANT_REMOVE_ALL_FIELDS + + + Cannot DROP, check that the column or key exists. + ER_CANT_DROP_FIELD_OR_KEY + + + Information returned by an INSERT statement. + ER_INSERT_INFO + + + The target table cannot be specified for update in FROM clause. + ER_UPDATE_TABLE_USED + + + The specified thread ID is unknown. + ER_NO_SUCH_THREAD + + + The thread cannot be killed, the current user is not the owner. + ER_KILL_DENIED_ERROR + + + No tables used in the statement. + ER_NO_TABLES_USED + + + Too many string have been used for the specified column and SET. + ER_TOO_BIG_SET + + + A unique filename couldn't be generated. + ER_NO_UNIQUE_LOGFILE + + + The specified table was locked with a READ lock, and can't be updated. + ER_TABLE_NOT_LOCKED_FOR_WRITE + + + The specified table was not locked with LOCK TABLES. + ER_TABLE_NOT_LOCKED + + + BLOB and Text columns cannot have a default value. + ER_BLOB_CANT_HAVE_DEFAULT + + + The specified database name is incorrect. + ER_WRONG_DB_NAME + + + The specified table name is incorrect. + ER_WRONG_TABLE_NAME + + + The SELECT command would examine more than MAX_JOIN_SIZE rows, check the WHERE clause and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok. + ER_TOO_BIG_SELECT + + + An unknown error occurred. + ER_UNKNOWN_ERROR + + + The specified procedure is unknown. + ER_UNKNOWN_PROCEDURE + + + The number of parameters provided for the specified procedure is incorrect. + ER_WRONG_PARAMCOUNT_TO_PROCEDURE + + + The parameters provided for the specified procedure are incorrect. + ER_WRONG_PARAMETERS_TO_PROCEDURE + + + The specified table is unknown. + ER_UNKNOWN_TABLE + + + The specified column has been specified twice. + ER_FIELD_SPECIFIED_TWICE + + + The group function has been incorrectly used. + ER_INVALID_GROUP_FUNC_USE + + + The specified table uses an extension that doesn't exist in this MySQL version. + ER_UNSUPPORTED_EXTENSION + + + The table must have at least one column. + ER_TABLE_MUST_HAVE_COLUMNS + + + The specified table is full. + ER_RECORD_FILE_FULL + + + The specified character set is unknown. + ER_UNKNOWN_CHARACTER_SET + + + Too many tables, MySQL can only use the specified number of tables in a JOIN. + ER_TOO_MANY_TABLES + + + Too many columns + ER_TOO_MANY_FIELDS + + + The row size is too large, the maximum row size for the used tables (not counting BLOBS) is specified, change some columns or BLOBS. + ER_TOO_BIG_ROWSIZE + + + A thread stack overrun occurred. Stack statistics are specified. + ER_STACK_OVERRUN + + + A cross dependency was found in the OUTER JOIN, examine the ON conditions. + ER_WRONG_OUTER_JOIN + + + The table handler doesn't support NULL in the given index, change specified column to be NOT NULL or use another handler. + ER_NULL_COLUMN_IN_INDEX + + + The specified user defined function cannot be loaded. + ER_CANT_FIND_UDF + + + The specified user defined function cannot be initialised. + ER_CANT_INITIALIZE_UDF + + + No paths are allowed for the shared library. + ER_UDF_NO_PATHS + + + The specified user defined function already exists. + ER_UDF_EXISTS + + + The specified shared library cannot be opened. + ER_CANT_OPEN_LIBRARY + + + The specified symbol cannot be found in the library. + ER_CANT_FIND_DL_ENTRY + + + The specified function is not defined. + ER_FUNCTION_NOT_DEFINED + + + The specified host is blocked because of too many connection errors, unblock with 'mysqladmin flush-hosts'. + ER_HOST_IS_BLOCKED + + + + The given host is not allowed to connect + + + + + The anonymous user is not allowed to connect + + + + + The given password is not allowed + + + + + The given password does not match + + + + Information returned by an UPDATE statement. + ER_UPDATE_INFO + + + A new thread couldn't be created. + ER_CANT_CREATE_THREAD + + + The column count doesn't match the value count. + ER_WRONG_VALUE_COUNT_ON_ROW + + + The specified table can't be re-opened. + ER_CANT_REOPEN_TABLE + + + The NULL value has been used incorrectly. + ER_INVALID_USE_OF_NULL + + + The regular expression contains an error. + ER_REGEXP_ERROR + + + GROUP columns (MIN(), MAX(), COUNT(), ...) cannot be mixes with no GROUP columns if there is not GROUP BY clause. + ER_MIX_OF_GROUP_FUNC_AND_FIELDS + + + + ER_NONEXISTING_GRANT + + + + ER_TABLEACCESS_DENIED_ERROR + + + + ER_COLUMNACCESS_DENIED_ERROR + + + + ER_ILLEGAL_GRANT_FOR_TABLE + + + + ER_GRANT_WRONG_HOST_OR_USER + + + + ER_NO_SUCH_TABLE + + + + ER_NONEXISTING_TABLE_GRANT + + + + ER_NOT_ALLOWED_COMMAND + + + + ER_SYNTAX_ERROR + + + + ER_DELAYED_CANT_CHANGE_LOCK + + + + ER_TOO_MANY_DELAYED_THREADS + + + + ER_ABORTING_CONNECTION + + + + An attempt was made to send or receive a packet larger than + max_allowed_packet_size + + + + + ER_NET_READ_ERROR_FROM_PIPE + + + + ER_NET_FCNTL_ERROR + + + + ER_NET_PACKETS_OUT_OF_ORDER + + + + ER_NET_UNCOMPRESS_ERROR + + + + ER_NET_READ_ERROR + + + + ER_NET_READ_INTERRUPTED + + + + ER_NET_ERROR_ON_WRITE + + + + ER_NET_WRITE_INTERRUPTED + + + + ER_TOO_LONG_STRING + + + + ER_TABLE_CANT_HANDLE_BLOB + + + + ER_TABLE_CANT_HANDLE_AUTO_INCREMENT + + + + ER_DELAYED_INSERT_TABLE_LOCKED + + + + ER_WRONG_COLUMN_NAME + + + + ER_WRONG_KEY_COLUMN + + + + ER_WRONG_MRG_TABLE + + + + ER_DUP_UNIQUE + + + + ER_BLOB_KEY_WITHOUT_LENGTH + + + + ER_PRIMARY_CANT_HAVE_NULL + + + + ER_TOO_MANY_ROWS + + + + ER_REQUIRES_PRIMARY_KEY + + + + ER_NO_RAID_COMPILED + + + + ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE + + + + ER_KEY_DOES_NOT_EXITS + + + + ER_CHECK_NO_SUCH_TABLE + + + + ER_CHECK_NOT_IMPLEMENTED + + + + ER_CANT_DO_THIS_DURING_AN_TRANSACTION + + + + ER_ERROR_DURING_COMMIT + + + + ER_ERROR_DURING_ROLLBACK + + + + ER_ERROR_DURING_FLUSH_LOGS + + + + ER_ERROR_DURING_CHECKPOINT + + + + ER_NEW_ABORTING_CONNECTION + + + + ER_DUMP_NOT_IMPLEMENTED + + + + ER_FLUSH_MASTER_BINLOG_CLOSED + + + + ER_INDEX_REBUILD + + + + ER_MASTER + + + + ER_MASTER_NET_READ + + + + ER_MASTER_NET_WRITE + + + + ER_FT_MATCHING_KEY_NOT_FOUND + + + + ER_LOCK_OR_ACTIVE_TRANSACTION + + + + ER_UNKNOWN_SYSTEM_VARIABLE + + + + ER_CRASHED_ON_USAGE + + + + ER_CRASHED_ON_REPAIR + + + + ER_WARNING_NOT_COMPLETE_ROLLBACK + + + + ER_TRANS_CACHE_FULL + + + + ER_SLAVE_MUST_STOP + + + + ER_SLAVE_NOT_RUNNING + + + + ER_BAD_SLAVE + + + + ER_MASTER_INFO + + + + ER_SLAVE_THREAD + + + + ER_TOO_MANY_USER_CONNECTIONS + + + + ER_SET_CONSTANTS_ONLY + + + + ER_LOCK_WAIT_TIMEOUT + + + + ER_LOCK_TABLE_FULL + + + + ER_READ_ONLY_TRANSACTION + + + + ER_DROP_DB_WITH_READ_LOCK + + + + ER_CREATE_DB_WITH_READ_LOCK + + + + ER_WRONG_ARGUMENTS + + + + ER_NO_PERMISSION_TO_CREATE_USER + + + + ER_UNION_TABLES_IN_DIFFERENT_DIR + + + + ER_LOCK_DEADLOCK + + + + ER_TABLE_CANT_HANDLE_FT + + + + ER_CANNOT_ADD_FOREIGN + + + + ER_NO_REFERENCED_ROW + + + + ER_ROW_IS_REFERENCED + + + + ER_CONNECT_TO_MASTER + + + + ER_QUERY_ON_MASTER + + + + ER_ERROR_WHEN_EXECUTING_COMMAND + + + + ER_WRONG_USAGE + + + + ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT + + + + ER_CANT_UPDATE_WITH_READLOCK + + + + ER_MIXING_NOT_ALLOWED + + + + ER_DUP_ARGUMENT + + + + ER_USER_LIMIT_REACHED + + + + ER_SPECIFIC_ACCESS_DENIED_ERROR + + + + ER_LOCAL_VARIABLE + + + + ER_GLOBAL_VARIABLE + + + + ER_NO_DEFAULT + + + + ER_WRONG_VALUE_FOR_VAR + + + + ER_WRONG_TYPE_FOR_VAR + + + + ER_VAR_CANT_BE_READ + + + + ER_CANT_USE_OPTION_HERE + + + + ER_NOT_SUPPORTED_YET + + + + ER_MASTER_FATAL_ERROR_READING_BINLOG + + + + ER_SLAVE_IGNORED_TABLE + + + + ER_INCORRECT_GLOBAL_LOCAL_VAR + + + + ER_WRONG_FK_DEF + + + + ER_KEY_REF_DO_NOT_MATCH_TABLE_REF + + + + ER_OPERAND_COLUMNS + + + + ER_SUBQUERY_NO_1_ROW + + + + ER_UNKNOWN_STMT_HANDLER + + + + ER_CORRUPT_HELP_DB + + + + ER_CYCLIC_REFERENCE + + + + ER_AUTO_CONVERT + + + + ER_ILLEGAL_REFERENCE + + + + ER_DERIVED_MUST_HAVE_ALIAS + + + + ER_SELECT_REDUCED + + + + ER_TABLENAME_NOT_ALLOWED_HERE + + + + ER_NOT_SUPPORTED_AUTH_MODE + + + + ER_SPATIAL_CANT_HAVE_NULL + + + + ER_COLLATION_CHARSET_MISMATCH + + + + ER_SLAVE_WAS_RUNNING + + + + ER_SLAVE_WAS_NOT_RUNNING + + + + ER_TOO_BIG_FOR_UNCOMPRESS + + + + ER_ZLIB_Z_MEM_ERROR + + + + ER_ZLIB_Z_BUF_ERROR + + + + ER_ZLIB_Z_DATA_ERROR + + + + ER_CUT_VALUE_GROUP_CONCAT + + + + ER_WARN_TOO_FEW_RECORDS + + + + ER_WARN_TOO_MANY_RECORDS + + + + ER_WARN_NULL_TO_NOTNULL + + + + ER_WARN_DATA_OUT_OF_RANGE + + + + WARN_DATA_TRUNCATED + + + + ER_WARN_USING_OTHER_HANDLER + + + + ER_CANT_AGGREGATE_2COLLATIONS + + + + ER_DROP_USER + + + + ER_REVOKE_GRANTS + + + + ER_CANT_AGGREGATE_3COLLATIONS + + + + ER_CANT_AGGREGATE_NCOLLATIONS + + + + ER_VARIABLE_IS_NOT_STRUCT + + + + ER_UNKNOWN_COLLATION + + + + ER_SLAVE_IGNORED_SSL_PARAMS + + + + ER_SERVER_IS_IN_SECURE_AUTH_MODE + + + + ER_WARN_FIELD_RESOLVED + + + + ER_BAD_SLAVE_UNTIL_COND + + + + ER_MISSING_SKIP_SLAVE + + + + ER_UNTIL_COND_IGNORED + + + + ER_WRONG_NAME_FOR_INDEX + + + + ER_WRONG_NAME_FOR_CATALOG + + + + ER_WARN_QC_RESIZE + + + + ER_BAD_FT_COLUMN + + + + ER_UNKNOWN_KEY_CACHE + + + + ER_WARN_HOSTNAME_WONT_WORK + + + + ER_UNKNOWN_STORAGE_ENGINE + + + + ER_WARN_DEPRECATED_SYNTAX + + + + ER_NON_UPDATABLE_TABLE + + + + ER_FEATURE_DISABLED + + + + ER_OPTION_PREVENTS_STATEMENT + + + + ER_DUPLICATED_VALUE_IN_TYPE + + + + ER_TRUNCATED_WRONG_VALUE + + + + ER_TOO_MUCH_AUTO_TIMESTAMP_COLS + + + + ER_INVALID_ON_UPDATE + + + + ER_UNSUPPORTED_PS + + + + ER_GET_ERRMSG + + + + ER_GET_TEMPORARY_ERRMSG + + + + ER_UNKNOWN_TIME_ZONE + + + + ER_WARN_INVALID_TIMESTAMP + + + + ER_INVALID_CHARACTER_STRING + + + + ER_WARN_ALLOWED_PACKET_OVERFLOWED + + + + ER_CONFLICTING_DECLARATIONS + + + + ER_SP_NO_RECURSIVE_CREATE + + + + ER_SP_ALREADY_EXISTS + + + + ER_SP_DOES_NOT_EXIST + + + + ER_SP_DROP_FAILED + + + + ER_SP_STORE_FAILED + + + + ER_SP_LILABEL_MISMATCH + + + + ER_SP_LABEL_REDEFINE + + + + ER_SP_LABEL_MISMATCH + + + + ER_SP_UNINIT_VAR + + + + ER_SP_BADSELECT + + + + ER_SP_BADRETURN + + + + ER_SP_BADSTATEMENT + + + + ER_UPDATE_LOG_DEPRECATED_IGNORED + + + + ER_UPDATE_LOG_DEPRECATED_TRANSLATED + + + + ER_QUERY_INTERRUPTED + + + + ER_SP_WRONG_NO_OF_ARGS + + + + ER_SP_COND_MISMATCH + + + + ER_SP_NORETURN + + + + ER_SP_NORETURNEND + + + + ER_SP_BAD_CURSOR_QUERY + + + + ER_SP_BAD_CURSOR_SELECT + + + + ER_SP_CURSOR_MISMATCH + + + + ER_SP_CURSOR_ALREADY_OPEN + + + + ER_SP_CURSOR_NOT_OPEN + + + + ER_SP_UNDECLARED_VAR + + + + ER_SP_WRONG_NO_OF_FETCH_ARGS + + + + ER_SP_FETCH_NO_DATA + + + + ER_SP_DUP_PARAM + + + + ER_SP_DUP_VAR + + + + ER_SP_DUP_COND + + + + ER_SP_DUP_CURS + + + + ER_SP_CANT_ALTER + + + + ER_SP_SUBSELECT_NYI + + + + ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG + + + + ER_SP_VARCOND_AFTER_CURSHNDLR + + + + ER_SP_CURSOR_AFTER_HANDLER + + + + ER_SP_CASE_NOT_FOUND + + + + ER_FPARSER_TOO_BIG_FILE + + + + ER_FPARSER_BAD_HEADER + + + + ER_FPARSER_EOF_IN_COMMENT + + + + ER_FPARSER_ERROR_IN_PARAMETER + + + + ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER + + + + ER_VIEW_NO_EXPLAIN + + + + ER_FRM_UNKNOWN_TYPE + + + + ER_WRONG_OBJECT + + + + ER_NONUPDATEABLE_COLUMN + + + + ER_VIEW_SELECT_DERIVED + + + + ER_VIEW_SELECT_CLAUSE + + + + ER_VIEW_SELECT_VARIABLE + + + + ER_VIEW_SELECT_TMPTABLE + + + + ER_VIEW_WRONG_LIST + + + + ER_WARN_VIEW_MERGE + + + + ER_WARN_VIEW_WITHOUT_KEY + + + + ER_VIEW_INVALID + + + + ER_SP_NO_DROP_SP + + + + ER_SP_GOTO_IN_HNDLR + + + + ER_TRG_ALREADY_EXISTS + + + + ER_TRG_DOES_NOT_EXIST + + + + ER_TRG_ON_VIEW_OR_TEMP_TABLE + + + + ER_TRG_CANT_CHANGE_ROW + + + + ER_TRG_NO_SUCH_ROW_IN_TRG + + + + ER_NO_DEFAULT_FOR_FIELD + + + + ER_DIVISION_BY_ZERO + + + + ER_TRUNCATED_WRONG_VALUE_FOR_FIELD + + + + ER_ILLEGAL_VALUE_FOR_TYPE + + + + ER_VIEW_NONUPD_CHECK + + + + ER_VIEW_CHECK_FAILED + + + + ER_PROCACCESS_DENIED_ERROR + + + + ER_RELAY_LOG_FAIL + + + + ER_PASSWD_LENGTH + + + + ER_UNKNOWN_TARGET_BINLOG + + + + ER_IO_ERR_LOG_INDEX_READ + + + + ER_BINLOG_PURGE_PROHIBITED + + + + ER_FSEEK_FAIL + + + + ER_BINLOG_PURGE_FATAL_ERR + + + + ER_LOG_IN_USE + + + + ER_LOG_PURGE_UNKNOWN_ERR + + + + ER_RELAY_LOG_INIT + + + + ER_NO_BINARY_LOGGING + + + + ER_RESERVED_SYNTAX + + + + ER_WSAS_FAILED + + + + ER_DIFF_GROUPS_PROC + + + + ER_NO_GROUP_FOR_PROC + + + + ER_ORDER_WITH_PROC + + + + ER_LOGGING_PROHIBIT_CHANGING_OF + + + + ER_NO_FILE_MAPPING + + + + ER_WRONG_MAGIC + + + + ER_PS_MANY_PARAM + + + + ER_KEY_PART_0 + + + + ER_VIEW_CHECKSUM + + + + ER_VIEW_MULTIUPDATE + + + + ER_VIEW_NO_INSERT_FIELD_LIST + + + + ER_VIEW_DELETE_MERGE_VIEW + + + + ER_CANNOT_USER + + + + ER_XAER_NOTA + + + + ER_XAER_INVAL + + + + ER_XAER_RMFAIL + + + + ER_XAER_OUTSIDE + + + + ER_XAER_RMERR + + + + ER_XA_RBROLLBACK + + + + ER_NONEXISTING_PROC_GRANT + + + + ER_PROC_AUTO_GRANT_FAIL + + + + ER_PROC_AUTO_REVOKE_FAIL + + + + ER_DATA_TOO_LONG + + + + ER_SP_BAD_SQLSTATE + + + + ER_STARTUP + + + + ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR + + + + ER_CANT_CREATE_USER_WITH_GRANT + + + + ER_WRONG_VALUE_FOR_TYPE + + + + ER_TABLE_DEF_CHANGED + + + + ER_SP_DUP_HANDLER + + + + ER_SP_NOT_VAR_ARG + + + + ER_SP_NO_RETSET + + + + ER_CANT_CREATE_GEOMETRY_OBJECT + + + + ER_FAILED_ROUTINE_BREAK_BINLOG + + + + ER_BINLOG_UNSAFE_ROUTINE + + + + ER_BINLOG_CREATE_ROUTINE_NEED_SUPER + + + + ER_EXEC_STMT_WITH_OPEN_CURSOR + + + + ER_STMT_HAS_NO_OPEN_CURSOR + + + + ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG + + + + ER_NO_DEFAULT_FOR_VIEW_FIELD + + + + ER_SP_NO_RECURSION + + + + ER_TOO_BIG_SCALE + + + + ER_TOO_BIG_PRECISION + + + + ER_M_BIGGER_THAN_D + + + + ER_WRONG_LOCK_OF_SYSTEM_TABLE + + + + ER_CONNECT_TO_FOREIGN_DATA_SOURCE + + + + ER_QUERY_ON_FOREIGN_DATA_SOURCE + + + + ER_FOREIGN_DATA_SOURCE_DOESNT_EXIST + + + + ER_FOREIGN_DATA_STRING_INVALID_CANT_CREATE + + + + ER_FOREIGN_DATA_STRING_INVALID + + + + ER_CANT_CREATE_FEDERATED_TABLE + + + + ER_TRG_IN_WRONG_SCHEMA + + + + ER_STACK_OVERRUN_NEED_MORE + + + + ER_TOO_LONG_BODY + + + + ER_WARN_CANT_DROP_DEFAULT_KEYCACHE + + + + ER_TOO_BIG_DISPLAYWIDTH + + + + ER_XAER_DUPID + + + + ER_DATETIME_FUNCTION_OVERFLOW + + + + ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG + + + + ER_VIEW_PREVENT_UPDATE + + + + ER_PS_NO_RECURSION + + + + ER_SP_CANT_SET_AUTOCOMMIT + + + + ER_MALFORMED_DEFINER + + + + ER_VIEW_FRM_NO_USER + + + + ER_VIEW_OTHER_USER + + + + ER_NO_SUCH_USER + + + + ER_FORBID_SCHEMA_CHANGE + + + + ER_ROW_IS_REFERENCED_2 + + + + ER_NO_REFERENCED_ROW_2 + + + + ER_SP_BAD_VAR_SHADOW + + + + ER_TRG_NO_DEFINER + + + + ER_OLD_FILE_FORMAT + + + + ER_SP_RECURSION_LIMIT + + + + ER_SP_PROC_TABLE_CORRUPT + + + + ER_SP_WRONG_NAME + + + + ER_TABLE_NEEDS_UPGRADE + + + + ER_SP_NO_AGGREGATE + + + + ER_MAX_PREPARED_STMT_COUNT_REACHED + + + + ER_VIEW_RECURSIVE + + + + ER_NON_GROUPING_FIELD_USED + + + + ER_TABLE_CANT_HANDLE_SPKEYS + + + + ER_NO_TRIGGERS_ON_SYSTEM_SCHEMA + + + + ER_REMOVED_SPACES + + + + ER_AUTOINC_READ_FAILED + + + + ER_USERNAME + + + + ER_HOSTNAME + + + + ER_WRONG_STRING_LENGTH + + + + ER_NON_INSERTABLE_TABLE + + + + ER_ADMIN_WRONG_MRG_TABLE + + + + ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT + + + + ER_NAME_BECOMES_EMPTY + + + + ER_AMBIGUOUS_FIELD_TERM + + + + ER_FOREIGN_SERVER_EXISTS + + + + ER_FOREIGN_SERVER_DOESNT_EXIST + + + + ER_ILLEGAL_HA_CREATE_OPTION + + + + ER_PARTITION_REQUIRES_VALUES_ERROR + + + + ER_PARTITION_WRONG_VALUES_ERROR + + + + ER_PARTITION_MAXVALUE_ERROR + + + + ER_PARTITION_SUBPARTITION_ERROR + + + + ER_PARTITION_SUBPART_MIX_ERROR + + + + ER_PARTITION_WRONG_NO_PART_ERROR + + + + ER_PARTITION_WRONG_NO_SUBPART_ERROR + + + + ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR + + + + ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR + + + + ER_FIELD_NOT_FOUND_PART_ERROR + + + + ER_LIST_OF_FIELDS_ONLY_IN_HASH_ERROR + + + + ER_INCONSISTENT_PARTITION_INFO_ERROR + + + + ER_PARTITION_FUNC_NOT_ALLOWED_ERROR + + + + ER_PARTITIONS_MUST_BE_DEFINED_ERROR + + + + ER_RANGE_NOT_INCREASING_ERROR + + + + ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR + + + + ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR + + + + ER_PARTITION_ENTRY_ERROR + + + + ER_MIX_HANDLER_ERROR + + + + ER_PARTITION_NOT_DEFINED_ERROR + + + + ER_TOO_MANY_PARTITIONS_ERROR + + + + ER_SUBPARTITION_ERROR + + + + ER_CANT_CREATE_HANDLER_FILE + + + + ER_BLOB_FIELD_IN_PART_FUNC_ERROR + + + + ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF + + + + ER_NO_PARTS_ERROR + + + + ER_PARTITION_MGMT_ON_NONPARTITIONED + + + + ER_FOREIGN_KEY_ON_PARTITIONED + + + + ER_DROP_PARTITION_NON_EXISTENT + + + + ER_DROP_LAST_PARTITION + + + + ER_COALESCE_ONLY_ON_HASH_PARTITION + + + + ER_REORG_HASH_ONLY_ON_SAME_NO + + + + ER_REORG_NO_PARAM_ERROR + + + + ER_ONLY_ON_RANGE_LIST_PARTITION + + + + ER_ADD_PARTITION_SUBPART_ERROR + + + + ER_ADD_PARTITION_NO_NEW_PARTITION + + + + ER_COALESCE_PARTITION_NO_PARTITION + + + + ER_REORG_PARTITION_NOT_EXIST + + + + ER_SAME_NAME_PARTITION + + + + ER_NO_BINLOG_ERROR + + + + ER_CONSECUTIVE_REORG_PARTITIONS + + + + ER_REORG_OUTSIDE_RANGE + + + + ER_PARTITION_FUNCTION_FAILURE + + + + ER_PART_STATE_ERROR + + + + ER_LIMITED_PART_RANGE + + + + ER_PLUGIN_IS_NOT_LOADED + + + + ER_WRONG_VALUE + + + + ER_NO_PARTITION_FOR_GIVEN_VALUE + + + + ER_FILEGROUP_OPTION_ONLY_ONCE + + + + ER_CREATE_FILEGROUP_FAILED + + + + ER_DROP_FILEGROUP_FAILED + + + + ER_TABLESPACE_AUTO_EXTEND_ERROR + + + + ER_WRONG_SIZE_NUMBER + + + + ER_SIZE_OVERFLOW_ERROR + + + + ER_ALTER_FILEGROUP_FAILED + + + + ER_BINLOG_ROW_LOGGING_FAILED + + + + ER_BINLOG_ROW_WRONG_TABLE_DEF + + + + ER_BINLOG_ROW_RBR_TO_SBR + + + + ER_EVENT_ALREADY_EXISTS + + + + ER_EVENT_STORE_FAILED + + + + ER_EVENT_DOES_NOT_EXIST + + + + ER_EVENT_CANT_ALTER + + + + ER_EVENT_DROP_FAILED + + + + ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG + + + + ER_EVENT_ENDS_BEFORE_STARTS + + + + ER_EVENT_EXEC_TIME_IN_THE_PAST + + + + ER_EVENT_OPEN_TABLE_FAILED + + + + ER_EVENT_NEITHER_M_EXPR_NOR_M_AT + + + + ER_COL_COUNT_DOESNT_MATCH_CORRUPTED + + + + ER_CANNOT_LOAD_FROM_TABLE + + + + ER_EVENT_CANNOT_DELETE + + + + ER_EVENT_COMPILE_ERROR + + + + ER_EVENT_SAME_NAME + + + + ER_EVENT_DATA_TOO_LONG + + + + ER_DROP_INDEX_FK + + + + ER_WARN_DEPRECATED_SYNTAX_WITH_VER + + + + ER_CANT_WRITE_LOCK_LOG_TABLE + + + + ER_CANT_LOCK_LOG_TABLE + + + + ER_FOREIGN_DUPLICATE_KEY + + + + ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE + + + + ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR + + + + ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT + + + + ER_NDB_CANT_SWITCH_BINLOG_FORMAT + + + + ER_PARTITION_NO_TEMPORARY + + + + ER_PARTITION_CONST_DOMAIN_ERROR + + + + ER_PARTITION_FUNCTION_IS_NOT_ALLOWED + + + + ER_DDL_LOG_ERROR + + + + ER_NULL_IN_VALUES_LESS_THAN + + + + ER_WRONG_PARTITION_NAME + + + + ER_CANT_CHANGE_TRANSACTION_ISOLATION + + + + ER_DUP_ENTRY_AUTOINCREMENT_CASE + + + + ER_EVENT_MODIFY_QUEUE_ERROR + + + + ER_EVENT_SET_VAR_ERROR + + + + ER_PARTITION_MERGE_ERROR + + + + ER_CANT_ACTIVATE_LOG + + + + ER_RBR_NOT_AVAILABLE + + + + ER_BASE64_DECODE_ERROR + + + + ER_EVENT_RECURSION_FORBIDDEN + + + + ER_EVENTS_DB_ERROR + + + + ER_ONLY_INTEGERS_ALLOWED + + + + ER_UNSUPORTED_LOG_ENGINE + + + + ER_BAD_LOG_STATEMENT + + + + ER_CANT_RENAME_LOG_TABLE + + + + ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT + + + + ER_WRONG_PARAMETERS_TO_NATIVE_FCT + + + + ER_WRONG_PARAMETERS_TO_STORED_FCT + + + + ER_NATIVE_FCT_NAME_COLLISION + + + + ER_DUP_ENTRY_WITH_KEY_NAME + + + + ER_BINLOG_PURGE_EMFILE + + + + ER_EVENT_CANNOT_CREATE_IN_THE_PAST + + + + ER_EVENT_CANNOT_ALTER_IN_THE_PAST + + + + ER_SLAVE_INCIDENT + + + + ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT + + + + ER_BINLOG_UNSAFE_STATEMENT + + + + ER_SLAVE_FATAL_ERROR + + + + ER_SLAVE_RELAY_LOG_READ_FAILURE + + + + ER_SLAVE_RELAY_LOG_WRITE_FAILURE + + + + ER_SLAVE_CREATE_EVENT_FAILURE + + + + ER_SLAVE_MASTER_COM_FAILURE + + + + ER_BINLOG_LOGGING_IMPOSSIBLE + + + + ER_VIEW_NO_CREATION_CTX + + + + ER_VIEW_INVALID_CREATION_CTX + + + + ER_SR_INVALID_CREATION_CTX + + + + ER_TRG_CORRUPTED_FILE + + + + ER_TRG_NO_CREATION_CTX + + + + ER_TRG_INVALID_CREATION_CTX + + + + ER_EVENT_INVALID_CREATION_CTX + + + + ER_TRG_CANT_OPEN_TABLE + + + + ER_CANT_CREATE_SROUTINE + + + + ER_SLAVE_AMBIGOUS_EXEC_MODE + + + + ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT + + + + ER_SLAVE_CORRUPT_EVENT + + + + ER_LOAD_DATA_INVALID_COLUMN + + + + ER_LOG_PURGE_NO_FILE + + + + ER_XA_RBTIMEOUT + + + + ER_XA_RBDEADLOCK + + + + ER_NEED_REPREPARE + + + + ER_DELAYED_NOT_SUPPORTED + + + + WARN_NO_MASTER_INFO + + + + WARN_OPTION_IGNORED + + + + WARN_PLUGIN_DELETE_BUILTIN + + + + WARN_PLUGIN_BUSY + + + + ER_VARIABLE_IS_READONLY + + + + ER_WARN_ENGINE_TRANSACTION_ROLLBACK + + + + ER_SLAVE_HEARTBEAT_FAILURE + + + + ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE + + + + ER_NDB_REPLICATION_SCHEMA_ERROR + + + + ER_CONFLICT_FN_PARSE_ERROR + + + + ER_EXCEPTIONS_WRITE_ERROR + + + + ER_TOO_LONG_TABLE_COMMENT + + + + ER_TOO_LONG_FIELD_COMMENT + + + + ER_FUNC_INEXISTENT_NAME_COLLISION + + + + ER_DATABASE_NAME + + + + ER_TABLE_NAME + + + + ER_PARTITION_NAME + + + + ER_SUBPARTITION_NAME + + + + ER_TEMPORARY_NAME + + + + ER_RENAMED_NAME + + + + ER_TOO_MANY_CONCURRENT_TRXS + + + + WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED + + + + ER_DEBUG_SYNC_TIMEOUT + + + + ER_DEBUG_SYNC_HIT_LIMIT + + + + ER_ERROR_LAST + + + + WriteInteger + + + + + + + Summary description for MySqlPool. + + + + + It is assumed that this property will only be used from inside an active + lock. + + + + + Indicates whether this pool is being cleared. + + + + + It is assumed that this method is only called from inside an active lock. + + + + + It is assumed that this method is only called from inside an active lock. + + + + + Removes a connection from the in use pool. The only situations where this method + would be called are when a connection that is in use gets some type of fatal exception + or when the connection is being returned to the pool and it's too old to be + returned. + + + + + + Clears this pool of all idle connections and marks this pool and being cleared + so all other connections are closed when they are returned. + + + + + Remove expired drivers from the idle pool + + + + Closing driver is a potentially lengthy operation involving network + IO. Therefore we do not close expired drivers while holding + idlePool.SyncRoot lock. We just remove the old drivers from the idle + queue and return them to the caller. The caller will need to close + them (or let GC close them) + + + + + Summary description for MySqlPoolManager. + + + + + Queue of demoted hosts. + + + + + List of hosts that will be attempted to connect to. + + + + + Timer to be used when a host have been demoted. + + + + + Remove drivers that have been idle for too long. + + + + + Remove hosts that have been on the demoted list for more + than 120,000 milliseconds and add them to the available hosts list. + + + + + Provides a class capable of executing a SQL script containing + multiple SQL statements including CREATE PROCEDURE statements + that require changing the delimiter + + + + + Handles the event raised whenever a statement is executed. + + + + + Handles the event raised whenever an error is raised by the execution of a script. + + + + + Handles the event raised whenever a script execution is finished. + + + + + Initializes a new instance of the + class. + + + + + Initializes a new instance of the + class. + + The connection. + + + + Initializes a new instance of the + class. + + The query. + + + + Initializes a new instance of the + class. + + The connection. + The query. + + + + Gets or sets the connection. + + The connection. + + + + Gets or sets the query. + + The query. + + + + Gets or sets the delimiter. + + The delimiter. + + + + Executes this instance. + + The number of statements executed as part of the script. + + + + Initiates the asynchronous execution of SQL statements. + + The number of statements executed as part of the script inside. + + + + Initiates the asynchronous execution of SQL statements. + + The cancellation token. + The number of statements executed as part of the script inside. + + + + Represents the method that will handle errors when executing MySQL statements. + + + + + Represents the method that will handle errors when executing MySQL scripts. + + + + + Sets the arguments associated to MySQL scripts. + + + + + Gets the statement text. + + The statement text. + + + + Gets the line. + + The line. + + + + Gets the position. + + The position. + + + + Sets the arguments associated to MySQL script errors. + + + + + Initializes a new instance of the class. + + The exception. + + + + Gets the exception. + + The exception. + + + + Gets or sets a value indicating whether this is ignored. + + true if ignore; otherwise, false. + + + + Summary description for MySqlStream. + + + + + ReadPacket is called by NativeDriver to start reading the next + packet on the stream. + + + + + Reads the specified number of bytes from the stream and stores them at given + offset in the buffer. + Throws EndOfStreamException if not all bytes can be read. + + Stream to read from + Array to store bytes read from the stream + The offset in buffer at which to begin storing the data read from the current stream. + Number of bytes to read + + + + LoadPacket loads up and decodes the header of the incoming packet. + + + + + Traces information about the client execution. + + + + + Gets the list of trace listeners. + + + + + Gets or sets the switch to control tracing and debugging. + + + + + Gets or sets a flag indicating if query analysis is enabled. + + + + + Enables query analysis. + + The host on which to enable query analysis. + The interval of time for logging trace information. + + + + Disables query analysis. + + + + + Specifies the types of warning flags. + + + + + No index exists. + + + + + Bad index exists. + + + + + Rows have been excluded from the result. + + + + + Columns have been excluded from the result. + + + + + Type conversions took place. + + + + + Specifies the event that triggered the trace. + + + + + A connection has been opened. + + + + + A connection has been closed. + + + + + A query has been executed. + + + + + Data has been retrieved from the resultset. + + + + + Data retrieval has ended. + + + + + Query execution has ended. + + + + + The statement to be executed has been created. + + + + + The statement has been executed. + + + + + The statement is no longer required. + + + + + The query provided is of a nonquery type. + + + + + Usage advisor warnings have been requested. + + + + + Noncritical problem. + + + + + An error has been raised during data retrieval. + + + + + The query has been normalized. + + + + + Summary description for Driver. + + + + + Sets the current database for the this connection + + + + + + Return the appropriate set of connection flags for our + server capabilities and our user requested options. + + + + + Query is the method that is called to send all queries to the server + + + + + Sends the specified file to the server. + This supports the LOAD DATA LOCAL INFILE + + + + + + FetchDataRow is the method that the data reader calls to see if there is another + row to fetch. In the non-prepared mode, it will simply read the next data packet. + In the prepared mode (statementId > 0), it will + + + + + Execution timeout, in milliseconds. When the accumulated time for network IO exceeds this value + TimeoutException is thrown. This timeout needs to be reset for every new command + + + + + + Summary description for PreparedStatement. + + + + + Prepares CommandText for use with the Prepare method + + Command text stripped of all paramter names + + Takes the output of TokenizeSql and creates a single string of SQL + that only contains '?' markers for each parameter. It also creates + the parameterMap array list that includes all the paramter names in the + order they appeared in the SQL + + + + + Defines a replication configurarion element in the configuration file. + + + + + Gets a collection of objects representing the server groups. + + + + + Defines a replication server group in the configuration file. + + + + + Gets or sets the name of the replication server group configuration. + + + + + Gets or sets the group type of the replication server group configuration. + + + + + Gets or sets the number of seconds to wait for retry. + + + + + Gets a collection of objects representing the + server configurations associated to this group configuration. + + + + + Defines a replication server in configuration file. + + + + + Gets or sets the name of the replication server configuration. + + + + + Gets or sets whether the replication server is configured as master. + + + + + Gets or sets the connection string associated to this replication server. + + + + + Manager for Replication and Load Balancing features + + + + + Returns Replication Server Group List + + + + + Adds a Default Server Group to the list + + Group name + Time between reconnections for failed servers + Replication Server Group added + + + + Adds a Server Group to the list + + Group name + ServerGroup type reference + Time between reconnections for failed servers + Server Group added + + + + Gets the next server from a replication group + + Group name + True if the server to return must be a master + Replication Server defined by the Load Balancing plugin + + + + Gets a Server Group by name + + Group name + Server Group if found, otherwise throws an MySqlException + + + + Validates if the replication group name exists + + Group name to validate + true if the replication group name is found; otherwise, false + + + + Assigns a new server driver to the connection object + + Group name + True if the server connection to assign must be a master + MySqlConnection object where the new driver will be assigned + + + + Class that implements Round Robing Load Balancing technique. + + + + + Gets an available server based on Round Robin load balancing. + + Flag indicating if the server to return must be a master. + A object representing the next available server. + + + + Represents a server in a Replication environment. + + + + + Gets the server name. + + + + + Gets a value indicating whether the server is master or slave. + + + + + Gets the connection string used to connect to the server. + + + + + Gets a flag indicating if the server is available to be considered in load balancing. + + + + + Base class used to implement load balancing features. + + + + + List of servers available for replication. + + + + The group name. + The number of seconds to perform a retry. + + + + Gets the group name. + + + + + Gets the retry time between connections to failed servers. + + + + + Gets the server list in the group. + + + + + Adds a server into the group. + + The server name. + A flag indicating if the server to add is master or slave. + The connection string used by this server. + A object representing the recently added object. + + + + Removes a server from the group. + + The server name. + + + + Gets a server by name. + + The server name. + The replication server. + + + + Must be implemented. Defines the next server for a custom load balancing implementation. + + Defines if the server to return is a master or any. + The next server based on the load balancing implementation. + Null if no available server is found. + + + + + Defines the next server for a custom load balancing implementation. + + Defines if the server to return is a master or any. + Currently not being used. + The next server based on the load balancing implementation. + Null if no available server is found. + + + + + Handles a failed connection to a server. + + The failed server. + This method can be overrided to implement a custom failover handling. + + + + Handles a failed connection to a server. + + The failed server. + The exception that caused the failover. + + + + return the ordinal for the given column name + + + + + + + Retrieve the value as the given column index + + The column value to retrieve + The value as the given column + + + + Closes the current resultset, dumping any data still on the wire + + + + + Loads the column metadata for the current resultset + + + + + Represents a schema and its contents. + + + + + Gets or sets the name of the schema. + + + + + Gets the list of columns in the schema. + + + + + Gets the list of rows in the schema. + + + + + Represents a row within a schema. + + + + + Represents a column within a schema. + + + + + The name of the column. + + + + + The type of the column. + + + + + GetForeignKeysOnTable retrieves the foreign keys on the given table. + Since MySQL supports foreign keys on versions prior to 5.0, we can't use + information schema. MySQL also does not include any type of SHOW command + for foreign keys so we have to resort to use SHOW CREATE TABLE and parsing + the output. + + The table to store the key info in. + The table to get the foeign key info for. + Only get foreign keys that match this name. + Should column information be included in the table. + + + + Serializes the given parameter to the given memory stream + + + This method is called by PrepareSqlBuffers to convert the given + parameter to bytes and write those bytes to the given memory stream. + + + True if the parameter was successfully serialized, false otherwise. + + + + Summary description for StoredProcedure. + + + + + Defines the basic operations to be performed on the table cache. + + + + + The maximum age allowed for cache entries. + + + + + Adds the given command and result set to the cache. + + The command to store in the cache. + The resultset associated to the stored command. + + + + Retrieves the specified command from the cache. + + The command to retrieve. + The allowed age for the cache entry. + + + + + Removes the specified command from the cache. + + The command to remove from the cache. + + + + Clears the cache. + + + + + Removes cache entries older than the value defined by . + + + + + Stream that supports timeout of IO operations. + This class is used is used to support timeouts for SQL command, where a + typical operation involves several network reads/writes. + Timeout here is defined as the accumulated duration of all IO operations. + + + + + Construct a TimedStream + + Undelying stream + + + + Figure out whether it is necessary to reset timeout on stream. + We track the current value of timeout and try to avoid + changing it too often, because setting Read/WriteTimeout property + on network stream maybe a slow operation that involves a system call + (setsockopt). Therefore, we allow a small difference, and do not + reset timeout if current value is slightly greater than the requested + one (within 0.1 second). + + + + + Common handler for IO exceptions. + Resets timeout to infinity if timeout exception is + detected and stops the times. + + original exception + + + + Represents a SQL transaction to be made in a MySQL database. This class cannot be inherited. + + The application creates a MySqlTransaction object by calling + on the object. All subsequent operations associated with the + transaction (for example, committing or aborting the transaction), are performed on the + MySqlTransaction object. + + The following example creates a and a MySqlTransaction. + It also demonstrates how to use the , + , and methods. + + Public Sub RunTransaction(myConnString As String) + Dim myConnection As New MySqlConnection(myConnString) + myConnection.Open() + + Dim myCommand As MySqlCommand = myConnection.CreateCommand() + Dim myTrans As MySqlTransaction + + ' Start a local transaction + myTrans = myConnection.BeginTransaction() + ' Must assign both transaction object and connection + ' to Command object for a pending local transaction + myCommand.Connection = myConnection + myCommand.Transaction = myTrans + + Try + myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')" + myCommand.ExecuteNonQuery() + myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')" + myCommand.ExecuteNonQuery() + myTrans.Commit() + Console.WriteLine("Both records are written to database.") + Catch e As Exception + Try + myTrans.Rollback() + Catch ex As MySqlException + If Not myTrans.Connection Is Nothing Then + Console.WriteLine("An exception of type " & ex.GetType().ToString() & _ + " was encountered while attempting to roll back the transaction.") + End If + End Try + + Console.WriteLine("An exception of type " & e.GetType().ToString() & _ + "was encountered while inserting the data.") + Console.WriteLine("Neither record was written to database.") + Finally + myConnection.Close() + End Try + End Sub 'RunTransaction + + + public void RunTransaction(string myConnString) + { + MySqlConnection myConnection = new MySqlConnection(myConnString); + myConnection.Open(); + + MySqlCommand myCommand = myConnection.CreateCommand(); + MySqlTransaction myTrans; + + // Start a local transaction + myTrans = myConnection.BeginTransaction(); + // Must assign both transaction object and connection + // to Command object for a pending local transaction + myCommand.Connection = myConnection; + myCommand.Transaction = myTrans; + + try + { + myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')"; + myCommand.ExecuteNonQuery(); + myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')"; + myCommand.ExecuteNonQuery(); + myTrans.Commit(); + Console.WriteLine("Both records are written to database."); + } + catch(Exception e) + { + try + { + myTrans.Rollback(); + } + catch (MySqlException ex) + { + if (myTrans.Connection != null) + { + Console.WriteLine("An exception of type " + ex.GetType() + + " was encountered while attempting to roll back the transaction."); + } + } + + Console.WriteLine("An exception of type " + e.GetType() + + " was encountered while inserting the data."); + Console.WriteLine("Neither record was written to database."); + } + finally + { + myConnection.Close(); + } + } + + + + + + Gets the object associated with the transaction, or a null reference (Nothing in Visual Basic) if the transaction is no longer valid. + + The object associated with this transaction. + + A single application may have multiple database connections, each + with zero or more transactions. This property enables you to + determine the connection object associated with a particular + transaction created by . + + + + + Specifies the for this transaction. + + + The for this transaction. The default is ReadCommitted. + + + Parallel transactions are not supported. Therefore, the IsolationLevel + applies to the entire transaction. + + + + + Commits the database transaction. + + The Commit method is equivalent to the MySQL SQL statement + COMMIT. + + The following example creates a and a + . It also demonstrates how to use the + , , and Rollback + methods. + + Public Sub RunSqlTransaction(myConnString As String) + Dim myConnection As New MySqlConnection(myConnString) + myConnection.Open() + + Dim myCommand As MySqlCommand = myConnection.CreateCommand() + Dim myTrans As MySqlTransaction + + ' Start a local transaction + myTrans = myConnection.BeginTransaction() + + ' Must assign both transaction object and connection + ' to Command object for a pending local transaction + myCommand.Connection = myConnection + myCommand.Transaction = myTrans + + Try + myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')" + myCommand.ExecuteNonQuery() + myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')" + myCommand.ExecuteNonQuery() + myTrans.Commit() + Console.WriteLine("Success.") + Catch e As Exception + Try + myTrans.Rollback() + Catch ex As MySqlException + If Not myTrans.Connection Is Nothing Then + Console.WriteLine("An exception of type " & ex.GetType().ToString() & _ + " was encountered while attempting to roll back the transaction.") + End If + End Try + + Console.WriteLine("An exception of type " & e.GetType().ToString() & _ + "was encountered while inserting the data.") + Console.WriteLine("Neither record was written to database.") + Finally + myConnection.Close() + End Try + End Sub + + + public void RunSqlTransaction(string myConnString) + { + MySqlConnection myConnection = new MySqlConnection(myConnString); + myConnection.Open(); + + MySqlCommand myCommand = myConnection.CreateCommand(); + MySqlTransaction myTrans; + + // Start a local transaction + myTrans = myConnection.BeginTransaction(); + // Must assign both transaction object and connection + // to Command object for a pending local transaction + myCommand.Connection = myConnection; + myCommand.Transaction = myTrans; + + try + { + myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')"; + myCommand.ExecuteNonQuery(); + myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')"; + myCommand.ExecuteNonQuery(); + myTrans.Commit(); + Console.WriteLine("Both records are written to database."); + } + catch(Exception e) + { + try + { + myTrans.Rollback(); + } + catch (MySqlException ex) + { + if (myTrans.Connection != null) + { + Console.WriteLine("An exception of type " + ex.GetType() + + " was encountered while attempting to roll back the transaction."); + } + } + + Console.WriteLine("An exception of type " + e.GetType() + + " was encountered while inserting the data."); + Console.WriteLine("Neither record was written to database."); + } + finally + { + myConnection.Close(); + } + } + + + + + + Rolls back a transaction from a pending state. + + The Rollback method is equivalent to the MySQL statement ROLLBACK. + The transaction can only be rolled back from a pending state + (after BeginTransaction has been called, but before Commit is + called). + + The following example creates a and a + . It also demonstrates how to use the + , , and Rollback + methods. + + Public Sub RunSqlTransaction(myConnString As String) + Dim myConnection As New MySqlConnection(myConnString) + myConnection.Open() + + Dim myCommand As MySqlCommand = myConnection.CreateCommand() + Dim myTrans As MySqlTransaction + + ' Start a local transaction + myTrans = myConnection.BeginTransaction() + + ' Must assign both transaction object and connection + ' to Command object for a pending local transaction + myCommand.Connection = myConnection + myCommand.Transaction = myTrans + + Try + myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')" + myCommand.ExecuteNonQuery() + myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')" + myCommand.ExecuteNonQuery() + myTrans.Commit() + Console.WriteLine("Success.") + Catch e As Exception + Try + myTrans.Rollback() + Catch ex As MySqlException + If Not myTrans.Connection Is Nothing Then + Console.WriteLine("An exception of type " & ex.GetType().ToString() & _ + " was encountered while attempting to roll back the transaction.") + End If + End Try + + Console.WriteLine("An exception of type " & e.GetType().ToString() & _ + "was encountered while inserting the data.") + Console.WriteLine("Neither record was written to database.") + Finally + myConnection.Close() + End Try + End Sub + + + public void RunSqlTransaction(string myConnString) + { + MySqlConnection myConnection = new MySqlConnection(myConnString); + myConnection.Open(); + + MySqlCommand myCommand = myConnection.CreateCommand(); + MySqlTransaction myTrans; + + // Start a local transaction + myTrans = myConnection.BeginTransaction(); + // Must assign both transaction object and connection + // to Command object for a pending local transaction + myCommand.Connection = myConnection; + myCommand.Transaction = myTrans; + + try + { + myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')"; + myCommand.ExecuteNonQuery(); + myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')"; + myCommand.ExecuteNonQuery(); + myTrans.Commit(); + Console.WriteLine("Both records are written to database."); + } + catch(Exception e) + { + try + { + myTrans.Rollback(); + } + catch (MySqlException ex) + { + if (myTrans.Connection != null) + { + Console.WriteLine("An exception of type " + ex.GetType() + + " was encountered while attempting to roll back the transaction."); + } + } + + Console.WriteLine("An exception of type " + e.GetType() + + " was encountered while inserting the data."); + Console.WriteLine("Neither record was written to database."); + } + finally + { + myConnection.Close(); + } + } + + + + + + DNS resolver that runs queries against a server. + + + + + Initializes a new instance of the class. + + + + + Gets the DNS SVR records of the service name that is provided. + + A list of s sorted as described in RFC2782. + + + + Sorts a list of DNS SRV records according to the sorting rules described in RFC2782. + + List of s to sort. + A new list of sorted s. + + + + Resets the DnsSrvResolver + + + + + Class that represents a DNS SRV record. + RFC 2782 (https://tools.ietf.org/html/rfc2782) + + + + + Gets the port. + + + + + Gets the priority. + + + + + Gets the target domain name. + + + + + Gets the weight. + + + + + Initializes a new instance of class. + + The port. + The priority. + The target. + The weight. + + + + Initializes a new instance of class. + + The DNS SRV record. + + + + Compare two objects. First, using their priority and + if both have the same, then using their weights. + + A to compare. + A to compare. + + + + + Initializes a new instance of the class from a . + + The DNS SRV record. + + + + This class is modeled after .NET Stopwatch. It provides better + performance (no system calls).It is however less precise than + .NET Stopwatch, measuring in milliseconds. It is adequate to use + when high-precision is not required (e.g for measuring IO timeouts), + but not for other tasks. + + + + + Wrapper around NetworkStream. + + MyNetworkStream is equivalent to NetworkStream, except + 1. It throws TimeoutException if read or write timeout occurs, instead + of IOException, to match behavior of other streams (named pipe and + shared memory). This property comes handy in TimedStream. + + 2. It implements workarounds for WSAEWOULDBLOCK errors, that can start + occuring after stream has times out. For a discussion about the CLR bug, + refer to http://tinyurl.com/lhgpyf. This error should never occur, as + we're not using asynchronous operations, but apparerntly it does occur + directly after timeout has expired. + The workaround is hinted in the URL above and implemented like this: + For each IO operation, if it throws WSAEWOULDBLOCK, we explicitely set + the socket to Blocking and retry the operation once again. + + + + + Set keepalive + timeout on socket. + + socket + keepalive timeout, in seconds + + + + Static class to manage SSH connections created with SSH .NET. + + + + + Gets or sets the SSH client initialized when calling the method. + + + + + Stores a list of SSH clients having different connection settings. + + + + + Removes the MySQL unsupported encryptions (SSH Ciphers), MACs and key exchange algorithms. + + The instance containing the list of supported elements. + See https://confluence.oraclecorp.com/confluence/display/GPS/Approved+Security+Technologies%3A+Standards+-+SSH+Ciphers+and+Versions for an updated list. + + + + Initializes an instance if no SSH client with similar connection options has already been initialized. + + The SSH host name. + The SSH user name. + The SSH password. + The SSH key file. + The SSH pass phrase. + The SSH port. + The local host name. + The local port number. + Flag to indicate if the connection will be created for the classic or X Protocol. + + + + + Raises warning messages if the SSH client is using a deprecated encryption, MAC or key exchanged algorithm. + + The instance containing the + encryption, MAC algorithm and key exchange algorithm currently being used. + + + + Read a single quoted identifier from the stream + + + + + + + Helper class to encapsulate shared memory functionality + Also cares of proper cleanup of file mapping object and cew + + + + + Summary description for SharedMemoryStream. + + + + + By creating a private ctor, we keep the compiler from creating a default ctor + + + + + Mark - or + signs that are unary ops as no output + + + + + + Wrapper class used for handling SSH connections. + + + + + Starts the SSH client. + + + + + Stops the SSH client. + + + + + Handles SSL connections for the Classic and X protocols. + + + + + Contains the connection options provided by the user. + + + + + A flag to establish how certificates are to be treated and validated. + + + + + Defines the supported TLS protocols. + + + + + Retrieves a collection containing the client SSL PFX certificates. + + Dependent on connection string settings. + Either file or store based certificates are used. + + + + Initiates the SSL connection. + + The base stream. + The encoding used in the SSL connection. + The connection string used to establish the connection. + A instance ready to initiate an SSL connection. + + + + Verifies the SSL certificates used for authentication. + + An object that contains state information for this validation. + The MySQL server certificate used to authenticate the remote party. + The chain of certificate authorities associated with the remote certificate. + One or more errors associated with the remote certificate. + true if no errors were found based on the selected SSL mode; false, otherwise. + + + + Gets the extension of the specified file. + + The path of the file. + Flag to indicate if the result should be converted to lower case. + The . character is ommited from the result. + + + + + Summary description for StreamCreator. + + + + + Set the keepalive timeout on the socket. + + The socket object. + The keepalive timeout, in seconds. + + + + Summary description for Version. + + + + + Provides functionality to read SSL PEM certificates and to perform multiple validations via Bouncy Castle. + + + + + Raises an exception if the specified connection option is null, empty or whitespace. + + The connection option to verify. + + + + Reads the specified file as a byte array. + + The path of the file to read. + A byte array representing the read file. + + + + Reads the SSL certificate file. + + The path to the certificate file. + A instance representing the SSL certificate file. + + + + Reads the SSL certificate key file. + + The path to the certificate key file. + A instance representing the SSL certificate key file. + + + + Verifies that the certificate has not yet expired. + + The certificate to verify. + + + + Verifies a certificate CA status. + + The certificate to validate. + A flag indicating the expected CA status. + + + + Verifies that the certificate was signed using the private key that corresponds to the specified public key + + The client side certificate containing the public key. + The server certificate. + + + + Verifies that no SSL policy errors regarding the identitfy of the host were raised. + + A instance set with the raised SSL errors. + + + + Verifies that the issuer matches the CA by comparing the CA certificate issuer and the server certificate issuer. + + The CA certificate. + The server certificate. + + + + + Gets and sets the host list. + + + + + Gets the active host. + + + + + Active host. + + + + + Sets the initial active host. + + + + + Determines the next host. + + object that represents the next available host. + + + + Implements common elements that allow to manage the hosts available for client side failover. + + + + + Gets and sets the failover group which consists of a host list. + + + + + Resets the manager. + + + + + Sets the host list to be used during failover operations. + + The host list. + The failover method. + + + + Attempts to establish a connection to a host specified from the list. + + The original connection string set by the user. + An out parameter that stores the updated connection string. + A object in case this is a pooling scenario. + An instance if the connection was succesfully established, a exception is thrown otherwise. + + + + + Creates a if more than one host is found. + + A string containing an unparsed list of hosts. + true if the connection is X Protocol; otherwise false. + true if the connection data is a URI; otherwise false. + The number of hosts found, -1 if an error was raised during parsing. + + + + Creates a object based on the provided parameters. + + The host string that can be a simple host name or a host name and port. + The priority of the host. + The port number of the host. + true if the connection data is a URI; otherwise false. + + + + + Attempts the next host in the list. Moves to the first element if the end of the list is reached. + + + + + Determines the next host on which to attempt a connection by checking the value of the Priority property in descending order. + + + + + Determines the next host on which to attempt a connection randomly. + + + + + Depicts a host which can be failed over to. + + + + + Gets and sets the name or address of the host. + + + + + Gets and sets the port number. + + + + + Gets a value between 0 and 100 which represents the priority of the host. + + + + + Flag to indicate if this host is currently being used. + + + + + Flag to indicate if this host has been attempted to connection. + + + + + Time since the host has been demoted. + + + + + Initializes a object. + + The host. + The port. + The priority. + + + + Compares two objects of type . + + FailoverServer object to compare. + True if host properties are the same. Otherwise, false. + + + + Manages the hosts available for client side failover using the Random Failover method. + The Random Failover method attempts to connect to the hosts specified in the list randomly until all the hosts have been attempted. + + + + + The initial host taken from the list. + + + + + The host for the current connection attempt. + + + + + Random object to get the next host. + + + + + Sets the initial active host. + + + + + Determines the next host. + + A object that represents the next available host. + + + + Manages the hosts available for client side failover using the Sequential Failover method. + The Sequential Failover method attempts to connect to the hosts specified in the list one after another until the initial host is reached. + + + + + The initial host taken from the list. + + + + + The index of the current host. + + + + + The host for the current connection attempt. + + + + + Sets the initial active host. + + + + + Determines the next host. + + A object that represents the next available host. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Looks up a localized string similar to Improper MySqlCommandBuilder state: adapter is null. + + + + + Looks up a localized string similar to Improper MySqlCommandBuilder state: adapter's SelectCommand is null. + + + + + Looks up a localized string similar to Invalid attempt to access a field before calling Read(). + + + + + Looks up a localized string similar to Authentication to host '{0}' for user '{1}' using method '{2}' failed with message: {3}. + + + + + Looks up a localized string similar to Authentication method '{0}' not supported by any of the available plugins.. + + + + + Looks up a localized string similar to Version string not in acceptable format. + + + + + Looks up a localized string similar to The buffer cannot be null. + + + + + Looks up a localized string similar to Buffer is not large enough. + + + + + Looks up a localized string similar to Canceling an executing query requires MySQL 5.0 or higher.. + + + + + Looks up a localized string similar to Canceling an active query is only supported on MySQL 5.0.0 and above. . + + + + + Looks up a localized string similar to Parameters can only be derived for commands using the StoredProcedure command type.. + + + + + Looks up a localized string similar to MySqlCommandBuilder does not support multi-table statements. + + + + + Looks up a localized string similar to MySqlCommandBuilder cannot operate on tables with no unique or key columns. + + + + + Looks up a localized string similar to Chaos isolation level is not supported . + + + + + Looks up a localized string similar to The CommandText property has not been properly initialized.. + + + + + Looks up a localized string similar to Compression is not supported.. + + + + + Looks up a localized string similar to The connection is already open.. + + + + + Looks up a localized string similar to Connection unexpectedly terminated.. + + + + + Looks up a localized string similar to Connection must be valid and open. + + + + + Looks up a localized string similar to The connection is not open.. + + + + + Looks up a localized string similar to The connection property has not been set or is null.. + + + + + Looks up a localized string similar to Could not find specified column in results: {0}. + + + + + Looks up a localized string similar to Count cannot be negative. + + + + + Looks up a localized string similar to SetLength is not a valid operation on CompressedStream. + + + + + Looks up a localized string similar to The given value was not in a supported format.. + + + + + Looks up a localized string similar to There is already an open DataReader associated with this Connection which must be closed first.. + + + + + Looks up a localized string similar to The default connection encoding was not found. Please report this as a bug along with your connection string and system details.. + + + + + Looks up a localized string similar to The {0} algorithm being used by the server({1}) has been deprecated and will be removed in a future version. It is recommended that you configure the server to use a non-deprecated {0} algorithm.. + + + + + Looks up a localized string similar to MySQL Connector/NET does not currently support distributed transactions.. + + + + + Looks up a localized string similar to Specifying multiple host names with DNS SRV lookup is not permitted.. + + + + + Looks up a localized string similar to Specifying a port number with DNS SRV lookup is not permitted.. + + + + + Looks up a localized string similar to Using Unix domain sockets with DNS SRV lookup is not permitted.. + + + + + Looks up a localized string similar to Unable to locate any hosts for {0}.. + + + + + Looks up a localized string similar to Connection option '{0}' is duplicated.. + + + + + Looks up a localized string similar to SSL connection option '{0}' is duplicated.. + + + + + Looks up a localized string similar to Encoding error during validation.. + + + + + Looks up a localized string similar to Error creating socket connection. + + + + + Looks up a localized string similar to Verify that user '{0}'@'{1}' has enough privileges to execute.. + + + + + Looks up a localized string similar to Fatal error encountered during command execution.. + + + + + Looks up a localized string similar to Fatal error encountered during data read.. + + + + + Looks up a localized string similar to Fatal error encountered attempting to read the resultset.. + + + + + Looks up a localized string similar to File based certificates are only supported when connecting to MySQL Server 5.1 or greater.. + + + + + Looks up a localized string similar to The specified file cannot be converted to a certificate.. + + + + + Looks up a localized string similar to The specified file cannot be converted to a key.. + + + + + Looks up a localized string similar to Failed to read file at the specified location.. + + + + + Looks up a localized string similar to No file path has been provided for the connection option {0}.. + + + + + Looks up a localized string similar to From index and length use more bytes than from contains. + + + + + Looks up a localized string similar to From index must be a valid index inside the from buffer. + + + + + Looks up a localized string similar to Call to GetHostEntry failed after {0} while querying for hostname '{1}': SocketErrorCode={2}, ErrorCode={3}, NativeErrorCode={4}.. + + + + + Looks up a localized string similar to Retrieving procedure metadata for {0} from server.. + + + + + Looks up a localized string similar to Value has an unsupported format.. + + + + + Looks up a localized string similar to An incorrect response was received from the server.. + + + + + Looks up a localized string similar to Index and length use more bytes than to has room for. + + + + + Looks up a localized string similar to Index must be a valid position in the buffer. + + + + + Looks up a localized string similar to The provided key is invalid.. + + + + + Looks up a localized string similar to You have specified an invalid column ordinal.. + + + + + Looks up a localized string similar to The requested value '{0}' is invalid for the given keyword '{1}'.. + + + + + Looks up a localized string similar to The host name or IP address is invalid.. + + + + + Looks up a localized string similar to Microsecond must be a value between 0 and 999999.. + + + + + Looks up a localized string similar to Millisecond must be a value between 0 and 999. For more precision use Microsecond.. + + + + + Looks up a localized string similar to No other SSL options are accepted when SSL Mode is set to None.. + + + + + Looks up a localized string similar to Procedure or function '{0}' cannot be found in database '{1}'.. + + + + + Looks up a localized string similar to The certificate is invalid.. + + + + + Looks up a localized string similar to Unable to validate the signature.. + + + + + Looks up a localized string similar to Unable to verify the signature.. + + + + + Looks up a localized string similar to Value '{0}' is not of the correct type.. + + + + + Looks up a localized string similar to Option "tls-version" can not be specified when SSL connections are disabled.. + + + + + Looks up a localized string similar to '{0}' not recognized as a valid TLS protocol version (should be one of TLSv1, TLSv1.1, TLSv1.2{1}).. + + + + + Looks up a localized string similar to '{0}' is an illegal value for a boolean option.. + + + + + Looks up a localized string similar to Keyword does not allow null values.. + + + + + Looks up a localized string similar to Option not supported.. + + + + + Looks up a localized string similar to ACCESSIBLE + ADD + ALL + ALTER + ANALYZE + AND + AS + ASC + ASENSITIVE + BEFORE + BEGIN + BETWEEN + BIGINT + BINARY + BLOB + BOTH + BY + CALL + CASCADE + CASE + CHANGE + CHAR + CHARACTER + CHECK + COLLATE + COLUMN + COMMIT + CONDITION + CONNECTION + CONSTRAINT + CONTINUE + CONVERT + CREATE + CROSS + CURRENT_DATE + CURRENT_TIME + CURRENT_TIMESTAMP + CURRENT_USER + CURSOR + DATABASE + DATABASES + DAY_HOUR + DAY_MICROSECOND + DAY_MINUTE + DAY_SECOND + DEC + DECIMAL + DECLARE + DEFAULT + DELAYED + DELETE + DESC + DESCRIBE + DETERMINISTIC + DISTINCT + DISTINCTROW + DIV + DO + DOUBLE + DROP + DUAL + EACH + ELSE + ELSEIF + ENCLOSED + END + ESC [rest of string was truncated]";. + + + + + Looks up a localized string similar to Server asked for stream in response to LOAD DATA LOCAL INFILE, but the functionality is disabled by the client setting 'allowlocalinfile' to 'false'.. + + + + + Looks up a localized string similar to Mixing named and unnamed parameters is not allowed.. + + + + + Looks up a localized string similar to INTERNAL ERROR: More than one output parameter row detected.. + + + + + Looks up a localized string similar to Multiple simultaneous connections or connections with different connection strings inside the same transaction are not currently supported.. + + + + + Looks up a localized string similar to NamedPipeStream does not support seeking. + + + + + Looks up a localized string similar to NamedPipeStream doesn't support SetLength. + + + + + Looks up a localized string similar to The new value must be a MySqlParameter object.. + + + + + Looks up a localized string similar to Invalid attempt to call NextResult when the reader is closed.. + + + + + Looks up a localized string similar to When calling stored procedures and 'Use Procedure Bodies' is false, all parameters must have their type explicitly set.. + + + + + Looks up a localized string similar to Nested transactions are not supported.. + + + + + Looks up a localized string similar to The host {0} does not support SSL connections.. + + + + + Looks up a localized string similar to Unix sockets are not supported on Windows.. + + + + + Looks up a localized string similar to Cannot retrieve Windows identity for current user. Connections that use IntegratedSecurity cannot be pooled. Use either 'ConnectionReset=true' or 'Pooling=false' in the connection string to fix.. + + + + + Looks up a localized string similar to The object is not open or has been disposed.. + + + + + Looks up a localized string similar to Offset cannot be negative. + + + + + Looks up a localized string similar to Offset must be a valid position in buffer. + + + + + Looks up a localized string similar to Authentication with old password no longer supported, use 4.1 style passwords.. + + + + + Looks up a localized string similar to The option '{0}' is not currently supported.. + + + + + Looks up a localized string similar to Parameter '{0}' has already been defined.. + + + + + Looks up a localized string similar to Parameter cannot have a negative value. + + + + + Looks up a localized string similar to Parameter cannot be null. + + + + + Looks up a localized string similar to Parameter '{0}' can't be null or empty.. + + + + + Looks up a localized string similar to Parameter index was not found in Parameter Collection.. + + + + + Looks up a localized string similar to Parameter is invalid.. + + + + + Looks up a localized string similar to Parameter '{0}' must be defined.. + + + + + Looks up a localized string similar to Parameter '{0}' was not found during prepare.. + + + + + Looks up a localized string similar to Parameter can't be null or empty.. + + + + + Looks up a localized string similar to Password must be valid and contain length characters. + + + + + Looks up a localized string similar to This category includes a series of counters for MySQL. + + + + + Looks up a localized string similar to .NET Data Provider for MySQL. + + + + + Looks up a localized string similar to The number of times a procedures metadata had to be queried from the server.. + + + + + Looks up a localized string similar to Hard Procedure Queries. + + + + + Looks up a localized string similar to The number of times a procedures metadata was retrieved from the client-side cache.. + + + + + Looks up a localized string similar to Soft Procedure Queries. + + + + + Looks up a localized string similar to same name are not supported.. + + + + + Looks up a localized string similar to Packets larger than max_allowed_packet are not allowed.. + + + + + Looks up a localized string similar to Reading from the stream has failed.. + + + + + Looks up a localized string similar to Invalid attempt to read a prior column using SequentialAccess. + + + + + Looks up a localized string similar to Replicated connections allow only readonly statements.. + + + + + Looks up a localized string similar to Attempt to connect to '{0}' server failed.. + + + + + Looks up a localized string similar to No available server found.. + + + + + Looks up a localized string similar to Replication group '{0}' not found.. + + + + + Looks up a localized string similar to Replicated server not found: '{0}'. + + + + + Looks up a localized string similar to Routine '{0}' cannot be found. Either check the spelling or make sure you have sufficient rights to execute the routine.. + + + + + Looks up a localized string similar to Attempt to call stored function '{0}' without specifying a return parameter. + + + + + Looks up a localized string similar to Retrieval of the RSA public key is not enabled for insecure connections.. + + + + + Looks up a localized string similar to Connector/NET no longer supports server versions prior to 5.0. + + + + + Looks up a localized string similar to Snapshot isolation level is not supported.. + + + + + Looks up a localized string similar to Socket streams do not support seeking. + + + + + Looks up a localized string similar to Retrieving procedure metadata for {0} from procedure cache.. + + + + + Looks up a localized string similar to Stored procedures are not supported on this version of MySQL. + + + + + Looks up a localized string similar to The SSH Key File and/or SSH Password must be provided.. + + + + + Looks up a localized string similar to The provided passphrase is invalid.. + + + + + Looks up a localized string similar to The certificate authority (CA) does not match.. + + + + + Looks up a localized string similar to The host name does not match the name on the certificate.. + + + + + Looks up a localized string similar to The certificate is not a certificate authority (CA).. + + + + + Looks up a localized string similar to SSL Connection error.. + + + + + Looks up a localized string similar to The stream has already been closed. + + + + + Looks up a localized string similar to The stream does not support reading. + + + + + Looks up a localized string similar to The stream does not support writing. + + + + + Looks up a localized string similar to String can't be empty.. + + + + + Looks up a localized string similar to Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.. + + + + + Looks up a localized string similar to error connecting: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.. + + + + + Looks up a localized string similar to All server connection attempts were aborted. Timeout of {0} seconds was exceeded for each selected server.. + + + + + Looks up a localized string similar to TLSv1.3 is supported in .NET Framework 4.8 or .NET Core 3.0.. + + + + + Looks up a localized string similar to No supported TLS protocol version found in the 'tls-versions' list.. + + + + + Looks up a localized string similar to {0}: Connection Closed. + + + + + Looks up a localized string similar to Unable to trace. There are more than Int32.MaxValue connections in use.. + + + + + Looks up a localized string similar to {0}: Error encountered during row fetch. Number = {1}, Message={2}. + + + + + Looks up a localized string similar to {0}: Connection Opened: connection string = '{1}'. + + + + + Looks up a localized string similar to {0}: Error encountered attempting to open result: Number={1}, Message={2}. + + + + + Looks up a localized string similar to {0}: Query Closed. + + + + + Looks up a localized string similar to {0}: Query Normalized: {2}. + + + + + Looks up a localized string similar to {0}: Query Opened: {2}. + + + + + Looks up a localized string similar to {0}: Resultset Opened: field(s) = {1}, affected rows = {2}, inserted id = {3}. + + + + + Looks up a localized string similar to {0}: Resultset Closed. Total rows={1}, skipped rows={2}, size (bytes)={3}. + + + + + Looks up a localized string similar to {0}: Set Database: {1}. + + + + + Looks up a localized string similar to {0}: Statement closed: statement id = {1}. + + + + + Looks up a localized string similar to {0}: Statement executed: statement id = {1}. + + + + + Looks up a localized string similar to {0}: Statement prepared: sql='{1}', statement id={2}. + + + + + Looks up a localized string similar to {0}: Usage Advisor Warning: Query is using a bad index. + + + + + Looks up a localized string similar to {0}: Usage Advisor Warning: The field '{2}' was converted to the following types: {3}. + + + + + Looks up a localized string similar to {0}: Usage Advisor Warning: Query does not use an index. + + + + + Looks up a localized string similar to {0}: Usage Advisor Warning: The following columns were not accessed: {2}. + + + + + Looks up a localized string similar to {0}: Usage Advisor Warning: Skipped {2} rows. Consider a more focused query.. + + + + + Looks up a localized string similar to {0}: MySql Warning: Level={1}, Code={2}, Message={3}. + + + + + Looks up a localized string similar to Type '{0}' is not derived from BaseCommandInterceptor. + + + + + Looks up a localized string similar to Type '{0}' is not derived from BaseExceptionInterceptor. + + + + + Looks up a localized string similar to Unable to connect to any of the specified MySQL hosts.. + + + + + Looks up a localized string similar to Unable to create plugin for authentication method '{0}'. Please see inner exception for details.. + + + + + Looks up a localized string similar to Unable to derive stored routine parameters. The 'Parameters' information schema table is not available and access to the stored procedure body has been disabled.. + + + + + Looks up a localized string similar to Unable to enable query analysis. Be sure the MySql.Data.EMTrace assembly is properly located and registered.. + + + + + Looks up a localized string similar to An error occured attempting to enumerate the user-defined functions. Do you have SELECT privileges on the mysql.func table?. + + + + + Looks up a localized string similar to Unable to execute stored procedure '{0}'.. + + + + + Looks up a localized string similar to There was an error parsing the foreign key definition.. + + + + + Looks up a localized string similar to Error encountered reading the RSA public key.. + + + + + Looks up a localized string similar to Unable to retrieve stored procedure metadata for routine '{0}'. Either grant SELECT privilege to mysql.proc for this user or use "check parameters=false" with your connection string.. + + + + + Looks up a localized string similar to Unable to start a second async operation while one is running.. + + + + + Looks up a localized string similar to Unix sockets are not supported on Windows. + + + + + Looks up a localized string similar to Unknown authentication method '{0}' was requested.. + + + + + Looks up a localized string similar to Unknown connection protocol. + + + + + Looks up a localized string similar to Value '{0}' is not of the correct type.. + + + + + Looks up a localized string similar to The requested column value could not be treated as or conveted to a Guid.. + + + + + Looks up a localized string similar to Windows authentication connections are not supported on {0}. + + + + + Looks up a localized string similar to Writing to the stream failed.. + + + + + Looks up a localized string similar to Parameter '{0}' is not found but a parameter with the name '{1}' is found. Parameter names must include the leading parameter marker.. + + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Looks up a localized string similar to Appdata path is not defined.. + + + + + Looks up a localized string similar to Authentication failed using MYSQL41 and SHA256_MEMORY. Check the user name and password or try using a secure connection.. + + + + + Looks up a localized string similar to You can't get more sessions because Client is closed.. + + + + + Looks up a localized string similar to Client option '{0}' does not support value '{1}'.. + + + + + Looks up a localized string similar to Client option '{0}' is not recognized as valid.. + + + + + Looks up a localized string similar to {0} '{1}' does not exist in schema '{2}'.. + + + + + Looks up a localized string similar to '{0}' cannot be set to false with DNS SRV lookup enabled.. + + + + + Looks up a localized string similar to Scheme '{0}' is not valid.. + + + + + + Looks up a localized string similar to Compression using {0} is not supported.. + + + + + Looks up a localized string similar to Failed to load libzstd.dll. Removing zstd_stream from the client supported compression algorithms.. + + + + + Looks up a localized string similar to Compression using {0} is not supported in .NET Framework.. + + + + + Looks up a localized string similar to The connection property 'compression' acceptable values are: 'preferred', 'required' or 'disabled'. The value '{0}' is not acceptable.. + + + + + Looks up a localized string similar to Compression is not enabled.. + + + + + Looks up a localized string similar to Compression requested but the server does not support it.. + + + + + Looks up a localized string similar to There are still decompressed messages pending to be processed.. + + + + + Looks up a localized string similar to Duplicate key '{0}' used in "connection-attributes".. + + + + + Looks up a localized string similar to Key name in connection attribute cannot be an empty string.. + + + + + Looks up a localized string similar to At least one option must be specified.. + + + + + Looks up a localized string similar to This feature is currently not supported.. + + + + + Looks up a localized string similar to This functionality is only supported in MySQL {0} and higher.. + + + + + Looks up a localized string similar to Collation with id '{0}' not found.. + + + + + Looks up a localized string similar to The value of "connection-attributes" must be either a boolean or a list of key-value pairs.. + + + + + Looks up a localized string similar to Connection Data is incorrect.. + + + + + Looks up a localized string similar to The connection string is invalid.. + + + + + Looks up a localized string similar to '{0}' is not a valid connection string attribute.. + + + + + Looks up a localized string similar to The connection timeout value must be a positive integer (including 0).. + + + + + Looks up a localized string similar to Decimal (BCD) format is invalid.. + + + + + Looks up a localized string similar to Field type with name '{0}' not found.. + + + + + Looks up a localized string similar to Index type with name '{0}' not found.. + + + + + Looks up a localized string similar to The value provided is not a valid JSON document. {0}. + + + + + Looks up a localized string similar to {0} is not a valid column name in the row.. + + + + + Looks up a localized string similar to {0} is not a valid index for the row.. + + + + + Looks up a localized string similar to Session state is not valid.. + + + + + Looks up a localized string similar to Invalid Uri . + + + + + Looks up a localized string similar to Invalid uri query value. + + + + + Looks up a localized string similar to Key names in "connection-attributes" cannot start with "_".. + + + + + Looks up a localized string similar to Json configuration must contain 'uri' or 'host' but not both.. + + + + + Looks up a localized string similar to Keyword '{0}' not found.. + + + + + Looks up a localized string similar to Keyword not supported.. + + + + + Looks up a localized string similar to Field '{0}' is mandatory.. + + + + + Looks up a localized string similar to Missed required 'schema' option.. + + + + + Looks up a localized string similar to More than one document id was generated. Please use the DocumentIds property instead.. + + + + + Looks up a localized string similar to There is no data at index {0}. + + + + + Looks up a localized string similar to No 'host' has been specified.. + + + + + Looks up a localized string similar to No more data in resultset.. + + + + + Looks up a localized string similar to Object '{0}' not found. + + + + + Looks up a localized string similar to No placeholders.. + + + + + Looks up a localized string similar to {0} must be a value greater than 0.. + + + + + Looks up a localized string similar to Path not found '{0}'.. + + + + + Looks up a localized string similar to Queue timeout expired. The timeout period elapsed prior to getting a session from the pool.. + + + + + Looks up a localized string similar to Providing a port number as part of the host address isn't supported when using connection strings in basic format or anonymous objects. Use URI format instead.. + + + + + Looks up a localized string similar to You must either assign no priority to any of the hosts or give a priority for every host.. + + + + + Looks up a localized string similar to The priority must be between 0 and 100.. + + + + + Looks up a localized string similar to ProgramData path is not defined.. + + + + + Looks up a localized string similar to The server doesn't support the requested operation. Please update the MySQL Server and/or Client library. + + + + + Looks up a localized string similar to The process of closing the resultset and resulted in results being lost.. + + + + + Looks up a localized string similar to All server connection attempts were aborted. Timeout of {0} milliseconds was exceeded for each selected server.. + + + + + Looks up a localized string similar to All server connection attempts were aborted. Timeout was exceeded for each selected server.. + + + + + Looks up a localized string similar to Connection attempt to the server was aborted. Timeout of {0} milliseconds was exceeded.. + + + + + Looks up a localized string similar to Connection attempt to the server was aborted. Timeout was exceeded.. + + + + + Looks up a localized string similar to Unable to connect to any specified host.. + + + + + Looks up a localized string similar to Unable to read or decode data value.. + + + + + Looks up a localized string similar to Unable to open a session.. + + + + + Looks up a localized string similar to Unexpected end of packet found while reading data values. + + + + + Looks up a localized string similar to Field name '{0}' is not allowed.. + + + + + Looks up a localized string similar to Unknown placeholder :{0}. + + + + + Looks up a localized string similar to Value '{0}' is not of the correct type.. + + + + + Summary description for MySqlUInt64. + + + + + An exception thrown by MySQL when a type conversion does not succeed. + + + + Initializes a new instance of the class with a specified error message. + Message describing the error. + + + + Represents a datetime data type object in a MySql database. + + + + + Defines whether the UTF or local timezone will be used. + + + + + Constructs a new MySqlDateTime object by setting the individual time properties to + the given values. + + The year to use. + The month to use. + The day to use. + The hour to use. + The minute to use. + The second to use. + The microsecond to use. + + + + Constructs a new MySqlDateTime object by using values from the given object. + + The object to copy. + + + + Constructs a new MySqlDateTime object by copying the current value of the given object. + + The MySqlDateTime object to copy. + + + + Enables the contruction of a MySqlDateTime object by parsing a string. + + + + + Indicates if this object contains a value that can be represented as a DateTime + + + + Returns the year portion of this datetime + + + Returns the month portion of this datetime + + + Returns the day portion of this datetime + + + Returns the hour portion of this datetime + + + Returns the minute portion of this datetime + + + Returns the second portion of this datetime + + + + Returns the milliseconds portion of this datetime + expressed as a value between 0 and 999 + + + + + Returns the microseconds portion of this datetime (6 digit precision) + + + + + Returns true if this datetime object has a null value + + + + + Retrieves the value of this as a DateTime object. + + + + Returns this value as a DateTime + + + Returns a MySQL specific string representation of this value + + + + + + + + + Represents a decimal data type object in a MySql database. + + + + + Gets a boolean value signaling if the type is null. + + + + + Gets or sets the decimal precision of the type. + + + + + Gets or sets the scale of the type. + + + + + Gets the decimal value associated to this type. + + + + + Converts this decimal value to a double value. + + The value of this type converted to a dobule value. + + + + Represents a geometry data type object in a MySql database. + + + + + Gets the x coordinate. + + + + + Gets the y coordinate. + + + + + Gets the SRID value. + + + + + Gets a boolean value that signals if the type is null. + + + + + Gets the value associated to this type. + + + + + Gets the value associated to this type. + + + + Returns the Well-Known Text representation of this value + POINT({0} {1})", longitude, latitude + http://dev.mysql.com/doc/refman/4.1/en/gis-wkt-format.html + + + + Get value from WKT format + SRID=0;POINT (x y) or POINT (x y) + + WKT string format + + + + Try to get value from WKT format + SRID=0;POINT (x y) or POINT (x y) + + WKT string format + Out mysqlGeometryValue + + + + Sets the DSInfo when GetSchema is called for the DataSourceInformation collection. + + + + + Gets the well-known text representation of the geomtry object. + + A string representation of the WKT. + + + + Provides functionality for loading unmanaged libraries. + + + + + Loads the specified unmanaged library from the embedded resources. + + The application name. + The library name. + + + + Provides support for configuring X Protocol compressed messages. + + + + + The capabilities sub-key used to specify the compression algorithm. + + + + + The capabilities key used to specify the compression capability. + + + + + Messages with a value lower than this threshold will not be compressed. + + + + + Default value for enabling or disabling combined compressed messages. + + + + + Default value for the maximum number of combined compressed messages contained in a compression message. + + + + + deflate_stream compression algorithm. + + + + + lz4_message compression algorithm. + + + + + The capabilities sub-key used to specify if combining compressed messages is permitted. + + + + + The capabilities sub-key used to specify the maximum number of compressed messages contained in a compression message. + + + + + zstd_stream compression algorithm. + + + + + Buffer used to store the data received from the server. + + + + + Deflate stream used for compressing data. + + + + + Deflate stream used for decompressing data. + + + + + Flag indicating if the initialization is for compression or decompression. + + + + + Stores the communication packet generated the last time ReadNextBufferedMessage method was called. + + + + + Indicates if the libzstd.dll has been loaded. + + + + + Stream used to store multiple X Protocol messages. + + + + + ZStandard stream used for decompressing data. + + + + + Static constructor used to initialize the client supported compression algorithms. + + + + + Main constructor used to set the compression algorithm and initialize the list of messages to + be compressed by the client. + + The compression algorithm to use. + Flag indicating if the initialization is for compression or decompression. + + + + Gets or sets the list of messages that should be compressed by the client when compression is enabled. + + + + + Gets or sets an array containing the compression algorithms supported by the client. + + + + + Gets or sets the compression algorithm. + + + + + Flag indicating if compression is enabled. + + + + + Flag indicating if the last decompressed message contains multiple messages. + + + + + General method used to compress data using the compression algorithm defined in the constructor. + + The data to compress. + A compressed byte array. + + + + Compresses data using the deflate_stream algorithm. + + The data to compress. + A compressed byte array. + + + + Compresses data using the lz4_message algorithm. + + The data to compress. + A compressed byte array. + + + + Compresses data using the zstd_stream algorithm. + + The data to compress. + A compressed byte array. + + + + General method used to decompress data using the compression algorithm defined in the constructor. + + The data to decompress. + The expected length of the decompressed data. + A decompressed byte array. + + + + Decompresses data using the deflate_stream compression algorithm. + + The data to decompress. + The expected length of the decompressed data. + A decompressed byte array. + + + + Decompresses data using the lz4_message compression algorithm. + + The data to decompress. + The expected length of the decompressed data. + A decompressed byte array. + + + + Decompresses data using the zstd_stream compression algorithm. + + The data to decompress. + The expected length of the decompressed data. + A decompressed byte array. + + + + Closes and disposes of any open streams. + + + + + Gets the byte array representing the next X Protocol frame that is stored in cache. + + A byte array representing an X Protocol frame. + + + + Gets a representing the next X Protocol frame that is stored in cache. + + A with the next X Protocol frame. + + + + Loads the libzstd.dll assembly. + + + + + This object store the required parameters to create a Collection with schema validation. + + If false, throws an exception if the collection exists. + Object which hold the Level and Schema parameters + + + + + This object store the required parameters to Modify a Collection with schema validation. + + Object which hold the Level and Schema parameters + + + + + This object store the required parameters to create a Collection with schema validation. + + It can be STRICT to enable schema validation or OFF to disable + The JSON which define the rules to be validated in the collection + + + + The possible values for parameter Level in Validation object. + + Enforce schema validation. + Schema validation disabled. + + + + Implementation of EXTERNAL authentication type. + + + + + Implementation of MySQL41 authentication type. + + + + + Implementation of PLAIN authentication type. + + + + + Compares two Guids in string format. + + The first string to compare. + The first string to compare. + An integer that indicates the lexical relationship between the two comparands, similar to + + + + Compares two objects. + + The first to compare. + The second to compare. + An integer that indicates the lexical relationship between the two comparands, similar to + + + + Constructor that sets the stream used to read or write data. + + The stream used to read or write data. + + + + Constructor that sets the stream used to read or write data and the compression controller. + + The stream used to read or write data. + The compression controller. + + + + Gets or sets the compression controller uses to manage compression operations. + + + + + Writes X Protocol frames to the X Plugin. + + The integer representation of the client message identifier used for the message. + The message to include in the X Protocol frame. + + + + Writes X Protocol frames to the X Plugin. + + The client message identifier used for the message. + The message to include in the X Protocol frame. + + + + Reads X Protocol frames incoming from the X Plugin. + + A instance representing the X Protocol frame that was read. + + + + Abstract class for the protocol base operations in client/server communication. + + + + + Expression parser for MySQL-X protocol. + + + string being parsed. + + + Token stream produced by lexer. + + + Parser's position in token stream. + + + Mapping of names to positions for named placeholders. Used for both string values ":arg" and numeric values ":2". + + + Number of positional placeholders. + + + Are relational columns identifiers allowed? + + + Token types used by the lexer. + + + Token. Includes type and string value of the token. + + + Mapping of reserved words to token types. + + + Does the next character equal the given character? (respects bounds) + + + Helper function to match integer or floating point numbers. This function should be called when the position is on the first character of the number (a + digit or '.'). + + @param i The current position in the string + @return the next position in the string after the number. + + + Lexer for MySQL-X expression language. + + + Assert that the token at pos is of type type. + + + Does the current token have type `t'? + + + Does the next token have type `t'? + + + Does the token at position `pos' have type `t'? + + + Consume token. + + @return the string value of the consumed token + + + Parse a paren-enclosed expression list. This is used for function params or IN params. + + @return a List of expressions + + + Parse a function call of the form: IDENTIFIER PAREN_EXPR_LIST. + + @return an Expr representing the function call. + + + Parse an identifier for a function call: [schema.]name + + + Parse a document path member. + + + Parse a document path array index. + + + Parse a JSON-style document path, like WL#7909, but prefix by @. instead of $. + + + Parse a document field. + + + Parse a column identifier (which may optionally include a JSON document path). + + + Build a unary operator expression. + + + Parse an atomic expression. (c.f. grammar at top) + + + Parse a left-associated binary operator. + + @param types + The token types that denote this operator. + @param innerParser + The inner parser that should be called to parse operands. + @return an expression tree of the binary operator or a single operand + + + Parse the entire string as an expression. + + @return an X-protocol expression tree + + + + Parse an ORDER BY specification which is a comma-separated list of expressions, each may be optionally suffixed by ASC/DESC. + + + Parse a SELECT projection which is a comma-separated list of expressions, each optionally suffixed with a target alias. + + + Parse an INSERT field name. + @todo unit test + + + Parse an UPDATE field which can include can document paths. + + + Parse a document projection which is similar to SELECT but with document paths as the target alias. + + + Parse a list of expressions used for GROUP BY. + + + @return the number of positional placeholders in the expression. + + + @return a mapping of parameter names to positions. + + + Proto-buf helper to build a LITERAL Expr with a Scalar NULL type. + + + Proto-buf helper to build a LITERAL Expr with a Scalar DOUBLE type (wrapped in Any). + + + Proto-buf helper to build a LITERAL Expr with a Scalar SINT (signed int) type (wrapped in Any). + + + Proto-buf helper to build a LITERAL Expr with a Scalar UINT (unsigned int) type (wrapped in Any). + + + Proto-buf helper to build a LITERAL Expr with a Scalar STRING type (wrapped in Any). + + + Proto-buf helper to build a LITERAL Expr with a Scalar OCTETS type (wrapped in Any). + + + Proto-buf helper to build a LITERAL Expr with a Scalar BOOL type (wrapped in Any). + + + Wrap an Any value in a LITERAL expression. + + + Build an Any with a string value. + + + + Parses an anonymous object into a dictionary. + + The object to parse. + A dictionary if the provided object is an anonymous object; otherwise, null. + + + List of operators which will be serialized as infix operators. + + + Scalar to string. + + + JSON document path to string. + + + Column identifier (or JSON path) to string. + + + Function call to string. + + + Create a string from a list of (already stringified) parameters. Surround by parens and separate by commas. + + + Convert an operator to a string. Includes special cases for chosen infix operators (AND, OR) and special forms such as LIKE and BETWEEN. + + + Escape a string literal. + + + Quote a named identifer. + + + Serialize an expression to a string. + + + + Build the message to be sent to MySQL Server to execute statement "Create" or "Modify" collection with schema options + + The namespace + The name of the command to be executed on MySql Server + Array of KeyValuePairs with the parameters required to build the message + void. + + + + Sends the delete documents message + + + + + Sends the CRUD modify message + + + + + Class implementation for a default communication kind. + + + + + Constructor method for the communication routing service + + A MySqlXConnectionStringBuilder setted with the information to use in the connection + + + + Gets the current connection base on the connection mode + + One of the values of ConnectionMode Offline, ReadOnly, WriteOnly, ReadWrite + + + + + Abstract class used to define the kind of server in environments with multiple types of distributed systems. + + + + + Main class for parsing json strings. + + + + + Initializes a new instance of the JsonParser class. + + + + + Parses the received string into a dictionary. + + The string to parse. + A object that represents the parsed string. + + + + Abstract class to manage and encapsulate one or more actual connections. + + + + + Creates a new session object with the values of the settings parameter. + + Settings to be used in the session object + + + + Sets the connection's charset default collation. + + The opened session. + The character set. + + + + Gets the version of the server. + + An instance of containing the server version. + + + + Gets the thread Id of the connection. + + Thread Id + + + + Implementation class for object that manages low-level work of queuing tasks onto threads. + + + + + Implementation class of InternalSession to manage connections using the Xprotocol type object. + + + + + Defines the compression controller that will be passed on the instance when + compression is enabled. + + + + + Defines the compression controller that will be passed on the instance when + compression is enabled. + + + + + The used client to handle SSH connections. + + + + + Negotiates compression capabilities with the server. + + An array containing the compression algorithms supported by the server. + + + + Prepare the dictionary of arguments required to create a MySQL message. + + The name of the MySQL schema. + The name of the collection. + This object hold the parameters required to create the collection. + + Collection referente. + + + + Prepare the dictionary of arguments required to Modify a MySQL message. + + The name of the MySQL schema. + The name of the collection. + This object hold the parameters required to Modify the collection. + + Collection referente. + + + + Gets the compression algorithm being used to compress or decompress data. + + Flag to indicate if the compression algorithm should be + retrieved from the reader or writer controller. + The name of the compression algorithm being used if any. + null if no compression algorithm is being used. + + + + Represents a base class for a Session. + + + + + Flag to set if prepared statements are supported. + + + + + Gets the connection settings for this session. + + + + + Gets the currently active schema. + + + + + Gets the default schema provided when creating the session. + + + + + Gets the connection uri representation of the connection options provided during the creation of the session. + + + + + Initializes a new instance of the BaseSession class based on the specified connection string. + + The connection used to create the session. + is null. + Unable to parse the when + in URI format. + + When using Unix sockets the protocol=unix or protocol=unixsocket connection option is required. + This will enable elements passed in the server connection option to be treated as Unix sockets. The user is also required + to explicitly set sslmode to none since X Plugin does not support SSL when using Unix sockets. Note that + protocol=unix and protocol=unixsocket are synonyms. +   + Multiple hosts can be specified as part of the , + which enables client-side failover when trying to establish a connection. +   + Connection URI examples: + - mysqlx://test:test@[192.1.10.10,localhost] + - mysqlx://test:test@[192.1.10.10,127.0.0.1] + - mysqlx://root:@[../tmp/mysqlx.sock,/tmp/mysqld.sock]?protocol=unix&sslmode=none + - mysqlx://test:test@[192.1.10.10:33060,127.0.0.1:33060] + - mysqlx://test:test@[192.1.10.10,120.0.0.2:22000,[::1]:33060]/test?connectiontimeout=10 + - mysqlx://test:test@[(address=server.example,priority=20),(address=127.0.0.1,priority=100)] + - mysqlx://test:test@[(address=server.example,priority=100),(address=127.0.0.1,priority=75),(address=192.0.10.56,priority=25)] + +   + Connection string examples: + - server=10.10.10.10,localhost;port=33060;uid=test;password=test; + - host=10.10.10.10,192.101.10.2,localhost;port=5202;uid=test;password=test; + - host=./tmp/mysqld.sock,/var/run/mysqldx.sock;port=5202;uid=root;protocol=unix;sslmode=none; + - server=(address=server.example,priority=20),(address=127.0.0.1,priority=100);port=33060;uid=test;password=test; + - server=(address=server.example,priority=100),(address=127.0.0.1,priority=75),(address=192.0.10.56,priority=25);port=33060;uid=test;password=test; + +   + Failover methods + - Sequential: Connection attempts will be performed in a sequential order, that is, one after another until + a connection is successful or all the elements from the list have been tried. + + - Priority based: If a priority is provided, the connection attemps will be performed in descending order, starting + with the host with the highest priority. Priority must be a value between 0 and 100. Additionally, it is required to either + give a priority for every host or no priority to any host. + + + + + + Initializes a new instance of the BaseSession class based on the specified anonymous type object. + + The connection data as an anonymous type used to create the session. + is null. + + Multiple hosts can be specified as part of the , which enables client-side failover when trying to + establish a connection. +   + To assign multiple hosts, create a property similar to the connection string examples shown in + . Note that the value of the property must be a string. + + + + + + Drops the database/schema with the given name. + + The name of the schema. + is null. + + + + Creates a schema/database with the given name. + + The name of the schema/database. + A object that matches the recently created schema/database. + + + + Gets the schema with the given name. + + The name of the schema. + A object set with the provided schema name. + + + + Gets a list of schemas (or databases) in this session. + + A list containing all existing schemas (or databases). + + + + Starts a new transaction. + + + + + Commits the current transaction. + + A object containing the results of the commit operation. + + + + Rolls back the current transaction. + + + + + Closes this session or releases it to the pool. + + + + + Closes this session + + + + + Sets a transaction savepoint with an autogenerated name. + + The autogenerated name of the transaction savepoint. + + + + Sets a named transaction savepoint. + + The name of the transaction savepoint. + The name of the transaction savepoint. + + + + Removes the named savepoint from the set of savepoints within the current transaction. + + The name of the transaction savepoint. + + + + Rolls back a transaction to the named savepoint without terminating the transaction. + + The name of the transaction savepoint. + + + + Parses the connection data. + + The connection string or connection URI. + An updated connection string representation of the provided connection string or connection URI. + + + + Parses a connection URI. + + The connection URI to parse. + The connection string representation of the provided . + + + + Validates if the string provided is a Unix socket file. + + The Unix socket to evaluate. + true if is a valid Unix socket; otherwise, false. + + + + Converts the URI object into a connection string. + + An instance with the values for the provided connection options. + The path of the Unix socket file. + If true the replaces the value for the server connection option; otherwise, false + A connection string. + + + + Parses a connection string. + + The connection string to parse. + The parsed connection string. + + + + Normalizes the Unix socket by removing leading and ending parenthesis as well as removing special characters. + + The Unix socket to normalize. + A normalized Unix socket. + + + + Disposes the current object. Disposes of the managed state if the flag is set to true. + + Flag to indicate if the managed state is to be disposed. + + + + Disposes the current object. Code added to correctly implement the disposable pattern. + + + + + Describes the state of the session. + + + + + The session is closed. + + + + + The session is open. + + + + + The session object is connecting to the data source. + + + + + The session object is executing a command. + + + + + Class encapsulating a session pooling functionality. + + + + + Queue of demoted hosts. + + + + + List of hosts that will be attempted to connect to. + + + + + Timer to be used when a host have been demoted. + + + + + Remove hosts from the demoted list that have already been there for more + than 120,000 milliseconds and add them to the available hosts list. + + + + + Get a session from pool or create a new one. + + + + + + Closes all sessions the Client object created and destroys the managed pool. + + + + + Represents a collection of documents. + + + + + Creates an containing the provided objects that can be used to add + one or more items to a collection. + + The objects to add. + An object containing the objects to add. + is null. + This method can take anonymous objects, domain objects, or just plain JSON strings. + The statement can be further modified before execution. + + + + Creates a with the given condition that can be used to remove + one or more documents from a collection.The statement can then be further modified before execution. + + The condition to match documents. + A object set with the given condition. + is null or white space. + The statement can then be further modified before execution. + + + + Removes the document with the given identifier. + + The unique identifier of the document to replace. + A object containing the results of the execution. + is null or white space. + This is a direct execution method. + + + + Creates a with the given condition that can be used to modify one or more + documents from a collection. + + The condition to match documents. + A object set with the given condition. + is null or white space. + The statement can then be further modified before execution. + + + + Replaces the document matching the given identifier. + + The unique identifier of the document to replace. + The document to replace the matching document. + A object containing the results of the execution. + is null or whitespace. + is null. + This is a direct execution method. Operation succeeds even if no matching document was found; + in which case, the Result.RecordsAffected property is zero. If the new document contains an identifier, the value + is ignored. + + + + Adds the given document to the collection unless the identifier or any other field that has a unique index + already exists, in which case it will update the matching document. + + The unique identifier of the document to replace. + The document to replace the matching document. + A object containing the results of the execution. + The server version is lower than 8.0.3. + is null or white space. + is null. + The is different from the one in . + This is a direct execution method. + + + + Returns the number of documents in this collection on the server. + + The number of documents found. + + + + Creates a with the given condition which can be used to find documents in a + collection. + + An optional condition to match documents. + A object set with the given condition. + The statement can then be further modified before execution. + + + + Creates an index based on the properties provided in the JSON document. + + The index name. + JSON document describing the index to be created. + + is a JSON document with the following fields: + + - fields: array of IndexField objects, each describing a single document member to be + included in the index (see below). + - type: string, (optional) the type of index. One of INDEX or SPATIAL. Default is INDEX and may + be omitted. + +   + A single IndexField description consists of the following fields: + + - field: string, the full document path to the document member or field to be indexed. + - type: string, one of the supported SQL column types to map the field into (see the following list). + For numeric types, the optional UNSIGNED keyword may follow. For the TEXT type, the length to consider for + indexing may be added. + - required: bool, (optional) true if the field is required to exist in the document. defaults to + false, except for GEOJSON where it defaults to true. + - options: int, (optional) special option flags for use when decoding GEOJSON data. + - srid: int, (optional) srid value for use when decoding GEOJSON data. + +   + Supported SQL column types: + + - INT [UNSIGNED] + - TINYINT [UNSIGNED] + - SMALLINT [UNSIGNED] + - MEDIUMINT [UNSIGNED] + - INTEGER [UNSIGNED] + - BIGINT [UNSIGNED] + - REAL [UNSIGNED] + - FLOAT [UNSIGNED] + - DOUBLE [UNSIGNED] + - DECIMAL [UNSIGNED] + - NUMERIC [UNSIGNED] + - DATE + - TIME + - TIMESTAMP + - DATETIME + - TEXT[(length)] + - CHAR[(lenght)] + - GEOJSON (extra options: options, srid) + + + + + + Drops a collection index. + + The index name. + is null or white space. + + + + Verifies if the current collection exists in the server schema. + + true if the collection exists; otherwise, false. + + + + Returns the document with the given identifier. + + The unique identifier of the document to replace. + A object if a document matching given identifier exists; otherwise, null. + is null or white space. + This is a direct execution method. + + + + Base abstract class that defines elements inherited by all result types. + + + + + Gets the number of records affected by the statement that generated this result. + + + + + Gets the object of the session. + + + + + Gets a read-only collection of objects derived from statement execution. + + + + + Gets the number of warnings in the collection derived from statement execution. + + + + + No action is performed by this method. It is intended to be overriden by child classes if required. + + + + + Base abstract class for API statement. + + + + + + Initializes a new instance of the BaseStatement class based on the specified session. + + The session where the statement will be executed. + + + + Gets the that owns the statement. + + + + + Executes the base statements. This method is intended to be defined by child classes. + + A result object containing the details of the execution. + + + + Executes a statement asynchronously. + + A result object containing the details of the execution. + + + + Validates if the session is open and valid. + + + + + Sets the status as Changed for prepared statement validation. + + + + + Converts a statement to prepared statement for a second execution + without any change but Bind, Limit, or Offset. + + + + + Abstract class for buffered results. + + Generic result type. + + + + Index of the current item. + + + + + List of generic items in this buffered result. + + + + + Flag that indicates if all items have been read. + + + + + Gets a dictionary containing the column names and their index. + + + + + Gets the page size set for this buffered result. + + + + + Loads the column data into the field. + + + + + Retrieves a read-only list of the generic items associated to this buffered result. + + A generic list representing items in this buffered result. + + + + Retrieves one element from the generic items associated to this buffered result. + + A generic object that corresponds to the current or default item. + + + + Determines if all items have already been read. + + True if all items have been retrived, false otherwise. + + + + Gets the current item. + + All items have already been read. + + + + Determines if all items have already been read. + + True if all items have been retrived, false otherwise. + + + + Resets the value of the field to zero. + + + + + Gets an representation of this object. + + An representation of this object. + + + + Gets an representation of this object. + + An representation of this object. + + + + Retrieves a read-only list of the generic items associated to this buffered result. + + A generic list representing items in this buffered result. + + + + No body has been defined for this method. + + + + + Class to represent an error in this result. + + + + + Numeric code. + + + + + Return code indicating the outcome of the executed SQL statement. + + + + + Error message. + + + + + Initializes a new instance of the ErrorInfo class. + + + + + Abstract class for filterable statements. + + The filterable statement. + The database object. + The type of result. + + + + Initializes a new instance of the FiltarableStatement class based on the target and condition. + + The database object. + The optional filter condition. + + + + Enables the setting of Where condition for this operation. + + The Where condition. + The implementing statement type. + + + + Sets the number of items to be returned by the operation. + + The number of items to be returned. + The implementing statement type. + is equal or lower than 0. + + + + Sets the number of items to be skipped before including them into the result. + + The number of items to be skipped. + The implementing statement type. + + + + Binds the parameter values in filter expression. + + The parameter name. + The value of the parameter. + A generic object representing the implementing statement type. + + + + Binds the parameter values in filter expression. + + The parameters as a DbDoc object. + A generic object representing the implementing statement type. + + + + Binds the parameter values in filter expression. + + The parameters as a JSON string. + The implementing statement type. + + + + Binds the parameter values in filter expression. + + The parameters as an anonymous object: new { param1 = value1, param2 = value2, ... }. + The implementing statement type. + + + + Executes the statement. + + The function to execute. + The generic object to use. + A generic result object containing the results of the execution. + + + + Clones the filterable data but Session and Target remain the + same. + + A clone of this filterable statement. + + + + Represents a general statement result. + + + + + Gets the last inserted identifier (if there is one) by the statement that generated this result. + + + + + Gets the list of generated identifiers in the order of the Add() calls. + + + + + Abstract class to select a database object target. + + The database object. + The execution result. + + + + Initializes a new instance of the TargetedBaseStatement class based on the provided target. + + The database object. + + + + Gets the database target. + + + + + Represents a warning in this result. + + + + + Numeric value associated to the warning message. + + + + + Error message. + + + + + Strict level for the warning. + + + + + Initializes a new instance of the WarningInfo class based on the code and msg. + + The code for the warning. + The error message for the warning. + + + + Represents a chaining collection insert statement. + + + + + Adds documents to the collection. + + The documents to add. + This object. + The array is null. + + + + Executes the Add statement. + + A object containing the results of the execution. + + + + Implementation class for CRUD statements with collections using an index. + + + + + Executes this statement. + + A object containing the results of the execution. + + + + Represents a collection statement. + + + + + + Converts base s into objects. + + Array of objects to be converted to objects. + An enumerable collection of objects. + + + + Represents the result of an operation that includes a collection of documents. + + + + + Represents a chaining collection find statement. + + + + + List of column projections that shall be returned. + + List of columns. + This object set with the specified columns or fields. + + + + Executes the Find statement. + + A object containing the results of execution and data. + + + + Locks matching rows against updates. + + Optional row lock option to use. + This same object set with the lock shared option. + The server version is lower than 8.0.3. + + + + Locks matching rows so no other transaction can read or write to it. + + Optional row lock option to use. + This same object set with the lock exclusive option. + The server version is lower than 8.0.3. + + + + Sets the collection aggregation. + + The field list for aggregation. + This same object set with the specified group-by criteria. + + + + Filters criteria for aggregated groups. + + The filter criteria for aggregated groups. + This same object set with the specified filter criteria. + + + + Sets user-defined sorting criteria for the operation. The strings use normal SQL syntax like + "order ASC" or "pages DESC, age ASC". + + The order criteria. + A generic object representing the implementing statement type. + + + + Enables the setting of Where condition for this operation. + + The Where condition. + The implementing statement type. + + + + Represents a chaining collection modify statement. + + + + + Sets key and value. + + The document path key. + The new value. + This object. + + + + Changes value for a key. + + The document path key. + The new value. + This object. + + + + Removes keys or values from a document. + + An array of document paths representing the keys to be removed. + This object. + + + + Creates a object set with the changes to be applied to all matching documents. + + The JSON-formatted object describing the set of changes. + A object set with the changes described in . + can be a object, an anonymous object, or a JSON string. + is null. + is null or white space. + + + + Inserts an item into the specified array. + + The document path key including the index on which the item will be inserted. + The value to insert into the array. + A object containing the updated array. + + + + Appends an item to the specified array. + + The document path key. + The value to append to the array. + A object containing the updated array. + + + + Allows the user to set the sorting criteria for the operation. The strings use normal SQL syntax like + "order ASC" or "pages DESC, age ASC". + + The order criteria. + A generic object representing the implementing statement type. + + + + Enables the setting of Where condition for this operation. + + The Where condition. + The implementing statement type. + + + + Executes the modify statement. + + A object containing the results of the execution. + + + + Represents a chaining collection remove statement. + + + + + Sets user-defined sorting criteria for the operation. The strings use normal SQL syntax like + "order ASC" or "pages DESC, age ASC". + + The order criteria. + A generic object representing the implementing statement type. + + + + Enables the setting of Where condition for this operation. + + The Where condition. + The implementing statement type. + + + + Executes the remove statement. + + A object containing the results of the execution. + + + + Represents a database object. + + + + + Gets the session that owns the database object. + + + + + Gets the schema that owns the database object. + + + + + Gets the database object name. + + + + + Verifies that the database object exists in the database. + + True if the object exists in database, false otherwise. + + + + Represents a generic document in JSON format. + + + + + Initializes a new instance of the DbDoc class based on the object provided. The value can be a domain object, anonymous object, or JSON string. + + The value for this DbDoc. + + + + Gets the value of a document property. + + The key path for the property. + + + + + Gets the identifier of the document. + + + + + Gets a value indicating if this document has an identifier (property named _id with a value). + + + + + Sets a property on this document. + + The key of the property. + The new property value. + + + + Returns this document in Json format. + + A Json formatted string. + + + + Compares this DbDoc with another one. + + The DbDoc to compare to. + True if they are equal, false otherwise. + + + + Gets a value that serves as a hash function for a particular type. + + A hash code for the current object. + + + + Represents a collection of documents with a generic type. + + + + + Initializes a new instance of the generic Collection class based on the specified schema + and name. + + The object associated to this collection. + The name of the collection. + + + + Creates an containing the provided generic object. The add + statement can be further modified before execution. + + The generic object to add. + An object containing the object to add. + + + + Defines elements that allow to iterate through the contents of various items. + + + + + Initializes a new instance of the Iterator class. + + + + + This method is not yet implemented. + + + + Exception is always thrown since the body of the method is not yet implemented. + + + + Main class for session operations related to Connector/NET implementation of the X DevAPI. + + + + + Opens a session to the server given or to the first available server if multiple servers were specified. + + The connection string or URI string format. + A object representing the established session. + Multiple hosts can be specified as part of the which + will enable client side failover when trying to establish a connection. For additional details and syntax + examples refer to the remarks section. + + + + Opens a session to the server given. + + The connection data for the server. + A object representing the established session. + + + + Creates a new instance. + + The connection string or URI string format. + The connection options in JSON string format. + A object representing a session pool. + + + + Creates a new instance. + + The connection string or URI string format. + The connection options in object format. + + + new { pooling = new + { + enabled = true, + maxSize = 15, + maxIdleTime = 60000, + queueTimeout = 60000 + } + } + + + + A object representing a session pool. + + + + Creates a new instance. + + The connection data. + The connection options in JSON string format. + A object representing a session pool. + + + + Creates a new instance. + + The connection data. + The connection options in object format. + + + new { pooling = new + { + enabled = true, + maxSize = 15, + maxIdleTime = 60000, + queueTimeout = 60000 + } + } + + + + A object representing a session pool. + + + + Enables the creation of connection strings by exposing the connection options as properties. + Contains connection options specific to the X protocol. + + + + + Main constructor. + + + + + Constructor accepting a connection string. + + The connection string. + + + + Readonly field containing a collection of classic protocol and protocol shared connection options. + + + + + Gets or sets the connection timeout. + + + + + Gets or sets the connection attributes. + + + + + Path to a local file containing certificate revocation lists. + + + + + Gets or sets the compression type between client and server. + + + + + Gets or sets a connection option. + + The keyword that identifies the connection option to modify. + + + + Represents a table column. + + + + + Gets the original column name. + + + + + Gets the alias of the column name. + + + + + Gets the table name the column orginates from. + + + + + Gets the alias of the table name . + + + + + Gets the schema name the column originates from. + + + + + Gets the catalog the schema originates from. + In MySQL protocol this is `def` by default. + + + + + Gets the collation used for this column. + + + + + Gets the character set used for this column. + + + + + Gets the column length. + + + + + Gets the fractional decimal digits for floating point and fixed point numbers. + + + + + Gets the Mysql data type. + + + + + Gets the .NET Clr data type. + + + + + True if it's a signed number. + + + + + True if column is UINT zerofill or BYTES rightpad. + + + + + Initializes a new instance of the Column class. + + + + + Represents a resultset that contains rows of data. + + + + + Gets the columns in this resultset. + + + + + Gets the number of columns in this resultset. + + + + + Gets a list containing the column names in this resultset. + + + + + Gets the rows of this resultset. This collection will be incomplete unless all the rows have been read + either by using the Next method or the Buffer method. + + + + + Gets the value of the column value at the current index. + + The column index. + The CLR value at the column index. + + + + Allows getting the value of the column value at the current index. + + The column index. + The CLR value at the column index. + + + + Returns the index of the given column name. + + The name of the column to find. + The numeric index of column. + + + + Represents a single row of data in a table. + + + + + Gets the value of the row at the given index. + + The column index to retrieve the value. + The value at the index. + + + + Gets the value of the column as a string. + + The name of the column. + The value of the column as a string. + + + + Gets a string based indexer into the row. Returns the value as a CLR type. + + The column index to get. + The CLR value for the column. + + + + Inherits from . Creates a resultset that contains rows of data. + + + + + Represents a resultset that contains rows of data for relational operations. + + + + + Gets a boolean value indicating if this result has data. + + + + + Moves to next resultset. + + True if there is a new resultset, false otherwise. + + + + Represents a sql statement. + + + + + Initializes a new instance of the SqlStament class bassed on the session and sql statement. + + The session the Sql statement belongs to. + The Sql statement. + + + + Gets the current Sql statement. + + + + + Gets the list of parameters associated to this Sql statement. + + + + + Executes the current Sql statement. + + A object with the resultset and execution status. + + + + Binds the parameters values by position. + + The parameter values. + This set with the binded parameters. + + + + Represents a server Table or View. + + + + + Gets a value indicating whether the object is + a View (True) or a Table (False). + + + + + Creates a set with the columns to select. The table select + statement can be further modified before execution. This method is intended to select a set + of table rows. + + The optional column names to select. + A object for select chain operations. + + + + Creates a set with the fileds to insert to. The table + insert statement can be further modified before exeuction. This method is intended to + insert one or multiple rows into a table. + + The list of fields to insert. + A object for insert chain operations. + + + + Creates a . This method is intended to update table rows + values. + + A object for update chain operations. + + + + Creates a . This method is intended to delete rows from a + table. + + A object for delete chain operations. + + + + Returns the number of rows in the table on the server. + + The number of rows. + + + + Verifies if the table exists in the database. + + true if the table exists; otherwise, false. + + + + Represents a chaining table delete statement. + + + + + Sets user-defined sorting criteria for the operation. The strings use normal SQL syntax like + "order ASC" or "pages DESC, age ASC". + + The order criteria. + A generic object representing the implementing statement type. + + + + Executes the delete statement. + + A object containing the results of the delete execution. + + + + Represents a chaining table insert statement. + + + + + Executes the insert statement. + + A object containing the results of the insert statement. + + + + Values to be inserted. + Multiple rows supported. + + The values to be inserted. + This same object. + + + + Represents a chaining table select statement. + + + + + Executes the select statement. + + A object containing the results of the execution and data. + + + + Locks matching rows against updates. + + Optional row lock option to use. + This same object set with lock shared option. + The server version is lower than 8.0.3. + + + + Locks matching rows so no other transaction can read or write to it. + + Optional row lock option to use. + This same object set with the lock exclusive option. + The server version is lower than 8.0.3. + + + + Sets the table aggregation. + + The column list for aggregation. + This same object set with the specified group-by criteria. + + + + Filters criteria for aggregated groups. + + The filter criteria for aggregated groups. + This same object set with the specified filter criteria. + + + + Sets user-defined sorting criteria for the operation. The strings use normal SQL syntax like + "order ASC" or "pages DESC, age ASC". + + The order criteria. + A generic object that represents the implementing statement type. + + + + Represents a chaining table update statement. + + + + + Executes the update statement. + + A object ocntaining the results of the update statement execution. + + + + Column and value to be updated. + + Column name. + Value to be updated. + This same object. + + + + Sets user-defined sorting criteria for the operation. The strings use normal SQL syntax like + "order ASC" or "pages DESC, age ASC". + + The order criteria. + A generic object that represents the implementing statement type. + + + + Represents a schema or database. + + + + + Session related to current schema. + + + + + Returns a list of all collections in this schema. + + A list representing all found collections. + + + + Returns a list of all tables in this schema. + + A list representing all found tables. + + + + Gets a collection by name. + + The name of the collection to get. + Ensures the collection exists in the schema. + A object matching the given name. + + + + Gets a typed collection object. This is useful for using domain objects. + + The type of collection returned. + The name of collection to get. + A generic object set with the given name. + + + + Gets the given collection as a table. + + The name of the collection. + A object set with the given name. + + + + Gets a table object. Upon return the object may or may not be valid. + + The name of the table object. + A object set with the given name. + + + + Creates a collection. + + The name of the collection to create. + If false, throws an exception if the collection exists. + Collection referente. + + + + Creates a collection including a schema validation. + + The name of the collection to create. + This object hold the parameters required to create the collection. + + Collection referente. + + + + Modify a collection adding or removing schema validation parameters. + + The name of the collection to create. + This object encapsulate the Validation parameters level and schema. + Collection referente. + + + + Drops the given collection. + + The name of the collection to drop. + is null. + + + + Determines if this schema actually exists. + + True if exists, false otherwise. + + + + Represents a single server session. + + + + + Returns a object that can be used to execute the given SQL. + + The SQL to execute. + A object set with the provided SQL. + + + + Sets the schema in the database. + + The schema name to be set. + + + + Executes a query in the database to get the current schema. + + Current database object or null if no schema is selected. + + + Holder for reflection information generated from mysqlx.proto + + + File descriptor for mysqlx.proto + + + + IDs of messages that can be sent from client to the server + + .. note:: + this message is never sent on the wire. It is only used to let ``protoc`` + + * generate constants + * check for uniqueness + + + + Container for nested types declared in the ClientMessages message type. + + + + IDs of messages that can be sent from server to client + + .. note:: + this message is never sent on the wire. It is only used to let ``protoc`` + + * generate constants + * check for uniqueness + + + + Container for nested types declared in the ServerMessages message type. + + + + NOTICE has to stay at 11 forever + + + + + generic Ok message + + + + Field number for the "msg" field. + + + + generic Error message + + A ``severity`` of ``ERROR`` indicates the current message sequence is + aborted for the given error and the session is ready for more. + + In case of a ``FATAL`` error message the client should not expect + the server to continue handling any further messages and should + close the connection. + + :param severity: severity of the error message + :param code: error-code + :param sql_state: SQL state + :param msg: human readable error message + + + + Field number for the "severity" field. + + + Field number for the "code" field. + + + Field number for the "sql_state" field. + + + Field number for the "msg" field. + + + Container for nested types declared in the Error message type. + + + Holder for reflection information generated from mysqlx_connection.proto + + + File descriptor for mysqlx_connection.proto + + + + a Capability + + a tuple of a ``name`` and a :protobuf:msg:`Mysqlx.Datatypes::Any` + + + + Field number for the "name" field. + + + Field number for the "value" field. + + + + Capabilities + + + + Field number for the "capabilities" field. + + + + get supported connection capabilities and their current state + + :returns: :protobuf:msg:`Mysqlx.Connection::Capabilities` or :protobuf:msg:`Mysqlx::Error` + + + + + sets connection capabilities atomically + + only provided values are changed, other values are left unchanged. + If any of the changes fails, all changes are discarded. + + :precond: active sessions == 0 + :returns: :protobuf:msg:`Mysqlx::Ok` or :protobuf:msg:`Mysqlx::Error` + + + + Field number for the "capabilities" field. + + + + announce to the server that the client wants to close the connection + + it discards any session state of the server + + :Returns: :protobuf:msg:`Mysqlx::Ok` + + + + Field number for the "uncompressed_size" field. + + + Field number for the "server_messages" field. + + + Field number for the "client_messages" field. + + + Field number for the "payload" field. + + + Holder for reflection information generated from mysqlx_crud.proto + + + File descriptor for mysqlx_crud.proto + + + + DataModel to use for filters, names, ... + + + + + ViewAlgorithm defines how MySQL Server processes the view + + + + + MySQL chooses which algorithm to use + + + + + the text of a statement that refers to the view and the view definition are merged + + + + + the view are retrieved into a temporary table + + + + + ViewSqlSecurity defines the security context in which the view is going to be + executed, this means that VIEW can be executed with current user permissions or + with permissions of the uses who defined the VIEW + + + + + ViewCheckOption limits the write operations done on a `VIEW` + (`INSERT`, `UPDATE`, `DELETE`) to rows in which the `WHERE` clause is `TRUE` + + + + + the view WHERE clause is checked, but no underlying views are checked + + + + + the view WHERE clause is checked, then checking recurses to underlying views + + + + + column definition + + + + Field number for the "name" field. + + + + optional + + + + Field number for the "alias" field. + + + + optional + + + + Field number for the "document_path" field. + + + + a projection + + :param source: the expression identifying an element from the source data + which can include a column identifier or any expression + :param alias: optional alias. Required for DOCUMENTs (clients may use + the source string as default) + + + + Field number for the "source" field. + + + + required + + + + Field number for the "alias" field. + + + + optional + + + + + collection + + + + Field number for the "name" field. + + + + required + + + + Field number for the "schema" field. + + + + optional + + + + + limit + + :param row_count: maximum rows to filter + :param offset: maximum rows to skip before applying the row_count + + + + Field number for the "row_count" field. + + + + required + + + + Field number for the "offset" field. + + + + optional + + + + + limit expression + + LimitExpr in comparison to Limit, is able to specify that row_count and + offset are placeholders. + This message support expressions of following types Expr/literal/UINT, + Expr/PLACEHOLDER. + + :param row_count: maximum rows to filter + :param offset: maximum rows to skip before applying the row_count + + + + Field number for the "row_count" field. + + + + required + + + + Field number for the "offset" field. + + + + optional + + + + + sort order + + + + Field number for the "expr" field. + + + + required + + + + Field number for the "direction" field. + + + + optional//[ default=ASC ] + + + + Container for nested types declared in the Order message type. + + + + update operations + + :param source: specification of the value to be updated + if data_model is TABLE, a column name may be specified and also a document path, if the column has type JSON + if data_model is DOCUMENT, only document paths are allowed + in both cases, schema and table must be not set + :param operation: the type of operation to be performed + :param value: an expression to be computed as the new value for the operation + + + + Field number for the "source" field. + + + + required + + + + Field number for the "operation" field. + + + + required + + + + Field number for the "value" field. + + + + optional + + + + Container for nested types declared in the UpdateOperation message type. + + + + only allowed for TABLE + + + + + no value (removes the identified path from a object or array) + + + + + sets the new value on the identified path + + + + + replaces a value if the path exists + + + + + source and value must be documents + + + + + insert the value in the array at the index identified in the source path + + + + + append the value on the array at the identified path + + + + + merge JSON object value with the provided patch expression + + + + + Find Documents/Rows in a Collection/Table + + .. uml:: + + client -> server: Find + ... one or more Resultset ... + + :param collection: collection to insert into + :param data_model: datamodel that the operations refer to + :param projection: list of column projections that shall be returned + :param args: values for parameters used in filter expression + :param criteria: filter criteria + :param limit: numbers of rows that shall be skipped and returned (user can set one of: limit, limit_expr) + :param order: sort-order in which the rows/document shall be returned in + :param grouping: column expression list for aggregation (GROUP BY) + :param grouping_criteria: filter criteria for aggregated groups + :param locking: perform row locking on matches + :param locking_options: additional options how to handle locked rows + :param limit_expr: numbers of rows that shall be skipped and returned (user can set one of: limit, limit_expr) + :Returns: :protobuf:msg:`Mysqlx.Resultset::` + + + + Field number for the "collection" field. + + + + required + + + + Field number for the "data_model" field. + + + + optional + + + + Field number for the "projection" field. + + + Field number for the "criteria" field. + + + + optional + + + + Field number for the "args" field. + + + Field number for the "order" field. + + + Field number for the "grouping" field. + + + Field number for the "grouping_criteria" field. + + + + optional + + + + Field number for the "locking" field. + + + + optional + + + + Field number for the "locking_options" field. + + + + optional + + + + Field number for the "limit" field. + + + + optional + + + + Field number for the "limit_expr" field. + + + + optional + + + + Container for nested types declared in the Find message type. + + + + Lock matching rows against updates + + + + + Lock matching rows so no other transaction can read or write to it + + + + + Do not wait to acquire row lock, fail with an error if a requested row is locked + + + + + Do not wait to acquire a row lock, remove locked rows from the result set + + + + + Insert documents/rows into a collection/table + + :param collection: collection to insert into + :param data_model: datamodel that the operations refer to + :param projection: name of the columns to insert data into (empty if data_model is DOCUMENT) + :param row: set of rows to insert into the collection/table (a single expression with a JSON document literal or an OBJECT expression) + :param args: values for parameters used in row expressions + :param upsert: true if this should be treated as an Upsert (that is, update on duplicate key) + :Returns: :protobuf:msg:`Mysqlx.Resultset::` + + + + Field number for the "collection" field. + + + + required + + + + Field number for the "data_model" field. + + + + optional + + + + Field number for the "projection" field. + + + Field number for the "row" field. + + + Field number for the "args" field. + + + Field number for the "upsert" field. + + + + optional//[default = false] + + + + Container for nested types declared in the Insert message type. + + + Field number for the "field" field. + + + + Update documents/rows in a collection/table + + :param collection: collection to change + :param data_model: datamodel that the operations refer to + :param criteria: filter expression to match rows that the operations will apply on + :param args: values for parameters used in filter expression + :param limit: limits the number of rows to match (user can set one of: limit, limit_expr) + :param order: specifies order of matched rows + :param operation: list of operations to be applied. Valid operations will depend on the data_model. + :param limit_expr: limits the number of rows to match (user can set one of: limit, limit_expr) + :Returns: :protobuf:msg:`Mysqlx.Resultset::` + + + + Field number for the "collection" field. + + + + required + + + + Field number for the "data_model" field. + + + + optional + + + + Field number for the "criteria" field. + + + + optional + + + + Field number for the "args" field. + + + Field number for the "order" field. + + + Field number for the "operation" field. + + + Field number for the "limit" field. + + + + optional + + + + Field number for the "limit_expr" field. + + + + optional + + + + + Delete documents/rows from a Collection/Table + + :param collection: collection to change + :param data_model: datamodel that the operations refer to + :param criteria: filter expression to match rows that the operations will apply on + :param args: values for parameters used in filter expression + :param limit: limits the number of rows to match (user can set one of: limit, limit_expr) + :param order: specifies order of matched rows + :param limit_expr: limits the number of rows to match (user can set one of: limit, limit_expr) + :Returns: :protobuf:msg:`Mysqlx.Resultset::` + + + + Field number for the "collection" field. + + + + required + + + + Field number for the "data_model" field. + + + + optional + + + + Field number for the "criteria" field. + + + + optional + + + + Field number for the "args" field. + + + Field number for the "order" field. + + + Field number for the "limit" field. + + + + optional + + + + Field number for the "limit_expr" field. + + + + optional + + + + Field number for the "collection" field. + + + + required + + + + Field number for the "definer" field. + + + + optional + + + + Field number for the "algorithm" field. + + + + optional//[default = UNDEFINED] + + + + Field number for the "security" field. + + + + optional//[default = DEFINER] + + + + Field number for the "check" field. + + + + optional + + + + Field number for the "column" field. + + + Field number for the "stmt" field. + + + + required + + + + Field number for the "replace_existing" field. + + + + optional//[default = false] + + + + Field number for the "collection" field. + + + + required + + + + Field number for the "definer" field. + + + + optional + + + + Field number for the "algorithm" field. + + + + optional + + + + Field number for the "security" field. + + + + optional + + + + Field number for the "check" field. + + + + optional + + + + Field number for the "column" field. + + + Field number for the "stmt" field. + + + + optional + + + + Field number for the "collection" field. + + + + required + + + + Field number for the "if_exists" field. + + + + optional//[ default = false ] + + + + Holder for reflection information generated from mysqlx_cursor.proto + + + File descriptor for mysqlx_cursor.proto + + + + Open a cursor + + .. uml:: + + client -> server: Open + alt Success + ... none or partial Resultsets or full Resultsets ... + client <- server: StmtExecuteOk + else Failure + client <- server: Error + end + + :param cursor_id: client side assigned cursor id, the ID is going to represent new cursor and assigned to it statement + :param stmt: statement which resultset is going to be iterated through the cursor + :param fetch_rows: number of rows which should be retrieved from sequential cursor + :Returns: :protobuf:msg:`Mysqlx.Ok::` + + + + Field number for the "cursor_id" field. + + + + required + + + + Field number for the "stmt" field. + + + + required + + + + Field number for the "fetch_rows" field. + + + + optional + + + + Container for nested types declared in the Open message type. + + + Field number for the "type" field. + + + + required + + + + Field number for the "prepare_execute" field. + + + + optional + + + + Container for nested types declared in the OneOfMessage message type. + + + + Fetch next portion of data from a cursor + + .. uml:: + + client -> server: Fetch + alt Success + ... none or partial Resultsets or full Resultsets ... + client <- server: StmtExecuteOk + else + client <- server: Error + end + + :param cursor_id: client side assigned cursor id, must be already open + :param fetch_rows: number of rows which should be retrieved from sequential cursor + + + + Field number for the "cursor_id" field. + + + + required + + + + Field number for the "fetch_rows" field. + + + + optional + + + + + Close cursor + + .. uml:: + + client -> server: Close + alt Success + client <- server: Ok + else Failure + client <- server: Error + end + + :param cursor_id: client side assigned cursor id, must be allocated/open + :Returns: :protobuf:msg:`Mysqlx.Ok|Mysqlx.Error` + + + + Field number for the "cursor_id" field. + + + + required + + + + Holder for reflection information generated from mysqlx_datatypes.proto + + + File descriptor for mysqlx_datatypes.proto + + + + a scalar + + + + Field number for the "type" field. + + + + required + + + + Field number for the "v_signed_int" field. + + + Field number for the "v_unsigned_int" field. + + + Field number for the "v_octets" field. + + + + 4 is unused, was Null which doesn't have a storage anymore + + + + Field number for the "v_double" field. + + + Field number for the "v_float" field. + + + Field number for the "v_bool" field. + + + Field number for the "v_string" field. + + + Enum of possible cases for the "DefaultOneOf" oneof. + + + Container for nested types declared in the Scalar message type. + + + + a string with a charset/collation + + + + Field number for the "value" field. + + + + required + + + + Field number for the "collation" field. + + + Enum of possible cases for the "String_present" oneof. + + + + an opaque octet sequence, with an optional content_type + See ``Mysqlx.Resultset.ColumnMetadata`` for list of known values. + + + + Field number for the "value" field. + + + + required + + + + Field number for the "content_type" field. + + + + a object + + + + Field number for the "fld" field. + + + Container for nested types declared in the Object message type. + + + Field number for the "key" field. + + + + required + + + + Field number for the "value" field. + + + + required + + + + + a Array + + + + Field number for the "value" field. + + + + a helper to allow all field types + + + + Field number for the "type" field. + + + + required + + + + Field number for the "scalar" field. + + + Field number for the "obj" field. + + + Field number for the "array" field. + + + Container for nested types declared in the Any message type. + + + Holder for reflection information generated from mysqlx_expect.proto + + + File descriptor for mysqlx_expect.proto + + + + open an Expect block and set/unset the conditions that have to be fulfilled + + if any of the conditions fail, all enclosed messages will fail with + a Mysqlx.Error message. + + :returns: :protobuf:msg:`Mysqlx::Ok` on success, :protobuf:msg:`Mysqlx::Error` on error + + + + Field number for the "op" field. + + + + [ default = EXPECT_CTX_COPY_PREV ];//optional + + + + Field number for the "cond" field. + + + Container for nested types declared in the Open message type. + + + + copy the operations from the parent Expect-block + + + + + start with a empty set of operations + + + + Field number for the "condition_key" field. + + + + required + + + + Field number for the "condition_value" field. + + + + optional + + + + Field number for the "op" field. + + + + [ default = EXPECT_OP_SET ];//optional + + + + Container for nested types declared in the Condition message type. + + + + Change error propagation behaviour + + + + + Check if X Protocol field exists + + + + + Check if X Protocol support document _id generation + + + + + set the condition + + set, if not set + overwrite, if set + + + + + unset the condition + + + + + close a Expect block + + closing a Expect block restores the state of the previous Expect block + for the following messages + + :returns: :protobuf:msg:`Mysqlx::Ok` on success, :protobuf:msg:`Mysqlx::Error` on error + + + + Holder for reflection information generated from mysqlx_expr.proto + + + File descriptor for mysqlx_expr.proto + + + + Expressions + + the "root" of the expression tree + + .. productionlist:: + expr: `operator` | + : `identifier` | + : `function_call` | + : variable | + : `literal` | + : placeholder + + If expression type is PLACEHOLDER then it refers to the value of a parameter + specified when executing a statement (see `args` field of `StmtExecute` command). + Field `position` (which must be present for such an expression) gives 0-based + position of the parameter in the parameter list. + + + + Field number for the "type" field. + + + + required + + + + Field number for the "identifier" field. + + + Field number for the "variable" field. + + + Field number for the "literal" field. + + + Field number for the "function_call" field. + + + Field number for the "operator" field. + + + Field number for the "position" field. + + + Field number for the "object" field. + + + Field number for the "array" field. + + + Container for nested types declared in the Expr message type. + + + + identifier: name, schame.name + + .. productionlist:: + identifier: string "." string | + : string + + + + Field number for the "name" field. + + + + required + + + + Field number for the "schema_name" field. + + + + DocumentPathItem + + .. productionlist:: + document_path: path_item | path_item document_path + path_item : member | array_index | "**" + member : "." string | "." "*" + array_index : "[" number "]" | "[" "*" "]" + + + + Field number for the "type" field. + + + + required + + + + Field number for the "value" field. + + + Field number for the "index" field. + + + Container for nested types declared in the DocumentPathItem message type. + + + + .member + + + + + .* + + + + + [index] + + + + + [*] + + + + + ** + + + + + col_identifier (table): col@doc_path, tbl.col@doc_path col, tbl.col, schema.tbl.col + col_identifier (document): doc_path + + .. productionlist:: + col_identifier: string "." string "." string | + : string "." string | + : string | + : string "." string "." string "@" document_path | + : string "." string "@" document_path | + : string "@" document_path | + : document_path + document_path: member | arrayLocation | doubleAsterisk + member = "." string | "." "*" + arrayLocation = "[" index "]" | "[" "*" "]" + doubleAsterisk = "**" + + + + Field number for the "document_path" field. + + + Field number for the "name" field. + + + Field number for the "table_name" field. + + + Field number for the "schema_name" field. + + + + function call: ``func(a, b, "1", 3)`` + + .. productionlist:: + function_call: `identifier` "(" [ `expr` ["," `expr` ]* ] ")" + + + + Field number for the "name" field. + + + + required + + + + Field number for the "param" field. + + + + operator: ``<<(a, b)`` + + .. note:: + + Non-authoritative list of operators implemented (case sensitive): + + Nullary + * ``*`` + * ``default`` + + Unary + * ``!`` + * ``sign_plus`` + * ``sign_minus`` + * ``~`` + + Binary + * ``&&`` + * ``||`` + * ``xor`` + * ``==`` + * ``!=`` + * ``>`` + * ``>=`` + * ``<`` + * ``<=`` + * ``&`` + * ``|`` + * ``^`` + * ``<<`` + * ``>>`` + * ``+`` + * ``-`` + * ``*`` + * ``/`` + * ``div`` + * ``%`` + * ``is`` + * ``is_not`` + * ``regexp`` + * ``not_regexp`` + * ``like`` + * ``not_like`` + * ``cast`` + * ``cont_in`` + * ``not_cont_in`` + + Using special representation, with more than 2 params + * ``in`` (param[0] IN (param[1], param[2], ...)) + * ``not_in`` (param[0] NOT IN (param[1], param[2], ...)) + + Ternary + * ``between`` + * ``between_not`` + * ``date_add`` + * ``date_sub`` + + Units for date_add/date_sub + * ``MICROSECOND`` + * ``SECOND`` + * ``MINUTE`` + * ``HOUR`` + * ``DAY`` + * ``WEEK`` + * ``MONTH`` + * ``QUARTER`` + * ``YEAR`` + * ``SECOND_MICROSECOND`` + * ``MINUTE_MICROSECOND`` + * ``MINUTE_SECOND`` + * ``HOUR_MICROSECOND`` + * ``HOUR_SECOND`` + * ``HOUR_MINUTE`` + * ``DAY_MICROSECOND`` + * ``DAY_SECOND`` + * ``DAY_MINUTE`` + * ``DAY_HOUR`` + + Types for cast + * ``BINARY[(N)]`` + * ``CHAR[(N)]`` + * ``DATE`` + * ``DATETIME`` + * ``DECIMAL[(M[,D])]`` + * ``JSON`` + * ``SIGNED [INTEGER]`` + * ``TIME`` + * ``UNSIGNED [INTEGER]`` + + .. productionlist:: + operator: `name` "(" [ `expr` ["," `expr` ]* ] ")" + + + + Field number for the "name" field. + + + + required + + + + Field number for the "param" field. + + + + an object (with expression values) + + + + Field number for the "fld" field. + + + Container for nested types declared in the Object message type. + + + Field number for the "key" field. + + + + required + + + + Field number for the "value" field. + + + + required + + + + + a Array of expressions + + + + Field number for the "value" field. + + + Holder for reflection information generated from mysqlx_notice.proto + + + File descriptor for mysqlx_notice.proto + + + + Common Frame for all Notices + + ===================================================== ===== + .type value + ===================================================== ===== + :protobuf:msg:`Mysqlx.Notice::Warning` 1 + :protobuf:msg:`Mysqlx.Notice::SessionVariableChanged` 2 + :protobuf:msg:`Mysqlx.Notice::SessionStateChanged` 3 + ===================================================== ===== + + :param type: the type of the payload + :param payload: the payload of the notification + :param scope: global or local notification + + + + Field number for the "type" field. + + + + required + + + + Field number for the "scope" field. + + + + [ default = GLOBAL ];//optional + + + + Field number for the "payload" field. + + + + optional + + + + Container for nested types declared in the Frame message type. + + + + Server-side warnings and notes + + ``.scope`` == ``local`` + ``.level``, ``.code`` and ``.msg`` map the content of + + .. code-block:: sql + + SHOW WARNINGS + + ``.scope`` == ``global`` + (undefined) will be used for global, unstructured messages like: + + * server is shutting down + * a node disconnected from group + * schema or table dropped + + ========================================== ======================= + :protobuf:msg:`Mysqlx.Notice::Frame` field value + ========================================== ======================= + ``.type`` 1 + ``.scope`` ``local`` or ``global`` + ========================================== ======================= + + :param level: warning level: Note or Warning + :param code: warning code + :param msg: warning message + + + + Field number for the "level" field. + + + + [ default = WARNING ];//optional + + + + Field number for the "code" field. + + + + required + + + + Field number for the "msg" field. + + + + required + + + + Container for nested types declared in the Warning message type. + + + + Notify clients about changes to the current session variables + + Every change to a variable that is accessible through: + + .. code-block:: sql + + SHOW SESSION VARIABLES + + ========================================== ========= + :protobuf:msg:`Mysqlx.Notice::Frame` field value + ========================================== ========= + ``.type`` 2 + ``.scope`` ``local`` + ========================================== ========= + + :param namespace: namespace that param belongs to + :param param: name of the variable + :param value: the changed value of param + + + + Field number for the "param" field. + + + + required + + + + Field number for the "value" field. + + + + optional + + + + + Notify clients about changes to the internal session state + + ========================================== ========= + :protobuf:msg:`Mysqlx.Notice::Frame` field value + ========================================== ========= + ``.type`` 3 + ``.scope`` ``local`` + ========================================== ========= + + :param param: parameter key + :param value: updated value + + + + Field number for the "param" field. + + + + required + + + + Field number for the "value" field. + + + Container for nested types declared in the SessionStateChanged message type. + + + + .. more to be added + + + + Holder for reflection information generated from mysqlx_prepare.proto + + + File descriptor for mysqlx_prepare.proto + + + + Prepare a new statement + + .. uml:: + + client -> server: Prepare + alt Success + client <- server: Ok + else Failure + client <- server: Error + end + + :param stmt_id: client side assigned statement id, which is going to identify the result of preparation + :param stmt: defines one of following messages to be prepared - Crud.Find, Crud.Insert, Crud.Delete, Crud.Upsert, Sql.StmtExecute + :Returns: :protobuf:msg:`Mysqlx.Ok|Mysqlx.Error` + + + + Field number for the "stmt_id" field. + + + + required + + + + Field number for the "stmt" field. + + + + required + + + + Container for nested types declared in the Prepare message type. + + + Field number for the "type" field. + + + + required + + + + Field number for the "find" field. + + + + optional + + + + Field number for the "insert" field. + + + + optional + + + + Field number for the "update" field. + + + + optional + + + + Field number for the "delete" field. + + + + optional + + + + Field number for the "stmt_execute" field. + + + + optional + + + + Enum of possible cases for the "Type_present" oneof. + + + Container for nested types declared in the OneOfMessage message type. + + + + Determine which of optional fields was set by the client + (Workaround for missing "oneof" keyword in pb2.5) + + + + + Execute already prepared statement + + .. uml:: + + client -> server: Execute + alt Success + ... Resultsets... + client <- server: StmtExecuteOk + else Failure + client <- server: Error + end + + :param stmt_id: client side assigned statement id, must be already prepared + :param args_list: Arguments to bind to the prepared statement + :param compact_metadata: send only type information for :protobuf:msg:`Mysqlx.Resultset::ColumnMetadata`, skipping names and others + :Returns: :protobuf:msg:`Mysqlx.Ok::` + + + + Field number for the "stmt_id" field. + + + + required + + + + Field number for the "args" field. + + + Field number for the "compact_metadata" field. + + + + [ default = false ]; optional + + + + + Deallocate already prepared statement + + Deallocating the statement. + + .. uml:: + + client -> server: Deallocate + alt Success + client <- server: Ok + else Failure + client <- server: Error + end + + :param stmt_id: client side assigned statement id, must be already prepared + :Returns: :protobuf:msg:`Mysqlx.Ok|Mysqlx.Error` + + + + Field number for the "stmt_id" field. + + + + required + + + + Holder for reflection information generated from mysqlx_resultset.proto + + + File descriptor for mysqlx_resultset.proto + + + + a hint about the higher-level encoding of a BYTES field + + ====== ====== =========== + type value description + ====== ====== =========== + BYTES 0x0001 GEOMETRY (WKB encoding) + BYTES 0x0002 JSON (text encoding) + BYTES 0x0003 XML (text encoding) + ====== ====== =========== + + .. note:: + this list isn't comprehensive. As guideline: the field's value is expected + to pass a validator check on client and server if this field is set. + If the server adds more internal datatypes that rely on BLOB storage + like image manipulation, seeking into complex types in BLOBs, ... more + types will be added. + + + + + a hint about the higher-level encoding of a DATETIME field + + ====== ====== =========== + type value description + ======== ====== =========== + DATE 0x0001 DATETIME contains only date part + DATETIME 0x0002 DATETIME contains both date and time parts + ====== ====== =========== + + + + + resultsets are finished, OUT paramset is next + + + + + resultset and out-params are finished, but more resultsets available + + + + + all resultsets are finished + + + + + cursor is opened still the execution of PrepFetch or PrepExecute ended + + + + + meta data of a Column + + .. note:: the encoding used for the different ``bytes`` fields in the meta data is externally + controlled. + .. seealso:: https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html + + .. note:: + The server may not set the ``original_{table|name}`` fields if they are equal to the plain + ``{table|name}`` field. + + A client has to reconstruct it like:: + + if .original_name is empty and .name is not empty: + .original_name = .name + + if .original_table is empty and .table is not empty: + .original_table = .table + + .. note:: + ``compact metadata format`` can be requested by the client. In that case only ``.type`` is set and + all other fields are empty. + + :param type: + .. table:: Expected Datatype of Mysqlx.Resultset.Row per SQL Type for non NULL values + + ================= ============ ======= ========== ====== ======== + SQL Type .type .length .frac_dig .flags .charset + ================= ============ ======= ========== ====== ======== + TINY SINT x + TINY UNSIGNED UINT x x + SHORT SINT x + SHORT UNSIGNED UINT x x + INT24 SINT x + INT24 UNSIGNED UINT x x + INT SINT x + INT UNSIGNED UINT x x + LONGLONG SINT x + LONGLONG UNSIGNED UINT x x + DOUBLE DOUBLE x x x + FLOAT FLOAT x x x + DECIMAL DECIMAL x x x + VARCHAR,CHAR,... BYTES x x x + GEOMETRY BYTES + TIME TIME x + DATE DATETIME x + DATETIME DATETIME x + YEAR UINT x x + TIMESTAMP DATETIME x + SET SET x + ENUM ENUM x + NULL BYTES + BIT BIT x + ================= ============ ======= ========== ====== ======== + + .. note:: the SQL "NULL" value is sent as an empty field value in :protobuf:msg:`Mysqlx.Resultset::Row` + .. seealso:: protobuf encoding of primitive datatypes are decribed in https://developers.google.com/protocol-buffers/docs/encoding + + SINT + + ``.length`` + maximum number of displayable decimal digits (including minus sign) of the type + + .. note:: + valid range is 0-255, but usually you'll see 1-20 + + =============== == + SQL Type max digits per type + =============== == + TINY SIGNED 4 + SHORT SIGNED 6 + INT24 SIGNED 8 + INT SIGNED 11 + LONGLONG SIGNED 20 + =============== == + + .. seealso:: definition of ``M`` in https://dev.mysql.com/doc/refman/8.0/en/numeric-type-overview.html + + ``value`` + variable length encoded signed 64 integer + + UINT + + ``.flags & 1`` (zerofill) + the client has to left pad with 0's up to .length + + ``.length`` + maximum number of displayable decimal digits of the type + + .. note:: + valid range is 0-255, but usually you'll see 1-20 + + ================= == + SQL Type max digits per type + ================= == + TINY UNSIGNED 3 + SHORT UNSIGNED 5 + INT24 UNSIGNED 8 + INT UNSIGNED 10 + LONGLONG UNSIGNED 20 + ================= == + + .. seealso:: definition of ``M`` in https://dev.mysql.com/doc/refman/8.0/en/numeric-type-overview.html + + ``value`` + variable length encoded unsigned 64 integer + + BIT + + ``.length`` + maximum number of displayable binary digits + + .. note:: valid range for M of the ``BIT`` type is 1 - 64 + .. seealso:: https://dev.mysql.com/doc/refman/8.0/en/numeric-type-overview.html + + ``value`` + variable length encoded unsigned 64 integer + + DOUBLE + + ``.length`` + maximum number of displayable decimal digits (including the decimal point and ``.fractional_digits``) + + ``.fractional_digits`` + maximum number of displayable decimal digits following the decimal point + + ``value`` + encoded as Protobuf's 'double' + + FLOAT + + ``.length`` + maximum number of displayable decimal digits (including the decimal point and ``.fractional_digits``) + + ``.fractional_digits`` + maximum number of displayable decimal digits following the decimal point + + ``value`` + encoded as Protobuf's 'float' + + BYTES, ENUM + BYTES is used for all opaque byte strings that may have a charset + + * TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB + * TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT + * VARCHAR, VARBINARY + * CHAR, BINARY + * ENUM + + ``.length`` + the maximum length of characters of the underlying type + + ``.flags & 1`` (rightpad) + if the length of the field is less than ``.length``, the receiver is + supposed to add padding characters to the right end of the string. + If the ``.charset`` is "binary", the padding character is ``0x00``, + otherwise it is a space character as defined by that character set. + + ============= ======= ======== ======= + SQL Type .length .charset .flags + ============= ======= ======== ======= + TINYBLOB 256 binary + BLOB 65535 binary + VARCHAR(32) 32 utf8 + VARBINARY(32) 32 utf8_bin + BINARY(32) 32 binary rightpad + CHAR(32) 32 utf8 rightpad + ============= ======= ======== ======= + + ``value`` + sequence of bytes with added one extra '\0' byte at the end. To obtain the + original string, the extra '\0' should be removed. + .. note:: the length of the string can be acquired with protobuf's field length() method + length of sequence-of-bytes = length-of-field - 1 + .. note:: the extra byte allows to distinguish between a NULL and empty byte sequence + + TIME + A time value. + + ``value`` + the following bytes sequence: + + ``| negate [ | hour | [ | minutes | [ | seconds | [ | useconds | ]]]]`` + + * negate - one byte, should be one of: 0x00 for "+", 0x01 for "-" + * hour - optional variable length encoded unsigned64 value for the hour + * minutes - optional variable length encoded unsigned64 value for the minutes + * seconds - optional variable length encoded unsigned64 value for the seconds + * useconds - optional variable length encoded unsigned64 value for the microseconds + + .. seealso:: protobuf encoding in https://developers.google.com/protocol-buffers/docs/encoding + .. note:: hour, minutes, seconds, useconds are optional if all the values to the right are 0 + + Example: 0x00 -> +00:00:00.000000 + + DATETIME + A date or date and time value. + + ``value`` + a sequence of variants, arranged as follows: + + ``| year | month | day | [ | hour | [ | minutes | [ | seconds | [ | useconds | ]]]]`` + + * year - variable length encoded unsigned64 value for the year + * month - variable length encoded unsigned64 value for the month + * day - variable length encoded unsigned64 value for the day + * hour - optional variable length encoded unsigned64 value for the hour + * minutes - optional variable length encoded unsigned64 value for the minutes + * seconds - optional variable length encoded unsigned64 value for the seconds + * useconds - optional variable length encoded unsigned64 value for the microseconds + + .. note:: hour, minutes, seconds, useconds are optional if all the values to the right are 0 + + ``.flags & 1`` (timestamp) + + ============= ======= + SQL Type .flags + ============= ======= + DATETIME + TIMESTAMP 1 + + DECIMAL + An arbitrary length number. The number is encoded as a single byte + indicating the position of the decimal point followed by the Packed BCD + encoded number. Packed BCD is used to simplify conversion to and + from strings and other native arbitrary precision math datatypes. + .. seealso:: packed BCD in https://en.wikipedia.org/wiki/Binary-coded_decimal + + ``.length`` + maximum number of displayable decimal digits (*excluding* the decimal point and sign, but including ``.fractional_digits``) + + .. note:: should be in the range of 1 - 65 + + ``.fractional_digits`` + is the decimal digits to display out of length + + .. note:: should be in the range of 0 - 30 + + ``value`` + the following bytes sequence: + + ``| scale | BCD | sign | [0x0] |`` + + * scale - 8bit scale value (number of decimal digit after the '.') + * BCD - BCD encoded digits (4 bits for each digit) + * sign - sign encoded on 4 bits (0xc = "+", 0xd = "-") + * 0x0 - last 4bits if length(digits) % 2 == 0 + + Example: x04 0x12 0x34 0x01 0xd0 -> -12.3401 + + SET + A list of strings representing a SET of values. + + ``value`` + A sequence of 0 or more of protobuf's bytes (length prepended octets) or one of + the special sequences with a predefined meaning listed below. + + Example (length of the bytes array shown in brackets): + * ``[0]`` - the NULL value + * ``[1] 0x00`` - a set containing a blank string '' + * ``[1] 0x01`` - this would be an invalid value, but is to be treated as the empty set + * ``[2] 0x01 0x00`` - a set with a single item, which is the '\0' character + * ``[8] 0x03 F O O 0x03 B A R`` - a set with 2 items: FOO,BAR + + :param name: name of the column + :param original_name: name of the column before an alias was applied + :param table: name of the table the column orginates from + :param original_table: name of the table the column orginates from before an alias was applied + :param schema: schema the column originates from + :param catalog: + catalog the schema originates from + + .. note:: + as there is current no support for catalogs in MySQL, don't expect this field to be set. + In the MySQL C/S protocol the field had the value ``def`` all the time. + + :param fractional_digits: displayed factional decimal digits for floating point and fixed point numbers + :param length: maximum count of displayable characters of .type + :param flags: + ``.type`` specific flags + + ======= ====== =========== + type value description + ======= ====== =========== + UINT 0x0001 zerofill + DOUBLE 0x0001 unsigned + FLOAT 0x0001 unsigned + DECIMAL 0x0001 unsigned + BYTES 0x0001 rightpad + ======= ====== =========== + + ====== ================ + value description + ====== ================ + 0x0010 NOT_NULL + 0x0020 PRIMARY_KEY + 0x0040 UNIQUE_KEY + 0x0080 MULTIPLE_KEY + 0x0100 AUTO_INCREMENT + ====== ================ + + default: 0 + :param content_type: + a hint about the higher-level encoding of a BYTES field, for more informations + please refer to Mysqlx.Resultset.ContentType_BYTES enum. + + + + Field number for the "type" field. + + + + datatype of the field in a row + + + + Field number for the "name" field. + + + Field number for the "original_name" field. + + + Field number for the "table" field. + + + Field number for the "original_table" field. + + + Field number for the "schema" field. + + + Field number for the "catalog" field. + + + Field number for the "collation" field. + + + Field number for the "fractional_digits" field. + + + Field number for the "length" field. + + + Field number for the "flags" field. + + + Field number for the "content_type" field. + + + Container for nested types declared in the ColumnMetaData message type. + + + + Row in a Resultset + + a row is represented as a list of fields encoded as byte blobs. + Blob of size 0 represents the NULL value. Otherwise, if it contains at least + one byte, it encodes a non-null value of the field using encoding appropriate for the + type of the value given by ``ColumnMetadata``, as specified + in the :protobuf:msg:`Mysqlx.Resultset::ColumnMetaData` description. + + + + Field number for the "field" field. + + + Holder for reflection information generated from mysqlx_session.proto + + + File descriptor for mysqlx_session.proto + + + + the initial message send from the client to the server to start the + authentication proccess + + :param mech_name: authentication mechanism name + :param auth_data: authentication data + :param initial_response: initial response + :Returns: :protobuf:msg:`Mysqlx.Session::AuthenticateContinue` + + + + Field number for the "mech_name" field. + + + + required + + + + Field number for the "auth_data" field. + + + Field number for the "initial_response" field. + + + + send by client or server after a :protobuf:msg:`Mysqlx.Session::AuthenticateStart` to + exchange more auth data + + :param auth_data: authentication data + :Returns: :protobuf:msg:`Mysqlx.Session::AuthenticateContinue` + + + + Field number for the "auth_data" field. + + + + required + + + + + sent by the server after successful authentication + + :param auth_data: authentication data + + + + Field number for the "auth_data" field. + + + + reset the current session + param keep_open: if is true the session will be reset, but stays authenticated. + otherwise, the session will be closed and needs to be authenticated again. + + :Returns: :protobuf:msg:`Mysqlx::Ok` + + + + Field number for the "keep_open" field. + + + + close the current session + + :Returns: :protobuf:msg:`Mysqlx::Ok` + + + + Holder for reflection information generated from mysqlx_sql.proto + + + File descriptor for mysqlx_sql.proto + + + + execute a statement in the given namespace + + .. uml:: + + client -> server: StmtExecute + ... zero or more Resultsets ... + server --> client: StmtExecuteOk + + Notices: + This message may generate a notice containing WARNINGs generated by its execution. + This message may generate a notice containing INFO messages generated by its execution. + + :param namespace: namespace of the statement to be executed + :param stmt: statement that shall be executed. + :param args: values for wildcard replacements + :param compact_metadata: send only type information for :protobuf:msg:`Mysqlx.Resultset::ColumnMetadata`, skipping names and others + :returns: + * zero or one :protobuf:msg:`Mysqlx.Resultset::` followed by :protobuf:msg:`Mysqlx.Sql::StmtExecuteOk` + + + + Field number for the "namespace" field. + + + + optional [ default = "sql" ] + + + + Field number for the "stmt" field. + + + + required + + + + Field number for the "args" field. + + + Field number for the "compact_metadata" field. + + + + optional [ default = false ] + + + + + statement executed successful + + +
+
diff --git a/DLL/NPOI.OOXML.dll b/DLL/NPOI.OOXML.dll new file mode 100644 index 0000000..031d41d Binary files /dev/null and b/DLL/NPOI.OOXML.dll differ diff --git a/DLL/NPOI.OpenXml4Net.dll b/DLL/NPOI.OpenXml4Net.dll new file mode 100644 index 0000000..8da4ac2 Binary files /dev/null and b/DLL/NPOI.OpenXml4Net.dll differ diff --git a/DLL/NPOI.OpenXmlFormats.dll b/DLL/NPOI.OpenXmlFormats.dll new file mode 100644 index 0000000..4a8f87b Binary files /dev/null and b/DLL/NPOI.OpenXmlFormats.dll differ diff --git a/DLL/NPOI.dll b/DLL/NPOI.dll new file mode 100644 index 0000000..1a500e9 Binary files /dev/null and b/DLL/NPOI.dll differ diff --git a/DLL/Nai.Communication.Robot.FanucVarProxy.dll b/DLL/Nai.Communication.Robot.FanucVarProxy.dll new file mode 100644 index 0000000..ad9e8f8 Binary files /dev/null and b/DLL/Nai.Communication.Robot.FanucVarProxy.dll differ diff --git a/DLL/Newtonsoft.Json.dll b/DLL/Newtonsoft.Json.dll new file mode 100644 index 0000000..7af125a Binary files /dev/null and b/DLL/Newtonsoft.Json.dll differ diff --git a/DLL/Opc.Ua.Client.dll b/DLL/Opc.Ua.Client.dll new file mode 100644 index 0000000..8874d8f Binary files /dev/null and b/DLL/Opc.Ua.Client.dll differ diff --git a/DLL/Opc.Ua.Configuration.dll b/DLL/Opc.Ua.Configuration.dll new file mode 100644 index 0000000..b3f3970 Binary files /dev/null and b/DLL/Opc.Ua.Configuration.dll differ diff --git a/DLL/Opc.Ua.Core.dll b/DLL/Opc.Ua.Core.dll new file mode 100644 index 0000000..ee01d0d Binary files /dev/null and b/DLL/Opc.Ua.Core.dll differ diff --git a/DLL/OpcUaHelper.dll b/DLL/OpcUaHelper.dll new file mode 100644 index 0000000..1409de0 Binary files /dev/null and b/DLL/OpcUaHelper.dll differ diff --git a/DLL/Rhino3dm.dll b/DLL/Rhino3dm.dll new file mode 100644 index 0000000..76d1cb8 Binary files /dev/null and b/DLL/Rhino3dm.dll differ diff --git a/DLL/Robot.Common.dll b/DLL/Robot.Common.dll new file mode 100644 index 0000000..57679fd Binary files /dev/null and b/DLL/Robot.Common.dll differ diff --git a/DLL/Robot.MessageBus.dll b/DLL/Robot.MessageBus.dll new file mode 100644 index 0000000..2bede9f Binary files /dev/null and b/DLL/Robot.MessageBus.dll differ diff --git a/DLL/RobotMapper.dll b/DLL/RobotMapper.dll new file mode 100644 index 0000000..3bf3d77 Binary files /dev/null and b/DLL/RobotMapper.dll differ diff --git a/DLL/RobotStudio.Services.RobApi.Desktop.dll b/DLL/RobotStudio.Services.RobApi.Desktop.dll new file mode 100644 index 0000000..f265f71 Binary files /dev/null and b/DLL/RobotStudio.Services.RobApi.Desktop.dll differ diff --git a/DLL/RobotStudio.Services.RobApi.dll b/DLL/RobotStudio.Services.RobApi.dll new file mode 100644 index 0000000..c06854b Binary files /dev/null and b/DLL/RobotStudio.Services.RobApi.dll differ diff --git a/DLL/Robots.dll b/DLL/Robots.dll new file mode 100644 index 0000000..ff28838 Binary files /dev/null and b/DLL/Robots.dll differ diff --git a/DLL/S7.Net.dll b/DLL/S7.Net.dll new file mode 100644 index 0000000..d186e4a Binary files /dev/null and b/DLL/S7.Net.dll differ diff --git a/DLL/Serilog.Extensions.Logging.dll b/DLL/Serilog.Extensions.Logging.dll new file mode 100644 index 0000000..27dc8cf Binary files /dev/null and b/DLL/Serilog.Extensions.Logging.dll differ diff --git a/DLL/Serilog.dll b/DLL/Serilog.dll new file mode 100644 index 0000000..d13a6f4 Binary files /dev/null and b/DLL/Serilog.dll differ diff --git a/DLL/SqlCmd.dll b/DLL/SqlCmd.dll new file mode 100644 index 0000000..b6b25f9 Binary files /dev/null and b/DLL/SqlCmd.dll differ diff --git a/DLL/System.Buffers.dll b/DLL/System.Buffers.dll new file mode 100644 index 0000000..f2d83c5 Binary files /dev/null and b/DLL/System.Buffers.dll differ diff --git a/DLL/System.Net.Http.Formatting.dll b/DLL/System.Net.Http.Formatting.dll new file mode 100644 index 0000000..e9e80be Binary files /dev/null and b/DLL/System.Net.Http.Formatting.dll differ diff --git a/DLL/System.Net.Http.dll b/DLL/System.Net.Http.dll new file mode 100644 index 0000000..1c5c6fd Binary files /dev/null and b/DLL/System.Net.Http.dll differ diff --git a/DLL/System.Runtime.CompilerServices.Unsafe.dll b/DLL/System.Runtime.CompilerServices.Unsafe.dll new file mode 100644 index 0000000..01199f6 Binary files /dev/null and b/DLL/System.Runtime.CompilerServices.Unsafe.dll differ diff --git a/DLL/System.Runtime.InteropServices.RuntimeInformation.dll b/DLL/System.Runtime.InteropServices.RuntimeInformation.dll new file mode 100644 index 0000000..360e92a Binary files /dev/null and b/DLL/System.Runtime.InteropServices.RuntimeInformation.dll differ diff --git a/DLL/System.Web.Cors.dll b/DLL/System.Web.Cors.dll new file mode 100644 index 0000000..6f3da24 Binary files /dev/null and b/DLL/System.Web.Cors.dll differ diff --git a/DLL/System.Web.Http.Cors.dll b/DLL/System.Web.Http.Cors.dll new file mode 100644 index 0000000..fd0b539 Binary files /dev/null and b/DLL/System.Web.Http.Cors.dll differ diff --git a/DLL/System.Web.Http.SelfHost.dll b/DLL/System.Web.Http.SelfHost.dll new file mode 100644 index 0000000..852728e Binary files /dev/null and b/DLL/System.Web.Http.SelfHost.dll differ diff --git a/DLL/System.Web.Http.dll b/DLL/System.Web.Http.dll new file mode 100644 index 0000000..7e3bd30 Binary files /dev/null and b/DLL/System.Web.Http.dll differ diff --git a/DLL/Ubiety.Dns.Core.dll b/DLL/Ubiety.Dns.Core.dll new file mode 100644 index 0000000..2f0c84e Binary files /dev/null and b/DLL/Ubiety.Dns.Core.dll differ diff --git a/DLL/WeifenLuo.WinFormsUI.Docking.ThemeVS2015.dll b/DLL/WeifenLuo.WinFormsUI.Docking.ThemeVS2015.dll new file mode 100644 index 0000000..0dbf5f4 Binary files /dev/null and b/DLL/WeifenLuo.WinFormsUI.Docking.ThemeVS2015.dll differ diff --git a/DLL/WeifenLuo.WinFormsUI.Docking.dll b/DLL/WeifenLuo.WinFormsUI.Docking.dll new file mode 100644 index 0000000..e4b2787 Binary files /dev/null and b/DLL/WeifenLuo.WinFormsUI.Docking.dll differ diff --git a/DLL/Zstandard.Net.dll b/DLL/Zstandard.Net.dll new file mode 100644 index 0000000..83934d1 Binary files /dev/null and b/DLL/Zstandard.Net.dll differ diff --git a/DLL/log4net.dll b/DLL/log4net.dll new file mode 100644 index 0000000..8646b6f Binary files /dev/null and b/DLL/log4net.dll differ diff --git a/DLL/netstandard.dll b/DLL/netstandard.dll new file mode 100644 index 0000000..1f1ab22 Binary files /dev/null and b/DLL/netstandard.dll differ diff --git a/MW_Log/01_MW_Log.csproj b/MW_Log/01_MW_Log.csproj new file mode 100644 index 0000000..9ae8740 --- /dev/null +++ b/MW_Log/01_MW_Log.csproj @@ -0,0 +1,57 @@ + + + + + Debug + AnyCPU + {1AC112C4-2400-4D03-A26D-2E3ACE6FE6D4} + Library + Properties + MW_Log + MW_Log + v4.8 + 512 + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\DLL\log4net.dll + + + + + + + + + + + + + + + + + Always + + + + \ No newline at end of file diff --git a/MW_Log/LoggerHelper.cs b/MW_Log/LoggerHelper.cs new file mode 100644 index 0000000..eefb38c --- /dev/null +++ b/MW_Log/LoggerHelper.cs @@ -0,0 +1,49 @@ +using log4net; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MW_Log +{ + /// + /// LoggerHelper + /// + public class LoggerHelper + { + /// + /// LogInfo + /// + private static readonly ILog LogInfo = LogManager.GetLogger("LogInfo"); + /// + /// 记录Info日志 + /// + /// + /// + public static void Info(string type, string msg, Exception ex = null) + { + try + { + msg = $"【类别:{type}】\r\n【内容】:{msg}"; + if (ex != null) + { + LogInfo.Info(msg, ex); + } + else + { + LogInfo.Info(msg); + } + } + catch (Exception err) + { + } + + } + + + } + + + +} diff --git a/MW_Log/Properties/AssemblyInfo.cs b/MW_Log/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d199468 --- /dev/null +++ b/MW_Log/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("MW_Log")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MW_Log")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("1ac112c4-2400-4d03-a26d-2e3ace6fe6d4")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension = "config", Watch = true)] diff --git a/MW_Log/_codex_verify/MW_Log.dll b/MW_Log/_codex_verify/MW_Log.dll new file mode 100644 index 0000000..cb2a7e0 Binary files /dev/null and b/MW_Log/_codex_verify/MW_Log.dll differ diff --git a/MW_Log/_codex_verify/log4net.config b/MW_Log/_codex_verify/log4net.config new file mode 100644 index 0000000..d164c22 --- /dev/null +++ b/MW_Log/_codex_verify/log4net.config @@ -0,0 +1,35 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MW_Log/_codex_verify/log4net.dll b/MW_Log/_codex_verify/log4net.dll new file mode 100644 index 0000000..8646b6f Binary files /dev/null and b/MW_Log/_codex_verify/log4net.dll differ diff --git a/MW_Log/log4net.config b/MW_Log/log4net.config new file mode 100644 index 0000000..d164c22 --- /dev/null +++ b/MW_Log/log4net.config @@ -0,0 +1,35 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SCADA/App.config b/SCADA/App.config new file mode 100644 index 0000000..0657fcd --- /dev/null +++ b/SCADA/App.config @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SCADA/Core/AppConfig.cs b/SCADA/Core/AppConfig.cs new file mode 100644 index 0000000..5c9382a --- /dev/null +++ b/SCADA/Core/AppConfig.cs @@ -0,0 +1,317 @@ + +using HslCommunication.WebSocket; +using Newtonsoft.Json; +using NPOI.POIFS.Properties; +using NPOI.SS.Formula.Functions; +using OpcBasic; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Reflection.Emit; +using System.Threading; +using System.Windows.Forms; +using WebApi; +using static System.Configuration.ConfigurationManager; + +namespace MesWork +{ + /// + /// + /// + public partial class Temp { + public static MesWorkForm mesWorkForm = null; + } + /// + /// 配置信息 + /// + public partial class MesWorkForm + { + + public static int workerThreads = 4000; + public static int completionPortThreads = 2000; + + + public static string BasicDataTableFile = AppSettings["BasicDataTableFile"]; + public static int IsDemoMesServer = Convert.ToInt32(AppSettings["IsDemoMesServer"]); + public static int IsAllowWrite = Convert.ToInt32(AppSettings["IsAllowWrite"]); + public static int IsWriteMonitorLog = Convert.ToInt32(AppSettings["IsWriteMonitorLog"]); + public static int IsWriteLog4 = Convert.ToInt32(AppSettings["IsWriteLog4"]); + public static string ConnectionString = AppSettings["ConnectionString"]; + + public static string AuthorizationSet = AppSettings["AuthorizationSet"]; + + public static int WebApi_Port = Convert.ToInt32(AppSettings["WebApi_Port"]); + + public static string WebApi_ReqUrl = AppSettings["WebApi_ReqUrl"]; + + /// + /// 当前工位号 + /// + public static string Curr_Station = AppSettings["Curr_Station"] ?? ""; + + /// + /// 称重类型:Ground=地面称重, Hanging=空中称重/吊称 + /// + public static string WeighingType = AppSettings["WeighingType"] ?? "Hanging"; + + /// + /// 是否启用扫码枪:1=启用, 0=禁用 + /// + public static int IsUseBarcode = int.TryParse(AppSettings["IsUseBarcode"], out var _iub) ? _iub : 0; + /// + /// OP10扫码枪COM口(如COM3),空则不启用 + /// + public static string OP10BarCOM = AppSettings["OP10BarCOM"] ?? ""; + /// + /// OP20扫码枪COM口(如COM4),空则不启用 + /// + public static string OP20BarCOM = AppSettings["OP20BarCOM"] ?? ""; + /// + /// 扫码枪波特率 + /// + public static int BarcodeBaudRate = int.TryParse(AppSettings["BarcodeBaudRate"], out var _bbr) ? _bbr : 9600; + + /// + /// 设备工位名称列表(如 OP10, OP20),在OnStart中从设备表加载 + /// + public static System.Collections.Generic.List StationOpNames = new System.Collections.Generic.List(); + + /// + /// 工位显示名称映射(opName → "OP10 — 称重位1"),在OnStart中从设备表加载 + /// + public static System.Collections.Generic.Dictionary StationDisplayNames + = new System.Collections.Generic.Dictionary(System.StringComparer.OrdinalIgnoreCase); + + /// + /// 称重作业页面实例引用,供MIS_Funtion推送交互消息 + /// + public static Pages.UC_Weighing WeighingPage; + + public static Color color_Faw = Color.FromArgb(0, 44, 101);//蓝色,大众:0,44,101 + public static Color color_Good = Color.FromArgb(132, 185, 235);//浅蓝,自定义 + public static Color color_Wait = Color.FromArgb(240, 230, 140);//淡黄,显示等待状态 + public static Color color_Bad = SystemColors.ActiveBorder;//灰色,显示操作过程 + public static Color color_Grey = Color.FromArgb(192, 192, 192);//灰色,Table底色 + + public static Color color_Green = Color.FromArgb(22, 161, 136);//绿色 + public static Color color_Yellow = Color.FromArgb(246, 227, 74);//黄色 + public static Color color_Red = Color.FromArgb(255, 0, 0);//红色 + + public static Color color_Blue_FJ = Color.FromArgb(19, 34, 122);//深蓝 + public static Color color_White_FJ = Color.White;//白色 + public static Color color_Control = SystemColors.Control;//控件默认颜色 + + + + public static bool OnLine_Sql = false; + + public static string Curr_UserName = ""; + public static string Curr_LoginID = ""; + public static string Curr_UserPassWord = ""; + + + /// + /// WebApi + /// + public static InitServer initServer = null; + + + /// + /// 监控数据的所有变化,从这里产生 + /// + /// + /// + public override void OPCTagData_TagDataOnChangeMIS(object sender, DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(new WaitCallback(MIS_Funtion), e); + } + /// + /// 定时触发,检测PLC在线状态,周期:3 s + /// + /// + /// + public override void PlcStateEvent(object sender, DeviceDriver_BasicData.PlcStateEvetnArgs eState) + { + ThreadPool.QueueUserWorkItem(new WaitCallback(MIS_Device), eState); + } + /// + /// + /// + /// + /// + /// + public override void E_WriteLog(Enum_LogType t, string location, string content) + { + if (content .Contains("GetTagIDByTagTypeCodeID(),")) + { + return; + } + WriteLog_Info(t.ToString(), $"<[<{location}>]>{content}"); + } + + + /// + /// + /// + [STAThread] + static void Main() + { + new System.Threading.Mutex(true, $"MES_PWT_A95", out bool bCanRun); + if (!bCanRun) + { + MessageBox.Show("MES采集系统 已经在运行!不可重复启动!"); + return; + } + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(Temp.mesWorkForm = new MesWorkForm()); + } + + /// + /// + /// + /// + /// + private string Hello_You_All_Never_Know(string[] args) + { + return Guid.NewGuid().ToString() + Guid.NewGuid().ToString(); + } + + /// + /// 写入信号 + /// + /// + /// + /// + public static void WritePLC_IF(int tagTypeCodeID,string ststionName,object value) + { + if (IsAllowWrite == 1) + { + WritePLC(tagTypeCodeID, ststionName, value); + } + } + + + /// + /// 写日志 + /// 2023.10.30.llx + /// + public static void WriteLog_Info(string type, string msg, Exception ex = null) + { + if (IsWriteLog4 == 1) + { + MW_Log.LoggerHelper.Info(type, msg, ex); + } + } + + private void CommunicationCheckOnLine() + { + + new Thread(new ThreadStart(delegate () + { + while (true) + { + try + { + MesWorkForm.OnLine_Sql = DataLinkMesWork.SQLCommon.ExecuteDataTable("select getdate()", ConnectionString, out DataTable dt, out string err); + } + catch (Exception) { } + Thread.Sleep(5000); + } + })) + { IsBackground = true }.Start(); + + } + + + private void Loop_SelectAlarmShow() + { + while (true) + { + try + { + B_DB_Opera.Query_AlarmData(Curr_Station, out int count, out string text); + if (count > 0) + { + label_Alarm.Text = $"({count}) {text}"; + panel_Alarm.BackColor = Color.Red; + } + else + { + label_Alarm.Text = $""; + panel_Alarm.BackColor = Color.FromArgb(30, 58, 95); + } + + } + catch (Exception err) + { + } + Thread.Sleep(1000); + } + } + // Loop_ReadRealPageShow 已移除(旧UI控件引用),PLC信号显示将在 UC_Weighing 中实现 + + public void ShowSignal(Control c,string opName) + { + if (!c.Name.Contains("_Show_")) + { + return; + } + var tagTypeCodeID = Convert.ToInt32(c.Name.Split('_')[3]); + if (c is TextBox) + { + try + { + c.Text = PlcLinkForm.ReadPLC(tagTypeCodeID, opName).ToString(); + } + catch (Exception err) + { + c.Text = "不存在该信号!"; + } + } + } + + + public void ShowSignal(Control c, int tagTypeCodeID, string opName) + { + if (c is Panel) + { + try + { + c.BackColor = PlcLinkForm.ReadPLC(tagTypeCodeID, opName).ToString().ToLower().Replace("true", "1").Replace("false", "0") == "1" ? Color.Lime : color_Grey; + } + catch (Exception err) + { + c.BackColor = color_Grey; + } + } + } + + public static ConcurrentDictionary ReadPLC_OpName(string opName) + { + try + { + var res = new ConcurrentDictionary(); + var tagAdrListTagFormat0 = PlcLinkForm.ReadPLC_GroupData_SingleTag(opName); + foreach (var item in tagAdrListTagFormat0) + { + var key = item.Key; + var value = (TagFormat)item.Value; + res.TryAdd(key, value); + } + return res; + } + catch (Exception err) + { + return null; + + } + + } + + } +} diff --git a/SCADA/Core/BarcodeManager.cs b/SCADA/Core/BarcodeManager.cs new file mode 100644 index 0000000..46b89cb --- /dev/null +++ b/SCADA/Core/BarcodeManager.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace MesWork +{ + /// + /// 扫码枪管理器 — 管理最多2把扫码枪的生命周期和事件分发 + /// + public static class BarcodeManager + { + /// + /// 扫码枪实例字典,key = opName(OP10/OP20) + /// + public static Dictionary Scanners { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); + + /// + /// 是否启用扫码枪功能 + /// + public static bool IsEnabled => MesWorkForm.IsUseBarcode == 1; + + /// + /// 扫码事件回调(由外部设置,通常指向 MIS_Funtion 的处理方法) + /// + public static Action OnBarcodeScanned; + + /// + /// 初始化扫码枪(读取配置并创建实例) + /// + public static void Init() + { + if (!IsEnabled) return; + + int baudRate = MesWorkForm.BarcodeBaudRate; + + // OP10 + string op10Com = MesWorkForm.OP10BarCOM?.Trim(); + if (!string.IsNullOrEmpty(op10Com)) + { + var scanner = new BarcodeScanner("OP10", baudRate); + scanner.BarcodeReceived += HandleBarcodeReceived; + scanner.Log += HandleLog; + Scanners["OP10"] = scanner; + scanner.Connect(op10Com); + } + + // OP20 + string op20Com = MesWorkForm.OP20BarCOM?.Trim(); + if (!string.IsNullOrEmpty(op20Com)) + { + var scanner = new BarcodeScanner("OP20", baudRate); + scanner.BarcodeReceived += HandleBarcodeReceived; + scanner.Log += HandleLog; + Scanners["OP20"] = scanner; + scanner.Connect(op20Com); + } + } + + /// + /// 统一扫码事件处理 + /// + private static void HandleBarcodeReceived(string opName, string barcode) + { + OnBarcodeScanned?.Invoke(opName, barcode); + } + + /// + /// 扫码枪日志 → 系统日志 + 称重页面 + /// + private static void HandleLog(string message) + { + MesWorkForm.WriteLog_Info("BarcodeScanner", message); + MesWorkForm.WeighingPage?.AppendLog(message); + } + + /// + /// 手动发送条码(模拟扫码触发) + /// + public static void ManualSend(string opName, string barcode) + { + // 直接走事件回调,和自动扫码一样的路径 + if (!string.IsNullOrWhiteSpace(barcode)) + HandleBarcodeReceived(opName, barcode.Trim()); + } + + /// + /// 释放所有扫码枪 + /// + public static void Shutdown() + { + foreach (var scanner in Scanners.Values) + { + try { scanner.Dispose(); } catch { } + } + Scanners.Clear(); + } + + /// + /// 获取所有可用COM口 + /// + public static string[] GetAvailablePorts() + { + try { return System.IO.Ports.SerialPort.GetPortNames(); } + catch { return new string[0]; } + } + } +} diff --git a/SCADA/Core/BarcodeScanner.cs b/SCADA/Core/BarcodeScanner.cs new file mode 100644 index 0000000..72ae18f --- /dev/null +++ b/SCADA/Core/BarcodeScanner.cs @@ -0,0 +1,323 @@ +using System; +using System.IO.Ports; +using System.Text; +using System.Threading.Tasks; + +namespace MesWork +{ + /// + /// 单把扫码枪的串口通信封装 + /// 包含数据接收(缓冲+空闲提交)、防抖、断线自动重连 + /// + public class BarcodeScanner : IDisposable + { + // ── 基本属性 ── + /// 关联工位号(OP10/OP20) + public string OpName { get; } + + /// 当前COM口 + public string ComPort { get; private set; } + + /// 是否已连接 + public bool IsConnected + { + get { try { return _serial != null && _serial.IsOpen; } catch { return false; } } + } + + /// 最近一次扫到的条码 + public string LastBarcode { get; private set; } = ""; + + /// 最近一次扫码时间 + public DateTime? LastScanTime { get; private set; } + + // ── 事件 ── + /// 扫码完成事件(opName, barcode) + public event Action BarcodeReceived; + + /// 日志事件(message),由外部接入系统日志 + public event Action Log; + + // ── 私有字段 ── + private SerialPort _serial; + private readonly int _baudRate; + private readonly object _bufferLock = new object(); + private readonly StringBuilder _buffer = new StringBuilder(256); + private System.Windows.Forms.Timer _flushTimer; + private const int FlushIntervalMs = 60; + + // 防抖 + private string _lastDebounceCode = ""; + private DateTime _lastDebounceTime = DateTime.MinValue; + private const int DebounceMs = 500; + + // 断线重连 + private System.Windows.Forms.Timer _reconnectTimer; + private volatile bool _reconnecting = false; + private bool _disposed = false; + + public BarcodeScanner(string opName, int baudRate = 9600) + { + OpName = opName; + _baudRate = baudRate; + } + + /// + /// 连接指定COM口 + /// + public bool Connect(string comPort) + { + if (string.IsNullOrWhiteSpace(comPort) || comPort.Length < 3) + return false; + + try + { + Disconnect(); + ComPort = comPort; + + _serial = new SerialPort + { + PortName = comPort, + BaudRate = _baudRate, + Parity = Parity.None, + StopBits = StopBits.One, + ReadTimeout = 1000, + DtrEnable = true + }; + _serial.DataReceived += Serial_DataReceived; + _serial.Open(); + + // 空闲提交定时器 + if (_flushTimer == null) + { + _flushTimer = new System.Windows.Forms.Timer { Interval = FlushIntervalMs }; + _flushTimer.Tick += FlushTimer_Tick; + } + + // 断线重连定时器(每3秒检测) + if (_reconnectTimer == null) + { + _reconnectTimer = new System.Windows.Forms.Timer { Interval = 3000 }; + _reconnectTimer.Tick += ReconnectTimer_Tick; + } + _reconnectTimer.Start(); + + Log?.Invoke($"[{OpName}] 扫码枪已连接 ({comPort})"); + return true; + } + catch (Exception ex) + { + Log?.Invoke($"[{OpName}] 扫码枪连接失败 ({comPort}):{ex.Message}"); + return false; + } + } + + /// + /// 断开连接 + /// + public void Disconnect() + { + try + { + _reconnectTimer?.Stop(); + _flushTimer?.Stop(); + + if (_serial != null) + { + _serial.DataReceived -= Serial_DataReceived; + if (_serial.IsOpen) _serial.Close(); + _serial.Dispose(); + _serial = null; + } + } + catch { } + } + + /// + /// 测试当前COM口是否可连接 + /// + public bool TestConnection(string comPort) + { + try + { + using (var sp = new SerialPort(comPort, _baudRate)) + { + sp.Open(); + sp.Close(); + return true; + } + } + catch { return false; } + } + + // ── 串口数据接收 ── + private void Serial_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + try + { + if (_serial == null || !_serial.IsOpen) return; + + int bytesToRead = _serial.BytesToRead; + if (bytesToRead <= 0) return; + + byte[] buf = new byte[bytesToRead]; + _serial.Read(buf, 0, bytesToRead); + string chunk = Encoding.UTF8.GetString(buf, 0, bytesToRead); + + lock (_bufferLock) + { + _buffer.Append(chunk); + string acc = _buffer.ToString(); + + // 按换行符(\r \n)拆分完整条码 + int startIndex = 0; + for (int i = 0; i < acc.Length; i++) + { + if (acc[i] == '\r' || acc[i] == '\n') + { + int len = i - startIndex; + if (len > 0) + { + string line = acc.Substring(startIndex, len).Trim(); + if (!string.IsNullOrEmpty(line)) + SubmitBarcode(line); + } + startIndex = i + 1; + } + } + + if (startIndex >= acc.Length) + _buffer.Clear(); + else if (startIndex > 0) + { + _buffer.Clear(); + _buffer.Append(acc.Substring(startIndex)); + } + + // 无换行 → 启动空闲定时器 + if (_buffer.Length > 0) + { + try + { + _flushTimer?.Stop(); + _flushTimer?.Start(); + } + catch { } + } + } + } + catch (Exception ex) + { + if (ex is System.IO.IOException || ex is InvalidOperationException) + { + Log?.Invoke($"[{OpName}] 扫码枪通信异常,尝试重连:{ex.Message}"); + TryReopen(); + } + } + finally + { + try { _serial?.DiscardInBuffer(); } catch { } + } + } + + // 空闲超时提交缓冲区 + private void FlushTimer_Tick(object sender, EventArgs e) + { + _flushTimer.Stop(); + string toSend; + lock (_bufferLock) + { + toSend = _buffer.ToString().Trim(); + _buffer.Clear(); + } + if (!string.IsNullOrEmpty(toSend)) + SubmitBarcode(toSend); + } + + // 提交条码(含防抖) + private void SubmitBarcode(string barcode) + { + barcode = barcode.Replace("\r", "").Replace("\n", "").Replace("\0", "").Trim(); + if (string.IsNullOrEmpty(barcode)) return; + + // 防抖 + var now = DateTime.Now; + if (barcode == _lastDebounceCode && (now - _lastDebounceTime).TotalMilliseconds < DebounceMs) + return; + _lastDebounceCode = barcode; + _lastDebounceTime = now; + + // 更新状态 + LastBarcode = barcode; + LastScanTime = now; + + // 触发事件 + BarcodeReceived?.Invoke(OpName, barcode); + } + + /// + /// 手动发送条码(模拟扫码触发,走完整业务流程) + /// + public void ManualSend(string barcode) + { + if (!string.IsNullOrWhiteSpace(barcode)) + SubmitBarcode(barcode.Trim()); + } + + // ── 断线重连 ── + private void ReconnectTimer_Tick(object sender, EventArgs e) + { + if (_reconnecting || string.IsNullOrWhiteSpace(ComPort)) return; + if (IsConnected) return; + + _reconnecting = true; + Task.Run(() => + { + try { TryReopen(); } + catch { } + finally { _reconnecting = false; } + }); + } + + private void TryReopen() + { + try + { + string[] ports = SerialPort.GetPortNames(); + bool exists = Array.Exists(ports, p => string.Equals(p, ComPort, StringComparison.OrdinalIgnoreCase)); + if (!exists) return; + + if (_serial != null) + { + try { if (_serial.IsOpen) _serial.Close(); } catch { } + try { _serial.Dispose(); } catch { } + } + + _serial = new SerialPort + { + PortName = ComPort, + BaudRate = _baudRate, + Parity = Parity.None, + StopBits = StopBits.One, + ReadTimeout = 1000, + DtrEnable = true + }; + _serial.DataReceived += Serial_DataReceived; + _serial.Open(); + Log?.Invoke($"[{OpName}] 扫码枪自动重连成功 ({ComPort})"); + } + catch (Exception ex) + { + Log?.Invoke($"[{OpName}] 扫码枪自动重连失败 ({ComPort}):{ex.Message}"); + } + } + + public void Dispose() + { + if (_disposed) return; + _disposed = true; + Disconnect(); + _flushTimer?.Dispose(); + _reconnectTimer?.Dispose(); + } + } +} diff --git a/SCADA/Core/IconHelper.cs b/SCADA/Core/IconHelper.cs new file mode 100644 index 0000000..070683a --- /dev/null +++ b/SCADA/Core/IconHelper.cs @@ -0,0 +1,40 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace MesWork +{ + /// + /// 窗口图标加载工具类(多路径搜索 + exe回退) + /// + public static class IconHelper + { + private static readonly string[] IconSearchPaths = new[] + { + System.IO.Path.Combine(Application.StartupPath, "任务管理.ico"), + System.IO.Path.Combine(System.IO.Path.GetDirectoryName( + System.Reflection.Assembly.GetExecutingAssembly().Location) ?? "", "任务管理.ico"), + "任务管理.ico" + }; + + /// + /// 为指定窗体加载图标 + /// + public static void ApplyIcon(Form form) + { + try + { + foreach (var path in IconSearchPaths) + { + if (System.IO.File.Exists(path)) + { + form.Icon = new Icon(path); + return; + } + } + form.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); + } + catch { } + } + } +} diff --git a/SCADA/Core/OExcel.cs b/SCADA/Core/OExcel.cs new file mode 100644 index 0000000..3c0fff3 --- /dev/null +++ b/SCADA/Core/OExcel.cs @@ -0,0 +1,626 @@ +using NPOI.HPSF; +using NPOI.HSSF.UserModel; +using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NPOITest +{ + + /// + /// Execl工具辅助类 + /// + public class ExeclHelper + { + + /// + /// 读取Execl数据到DataTable中 + /// + /// 指定Execl文件路径 + /// 设置第一行是否是列名 + /// 返回一个DataTable数据集 + public static DataTable ExcelToDataTable(string filePath, string sheetName, bool isColumnName) + { + DataTable dataTable = null; + FileStream fs = null; + DataColumn column = null; + DataRow dataRow = null; + IWorkbook workbook = null; + ISheet sheet = null; + IRow row = null; + ICell cell = null; + int startRow = 0; + try + { + using (fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + // 2007版本 + if (filePath.IndexOf(".xlsx") > 0) + workbook = new XSSFWorkbook(fs); + // 2003版本 + else if (filePath.IndexOf(".xls") > 0) + workbook = new HSSFWorkbook(fs); + if (workbook != null) + { + sheet = workbook.GetSheet(sheetName);//读取第一个sheet,当然也可以循环读取每个sheet + dataTable = new DataTable(); + if (sheet != null) + { + int rowCount = sheet.LastRowNum;//总行数 + if (rowCount > 0) + { + IRow firstRow = sheet.GetRow(0);//第一行 + int cellCount = firstRow.LastCellNum;//列数 + + //构建datatable的列 + if (isColumnName) + { + startRow = 1;//如果第一行是列名,则从第二行开始读取 + for (int i = firstRow.FirstCellNum; i < cellCount; ++i) + { + cell = firstRow.GetCell(i); + if (cell != null) + { + if (cell.StringCellValue != null) + { + column = new DataColumn(cell.StringCellValue); + dataTable.Columns.Add(column); + } + } + } + } + else + { + for (int i = firstRow.FirstCellNum; i < cellCount; ++i) + { + column = new DataColumn("column" + (i + 1)); + dataTable.Columns.Add(column); + } + } + + //填充行 + for (int i = startRow; i <= rowCount; ++i) + { + row = sheet.GetRow(i); + if (row == null) continue; + + dataRow = dataTable.NewRow(); + for (int j = row.FirstCellNum; j < cellCount; ++j) + { + cell = row.GetCell(j); + if (cell == null) + { + dataRow[j] = ""; + } + else + { + //CellType(Unknown = -1,Numeric = 0,String = 1,Formula = 2,Blank = 3,Boolean = 4,Error = 5,) + switch (cell.CellType) + { + case CellType.Blank: + dataRow[j] = ""; + break; + case CellType.Numeric: + short format = cell.CellStyle.DataFormat; + //对时间格式(2015.12.5、2015/12/5、2015-12-5等)的处理 + if (format == 14 || format == 31 || format == 57 || format == 58) + dataRow[j] = cell.DateCellValue; + else + dataRow[j] = cell.NumericCellValue; + break; + case CellType.String: + dataRow[j] = cell.StringCellValue; + break; + } + } + } + dataTable.Rows.Add(dataRow); + } + } + } + } + } + return dataTable; + } + catch (Exception err) + { + if (fs != null) + { + fs.Close(); + } + return null; + } + } + + public static DataTable ExcelToDataTable(string filePath,int sheetIndex, bool isColumnName) + { + DataTable dataTable = null; + FileStream fs = null; + DataColumn column = null; + DataRow dataRow = null; + IWorkbook workbook = null; + ISheet sheet = null; + IRow row = null; + ICell cell = null; + int startRow = 0; + try + { + using (fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + // 2007版本 + if (filePath.IndexOf(".xlsx") > 0) + workbook = new XSSFWorkbook(fs); + // 2003版本 + else if (filePath.IndexOf(".xls") > 0) + workbook = new HSSFWorkbook(fs); + if (workbook != null) + { + sheet = workbook.GetSheetAt(sheetIndex);//读取第一个sheet,当然也可以循环读取每个sheet + dataTable = new DataTable(); + if (sheet != null) + { + int rowCount = sheet.LastRowNum;//总行数 + if (rowCount > 0) + { + IRow firstRow = sheet.GetRow(0);//第一行 + int cellCount = firstRow.LastCellNum;//列数 + + //构建datatable的列 + if (isColumnName) + { + startRow = 1;//如果第一行是列名,则从第二行开始读取 + for (int i = firstRow.FirstCellNum; i < cellCount; ++i) + { + cell = firstRow.GetCell(i); + if (cell != null) + { + if (cell.StringCellValue != null) + { + column = new DataColumn(cell.StringCellValue); + dataTable.Columns.Add(column); + } + } + } + } + else + { + for (int i = firstRow.FirstCellNum; i < cellCount; ++i) + { + column = new DataColumn("column" + (i + 1)); + dataTable.Columns.Add(column); + } + } + + //填充行 + for (int i = startRow; i <= rowCount; ++i) + { + row = sheet.GetRow(i); + if (row == null) continue; + + dataRow = dataTable.NewRow(); + for (int j = row.FirstCellNum; j < cellCount; ++j) + { + cell = row.GetCell(j); + if (cell == null) + { + dataRow[j] = ""; + } + else + { + //CellType(Unknown = -1,Numeric = 0,String = 1,Formula = 2,Blank = 3,Boolean = 4,Error = 5,) + switch (cell.CellType) + { + case CellType.Blank: + dataRow[j] = ""; + break; + case CellType.Numeric: + short format = cell.CellStyle.DataFormat; + //对时间格式(2015.12.5、2015/12/5、2015-12-5等)的处理 + if (format == 14 || format == 31 || format == 57 || format == 58 || format == 22) + dataRow[j] = cell.DateCellValue; + else + dataRow[j] = cell.NumericCellValue; + break; + case CellType.String: + dataRow[j] = cell.StringCellValue; + break; + } + } + } + dataTable.Rows.Add(dataRow); + } + } + } + } + } + return dataTable; + } + catch (Exception) + { + if (fs != null) + { + fs.Close(); + } + return null; + } + } + public static void DataTableToExcel(DataTable dataTable, string templatePath, string outputPath, int startRow, int startCol) + { + // 加载模板文件 + using (FileStream fs = new FileStream(templatePath, FileMode.Open, FileAccess.Read)) + { + IWorkbook workbook = new XSSFWorkbook(fs); + ISheet sheet = workbook.GetSheetAt(0); // 获取第一个工作表 + // 创建单元格样式 + ICellStyle cellStyle = workbook.CreateCellStyle(); + IFont font = workbook.CreateFont(); + font.FontHeightInPoints = 12; + cellStyle.SetFont(font); + cellStyle.BorderTop = BorderStyle.Thin; + cellStyle.BorderBottom = BorderStyle.Thin; + cellStyle.BorderLeft = BorderStyle.Thin; + cellStyle.BorderRight = BorderStyle.Thin; + cellStyle.Alignment = HorizontalAlignment.Center; + // 遍历DataTable的每一行 + for (int i = 0; i < dataTable.Rows.Count; i++) + { + IRow row = sheet.CreateRow(startRow + i); // 创建新行 + + // 遍历DataTable的每一列 + for (int j = 0; j < dataTable.Columns.Count; j++) + { + ICell cell = row.CreateCell(startCol + j); // 创建新单元格 + cell.SetCellValue(dataTable.Rows[i][j].ToString()); + cell.CellStyle = cellStyle; // 应用单元格样式 + } + } + + // 保存输出文件 + using (FileStream outputStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write)) + { + workbook.Write(outputStream); + } + } + } + /// + /// 将DataTable导出到Excel文档(自动根据扩展名选择 .xlsx / .xls 格式) + /// + /// 传入一个DataTable数据集 + /// 工作表名称 + /// 导出文件完整路径(支持 .xlsx 和 .xls) + /// True表示导出成功,False表示导出失败 + public static bool DataTableToExcel(DataTable dt, string sheetName, string Outpath) + { + if (dt == null || dt.Rows.Count == 0 || string.IsNullOrWhiteSpace(Outpath)) + return false; + + IWorkbook workbook = null; + try + { + // ── 1. 根据文件扩展名选择正确的 Workbook 类型 ── + string ext = Path.GetExtension(Outpath).ToLowerInvariant(); + if (ext == ".xlsx") + workbook = new XSSFWorkbook(); // OOXML 格式 + else + workbook = new HSSFWorkbook(); // BIFF8 格式 + + ISheet sheet = workbook.CreateSheet(sheetName); + int rowCount = dt.Rows.Count; + int columnCount = dt.Columns.Count; + + // ── 2. 创建表头样式(加粗 + 背景色 + 边框) ── + ICellStyle headerStyle = workbook.CreateCellStyle(); + IFont headerFont = workbook.CreateFont(); + headerFont.IsBold = true; + headerFont.FontHeightInPoints = 11; + headerFont.FontName = "微软雅黑"; + headerStyle.SetFont(headerFont); + headerStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey25Percent.Index; + headerStyle.FillPattern = FillPattern.SolidForeground; + headerStyle.Alignment = HorizontalAlignment.Center; + headerStyle.VerticalAlignment = VerticalAlignment.Center; + headerStyle.BorderTop = BorderStyle.Thin; + headerStyle.BorderBottom = BorderStyle.Thin; + headerStyle.BorderLeft = BorderStyle.Thin; + headerStyle.BorderRight = BorderStyle.Thin; + + // ── 3. 创建数据行样式(边框) ── + ICellStyle dataStyle = workbook.CreateCellStyle(); + IFont dataFont = workbook.CreateFont(); + dataFont.FontHeightInPoints = 10; + dataFont.FontName = "微软雅黑"; + dataStyle.SetFont(dataFont); + dataStyle.VerticalAlignment = VerticalAlignment.Center; + dataStyle.BorderTop = BorderStyle.Thin; + dataStyle.BorderBottom = BorderStyle.Thin; + dataStyle.BorderLeft = BorderStyle.Thin; + dataStyle.BorderRight = BorderStyle.Thin; + + // ── 4. 写入列头 ── + IRow headerRow = sheet.CreateRow(0); + headerRow.HeightInPoints = 22; + for (int c = 0; c < columnCount; c++) + { + ICell cell = headerRow.CreateCell(c); + cell.SetCellValue(dt.Columns[c].ColumnName); + cell.CellStyle = headerStyle; + } + + // ── 5. 写入数据行 ── + for (int i = 0; i < rowCount; i++) + { + IRow row = sheet.CreateRow(i + 1); + for (int j = 0; j < columnCount; j++) + { + ICell cell = row.CreateCell(j); + object val = dt.Rows[i][j]; + // 根据数据类型设置单元格值,保留数值精度 + if (val == null || val == DBNull.Value) + { + cell.SetCellValue(""); + } + else if (val is DateTime dtVal) + { + cell.SetCellValue(dtVal.ToString("yyyy-MM-dd HH:mm:ss")); + } + else if (val is double || val is float || val is decimal) + { + cell.SetCellValue(Convert.ToDouble(val)); + } + else if (val is int || val is long || val is short) + { + cell.SetCellValue(Convert.ToDouble(val)); + } + else + { + cell.SetCellValue(val.ToString()); + } + cell.CellStyle = dataStyle; + } + } + + // ── 6. 自动调整列宽(限制最大宽度避免过宽) ── + for (int c = 0; c < columnCount; c++) + { + sheet.AutoSizeColumn(c); + int colWidth = sheet.GetColumnWidth(c); + // 最大列宽限制为 50 个字符宽度 (50 * 256) + if (colWidth > 50 * 256) + sheet.SetColumnWidth(c, 50 * 256); + // 最小列宽 + else if (colWidth < 10 * 256) + sheet.SetColumnWidth(c, 10 * 256); + } + + // ── 7. 写入文件(使用 FileMode.Create 确保覆盖写入) ── + using (FileStream fs = new FileStream(Outpath, FileMode.Create, FileAccess.Write)) + { + workbook.Write(fs); + } + return true; + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"[ExeclHelper] 导出Excel失败: {ex.Message}"); + return false; + } + finally + { + if (workbook != null) + { + workbook.Close(); + workbook = null; + } + } + } + + + /// + /// 读取Execl数据到DataTable(DataSet)中 + /// + /// 指定Execl文件路径 + /// 设置第一行是否是列名 + /// 返回一个DataTable数据集 + public static DataSet ExcelToDataSet(string filePath, bool isFirstLineColumnName) + { + DataSet dataSet = new DataSet(); + int startRow = 0; + try + { + using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + IWorkbook workbook = null; + // 如果是2007+的Excel版本 + if (filePath.IndexOf(".xlsx") > 0) + { + workbook = new XSSFWorkbook(fs); + } + // 如果是2003-的Excel版本 + else if (filePath.IndexOf(".xls") > 0) + { + workbook = new HSSFWorkbook(fs); + } + if (workbook != null) + { + //循环读取Excel的每个sheet,每个sheet页都转换为一个DataTable,并放在DataSet中 + for (int p = 0; p < workbook.NumberOfSheets; p++) + { + ISheet sheet = workbook.GetSheetAt(p); + DataTable dataTable = new DataTable(); + dataTable.TableName = sheet.SheetName; + if (sheet != null) + { + int rowCount = sheet.LastRowNum;//获取总行数 + if (rowCount > 0) + { + IRow firstRow = sheet.GetRow(0);//获取第一行 + int cellCount = firstRow.LastCellNum;//获取总列数 + + //构建datatable的列 + if (isFirstLineColumnName) + { + startRow = 1;//如果第一行是列名,则从第二行开始读取 + for (int i = firstRow.FirstCellNum; i < cellCount; ++i) + { + ICell cell = firstRow.GetCell(i); + if (cell != null) + { + if (cell.StringCellValue != null) + { + DataColumn column = new DataColumn(cell.StringCellValue); + dataTable.Columns.Add(column); + } + } + } + } + else + { + for (int i = firstRow.FirstCellNum; i < cellCount; ++i) + { + DataColumn column = new DataColumn("column" + (i + 1)); + dataTable.Columns.Add(column); + } + } + + //填充行 + for (int i = startRow; i <= rowCount; ++i) + { + IRow row = sheet.GetRow(i); + if (row == null) continue; + + DataRow dataRow = dataTable.NewRow(); + for (int j = row.FirstCellNum; j < cellCount; ++j) + { + ICell cell = row.GetCell(j); + if (cell == null) + { + dataRow[j] = ""; + } + else + { + //CellType(Unknown = -1,Numeric = 0,String = 1,Formula = 2,Blank = 3,Boolean = 4,Error = 5,) + switch (cell.CellType) + { + case CellType.Blank: + dataRow[j] = ""; + break; + case CellType.Numeric: + short format = cell.CellStyle.DataFormat; + //对时间格式(2015.12.5、2015/12/5、2015-12-5等)的处理 + if (format == 14 || format == 31 || format == 57 || format == 58) + dataRow[j] = cell.DateCellValue; + else + dataRow[j] = cell.NumericCellValue; + break; + case CellType.String: + dataRow[j] = cell.StringCellValue; + break; + } + } + } + dataTable.Rows.Add(dataRow); + } + } + } + dataSet.Tables.Add(dataTable); + } + + } + } + return dataSet; + } + catch (Exception err) + { + return null; + } + } + + + /// + /// 将DataTable(DataSet)导出到Execl文档 + /// + /// 传入一个DataSet + /// 导出路径(可以不加扩展名,不加默认为.xls) + /// 返回一个Bool类型的值,表示是否导出成功 + /// True表示导出成功,Flase表示导出失败 + public static bool DataSetToExcel(DataSet dataSet, string Outpath) + { + bool result = false; + try + { + if (dataSet == null || dataSet.Tables == null || dataSet.Tables.Count == 0 || string.IsNullOrEmpty(Outpath)) + throw new Exception("输入的DataSet或路径异常"); + int sheetIndex = 0; + //根据输出路径的扩展名判断workbook的实例类型 + IWorkbook workbook = null; + string pathExtensionName = Outpath.Trim().Substring(Outpath.Length - 5); + if (pathExtensionName.Contains(".xlsx")) + { + workbook = new XSSFWorkbook(); + } + else if (pathExtensionName.Contains(".xls")) + { + workbook = new HSSFWorkbook(); + } + else + { + Outpath = Outpath.Trim() + ".xls"; + workbook = new HSSFWorkbook(); + } + //将DataSet导出为Excel + foreach (DataTable dt in dataSet.Tables) + { + sheetIndex++; + if (dt != null && dt.Rows.Count > 0) + { + ISheet sheet = workbook.CreateSheet(string.IsNullOrEmpty(dt.TableName) ? ("sheet" + sheetIndex) : dt.TableName);//创建一个名称为Sheet0的表 + int rowCount = dt.Rows.Count;//行数 + int columnCount = dt.Columns.Count;//列数 + + //设置列头 + IRow row = sheet.CreateRow(0);//excel第一行设为列头 + for (int c = 0; c < columnCount; c++) + { + ICell cell = row.CreateCell(c); + cell.SetCellValue(dt.Columns[c].ColumnName); + } + + //设置每行每列的单元格, + for (int i = 0; i < rowCount; i++) + { + row = sheet.CreateRow(i + 1); + for (int j = 0; j < columnCount; j++) + { + ICell cell = row.CreateCell(j);//excel第二行开始写入数据 + cell.SetCellValue(dt.Rows[i][j].ToString()); + } + } + } + } + //向outPath输出数据 + using (FileStream fs = File.OpenWrite(Outpath)) + { + workbook.Write(fs);//向打开的这个xls文件中写入数据 + result = true; + } + return result; + } + catch (Exception ex) + { + return false; + } + } + + + } + + +} + + diff --git a/SCADA/Core/PLC_R.cs b/SCADA/Core/PLC_R.cs new file mode 100644 index 0000000..6ee298f --- /dev/null +++ b/SCADA/Core/PLC_R.cs @@ -0,0 +1,25 @@ +using System; +using System.Text; + +namespace DC_A95 +{ + public class PLC_R + { + /// + /// 清理PLC字符串乱码(统一入口,支持object参数) + /// 过滤不可见字符,保留可打印ASCII和中文等有效字符 + /// + public static string GetString_CleanGarbled(object input) + { + if (input == null) return ""; + string str = input.ToString(); + if (string.IsNullOrEmpty(str)) return ""; + var sb = new StringBuilder(); + foreach (char c in str) + { + if (c >= 0x20 && c < 0xFFFE) sb.Append(c); + } + return sb.ToString().Trim(); + } + } +} diff --git a/SCADA/Core/SqlOperation.cs b/SCADA/Core/SqlOperation.cs new file mode 100644 index 0000000..8d2c94d --- /dev/null +++ b/SCADA/Core/SqlOperation.cs @@ -0,0 +1,72 @@ +using MesWork; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; + +namespace MesWork +{ + public class SqlOperation + { + public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, MesWorkForm.ConnectionString, ref sqlParameters, out errorMessage); + } + public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out DataTable dt, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, MesWorkForm.ConnectionString, ref sqlParameters, out dt, out errorMessage); + } + public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, MesWorkForm.ConnectionString, ref sqlParameters, out ds, out errorMessage); + } + public static bool ExecuteSql(string sql, out DataTable dt, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteSql(sql, MesWorkForm.ConnectionString, out dt, out errorMessage); + } + + public static bool ExecuteSql(string sql, out DataSet ds, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteDataset(sql, MesWorkForm.ConnectionString, out ds, out errorMessage); + } + + public static bool ExecuteSql(string sql, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteSql(sql, MesWorkForm.ConnectionString, out errorMessage); + } + + + /// + /// 通过SqlBulkCopy复制table数据到数据库 + /// + /// + public static bool SqlbulkcopyInsert(DataTable dt, out string ErrMsg) + { + bool success = false; + ErrMsg = ""; + try + { + // SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(connectString, SqlBulkCopyOptions.KeepIdentity);//删除自增ID插入原始数据 + SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(MesWorkForm.ConnectionString, SqlBulkCopyOptions.UseInternalTransaction);//批量事务处理 + sqlbulkcopy.DestinationTableName = dt.TableName;//数据库中的表名 + for (int i = 0; i < dt.Columns.Count; i++) + { + var columnName = dt.Columns[i].ColumnName.ToString(); + sqlbulkcopy.ColumnMappings.Add(columnName, columnName); + } + sqlbulkcopy.WriteToServer(dt); + success = true; + } + catch (Exception err) + { + ErrMsg = err.Message; + } + return success; + + } + + + } +} diff --git a/SCADA/Frm_Login.Designer.cs b/SCADA/Frm_Login.Designer.cs new file mode 100644 index 0000000..2c92167 --- /dev/null +++ b/SCADA/Frm_Login.Designer.cs @@ -0,0 +1,192 @@ +namespace MesWork +{ + partial class Frm_Login + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + private void InitializeComponent() + { + this.pnl_Card = new System.Windows.Forms.Panel(); + this.lbl_Title = new System.Windows.Forms.Label(); + this.lbl_SubTitle = new System.Windows.Forms.Label(); + this.lbl_User = new System.Windows.Forms.Label(); + this.txt_LoginID = new System.Windows.Forms.TextBox(); + this.lbl_Pwd = new System.Windows.Forms.Label(); + this.txt_userPassword = new System.Windows.Forms.TextBox(); + this.btn_Login = new System.Windows.Forms.Button(); + this.btn_Cancel = new System.Windows.Forms.Button(); + this.lbl_Msg = new System.Windows.Forms.Label(); + this.pnl_Card.SuspendLayout(); + this.SuspendLayout(); + // + // pnl_Card - 白色登录卡片 + // + this.pnl_Card.BackColor = System.Drawing.Color.White; + this.pnl_Card.Location = new System.Drawing.Point(310, 180); + this.pnl_Card.Name = "pnl_Card"; + this.pnl_Card.Size = new System.Drawing.Size(400, 380); + this.pnl_Card.TabIndex = 0; + this.pnl_Card.Paint += new System.Windows.Forms.PaintEventHandler(this.pnl_Card_Paint); + // + // lbl_Title - 系统图标+名称 + // + this.lbl_Title.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Bold); + this.lbl_Title.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.lbl_Title.Location = new System.Drawing.Point(20, 30); + this.lbl_Title.Name = "lbl_Title"; + this.lbl_Title.Size = new System.Drawing.Size(360, 40); + this.lbl_Title.TabIndex = 0; + this.lbl_Title.Text = "⚖ 称重数据采集分析"; + this.lbl_Title.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lbl_SubTitle + // + this.lbl_SubTitle.Font = new System.Drawing.Font("微软雅黑", 11F); + this.lbl_SubTitle.ForeColor = System.Drawing.Color.FromArgb(107, 114, 128); + this.lbl_SubTitle.Location = new System.Drawing.Point(20, 72); + this.lbl_SubTitle.Name = "lbl_SubTitle"; + this.lbl_SubTitle.Size = new System.Drawing.Size(360, 24); + this.lbl_SubTitle.TabIndex = 1; + this.lbl_SubTitle.Text = "管理系统"; + this.lbl_SubTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lbl_User + // + this.lbl_User.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_User.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_User.Location = new System.Drawing.Point(40, 120); + this.lbl_User.Name = "lbl_User"; + this.lbl_User.Size = new System.Drawing.Size(60, 24); + this.lbl_User.TabIndex = 2; + this.lbl_User.Text = "👤 用户名"; + // + // txt_LoginID + // + this.txt_LoginID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_LoginID.Font = new System.Drawing.Font("微软雅黑", 12F); + this.txt_LoginID.Location = new System.Drawing.Point(40, 148); + this.txt_LoginID.Name = "txt_LoginID"; + this.txt_LoginID.Size = new System.Drawing.Size(320, 29); + this.txt_LoginID.TabIndex = 1; + this.txt_LoginID.Text = "admin"; + this.txt_LoginID.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_LoginID_KeyDown); + // + // lbl_Pwd + // + this.lbl_Pwd.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_Pwd.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_Pwd.Location = new System.Drawing.Point(40, 195); + this.lbl_Pwd.Name = "lbl_Pwd"; + this.lbl_Pwd.Size = new System.Drawing.Size(60, 24); + this.lbl_Pwd.TabIndex = 4; + this.lbl_Pwd.Text = "🔒 密码"; + // + // txt_userPassword + // + this.txt_userPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_userPassword.Font = new System.Drawing.Font("微软雅黑", 12F); + this.txt_userPassword.Location = new System.Drawing.Point(40, 223); + this.txt_userPassword.Name = "txt_userPassword"; + this.txt_userPassword.PasswordChar = '*'; + this.txt_userPassword.Size = new System.Drawing.Size(320, 29); + this.txt_userPassword.TabIndex = 2; + this.txt_userPassword.Text = "admin"; + this.txt_userPassword.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_userPassword_KeyDown); + // + // btn_Login - Steel Blue 主按钮 + // + this.btn_Login.BackColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.btn_Login.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Login.FlatAppearance.BorderSize = 0; + this.btn_Login.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Login.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold); + this.btn_Login.ForeColor = System.Drawing.Color.White; + this.btn_Login.Location = new System.Drawing.Point(40, 280); + this.btn_Login.Name = "btn_Login"; + this.btn_Login.Size = new System.Drawing.Size(150, 42); + this.btn_Login.TabIndex = 3; + this.btn_Login.Text = "登 录"; + this.btn_Login.UseVisualStyleBackColor = false; + this.btn_Login.Click += new System.EventHandler(this.btn_Login_Click); + // + // btn_Cancel - 灰色边框按钮 + // + this.btn_Cancel.BackColor = System.Drawing.Color.White; + this.btn_Cancel.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Cancel.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(209, 213, 219); + this.btn_Cancel.FlatAppearance.BorderSize = 1; + this.btn_Cancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Cancel.Font = new System.Drawing.Font("微软雅黑", 12F); + this.btn_Cancel.ForeColor = System.Drawing.Color.FromArgb(107, 114, 128); + this.btn_Cancel.Location = new System.Drawing.Point(210, 280); + this.btn_Cancel.Name = "btn_Cancel"; + this.btn_Cancel.Size = new System.Drawing.Size(150, 42); + this.btn_Cancel.TabIndex = 4; + this.btn_Cancel.Text = "取 消"; + this.btn_Cancel.UseVisualStyleBackColor = false; + this.btn_Cancel.Click += new System.EventHandler(this.btn_Cancel_Click); + // + // lbl_Msg + // + this.lbl_Msg.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_Msg.ForeColor = System.Drawing.Color.FromArgb(239, 68, 68); + this.lbl_Msg.Location = new System.Drawing.Point(40, 332); + this.lbl_Msg.Name = "lbl_Msg"; + this.lbl_Msg.Size = new System.Drawing.Size(320, 24); + this.lbl_Msg.TabIndex = 8; + this.lbl_Msg.Visible = false; + // + // 添加控件到卡片 + // + this.pnl_Card.Controls.Add(this.lbl_Title); + this.pnl_Card.Controls.Add(this.lbl_SubTitle); + this.pnl_Card.Controls.Add(this.lbl_User); + this.pnl_Card.Controls.Add(this.txt_LoginID); + this.pnl_Card.Controls.Add(this.lbl_Pwd); + this.pnl_Card.Controls.Add(this.txt_userPassword); + this.pnl_Card.Controls.Add(this.btn_Login); + this.pnl_Card.Controls.Add(this.btn_Cancel); + this.pnl_Card.Controls.Add(this.lbl_Msg); + // + // Frm_Login + // + this.AcceptButton = this.btn_Login; + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(240, 244, 248); + this.ClientSize = new System.Drawing.Size(1024, 720); + this.Controls.Add(this.pnl_Card); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "Frm_Login"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "称重数据采集分析管理系统 - 登录"; + this.pnl_Card.ResumeLayout(false); + this.pnl_Card.PerformLayout(); + this.ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.Panel pnl_Card; + private System.Windows.Forms.Label lbl_Title; + private System.Windows.Forms.Label lbl_SubTitle; + private System.Windows.Forms.Label lbl_User; + private System.Windows.Forms.TextBox txt_LoginID; + private System.Windows.Forms.Label lbl_Pwd; + private System.Windows.Forms.TextBox txt_userPassword; + private System.Windows.Forms.Button btn_Login; + private System.Windows.Forms.Button btn_Cancel; + private System.Windows.Forms.Label lbl_Msg; + } +} \ No newline at end of file diff --git a/SCADA/Frm_Login.cs b/SCADA/Frm_Login.cs new file mode 100644 index 0000000..99486b0 --- /dev/null +++ b/SCADA/Frm_Login.cs @@ -0,0 +1,219 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.IO; +using System.Windows.Forms; + +namespace MesWork +{ + /// + /// 登录页面 — 全屏背景图 + 右侧白色登录卡片 + /// + public partial class Frm_Login : Form + { + /// + /// 背景图片缓存 + /// + private Image _bgImage; + + public Frm_Login() + { + InitializeComponent(); + DoubleBuffered = true; + LoadBackgroundImage(); + LoadIcon(); + } + + /// + /// 加载任务栏图标 + /// + private void LoadIcon() + { + IconHelper.ApplyIcon(this); + } + + /// + /// 加载背景图片(从 Resources 目录) + /// + private void LoadBackgroundImage() + { + try + { + string bgPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "login_bg.png"); + if (File.Exists(bgPath)) + _bgImage = Image.FromFile(bgPath); + } + catch { /* 图片加载失败时使用渐变背景兜底 */ } + } + + /// + /// 绘制背景:优先使用背景图,否则渐变兜底 + /// + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + var g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + + if (_bgImage != null) + { + // 全屏铺满背景图 + g.DrawImage(_bgImage, 0, 0, ClientSize.Width, ClientSize.Height); + + // 右侧半透明白色蒙层(让登录卡片区域更清晰) + using (var overlay = new SolidBrush(Color.FromArgb(180, 255, 255, 255))) + { + g.FillRectangle(overlay, ClientSize.Width / 2, 0, ClientSize.Width / 2, ClientSize.Height); + } + } + else + { + // 渐变兜底 + using (var brush = new LinearGradientBrush( + ClientRectangle, + Color.FromArgb(30, 58, 95), + Color.FromArgb(240, 244, 248), + LinearGradientMode.Horizontal)) + { + g.FillRectangle(brush, ClientRectangle); + } + } + + // 底部版本信息(放在右下角白色区域,确保清晰可读) + using (var font = new Font("微软雅黑", 9F)) + using (var brush = new SolidBrush(Color.FromArgb(160, 120, 120, 120))) + { + string ver = "v1.0.0 | 潍柴动力 · 称重数据采集分析管理系统"; + var sz = g.MeasureString(ver, font); + g.DrawString(ver, font, brush, ClientSize.Width - sz.Width - 20, ClientSize.Height - 36); + } + } + + /// + /// 窗口大小变化时重新定位登录卡片到右半区中央 + /// + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + if (pnl_Card != null) + { + // 卡片放在右半区的中心位置 + int rightHalfCenter = ClientSize.Width / 2 + ClientSize.Width / 4; + pnl_Card.Location = new Point( + rightHalfCenter - pnl_Card.Width / 2, + (ClientSize.Height - pnl_Card.Height) / 2); + } + } + + /// + /// 卡片圆角绘制 + /// + private void pnl_Card_Paint(object sender, PaintEventArgs e) + { + var panel = (Panel)sender; + int radius = 12; + var rect = new Rectangle(0, 0, panel.Width - 1, panel.Height - 1); + using (var path = new GraphicsPath()) + { + path.AddArc(rect.X, rect.Y, radius * 2, radius * 2, 180, 90); + path.AddArc(rect.Right - radius * 2, rect.Y, radius * 2, radius * 2, 270, 90); + path.AddArc(rect.Right - radius * 2, rect.Bottom - radius * 2, radius * 2, radius * 2, 0, 90); + path.AddArc(rect.X, rect.Bottom - radius * 2, radius * 2, radius * 2, 90, 90); + path.CloseFigure(); + panel.Region = new Region(path); + } + } + + // ==================================================================== + // 登录逻辑 + // ==================================================================== + + private void btn_Cancel_Click(object sender, EventArgs e) + { + if (MesWorkForm.Curr_UserName == "") Application.Exit(); + else DialogResult = DialogResult.Cancel; + } + + private void btn_Login_Click(object sender, EventArgs e) + { + if (txt_LoginID.Text.Trim() == "") + { + lbl_Msg.Text = "⚠ 用户名不能为空"; + lbl_Msg.Visible = true; + return; + } + + // 调用新的用户管理表登录验证 + var res = User_Login(txt_LoginID.Text.Trim(), txt_userPassword.Text, out string name, out string perm); + if (res) + { + MesWorkForm.Curr_LoginID = txt_LoginID.Text.Trim(); + MesWorkForm.Curr_UserPassWord = txt_userPassword.Text; + MesWorkForm.Curr_UserName = name; + + // 记录登录日志 + try { B_DB_Opera.SaveLog_Request(MesWorkForm.Curr_Station, Log_Type.ZK_Login, "", Log_FromAndTo.ZK, Log_FromAndTo.ZK, $"用户[{name}({txt_LoginID.Text.Trim()})]登录系统", out long _); } catch { } + + DialogResult = DialogResult.OK; + } + else + { + lbl_Msg.Text = "⚠ 登录失败,请检查用户名和密码"; + lbl_Msg.Visible = true; + } + } + + /// + /// 调用 用户管理_登录验证 SP + /// + private bool User_Login(string userName, string pwd, out string name, out string permission) + { + name = ""; + permission = ""; + try + { + var sp = "用户管理_登录验证"; + var parms = new System.Data.SqlClient.SqlParameter[] + { + new System.Data.SqlClient.SqlParameter("@用户名", userName), + new System.Data.SqlClient.SqlParameter("@密码", pwd) + }; + SqlOperation.ExecuteStoredProcedure(sp, parms, out System.Data.DataTable dt, out string err); + if (dt != null && dt.Rows.Count > 0) + { + name = dt.Rows[0]["姓名"].ToString(); + permission = dt.Rows[0]["权限"].ToString(); + return true; + } + } + catch (Exception ex) + { + MesWorkForm.WriteLog_Info("Login", $"登录异常:{ex.Message}", ex); + } + return false; + } + + /// + /// 回车切换焦点:用户名 → 密码 + /// + private void txt_LoginID_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) { txt_userPassword.Focus(); e.SuppressKeyPress = true; } + } + + /// + /// 回车触发登录:密码 → 登录 + /// + private void txt_userPassword_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) { btn_Login_Click(sender, e); e.SuppressKeyPress = true; } + } + + protected override void OnFormClosed(FormClosedEventArgs e) + { + _bgImage?.Dispose(); + base.OnFormClosed(e); + } + } +} diff --git a/SCADA/Frm_Login.resx b/SCADA/Frm_Login.resx new file mode 100644 index 0000000..7c72981 --- /dev/null +++ b/SCADA/Frm_Login.resx @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SCADA/Funtion/B_DB_Opera.cs b/SCADA/Funtion/B_DB_Opera.cs new file mode 100644 index 0000000..fcdccc0 --- /dev/null +++ b/SCADA/Funtion/B_DB_Opera.cs @@ -0,0 +1,506 @@ +using DC_A95; +using ExternalDataSync; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Threading.Tasks; + +namespace MesWork +{ + /// + /// 数据库操作 + /// + public class B_DB_Opera + { + + public static void Event_WorkStart(string opName, int tagTypeCodeID, string partType, string tagID) + { + var ChangeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var procedureName = "Event_WorkStart"; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@OpName", opName), + new SqlParameter("@TagTypeCodeID", tagTypeCodeID), + new SqlParameter("@PartType", partType), + new SqlParameter("@ChangeTime",ChangeTime), + new SqlParameter("@TagID", tagID) + }; + SqlOperation.ExecuteStoredProcedure(procedureName, sqlParameter, out string errorMessage); + + } + + public static void Event_WorkEnd(string opName, int tagTypeCodeID, string partType + , string barCode, int qualityMask, int outCount, int duration + , string tagID) + { + var ChangeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var procedureName = "Event_WorkEnd"; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@OpName", opName), + new SqlParameter("@TagTypeCodeID", tagTypeCodeID), + new SqlParameter("@PartType", partType), + new SqlParameter("@BarCode", barCode), + new SqlParameter("@QualityMask", qualityMask), + new SqlParameter("@OutCount", outCount), + new SqlParameter("@Duration", duration), + new SqlParameter("@ChangeTime",ChangeTime), + new SqlParameter("@TagID", tagID) + }; + + SqlOperation.ExecuteStoredProcedure(procedureName, sqlParameter, out string errorMessage); + } + + + public static void Event_Signal_Log(string opName, int tagTypeCodeID, string value, string tagID) + { + var ChangeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var procedureName = "Event_Signal_Log"; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@OpName", opName), + new SqlParameter("@TagTypeCodeID", tagTypeCodeID), + new SqlParameter("@Value", value), + new SqlParameter("@ChangeTime",ChangeTime), + new SqlParameter("@TagID", tagID) + }; + + SqlOperation.ExecuteStoredProcedure(procedureName, sqlParameter, out string errorMessage); + } + + + public static void Event_Alarm_Start(string opName, int tagTypeCodeID, string alarmText, string alarmLevel, string tagID) + { + var ChangeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var procedureName = "Event_Alarm_Start"; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@OpName", opName), + new SqlParameter("@TagTypeCodeID", tagTypeCodeID), + new SqlParameter("@AlarmText", alarmText), + new SqlParameter("@AlarmLevel", alarmLevel), + new SqlParameter("@ChangeTime",ChangeTime), + new SqlParameter("@TagID", tagID) + }; + + SqlOperation.ExecuteStoredProcedure(procedureName, sqlParameter, out string errorMessage); + + } + + + public static void Event_Alarm_End(string opName, int tagTypeCodeID, string alarmText, string alarmLevel, string tagID) + { + var ChangeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var procedureName = "Event_Alarm_End"; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@OpName", opName), + new SqlParameter("@TagTypeCodeID", tagTypeCodeID), + new SqlParameter("@AlarmText", alarmText), + new SqlParameter("@AlarmLevel", alarmLevel), + new SqlParameter("@ChangeTime",ChangeTime), + new SqlParameter("@TagID", tagID) + }; + + SqlOperation.ExecuteStoredProcedure(procedureName, sqlParameter, out string errorMessage); + + } + + public static void Event_AlarmAndTip_Start(string opName, int tagTypeCodeID, string alarmText, string tagID, int Alarm1_Tip2) + { + var ChangeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var procedureName = "Event_AlarmAndTip_Start"; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@OpName", opName), + new SqlParameter("@TagTypeCodeID", tagTypeCodeID), + new SqlParameter("@AlarmText", alarmText), + new SqlParameter("@ChangeTime",ChangeTime), + new SqlParameter("@TagID", tagID), + new SqlParameter("@Alarm1_Tip2", Alarm1_Tip2), + }; + SqlOperation.ExecuteStoredProcedure(procedureName, sqlParameter, out string errorMessage); + + } + + public static void MES_StatusChange(string opName, int StatusCode, string TriggerTime) + { + var procedureName = "设备管理_状态变化新增"; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@opName", opName), + new SqlParameter("@StatusCode", StatusCode), + new SqlParameter("@TriggerTime", TriggerTime), + }; + + SqlOperation.ExecuteStoredProcedure(procedureName, sqlParameter, out string errorMessage); + } + + + + public static void Query_AlarmData(string opName, out int count, out string text) + { + count = 0; + text = ""; + + var ChangeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var procedureName = "Query_AlarmData"; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@OpName", opName), + }; + SqlOperation.ExecuteStoredProcedure(procedureName, sqlParameter, out DataTable dt, out string errorMessage); + if (dt.Rows.Count > 0) + { + count = Convert.ToInt32(dt.Rows[0]["COUNT"].ToString()); + text = dt.Rows[0]["TEXT"].ToString(); + } + + } + + + public static void Event_DeviceStatus_UseTime(string opName, string Onhours, string Workhours, string DeviceStatus) + { + var ChangeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var procedureName = "Event_DeviceStatus_UseTime"; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@OpName", opName), + new SqlParameter("@Onhours", Onhours), + new SqlParameter("@Workhours", Workhours), + new SqlParameter("@DeviceStatus", DeviceStatus), + new SqlParameter("@ChangeTime",ChangeTime), + }; + + SqlOperation.ExecuteStoredProcedure(procedureName, sqlParameter, out string errorMessage); + + } + + public static void Event_DeviceStatus_Change(string opName, string DeviceStatus) + { + var ChangeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var procedureName = "Event_DeviceStatus_Change"; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@OpName", opName), + new SqlParameter("@DeviceStatus", DeviceStatus), + new SqlParameter("@ChangeTime",ChangeTime), + }; + + SqlOperation.ExecuteStoredProcedure(procedureName, sqlParameter, out string errorMessage); + + } + + + /// + /// 请求日志记录 + /// + public static void SaveLog_Request(string StationName, Log_Type LogType, string ReqCode, Log_FromAndTo ReqFrom, Log_FromAndTo ReqTo, string ReqStr, out long AID, string ReqStrSafe = "") + { + AID = -1; + var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + ReqStr = PLC_R.GetString_CleanGarbled(ReqStr); + + var param1 = new SqlParameter[] { + new SqlParameter("@工位号", StationName), + new SqlParameter("@日志类型", LogType.ToString()), + new SqlParameter("@TaskID", ReqCode), + new SqlParameter("@请求CMD",""), + new SqlParameter("@请求FROM",ReqFrom.ToString()), + new SqlParameter("@请求TO",ReqTo.ToString()), + new SqlParameter("@请求时间",CreateTime), + new SqlParameter("@请求内容",ReqStr), + new SqlParameter("@请求内容安全",ReqStrSafe) + }; + DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("Event_Log_Request", MesWorkForm.ConnectionString, ref param1, out DataTable dt, out string errorMessage); + if (dt.Rows.Count > 0) + { + AID = Convert.ToInt64(dt.Rows[0]["AID"]); + } + } + /// + /// 响应日志记录 + /// + public static void SaveLog_Response(string result, long AID) + { + try + { + var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + var param4 = new SqlParameter[] + { + new SqlParameter("@AID",AID), + new SqlParameter("@响应时间",CreateTime), + new SqlParameter("@响应内容",JsonConvert.SerializeObject(result)) + }; + DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("Event_Log_Respond", MesWorkForm.ConnectionString, ref param4, out string errorMessage); + } + catch (Exception err) + { + } + + } + + + // ==================================================================== + // 称重业务数据库方法(调用存储过程,统一 result/msg 返回格式) + // ==================================================================== + + /// + /// 从工件管理表查询机型参数(加油量/抽油量/密度/残油量上下限) + /// + public static bool QueryWorkpieceByModel(string modelNo, out decimal addOilQty, out decimal extractOilQty, out decimal density, + out decimal residualOilUpperLimit, out decimal residualOilLowerLimit) + { + addOilQty = 0; extractOilQty = 0; density = 0; residualOilUpperLimit = 0; residualOilLowerLimit = 0; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@机型号", modelNo) + }; + SqlOperation.ExecuteStoredProcedure("称重_查询工件参数", sqlParameter, out DataTable dt, out string err); + if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1") + { + var row = dt.Rows[0]; + decimal.TryParse(row["加油量"]?.ToString(), out addOilQty); + decimal.TryParse(row["抽油量"]?.ToString(), out extractOilQty); + decimal.TryParse(row["密度"]?.ToString(), out density); + decimal.TryParse(row["残油量上限"]?.ToString(), out residualOilUpperLimit); + decimal.TryParse(row["残油量下限"]?.ToString(), out residualOilLowerLimit); + return true; + } + return false; + } + + /// + /// 插入称重记录 + /// + /// 新记录ID,失败返回-1 + public static long InsertWeighingRecord( + string stationNo, string weighType, string engineNo, string modelNo, + string orderNo, string palletNo, + decimal inWeight, decimal outWeight, + decimal addOilQty, decimal extractOilQty, decimal density, + decimal residualOilUpperLimit, decimal residualOilLowerLimit, + decimal oilRelease, decimal residualOil, + int qualityFlag, decimal waterContent, + string dataSource, string worker, int isComplete) + { + var sqlParameter = new SqlParameter[] { + new SqlParameter("@工位号", stationNo), + new SqlParameter("@称重类型", weighType), + new SqlParameter("@发动机号", engineNo), + new SqlParameter("@机型号", modelNo), + new SqlParameter("@工单号", orderNo), + new SqlParameter("@托盘号", palletNo), + new SqlParameter("@进站重量", inWeight), + new SqlParameter("@离站重量", outWeight), + new SqlParameter("@加油量", addOilQty), + new SqlParameter("@抽油量", extractOilQty), + new SqlParameter("@密度", density), + new SqlParameter("@残油量上限", residualOilUpperLimit), + new SqlParameter("@残油量下限", residualOilLowerLimit), + new SqlParameter("@放油量", oilRelease), + new SqlParameter("@残油量", residualOil), + new SqlParameter("@合格标志", qualityFlag), + new SqlParameter("@水含量", waterContent), + new SqlParameter("@数据来源", dataSource), + new SqlParameter("@操作者", worker), + new SqlParameter("@是否完成", isComplete) + }; + SqlOperation.ExecuteStoredProcedure("称重记录_增加", sqlParameter, out DataTable dt, out string err); + if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1") + { + return Convert.ToInt64(dt.Rows[0]["ID"]); + } + return -1; + } + + /// + /// 查询放油前记录(按发动机号匹配,称重类型='空中'且未完成) + /// + public static bool QueryWeighingBeforeOil(string engineNo, out long recordId, out decimal preWeight, out decimal addOilQty, out decimal extractOilQty, out decimal density) + { + recordId = 0; preWeight = 0; addOilQty = 0; extractOilQty = 0; density = 0; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@发动机号", engineNo) + }; + SqlOperation.ExecuteStoredProcedure("称重记录_查询放油前", sqlParameter, out DataTable dt, out string err); + if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1") + { + var row = dt.Rows[0]; + recordId = Convert.ToInt64(row["ID"]); + decimal.TryParse(row["进站重量"]?.ToString(), out preWeight); + decimal.TryParse(row["加油量"]?.ToString(), out addOilQty); + decimal.TryParse(row["抽油量"]?.ToString(), out extractOilQty); + decimal.TryParse(row["密度"]?.ToString(), out density); + return true; + } + return false; + } + + /// + /// 查询指定工位最新的称重记录(不过滤完成状态) + /// + public static bool QueryLatestRecord(string stationNo, string engineNo, + out long recordId, out decimal preWeight, + out decimal addOilQty, out decimal extractOilQty, out decimal density) + { + recordId = 0; preWeight = 0; addOilQty = 0; extractOilQty = 0; density = 0; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@工位号", stationNo), + new SqlParameter("@发动机号", engineNo) + }; + SqlOperation.ExecuteStoredProcedure("称重记录_查询最新", sqlParameter, out DataTable dt, out string err); + if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1") + { + var row = dt.Rows[0]; + recordId = Convert.ToInt64(row["ID"]); + decimal.TryParse(row["进站重量"]?.ToString(), out preWeight); + decimal.TryParse(row["加油量"]?.ToString(), out addOilQty); + decimal.TryParse(row["抽油量"]?.ToString(), out extractOilQty); + decimal.TryParse(row["密度"]?.ToString(), out density); + return true; + } + return false; + } + + /// + /// 更新称重记录为完成状态(保存称重结果) + /// + public static bool UpdateWeighingComplete(long recordId, string weighType, string stationNo, + decimal weight, decimal oilRelease, decimal residualOil, decimal waterContent, out int qualityFlag, out string msg) + { + qualityFlag = 2; + msg = ""; + var sqlParameter = new SqlParameter[] { + new SqlParameter("@ID", recordId), + new SqlParameter("@称重类型", weighType), + new SqlParameter("@工位号", stationNo), + new SqlParameter("@称重重量", weight), + new SqlParameter("@放油量", oilRelease), + new SqlParameter("@残油量", residualOil), + new SqlParameter("@水含量", waterContent) + }; + SqlOperation.ExecuteStoredProcedure("称重记录_完成更新", sqlParameter, out DataTable dt, out string err); + if (dt == null || dt.Rows.Count == 0) + { + msg = string.IsNullOrEmpty(err) ? "称重记录完成更新未返回结果" : err; + return false; + } + + qualityFlag = Convert.ToInt32(dt.Rows[0]["result"]); + msg = dt.Rows[0]["msg"].ToString(); + return true; + } + + // ==================================================================== + // 过站记录操作方法 + // ==================================================================== + + /// + /// 新增过站记录(case 44 请求工作时调用) + /// + public static long InsertStationRecord(string engineNo, string modelNo, string orderNo, string palletNo, + string stationNo, string stationName, decimal addOilQty, decimal extractOilQty, decimal density, string worker) + { + var sqlParameter = new SqlParameter[] { + new SqlParameter("@发动机号", engineNo), + new SqlParameter("@机型号", modelNo), + new SqlParameter("@工单号", orderNo), + new SqlParameter("@托盘号", palletNo), + new SqlParameter("@工位号", stationNo), + new SqlParameter("@工位名称", stationName), + new SqlParameter("@加油量", addOilQty), + new SqlParameter("@抽油量", extractOilQty), + new SqlParameter("@油密度", density), + new SqlParameter("@操作者", worker) + }; + SqlOperation.ExecuteStoredProcedure("过站记录_新增", sqlParameter, out DataTable dt, out string err); + if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1") + return Convert.ToInt64(dt.Rows[0]["ID"]); + return -1; + } + + /// + /// 更新过站记录为完成(case 19 请求保存时调用) + /// + public static bool UpdateStationComplete(string engineNo, string stationNo, decimal weight) + { + var sqlParameter = new SqlParameter[] { + new SqlParameter("@发动机号", engineNo), + new SqlParameter("@工位号", stationNo), + new SqlParameter("@称重重量", weight) + }; + SqlOperation.ExecuteStoredProcedure("过站记录_完成", sqlParameter, out DataTable dt, out string err); + return dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1"; + } + + // ==================================================================== + // 称重曲线数据操作方法 + // ==================================================================== + + /// + /// 创建曲线段记录(工件到位时调用) + /// + /// 段ID,失败返回-1 + public static long Curve_StartSegment(string opName, string engineNo, string modelNo) + { + var sqlParameter = new SqlParameter[] { + new SqlParameter("@工位号", opName), + new SqlParameter("@发动机号", engineNo), + new SqlParameter("@机型号", modelNo ?? (object)DBNull.Value) + }; + SqlOperation.ExecuteStoredProcedure("称重曲线_开始段", sqlParameter, out DataTable dt, out string err); + if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1") + { + return Convert.ToInt64(dt.Rows[0]["ID"]); + } + return -1; + } + + /// + /// 批量写入曲线采样点(采集线程每攒够N条调用一次) + /// + /// 段ID + /// 采样点列表 + /// 写入条数,失败返回0 + public static int Curve_WritePoints(long segmentId, List points) + { + if (points == null || points.Count == 0) return 0; + + // 用 JSON 序列化避免小数区域格式和字符串拼接转义问题。 + var json = JsonConvert.SerializeObject(points.Select(p => new + { + seq = p.SeqNo, + time = p.SampleTime.ToString("yyyy-MM-ddTHH:mm:ss.fff"), + weight = p.Weight + })); + + var sqlParameter = new SqlParameter[] { + new SqlParameter("@段ID", segmentId), + new SqlParameter("@采样数据", json) + }; + SqlOperation.ExecuteStoredProcedure("称重曲线_批量写入", sqlParameter, out DataTable dt, out string err); + if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1") + { + return Convert.ToInt32(dt.Rows[0]["count"]); + } + return 0; + } + + /// + /// 结束曲线段(请求保存时调用,关联称重记录ID) + /// + public static bool Curve_EndSegment(long segmentId, long weighingRecordId) + { + var sqlParameter = new SqlParameter[] { + new SqlParameter("@段ID", segmentId), + new SqlParameter("@称重记录ID", weighingRecordId > 0 ? (object)weighingRecordId : DBNull.Value) + }; + SqlOperation.ExecuteStoredProcedure("称重曲线_结束段", sqlParameter, out DataTable dt, out string err); + return dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1"; + } + + } + + /// + /// 曲线采样点数据结构 + /// + public class CurveSamplePoint + { + public int SeqNo; + public DateTime SampleTime; + public decimal Weight; + } +} diff --git a/SCADA/Funtion/MIS_Device.cs b/SCADA/Funtion/MIS_Device.cs new file mode 100644 index 0000000..5eb8fc2 --- /dev/null +++ b/SCADA/Funtion/MIS_Device.cs @@ -0,0 +1,40 @@ +using DC_A95; +using OpcBasic; +using OpcData; +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; +using SystemFramework; + +namespace MesWork +{ + /// + /// 设备状态的处理 + /// + public partial class MesWorkForm + { + + /// + /// 设备状态的处理 + /// + /// + private void MIS_Device(object e) + { + var eState = (DeviceDriver_BasicData.PlcStateEvetnArgs)e; + var ip = eState.IP.ToString(); + var onLine = eState.OnLine; + + } + + + + } +} diff --git a/SCADA/Funtion/MIS_Funtion.cs b/SCADA/Funtion/MIS_Funtion.cs new file mode 100644 index 0000000..e0d6562 --- /dev/null +++ b/SCADA/Funtion/MIS_Funtion.cs @@ -0,0 +1,509 @@ +using ExternalDataSync; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Threading; +using DC_A95; +/// +/// +/// +namespace MesWork +{ + /// + /// 处理MIS逻辑 + /// + public partial class MesWorkForm + { + /// + /// PLC信号变化处理入口 + /// 当Bool型信号值变化时由框架自动触发 + /// + /// + private void MIS_Funtion(object e) + { + try + { + var msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + if (msgEvent.TagValue == null) return; + var tagID = msgEvent.TagID.ToString(); + var opName = msgEvent.OpName.ToString(); + var tagTypeCodeID = (int)msgEvent.TagTypeCodeID; + var tagTypeID = (EnumTagTypeID)msgEvent.TagTypeID; + var isFirstValue = msgEvent.IsFirstValue.ToString().ToLower(); + var alarmLevel = msgEvent.ShaftID.ToString(); + var alarmMsg = msgEvent.ItemName.ToString(); + string tagValue; + switch (tagTypeID) + { + case EnumTagTypeID.BOOL: + tagValue = (Convert.ToInt32(msgEvent.TagValue)).ToString(); + break; + default: + tagValue = msgEvent.TagValue.ToString(); + break; + } + // ── 报警处理(编码900~2000)── + if (tagTypeCodeID >= 900 & tagTypeCodeID < 2000) + { + if (ValueT(isFirstValue)) + { + //不处理第一次变化的值 + return; + } + var opNameNew = opName.Replace("_Alarm", ""); + if (tagValue == "1") + { + B_DB_Opera.Event_Alarm_Start(opNameNew, tagTypeCodeID, alarmMsg, alarmLevel, tagID); + } + else + { + B_DB_Opera.Event_Alarm_End(opNameNew, tagTypeCodeID, alarmMsg, alarmLevel, tagID); + } + } + // ── 信号分发 ── + switch (tagTypeCodeID) + { + case 2: // 工件到位 → 启动/停止实时重量曲线采集 + if (tagValue == "1") + { + WeighingPage?.AppendLog($"[{opName}] 工件到位信号触发"); + CurveCollector_Start(opName); + } + else + { + CurveCollector_Stop(opName); + } + break; + case 14: // PLC心跳 → 回写PC心跳 + WritePLC_IF(15, opName, tagValue); + break; + case 44: // 请求工作 + if (ValueT(isFirstValue)) return; + if (tagValue == "1") + { + WeighingPage?.AppendLog($"[{opName}] PLC请求工作,开始处理..."); + Weighing_HandleRequestWork(opName, tagID); + } + else + { + WritePLC_IF(66, opName, false); //允许工作 + } + break; + case 19: // 请求保存 + if (ValueT(isFirstValue)) return; + if (tagValue == "1") + { + CurveCollector_StopSampling(opName, true); // 先停止采样,保存完成后再关联称重记录ID + WeighingPage?.AppendLog($"[{opName}] PLC请求保存数据..."); + Weighing_HandleRequestSave(opName, tagID); + } + else + { + WritePLC_IF(20, opName, false); //保存完成 + WritePLC_IF(21, opName, false); //合格标志 + } + break; + case 203: // 设备状态 + B_DB_Opera.Event_DeviceStatus_Change(opName, tagValue); + break; + default: + break; + } + } + catch (Exception err) + { } + } + // ==================================================================== + // 称重交互核心方法 + // ==================================================================== + /// + /// 获取称重类型:地面/放油前/放油后 + /// Ground模式:统一返回"地面" + /// Hanging模式:OP10=放油前,OP20=放油后 + /// + private string GetWeighingType(string opName) + { + if (WeighingType == "Ground") + return "地面"; + // Hanging模式 + return opName == "OP10" ? "放油前" : "放油后"; + } + /// + /// 处理请求工作信号 (tagTypeCodeID=44) + /// 流程:读取工件信息 → 查询参数 → 写过站记录 → 按类型处理称重记录 → 回写允许工作 + /// + private void Weighing_HandleRequestWork(string opName, string tagID) + { + B_DB_Opera.SaveLog_Request(opName, Log_Type.ZK_MesHandler, "MIS_Function", + Log_FromAndTo.ZK, Log_FromAndTo.ZK, $"触发信号【44-请求工作】", out long AID); + try + { + // 1. 读取PLC工件信息 + string engineNo = PLC_R.GetString_CleanGarbled(ReadPLC(10, opName)); // 总成编号 + string modelNo = PLC_R.GetString_CleanGarbled(ReadPLC(11, opName)); // 机型号 + string orderNo = PLC_R.GetString_CleanGarbled(ReadPLC(39, opName)); // 工单号 + string palletNo = PLC_R.GetString_CleanGarbled(ReadPLC(80, opName)); // 托盘号 + B_DB_Opera.SaveLog_Response($"【{opName}】读取工件:发动机={engineNo},机型={modelNo},工单={orderNo},托盘={palletNo}", AID); + // 推送工件信息到称重UI + int stIdx = WeighingPage?.GetStationIndex(opName) ?? 1; + WeighingPage?.UpdateStationInfo(stIdx, engineNo, modelNo, orderNo); + WeighingPage?.AppendLog($"[{opName}] 读取工件:{engineNo},机型={modelNo}"); + // 2. 查询工件管理参数(加油量/抽油量/密度/残油量上下限) + if (!B_DB_Opera.QueryWorkpieceByModel(modelNo, out decimal addOilQty, out decimal extractOilQty, out decimal density, + out decimal residualOilUpperLimit, out decimal residualOilLowerLimit)) + { + WritePLC_IF(112, opName, 3); // 报警代码=3,机型错误 + B_DB_Opera.SaveLog_Response($"【{opName}】工件管理中未找到机型[{modelNo}]的参数,发动机={engineNo}", AID); + WeighingPage?.AppendLog($"[{opName}] 机型[{modelNo}]未找到配置参数"); + return; + } + // 3. 推送工件参数到UI + WeighingPage?.UpdateOilInfo(stIdx, addOilQty, extractOilQty, density, 0, 0); + // 4. 确定称重类型和工位名称 + string weighType = GetWeighingType(opName); // 地面/放油前/放油后 + string stationName = weighType; // 工位名称直接用称重类型名 + // 4. 写过站记录(所有类型统一:INSERT一条,到达时间=NOW) + B_DB_Opera.InsertStationRecord(engineNo, modelNo, orderNo, palletNo, + opName, stationName, addOilQty, extractOilQty, density, Curr_UserName); + // 5. 按类型处理称重记录 + if (weighType == "放油后") + { + // 空中放油后:查找最新放油前记录(无论是否完成,支持多次测量) + if (!B_DB_Opera.QueryWeighingBeforeOil(engineNo, out _, out decimal preWeight, out _, out _, out _)) + { + // 写报警代码=3(发动机号错误),阻断流程 + WritePLC_IF(112, opName, 3); + B_DB_Opera.SaveLog_Response($"【{opName}】未找到发动机[{engineNo}]的空中称重记录", AID); + WeighingPage?.AppendLog($"[{opName}] 未找到[{engineNo}]放油前记录,进站失败"); + return; + } + else + { + B_DB_Opera.SaveLog_Response($"【{opName}】空中放油后准备完成,发动机={engineNo},机型={modelNo},放油前重量={preWeight}kg", AID); + } + } + else + { + // 地面 或 空中放油前:每次都新建称重记录(支持同一产品多次测量取最新) + string recordType = weighType == "地面" ? "地面" : "空中"; + B_DB_Opera.InsertWeighingRecord(opName, recordType, engineNo, modelNo, orderNo, palletNo, + 0, 0, addOilQty, extractOilQty, density, residualOilUpperLimit, residualOilLowerLimit, 0, 0, 0, 0, + opName, Curr_UserName, isComplete: 0); + B_DB_Opera.SaveLog_Response($"【{opName}】{weighType}准备完成,发动机={engineNo},机型={modelNo},残油量范围={residualOilLowerLimit:F4}-{residualOilUpperLimit:F4}L", AID); + } + // 6. 回写允许工作 + WritePLC_IF(66, opName, true); + } + catch (Exception err) + { + WritePLC_IF(112, opName, 1); // 报警代码=1,获取数据失败 + B_DB_Opera.SaveLog_Response($"【{opName}】请求工作处理失败:{err.Message}", AID); + } + } + /// + /// 处理请求保存信号 (tagTypeCodeID=19) + /// 流程:读取称重数据 → 更新过站记录 → 按类型处理称重记录 → 回写保存完成 + /// + private void Weighing_HandleRequestSave(string opName, string tagID) + { + B_DB_Opera.SaveLog_Request(opName, Log_Type.ZK_MesHandler, "MIS_Function", + Log_FromAndTo.ZK, Log_FromAndTo.ZK, $"触发信号【19-请求保存】", out long AID); + try + { + // 1. 读取PLC数据 + decimal weight = Convert.ToDecimal(ReadPLC(100140, opName)); // 重量 + decimal waterContent = Convert.ToDecimal(ReadPLC(100180, opName)); // 水含量 + string engineNo = PLC_R.GetString_CleanGarbled(ReadPLC(10, opName)); // 产品编号 + long curveWeighingRecordId = 0; + // 2. 更新过站记录(离开时间+称重重量) + B_DB_Opera.UpdateStationComplete(engineNo, opName, weight); + // 3. 确定类型并处理 + string weighType = GetWeighingType(opName); + decimal oilReleaseQty = 0; + decimal residualOilQty = 0; + int finalQualityFlag = 1; + string qualityMsg = ""; + if (weighType == "地面") + { + // 地面:查最新记录 → 放油量=重量/密度 → 标记完成 + B_DB_Opera.QueryLatestRecord(opName, engineNo, + out long recordId, out _, out decimal addOil, out decimal extractOil, out decimal dens); + curveWeighingRecordId = recordId; + oilReleaseQty = dens > 0 ? weight / dens : 0; + residualOilQty = addOil - extractOil - oilReleaseQty; + B_DB_Opera.UpdateWeighingComplete(recordId, "地面", opName, + weight, oilReleaseQty, residualOilQty, waterContent, out finalQualityFlag, out qualityMsg); + B_DB_Opera.SaveLog_Response( + $"【{opName}】地面保存完成:发动机={engineNo},重量={weight}kg,放油量={oilReleaseQty:F4}L,残油量={residualOilQty:F4}L,合格标志={finalQualityFlag},{qualityMsg}", AID); + WeighingPage?.UpdateOilResult(WeighingPage?.GetStationIndex(opName) ?? 1, oilReleaseQty, residualOilQty); + WeighingPage?.AppendLog($"[{opName}] 保存完成:{engineNo},重量={weight:F2}kg,放油量={oilReleaseQty:F4}L"); + } + else if (weighType == "放油前") + { + // 空中放油前:查最新记录 → 仅写入进站重量,不标记完成 + B_DB_Opera.QueryLatestRecord(opName, engineNo, + out long recordId, out _, out _, out _, out _); + curveWeighingRecordId = recordId; + B_DB_Opera.UpdateWeighingComplete(recordId, "空中放油前", opName, + weight, 0, 0, waterContent, out finalQualityFlag, out qualityMsg); + B_DB_Opera.SaveLog_Response( + $"【{opName}】空中放油前保存完成:发动机={engineNo},进站重量={weight}kg,合格标志={finalQualityFlag},{qualityMsg}", AID); + WeighingPage?.AppendLog($"[{opName}] 放油前保存:{engineNo},重量={weight:F2}kg"); + } + else // 放油后 + { + // 空中放油后:查最新放油前记录(无论是否完成),计算放油量更新到该记录 + if (B_DB_Opera.QueryWeighingBeforeOil(engineNo, out long recordId, out decimal preWeight, + out decimal addOil, out decimal extractOil, out decimal dens)) + { + curveWeighingRecordId = recordId; + oilReleaseQty = dens > 0 ? (preWeight - weight) / dens : 0; + residualOilQty = addOil - extractOil - oilReleaseQty; + B_DB_Opera.UpdateWeighingComplete(recordId, "空中放油后", opName, + weight, oilReleaseQty, residualOilQty, waterContent, out finalQualityFlag, out qualityMsg); + B_DB_Opera.SaveLog_Response( + $"【{opName}】空中放油后保存完成:发动机={engineNo},放油前={preWeight}kg,放油后={weight}kg,放油量={oilReleaseQty:F4}L,残油量={residualOilQty:F4}L,合格标志={finalQualityFlag},{qualityMsg}", AID); + WeighingPage?.UpdateOilResult(WeighingPage?.GetStationIndex(opName) ?? 1, oilReleaseQty, residualOilQty); + WeighingPage?.AppendLog($"[{opName}] 放油后保存:{engineNo},放油量={oilReleaseQty:F4}L,残油量={residualOilQty:F4}L"); + } + else + { + // 找不到放油前记录(可能直接进OP20):创建一条放油后记录并标记完成 + curveWeighingRecordId = B_DB_Opera.InsertWeighingRecord(opName, "空中放油后", engineNo, "", "", "", + 0, weight, 0, 0, 0, 0, 0, 0, 0, 2, waterContent, + opName, Curr_UserName, isComplete: 1); + finalQualityFlag = 2; + qualityMsg = "未找到放油前记录"; + B_DB_Opera.SaveLog_Response( + $"【{opName}】放油后保存(无放油前记录):发动机={engineNo},放油后重量={weight}kg", AID); + WeighingPage?.AppendLog($"[{opName}] ⚠️ 放油后保存:{engineNo}(无放油前记录,已新建)"); + } + } + CurveCollector_EndSegment(opName, curveWeighingRecordId); + // TODO: MES接口数据上传(接口对接后实现) + if (finalQualityFlag == 2 && !string.IsNullOrWhiteSpace(qualityMsg)) + { + WeighingPage?.AppendLog($"[{opName}] 判定不合格:{qualityMsg}"); + } + // 4. 先回写上位机判定的合格标志,再回写保存完成 + WritePLC_IF(21, opName, finalQualityFlag); + WritePLC_IF(20, opName, true); + } + catch (Exception err) + { + CurveCollector_EndSegment(opName, 0); + WritePLC_IF(112, opName, 2); // 报警代码=2,保存失败 + B_DB_Opera.SaveLog_Response($"【{opName}】保存处理失败:{err.Message}", AID); + WeighingPage?.AppendLog($"[{opName}] ❌ 保存异常:{err.Message}"); + } + } + // ==================================================================== + // 扫码枪业务处理 + // ==================================================================== + /// + /// 扫码枪扫码完成后的业务处理 + /// 将码值写入PLC地址102500,触发完成信号100016=1,1秒后复位 + /// + /// 工位号(OP10/OP20),由COM口绑定决定 + /// 扫到的条码值 + public void Barcode_HandleScan(string opName, string barcode) + { + B_DB_Opera.SaveLog_Request(opName, Log_Type.ZK_MesHandler, "MIS_Function", + Log_FromAndTo.ZK, Log_FromAndTo.ZK, $"扫码枪触发【{opName}】码值={barcode}", out long AID); + try + { + // 1. 写入码值到 PLC 地址 102500(PLC_PC_扫码枪值) + WritePLC_IF(102500, opName, barcode); + // 2. 写入扫码完成信号 100016 = 1(PC_PLC_扫码枪扫码完成) + WritePLC_IF(100016, opName, true); + // 3. 日志 + B_DB_Opera.SaveLog_Response($"【{opName}】扫码完成:码值={barcode}", AID); + WeighingPage?.AppendLog($"[{opName}] 触发扫码 码值:{barcode}"); + // 4. 1秒后复位 100016 = 0 + System.Threading.Tasks.Task.Delay(1000).ContinueWith(_ => + { + try { WritePLC_IF(100016, opName, false); } + catch { } + }); + } + catch (Exception err) + { + B_DB_Opera.SaveLog_Response($"【{opName}】扫码处理失败:{err.Message}", AID); + WeighingPage?.AppendLog($"[{opName}] ❌ 扫码处理异常:{err.Message}"); + } + } + + private class CurveCollectorState + { + public string OpName; + public long SegmentId; + public Thread WorkerThread; + public volatile bool IsRunning; + public bool IsSegmentEnded; + public bool IsWaitingSave; + public int SeqNo; + public readonly object BufferLock = new object(); + public readonly List Buffer = new List(); + } + + private static readonly ConcurrentDictionary _curveCollectors + = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + + /// + /// 工件到位后启动实时重量曲线采集。 + /// + private void CurveCollector_Start(string opName) + { + try + { + if (_curveCollectors.TryGetValue(opName, out CurveCollectorState oldState) && !oldState.IsSegmentEnded) + { + if (oldState.IsRunning) return; + CurveCollector_EndSegment(opName, 0); + } + + string engineNo = PLC_R.GetString_CleanGarbled(ReadPLC(10, opName)); + string modelNo = PLC_R.GetString_CleanGarbled(ReadPLC(11, opName)); + long segmentId = B_DB_Opera.Curve_StartSegment(opName, engineNo, modelNo); + if (segmentId <= 0) + { + WeighingPage?.AppendLog($"[{opName}] 曲线段创建失败,未启动采集"); + return; + } + + var state = new CurveCollectorState + { + OpName = opName, + SegmentId = segmentId, + IsRunning = true + }; + state.WorkerThread = new Thread(() => CurveCollector_Work(state)) + { + IsBackground = true, + Name = $"CurveCollector_{opName}" + }; + + _curveCollectors[opName] = state; + state.WorkerThread.Start(); + WeighingPage?.AppendLog($"[{opName}] 实时重量曲线采集启动,段ID={segmentId}"); + } + catch (Exception err) + { + WeighingPage?.AppendLog($"[{opName}] 曲线采集启动异常:{err.Message}"); + } + } + + /// + /// 采集线程:200ms读取一次实时重量,满10条批量写库。 + /// + private void CurveCollector_Work(CurveCollectorState state) + { + while (state.IsRunning) + { + try + { + decimal weight = Convert.ToDecimal(ReadPLC(100220, state.OpName)); + List writePoints = null; + lock (state.BufferLock) + { + state.Buffer.Add(new CurveSamplePoint + { + SeqNo = ++state.SeqNo, + SampleTime = DateTime.Now, + Weight = weight + }); + if (state.Buffer.Count >= 10) + { + writePoints = new List(state.Buffer); + state.Buffer.Clear(); + } + } + + if (writePoints != null) + { + B_DB_Opera.Curve_WritePoints(state.SegmentId, writePoints); + } + } + catch (Exception err) + { + WeighingPage?.AppendLog($"[{state.OpName}] 曲线采样异常:{err.Message}"); + } + Thread.Sleep(200); + } + + CurveCollector_Flush(state); + } + + /// + /// 停止采样线程并刷出剩余点,但暂不关闭曲线段。 + /// + private void CurveCollector_StopSampling(string opName, bool waitingSave = false) + { + if (!_curveCollectors.TryGetValue(opName, out CurveCollectorState state)) return; + + if (waitingSave) + { + state.IsWaitingSave = true; + } + state.IsRunning = false; + if (state.WorkerThread != null && state.WorkerThread.IsAlive) + { + state.WorkerThread.Join(2000); + } + CurveCollector_Flush(state); + } + + /// + /// 工件离开时停止采集并关闭曲线段。 + /// + private void CurveCollector_Stop(string opName) + { + if (_curveCollectors.TryGetValue(opName, out CurveCollectorState state) && state.IsWaitingSave) + { + return; + } + CurveCollector_EndSegment(opName, 0); + } + + /// + /// 保存完成后关闭曲线段,并关联称重记录ID。 + /// + private void CurveCollector_EndSegment(string opName, long weighingRecordId) + { + if (!_curveCollectors.TryGetValue(opName, out CurveCollectorState state)) return; + + CurveCollector_StopSampling(opName); + if (!state.IsSegmentEnded) + { + B_DB_Opera.Curve_EndSegment(state.SegmentId, weighingRecordId); + state.IsSegmentEnded = true; + WeighingPage?.AppendLog($"[{opName}] 实时重量曲线采集结束,段ID={state.SegmentId}"); + } + _curveCollectors.TryRemove(opName, out _); + } + + /// + /// 将采集缓冲区剩余点写入数据库。 + /// + private void CurveCollector_Flush(CurveCollectorState state) + { + List writePoints = null; + lock (state.BufferLock) + { + if (state.Buffer.Count > 0) + { + writePoints = new List(state.Buffer); + state.Buffer.Clear(); + } + } + + if (writePoints != null) + { + B_DB_Opera.Curve_WritePoints(state.SegmentId, writePoints); + } + } + } +} diff --git a/SCADA/MAIN_PAGE.Designer.cs b/SCADA/MAIN_PAGE.Designer.cs new file mode 100644 index 0000000..62083f9 --- /dev/null +++ b/SCADA/MAIN_PAGE.Designer.cs @@ -0,0 +1,518 @@ +using System.Windows.Forms; +namespace MesWork +{ + partial class MesWorkForm : PlcLinkForm + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + + // ── Timers ── + this.timer_OnLine_Show = new System.Windows.Forms.Timer(this.components); + this.timer_Clock = new System.Windows.Forms.Timer(this.components); + + // ── Top Bar ── + this.pnl_TopBar = new System.Windows.Forms.Panel(); + this.pnl_TopBarRight = new System.Windows.Forms.Panel(); + this.lbl_SystemTitle = new System.Windows.Forms.Label(); + this.lbl_DateTime = new System.Windows.Forms.Label(); + this.lbl_UserName = new System.Windows.Forms.Label(); + this.pnl_SqlIndicator = new System.Windows.Forms.Panel(); + this.lbl_SqlStatus = new System.Windows.Forms.Label(); + + // ── Sidebar ── + this.pnl_Sidebar = new System.Windows.Forms.Panel(); + this.pnl_SidebarScroll = new System.Windows.Forms.Panel(); + this.pnl_NavWeighing = new System.Windows.Forms.Panel(); + this.lbl_NavWeighing = new System.Windows.Forms.Label(); + this.pnl_NavUserMgmt = new System.Windows.Forms.Panel(); + this.lbl_NavUserMgmt = new System.Windows.Forms.Label(); + this.pnl_NavWorkpiece = new System.Windows.Forms.Panel(); + this.lbl_NavWorkpiece = new System.Windows.Forms.Label(); + this.pnl_NavTool = new System.Windows.Forms.Panel(); + this.lbl_NavTool = new System.Windows.Forms.Label(); + this.pnl_NavReport = new System.Windows.Forms.Panel(); + this.lbl_NavReport = new System.Windows.Forms.Label(); + this.pnl_NavStation = new System.Windows.Forms.Panel(); + this.lbl_NavStation = new System.Windows.Forms.Label(); + this.pnl_NavStatistics = new System.Windows.Forms.Panel(); + this.lbl_NavStatistics = new System.Windows.Forms.Label(); + this.pnl_NavSettings = new System.Windows.Forms.Panel(); + this.lbl_NavSettings = new System.Windows.Forms.Label(); + this.pnl_NavLog = new System.Windows.Forms.Panel(); + this.lbl_NavLog = new System.Windows.Forms.Label(); + this.pnl_NavPLC = new System.Windows.Forms.Panel(); + this.lbl_NavPLC = new System.Windows.Forms.Label(); + this.pnl_NavFullscreen = new System.Windows.Forms.Panel(); + this.lbl_NavFullscreen = new System.Windows.Forms.Label(); + this.pnl_NavClose = new System.Windows.Forms.Panel(); + this.lbl_NavClose = new System.Windows.Forms.Label(); + this.pnl_NavActiveIndicator = new System.Windows.Forms.Panel(); + + // ── Alarm Bar ── + this.panel_Alarm = new System.Windows.Forms.Panel(); + this.label_Alarm = new System.Windows.Forms.Label(); + this.lbl_AlarmIcon = new System.Windows.Forms.Label(); + + // ── Content ── + this.pnl_Content = new System.Windows.Forms.Panel(); + + this.pnl_TopBar.SuspendLayout(); + this.pnl_TopBarRight.SuspendLayout(); + this.pnl_Sidebar.SuspendLayout(); + this.pnl_SidebarScroll.SuspendLayout(); + this.panel_Alarm.SuspendLayout(); + this.SuspendLayout(); + + // ==================================================================== + // timer_OnLine_Show — 框架心跳/SQL检测 + // ==================================================================== + this.timer_OnLine_Show.Interval = 1000; + this.timer_OnLine_Show.Tick += new System.EventHandler(this.timer_OnLine_Show_Tick); + + // ==================================================================== + // timer_Clock — 时钟刷新 + // ==================================================================== + this.timer_Clock.Interval = 1000; + this.timer_Clock.Tick += new System.EventHandler(this.timer_Clock_Tick); + + // ==================================================================== + // pnl_TopBar — 顶部标题栏 (48px) + // ==================================================================== + this.pnl_TopBar.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_TopBar.Dock = System.Windows.Forms.DockStyle.Top; + this.pnl_TopBar.Height = 48; + this.pnl_TopBar.Name = "pnl_TopBar"; + this.pnl_TopBar.Controls.Add(this.lbl_SystemTitle); + this.pnl_TopBar.Controls.Add(this.pnl_TopBarRight); + + // lbl_SystemTitle + this.lbl_SystemTitle.AutoSize = false; + this.lbl_SystemTitle.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Bold); + this.lbl_SystemTitle.ForeColor = System.Drawing.Color.White; + this.lbl_SystemTitle.Location = new System.Drawing.Point(92, 0); + this.lbl_SystemTitle.Size = new System.Drawing.Size(400, 48); + this.lbl_SystemTitle.Name = "lbl_SystemTitle"; + this.lbl_SystemTitle.Text = "⚖ 称重数据采集分析管理系统"; + this.lbl_SystemTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + + // ── pnl_TopBarRight — 右侧控件容器(Dock=Right,确保任何分辨率可见)── + this.pnl_TopBarRight.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_TopBarRight.Dock = System.Windows.Forms.DockStyle.Right; + this.pnl_TopBarRight.Width = 420; + this.pnl_TopBarRight.Name = "pnl_TopBarRight"; + this.pnl_TopBarRight.Controls.Add(this.pnl_SqlIndicator); + this.pnl_TopBarRight.Controls.Add(this.lbl_SqlStatus); + this.pnl_TopBarRight.Controls.Add(this.lbl_UserName); + this.pnl_TopBarRight.Controls.Add(this.lbl_DateTime); + + // pnl_SqlIndicator — 数据库在线指示灯 + this.pnl_SqlIndicator.BackColor = System.Drawing.Color.FromArgb(209, 213, 219); + this.pnl_SqlIndicator.Location = new System.Drawing.Point(10, 17); + this.pnl_SqlIndicator.Size = new System.Drawing.Size(14, 14); + this.pnl_SqlIndicator.Name = "pnl_SqlIndicator"; + + // lbl_SqlStatus — 数据库状态标签 + this.lbl_SqlStatus.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_SqlStatus.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_SqlStatus.Location = new System.Drawing.Point(28, 0); + this.lbl_SqlStatus.Size = new System.Drawing.Size(55, 48); + this.lbl_SqlStatus.Name = "lbl_SqlStatus"; + this.lbl_SqlStatus.Text = "数据库"; + this.lbl_SqlStatus.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + + // lbl_UserName + this.lbl_UserName.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_UserName.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_UserName.Location = new System.Drawing.Point(90, 0); + this.lbl_UserName.Size = new System.Drawing.Size(160, 48); + this.lbl_UserName.Name = "lbl_UserName"; + this.lbl_UserName.Text = "操作员:"; + this.lbl_UserName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + // lbl_DateTime + this.lbl_DateTime.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_DateTime.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_DateTime.Location = new System.Drawing.Point(250, 0); + this.lbl_DateTime.Size = new System.Drawing.Size(165, 48); + this.lbl_DateTime.Name = "lbl_DateTime"; + this.lbl_DateTime.Text = "2026-04-07 20:00:00"; + this.lbl_DateTime.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + + // ==================================================================== + // pnl_Sidebar — 左侧导航栏 (80px, Navy背景) + // ==================================================================== + this.pnl_Sidebar.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_Sidebar.Dock = System.Windows.Forms.DockStyle.Left; + this.pnl_Sidebar.Width = 80; + this.pnl_Sidebar.Name = "pnl_Sidebar"; + // 全屏+退出 固定在侧栏底部 + this.pnl_NavFullscreen.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnl_NavFullscreen.Size = new System.Drawing.Size(80, 44); + this.pnl_NavClose.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnl_NavClose.Size = new System.Drawing.Size(80, 44); + this.pnl_Sidebar.Controls.Add(this.pnl_SidebarScroll); + this.pnl_Sidebar.Controls.Add(this.pnl_NavFullscreen); + this.pnl_Sidebar.Controls.Add(this.pnl_NavClose); + + // pnl_SidebarScroll — 内部滚动容器 + this.pnl_SidebarScroll.AutoScroll = true; + this.pnl_SidebarScroll.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_SidebarScroll.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnl_SidebarScroll.Name = "pnl_SidebarScroll"; + + // ── 导航项:称重作业 ── + this.pnl_NavWeighing.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavWeighing.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavWeighing.Location = new System.Drawing.Point(1, 8); + this.pnl_NavWeighing.Size = new System.Drawing.Size(78, 64); + this.pnl_NavWeighing.Name = "pnl_NavWeighing"; + this.pnl_NavWeighing.Tag = "⚖\n称重作业"; + this.lbl_NavWeighing.AutoSize = false; + this.lbl_NavWeighing.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavWeighing.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavWeighing.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_NavWeighing.Text = "⚖\n称重作业"; + this.lbl_NavWeighing.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavWeighing.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavWeighing.Controls.Add(this.lbl_NavWeighing); + // ── 导航项:用户管理 ── + this.pnl_NavUserMgmt.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavUserMgmt.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavUserMgmt.Location = new System.Drawing.Point(1, 74); + this.pnl_NavUserMgmt.Size = new System.Drawing.Size(78, 64); + this.pnl_NavUserMgmt.Name = "pnl_NavUserMgmt"; + this.pnl_NavUserMgmt.Tag = "👤\n用户管理"; + this.lbl_NavUserMgmt.AutoSize = false; + this.lbl_NavUserMgmt.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavUserMgmt.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavUserMgmt.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_NavUserMgmt.Text = "👤\n用户管理"; + this.lbl_NavUserMgmt.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavUserMgmt.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavUserMgmt.Controls.Add(this.lbl_NavUserMgmt); + // ── 导航项:工件管理 ── + this.pnl_NavWorkpiece.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavWorkpiece.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavWorkpiece.Location = new System.Drawing.Point(1, 140); + this.pnl_NavWorkpiece.Size = new System.Drawing.Size(78, 64); + this.pnl_NavWorkpiece.Name = "pnl_NavWorkpiece"; + this.pnl_NavWorkpiece.Tag = "⚙\n工件管理"; + this.lbl_NavWorkpiece.AutoSize = false; + this.lbl_NavWorkpiece.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavWorkpiece.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavWorkpiece.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_NavWorkpiece.Text = "⚙\n工件管理"; + this.lbl_NavWorkpiece.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavWorkpiece.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavWorkpiece.Controls.Add(this.lbl_NavWorkpiece); + // ── 导航项:工具管理 ── + this.pnl_NavTool.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavTool.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavTool.Location = new System.Drawing.Point(1, 206); + this.pnl_NavTool.Size = new System.Drawing.Size(78, 64); + this.pnl_NavTool.Name = "pnl_NavTool"; + this.pnl_NavTool.Tag = "🔧\n工具管理"; + this.lbl_NavTool.AutoSize = false; + this.lbl_NavTool.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavTool.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavTool.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_NavTool.Text = "🔧\n工具管理"; + this.lbl_NavTool.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavTool.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavTool.Controls.Add(this.lbl_NavTool); + // ── 导航项:报告查询 ── + this.pnl_NavReport.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavReport.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavReport.Location = new System.Drawing.Point(1, 272); + this.pnl_NavReport.Size = new System.Drawing.Size(78, 64); + this.pnl_NavReport.Name = "pnl_NavReport"; + this.pnl_NavReport.Tag = "📋\n报告查询"; + this.lbl_NavReport.AutoSize = false; + this.lbl_NavReport.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavReport.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavReport.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_NavReport.Text = "📋\n报告查询"; + this.lbl_NavReport.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavReport.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavReport.Controls.Add(this.lbl_NavReport); + // ── 导航项:过站记录 ── + this.pnl_NavStation.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavStation.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavStation.Location = new System.Drawing.Point(1, 338); + this.pnl_NavStation.Size = new System.Drawing.Size(78, 64); + this.pnl_NavStation.Name = "pnl_NavStation"; + this.pnl_NavStation.Tag = "📦\n过站记录"; + this.lbl_NavStation.AutoSize = false; + this.lbl_NavStation.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavStation.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavStation.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_NavStation.Text = "📦\n过站记录"; + this.lbl_NavStation.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavStation.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavStation.Controls.Add(this.lbl_NavStation); + // ── 导航项:统计分析 ── + this.pnl_NavStatistics.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavStatistics.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavStatistics.Location = new System.Drawing.Point(1, 404); + this.pnl_NavStatistics.Size = new System.Drawing.Size(78, 64); + this.pnl_NavStatistics.Name = "pnl_NavStatistics"; + this.pnl_NavStatistics.Tag = "📊\n统计分析"; + this.lbl_NavStatistics.AutoSize = false; + this.lbl_NavStatistics.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavStatistics.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavStatistics.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_NavStatistics.Text = "📊\n统计分析"; + this.lbl_NavStatistics.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavStatistics.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavStatistics.Controls.Add(this.lbl_NavStatistics); + // ── 导航项:系统设置 ── + this.pnl_NavSettings.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavSettings.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavSettings.Location = new System.Drawing.Point(1, 470); + this.pnl_NavSettings.Size = new System.Drawing.Size(78, 64); + this.pnl_NavSettings.Name = "pnl_NavSettings"; + this.pnl_NavSettings.Tag = "⚙\n系统设置"; + this.lbl_NavSettings.AutoSize = false; + this.lbl_NavSettings.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavSettings.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavSettings.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_NavSettings.Text = "⚙\n系统设置"; + this.lbl_NavSettings.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavSettings.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavSettings.Controls.Add(this.lbl_NavSettings); + // ── 导航项:日志查询 ── + this.pnl_NavLog.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavLog.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavLog.Location = new System.Drawing.Point(1, 536); + this.pnl_NavLog.Size = new System.Drawing.Size(78, 64); + this.pnl_NavLog.Name = "pnl_NavLog"; + this.pnl_NavLog.Tag = "📝\n日志查询"; + this.lbl_NavLog.AutoSize = false; + this.lbl_NavLog.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavLog.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavLog.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_NavLog.Text = "📝\n日志查询"; + this.lbl_NavLog.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavLog.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavLog.Controls.Add(this.lbl_NavLog); + // ── 导航项:PLC监控 ── + this.pnl_NavPLC.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavPLC.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavPLC.Location = new System.Drawing.Point(1, 602); + this.pnl_NavPLC.Size = new System.Drawing.Size(78, 64); + this.pnl_NavPLC.Name = "pnl_NavPLC"; + this.pnl_NavPLC.Tag = "📡\nPLC监控"; + this.lbl_NavPLC.AutoSize = false; + this.lbl_NavPLC.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavPLC.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavPLC.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_NavPLC.Text = "📡\nPLC监控"; + this.lbl_NavPLC.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavPLC.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavPLC.Controls.Add(this.lbl_NavPLC); + // ── 全屏按钮(固定在侧栏底部,退出按钮上方) ── + this.pnl_NavFullscreen.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavFullscreen.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavFullscreen.Name = "pnl_NavFullscreen"; + this.lbl_NavFullscreen.AutoSize = false; + this.lbl_NavFullscreen.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavFullscreen.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavFullscreen.ForeColor = System.Drawing.Color.FromArgb(148, 163, 184); + this.lbl_NavFullscreen.Text = "▣\n全屏"; + this.lbl_NavFullscreen.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavFullscreen.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavFullscreen.Controls.Add(this.lbl_NavFullscreen); + // ── 退出按钮(固定在侧栏底部) ── + this.pnl_NavClose.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.pnl_NavClose.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavClose.Name = "pnl_NavClose"; + this.pnl_NavClose.Tag = "✕\n退出"; + this.lbl_NavClose.AutoSize = false; + this.lbl_NavClose.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbl_NavClose.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lbl_NavClose.ForeColor = System.Drawing.Color.FromArgb(239, 68, 68); + this.lbl_NavClose.Text = "✕\n退出"; + this.lbl_NavClose.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_NavClose.Cursor = System.Windows.Forms.Cursors.Hand; + this.pnl_NavClose.Controls.Add(this.lbl_NavClose); + + // 导航Active指示条(4px宽蓝色条,初始隐藏,后续代码定位) + this.pnl_NavActiveIndicator.BackColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.pnl_NavActiveIndicator.Location = new System.Drawing.Point(0, 8); + this.pnl_NavActiveIndicator.Size = new System.Drawing.Size(4, 64); + this.pnl_NavActiveIndicator.Name = "pnl_NavActiveIndicator"; + + // 添加导航项到滚动容器(从下往上加,确保绘制顺序) + this.pnl_SidebarScroll.Controls.Add(this.pnl_NavActiveIndicator); + // pnl_NavClose 已从滚动容器移出到pnl_Sidebar底部 + this.pnl_SidebarScroll.Controls.Add(this.pnl_NavPLC); + this.pnl_SidebarScroll.Controls.Add(this.pnl_NavLog); + this.pnl_SidebarScroll.Controls.Add(this.pnl_NavSettings); + this.pnl_SidebarScroll.Controls.Add(this.pnl_NavStatistics); + this.pnl_SidebarScroll.Controls.Add(this.pnl_NavStation); + this.pnl_SidebarScroll.Controls.Add(this.pnl_NavReport); + this.pnl_SidebarScroll.Controls.Add(this.pnl_NavTool); + this.pnl_SidebarScroll.Controls.Add(this.pnl_NavWorkpiece); + this.pnl_SidebarScroll.Controls.Add(this.pnl_NavUserMgmt); + this.pnl_SidebarScroll.Controls.Add(this.pnl_NavWeighing); + + // 绑定导航点击事件 + this.pnl_NavWeighing.Click += new System.EventHandler(this.Nav_Click); + this.lbl_NavWeighing.Click += new System.EventHandler(this.Nav_Click); + this.pnl_NavUserMgmt.Click += new System.EventHandler(this.Nav_Click); + this.lbl_NavUserMgmt.Click += new System.EventHandler(this.Nav_Click); + this.pnl_NavWorkpiece.Click += new System.EventHandler(this.Nav_Click); + this.lbl_NavWorkpiece.Click += new System.EventHandler(this.Nav_Click); + this.pnl_NavTool.Click += new System.EventHandler(this.Nav_Click); + this.lbl_NavTool.Click += new System.EventHandler(this.Nav_Click); + this.pnl_NavReport.Click += new System.EventHandler(this.Nav_Click); + this.lbl_NavReport.Click += new System.EventHandler(this.Nav_Click); + this.pnl_NavStation.Click += new System.EventHandler(this.Nav_Click); + this.lbl_NavStation.Click += new System.EventHandler(this.Nav_Click); + this.pnl_NavStatistics.Click += new System.EventHandler(this.Nav_Click); + this.lbl_NavStatistics.Click += new System.EventHandler(this.Nav_Click); + this.pnl_NavSettings.Click += new System.EventHandler(this.Nav_Click); + this.lbl_NavSettings.Click += new System.EventHandler(this.Nav_Click); + this.pnl_NavLog.Click += new System.EventHandler(this.Nav_Click); + this.lbl_NavLog.Click += new System.EventHandler(this.Nav_Click); + this.pnl_NavPLC.Click += new System.EventHandler(this.Nav_Click); + this.lbl_NavPLC.Click += new System.EventHandler(this.Nav_Click); + this.pnl_NavFullscreen.Click += new System.EventHandler(this.btn_ToggleFullscreen_Click); + this.lbl_NavFullscreen.Click += new System.EventHandler(this.btn_ToggleFullscreen_Click); + this.pnl_NavClose.Click += new System.EventHandler(this.Nav_Click); + this.lbl_NavClose.Click += new System.EventHandler(this.Nav_Click); + + // ==================================================================== + // panel_Alarm — 底部报警栏 (32px) + // ==================================================================== + this.panel_Alarm.BackColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.panel_Alarm.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel_Alarm.Height = 32; + this.panel_Alarm.Name = "panel_Alarm"; + this.panel_Alarm.Controls.Add(this.label_Alarm); + this.panel_Alarm.Controls.Add(this.lbl_AlarmIcon); + + // lbl_AlarmIcon + this.lbl_AlarmIcon.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_AlarmIcon.ForeColor = System.Drawing.Color.White; + this.lbl_AlarmIcon.Location = new System.Drawing.Point(4, 0); + this.lbl_AlarmIcon.Size = new System.Drawing.Size(80, 32); + this.lbl_AlarmIcon.Name = "lbl_AlarmIcon"; + this.lbl_AlarmIcon.Text = "🔔 报警"; + this.lbl_AlarmIcon.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + + // label_Alarm — 保持原名以兼容 AppConfig.cs 中的引用 + this.label_Alarm.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Top; + this.label_Alarm.Font = new System.Drawing.Font("微软雅黑", 10F); + this.label_Alarm.ForeColor = System.Drawing.Color.White; + this.label_Alarm.Location = new System.Drawing.Point(88, 0); + this.label_Alarm.Size = new System.Drawing.Size(1800, 32); + this.label_Alarm.Name = "label_Alarm"; + this.label_Alarm.Text = ""; + this.label_Alarm.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + + // ==================================================================== + // pnl_Content — 主内容区域 (动态加载UserControl) + // ==================================================================== + this.pnl_Content.BackColor = System.Drawing.Color.FromArgb(245, 247, 250); + this.pnl_Content.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnl_Content.Name = "pnl_Content"; + this.pnl_Content.Padding = new System.Windows.Forms.Padding(8); + + // ==================================================================== + // MesWorkForm — 主窗口 + // ==================================================================== + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.ClientSize = new System.Drawing.Size(1920, 1080); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.Name = "MesWorkForm"; + this.Text = "称重数据采集分析管理系统"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + + // 添加顺序:先Dock的后Add(Fill最后被添加但先占位) + // 正确顺序:Content(Fill) → Sidebar(Left) → Alarm(Bottom) → TopBar(Top) + this.Controls.Add(this.pnl_Content); + this.Controls.Add(this.pnl_Sidebar); + this.Controls.Add(this.panel_Alarm); + this.Controls.Add(this.pnl_TopBar); + + this.Load += new System.EventHandler(this.MesWorkForm_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MesWorkForm_FormClosing); + + this.pnl_TopBar.ResumeLayout(false); + this.pnl_TopBarRight.ResumeLayout(false); + this.pnl_Sidebar.ResumeLayout(false); + this.pnl_SidebarScroll.ResumeLayout(false); + this.panel_Alarm.ResumeLayout(false); + this.ResumeLayout(false); + } + + #endregion + + // ── Timers ── + private System.Windows.Forms.Timer timer_OnLine_Show; + private System.Windows.Forms.Timer timer_Clock; + + // ── Top Bar ── + private System.Windows.Forms.Panel pnl_TopBar; + private System.Windows.Forms.Panel pnl_TopBarRight; + private System.Windows.Forms.Label lbl_SystemTitle; + private System.Windows.Forms.Label lbl_DateTime; + private System.Windows.Forms.Label lbl_UserName; + private System.Windows.Forms.Panel pnl_SqlIndicator; + private System.Windows.Forms.Label lbl_SqlStatus; + + // ── Sidebar ── + private System.Windows.Forms.Panel pnl_Sidebar; + private System.Windows.Forms.Panel pnl_SidebarScroll; + private System.Windows.Forms.Panel pnl_NavWeighing; + private System.Windows.Forms.Label lbl_NavWeighing; + private System.Windows.Forms.Panel pnl_NavUserMgmt; + private System.Windows.Forms.Label lbl_NavUserMgmt; + private System.Windows.Forms.Panel pnl_NavWorkpiece; + private System.Windows.Forms.Label lbl_NavWorkpiece; + private System.Windows.Forms.Panel pnl_NavTool; + private System.Windows.Forms.Label lbl_NavTool; + private System.Windows.Forms.Panel pnl_NavReport; + private System.Windows.Forms.Label lbl_NavReport; + private System.Windows.Forms.Panel pnl_NavStation; + private System.Windows.Forms.Label lbl_NavStation; + private System.Windows.Forms.Panel pnl_NavStatistics; + private System.Windows.Forms.Label lbl_NavStatistics; + private System.Windows.Forms.Panel pnl_NavSettings; + private System.Windows.Forms.Label lbl_NavSettings; + private System.Windows.Forms.Panel pnl_NavLog; + private System.Windows.Forms.Label lbl_NavLog; + private System.Windows.Forms.Panel pnl_NavPLC; + private System.Windows.Forms.Label lbl_NavPLC; + private System.Windows.Forms.Panel pnl_NavFullscreen; + private System.Windows.Forms.Label lbl_NavFullscreen; + private System.Windows.Forms.Panel pnl_NavClose; + private System.Windows.Forms.Label lbl_NavClose; + private System.Windows.Forms.Panel pnl_NavActiveIndicator; + + // ── Alarm Bar ── + private System.Windows.Forms.Panel panel_Alarm; + private System.Windows.Forms.Label label_Alarm; + private System.Windows.Forms.Label lbl_AlarmIcon; + + // ── Content ── + private System.Windows.Forms.Panel pnl_Content; + } +} diff --git a/SCADA/MAIN_PAGE.cs b/SCADA/MAIN_PAGE.cs new file mode 100644 index 0000000..c6361a4 --- /dev/null +++ b/SCADA/MAIN_PAGE.cs @@ -0,0 +1,322 @@ +namespace MesWork +{ + using DC_A95; + using System; + using System.Diagnostics; + using System.Drawing; + using System.Threading; + using System.Windows.Forms; + + /// + /// 主窗体 - 称重数据采集分析管理系统 + /// + public partial class MesWorkForm + { + public static int Curr_AID = 0; + + /// + /// 当前活跃的导航Panel + /// + private Panel _activeNavPanel = null; + + public MesWorkForm() + { + Frm_Login frm_Login = new Frm_Login(); + if (frm_Login.ShowDialog() == DialogResult.OK) + { + OnStart(); + + InitializeComponent(); + CheckForIllegalCrossThreadCalls = false; + IsMdiContainer = false; + + // 加载窗口图标 + LoadWindowIcon(); + + // 设置用户名 + lbl_UserName.Text = $"操作员:{MesWorkForm.Curr_UserName}"; + + // 标题追加工位号 + if (!string.IsNullOrEmpty(Curr_Station)) + Text = $"称重数据采集分析管理系统 - {Curr_Station}"; + + // 启动定时器 + timer_OnLine_Show.Interval = 1000; + timer_OnLine_Show.Enabled = true; + timer_Clock.Interval = 1000; + timer_Clock.Enabled = true; + + // 启动SQL在线检测 + CommunicationCheckOnLine(); + + // 初始化扫码枪 + if (MesWorkForm.IsUseBarcode == 1) + { + BarcodeManager.Init(); + BarcodeManager.OnBarcodeScanned = (opName, barcode) => + { + // 在线程池中执行业务处理(与PLC信号处理一致) + System.Threading.ThreadPool.QueueUserWorkItem(_ => + { + try { Barcode_HandleScan(opName, barcode); } + catch { } + }); + }; + } + + // 默认选中"称重作业" + SetActiveNav(pnl_NavWeighing); + } + else + { + Process.GetCurrentProcess().Kill(); + } + } + + // ==================================================================== + // 导航系统 + // ==================================================================== + + /// + /// 统一导航点击事件 + /// + private void Nav_Click(object sender, EventArgs e) + { + // 获取真正的导航Panel(可能点的是Label子控件) + Panel navPanel; + if (sender is Label lbl) + navPanel = lbl.Parent as Panel; + else + navPanel = sender as Panel; + + if (navPanel == null) return; + + string navTag = navPanel.Tag?.ToString() ?? ""; + + // 退出按钮特殊处理 + if (navTag.Contains("退出")) + { + DoClose(); + return; + } + + // PLC监控特殊处理(弹出独立窗口) + if (navTag.Contains("PLC")) + { + new OpcForm(IsDemoMesServer).Show(this); + return; + } + + // 日志查询 — 内嵌页面 + if (navTag.Contains("日志")) + { + SetActiveNav(navPanel); + return; + } + + // 切换选中状态和内容 + SetActiveNav(navPanel); + } + + /// + /// 设置当前选中的导航项,高亮+加载对应内容 + /// + private void SetActiveNav(Panel navPanel) + { + // 还原之前的选中项 + if (_activeNavPanel != null) + { + _activeNavPanel.BackColor = Color.FromArgb(30, 58, 95); + foreach (Control c in _activeNavPanel.Controls) + if (c is Label l) l.ForeColor = Color.FromArgb(148, 163, 184); + } + + // 高亮新选中项 + _activeNavPanel = navPanel; + _activeNavPanel.BackColor = Color.FromArgb(42, 74, 111); + foreach (Control c in _activeNavPanel.Controls) + if (c is Label l) l.ForeColor = Color.White; + + // 移动Active指示条 + pnl_NavActiveIndicator.Top = navPanel.Top; + pnl_NavActiveIndicator.Visible = true; + + // 加载对应内容 + LoadContentByNav(navPanel.Tag?.ToString() ?? ""); + } + + /// + /// 页面实例缓存(避免重复创建,保持页面状态) + /// + private readonly System.Collections.Generic.Dictionary _pageCache + = new System.Collections.Generic.Dictionary(); + + /// + /// 根据导航Tag加载对应的UserControl + /// + private void LoadContentByNav(string navTag) + { + pnl_Content.Controls.Clear(); + + string pageKey = ""; + UserControl uc = null; + + if (navTag.Contains("称重")) + { + pageKey = "weighing"; + if (!_pageCache.ContainsKey(pageKey)) + { + var wp = new Pages.UC_Weighing(); + _pageCache[pageKey] = wp; + MesWorkForm.WeighingPage = wp; + } + } + else if (navTag.Contains("用户")) + { + pageKey = "user"; + if (!_pageCache.ContainsKey(pageKey)) + _pageCache[pageKey] = new Pages.UC_UserMgmt(); + } + else if (navTag.Contains("工件")) + { + pageKey = "workpiece"; + if (!_pageCache.ContainsKey(pageKey)) + _pageCache[pageKey] = new Pages.UC_WorkpieceMgmt(); + } + else if (navTag.Contains("工具")) + { + pageKey = "tool"; + if (!_pageCache.ContainsKey(pageKey)) + _pageCache[pageKey] = new Pages.UC_ToolMgmt(); + } + else if (navTag.Contains("报告")) + { + pageKey = "report"; + if (!_pageCache.ContainsKey(pageKey)) + _pageCache[pageKey] = new Pages.UC_Report(); + } + else if (navTag.Contains("过站")) + { + pageKey = "station"; + if (!_pageCache.ContainsKey(pageKey)) + _pageCache[pageKey] = new Pages.UC_StationRecord(); + } + else if (navTag.Contains("统计")) + { + pageKey = "statistics"; + if (!_pageCache.ContainsKey(pageKey)) + _pageCache[pageKey] = new Pages.UC_Statistics(); + } + else if (navTag.Contains("设置")) + { + pageKey = "settings"; + if (!_pageCache.ContainsKey(pageKey)) + _pageCache[pageKey] = new Pages.UC_SystemSettings(); + } + else if (navTag.Contains("日志")) + { + pageKey = "log"; + if (!_pageCache.ContainsKey(pageKey)) + _pageCache[pageKey] = new Pages.UC_LogRecord(); + } + + if (!string.IsNullOrEmpty(pageKey) && _pageCache.ContainsKey(pageKey)) + { + uc = _pageCache[pageKey]; + uc.Dock = DockStyle.Fill; + pnl_Content.Controls.Add(uc); + } + } + + // ==================================================================== + // Timer Events + // ==================================================================== + + /// + /// 定时器:SQL在线状态刷新 + PLC信号灯等 + /// + private void timer_OnLine_Show_Tick(object sender, EventArgs e) + { + // 数据库在线状态指示(只变更指示灯颜色) + if (OnLine_Sql) + { + pnl_SqlIndicator.BackColor = Color.FromArgb(16, 185, 129); // 绿色 + } + else + { + pnl_SqlIndicator.BackColor = Color.FromArgb(239, 68, 68); // 红色 + } + } + + /// + /// 定时器:时钟刷新 + /// + private void timer_Clock_Tick(object sender, EventArgs e) + { + lbl_DateTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + + // ==================================================================== + // 窗口事件 + // ==================================================================== + + private void MesWorkForm_Load(object sender, EventArgs e) + { + // 主界面加载完成 + } + + private void MesWorkForm_FormClosing(object sender, FormClosingEventArgs e) + { + e.Cancel = true; + } + + private void DoClose() + { + if (MessageBox.Show("是否确认退出程序?", "退出", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) + { + timer_OnLine_Show.Enabled = false; + timer_Clock.Enabled = false; + CloseDeviceConn(); + BarcodeManager.Shutdown(); + + B_DB_Opera.SaveLog_Request(Curr_Station, Log_Type.ZK_Login, "", Log_FromAndTo.ZK, Log_FromAndTo.ZK, $"用户[{Curr_UserName}({Curr_LoginID})]退出称重系统", out long AID); + Process.GetCurrentProcess().Kill(); + } + } + + // ==================================================================== + // 全屏切换 + // ==================================================================== + + private void btn_ToggleFullscreen_Click(object sender, EventArgs e) + { + if (this.FormBorderStyle == FormBorderStyle.None) + { + // 退出全屏 → 恢复普通最大化 + this.FormBorderStyle = FormBorderStyle.Sizable; + this.WindowState = FormWindowState.Maximized; + lbl_NavFullscreen.Text = "▣\n全屏"; + } + else + { + // 进入全屏 → 覆盖整个屏幕(含任务栏) + this.FormBorderStyle = FormBorderStyle.None; + this.WindowState = FormWindowState.Normal; + this.Bounds = Screen.PrimaryScreen.Bounds; + lbl_NavFullscreen.Text = "▣\n窗口"; + } + } + + // ==================================================================== + // 窗口图标加载 + // ==================================================================== + + /// + /// 加载窗口图标(多路径搜索 + exe回退) + /// + private void LoadWindowIcon() + { + IconHelper.ApplyIcon(this); + } + } +} diff --git a/SCADA/MAIN_PAGE.resx b/SCADA/MAIN_PAGE.resx new file mode 100644 index 0000000..7c72981 --- /dev/null +++ b/SCADA/MAIN_PAGE.resx @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SCADA/MainGuide/MW.OnStart.cs b/SCADA/MainGuide/MW.OnStart.cs new file mode 100644 index 0000000..a9679f6 --- /dev/null +++ b/SCADA/MainGuide/MW.OnStart.cs @@ -0,0 +1,134 @@ +using DC_A95; +using ExternalDataSync; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Data; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; +using SystemFramework; +using WebApi; + +namespace MesWork +{ + /// + /// 程式启动 + /// + public partial class MesWorkForm + { + /// + /// 从这里启动 + /// + /// + protected override void OnShown(EventArgs e) + { + } + + public void OnStart(params object[] o) + { + //【1】系统基本参数设定 + ThreadPool.SetMaxThreads(workerThreads, completionPortThreads); + Never_Know.Hello_You_All_Never_Know = Hello_You_All_Never_Know; + + // 加载信号表(按设备类型对应表展开多工位) + var (dt_Tag_Mes, dt_Device) = BuildSignalTable(BasicDataTableFile); + + // 保存工位名称列表及显示名映射(供UC_Weighing标题使用) + StationOpNames = new System.Collections.Generic.List(); + StationDisplayNames = new System.Collections.Generic.Dictionary(System.StringComparer.OrdinalIgnoreCase); + int stIdx = 1; + foreach (System.Data.DataRow row in dt_Device.Rows) + { + string opName = row["工位号"].ToString().Trim(); + string dataSource = row["数据来源"].ToString().Trim(); // 称重位1, 称重位2 + StationOpNames.Add(opName); + // 显示格式:"OP10-称重位1" + StationDisplayNames[opName] = $"{opName}-{dataSource}"; + stIdx++; + } + + LoadOPCData(dt_Tag_Mes, dt_Device, IsDemoMesServer, IsWriteMonitorLog, true, false, out string error); + if (error.Length > 0) + { + MessageBox.Show($"加载信号产生错误,程序不能启动!!错误:{error}"); + Process.GetCurrentProcess().Kill(); + } + + Thread.Sleep(200); + StartServer(); + Thread.Sleep(200); + First_TagMonitor(); + + var task1 = new Thread(new ThreadStart(Loop_SelectAlarmShow)); + task1.IsBackground = true; + task1.Start(); + + // Loop_ReadRealPageShow 已移除,PLC信号显示将在 UC_Weighing 中实现 + // var task2 = new Thread(new ThreadStart(Loop_ReadRealPageShow)); + // task2.IsBackground = true; + // task2.Start(); + + + initServer = new InitServer(MesWorkForm.WebApi_Port); + + B_DB_Opera.SaveLog_Request(Curr_Station, Log_Type.ZK_Login, "", Log_FromAndTo.ZK, Log_FromAndTo.ZK, $"称重系统启动成功!WebPort:[{MesWorkForm.WebApi_Port}]", out long AID); + } + + + + + /// + /// 构建信号表:读取Excel模板,按「设备类型对应表」的工位配置展开 + /// 每个工位独立克隆一份模板,TagID加工位号前缀(如 OP10_TAG_0000001), + /// 并填充对应的 工位号、数据来源、IP、DB + /// + /// 信号表Excel文件路径 + /// (展开后的信号表, 设备类型对应表) + private static (DataTable dtTagMes, DataTable dtDevice) BuildSignalTable(string excelFile) + { + // 读取设备类型对应表(所有启用的工位) + var dtDevice = NPOITest.ExeclHelper.ExcelToDataTable(excelFile, "设备类型对应表", true) + .Select("是否启用='1'").CopyToDataTable(); + + // 读取 MES_基本变量原始数据 模板(取全部启用行作为模板) + var dtTemplate = NPOITest.ExeclHelper.ExcelToDataTable(excelFile, "MES_基本变量原始数据", true) + .Select("是否启用='1'").CopyToDataTable(); + + // 按工位数量克隆模板 + var dtTagMes = dtTemplate.Clone(); + foreach (DataRow devRow in dtDevice.Rows) + { + string stationNo = devRow["工位号"].ToString().Trim(); // OP10, OP20 + string dataSource = devRow["数据来源"].ToString().Trim(); // 称重位1, 称重位2 + string deviceIP = devRow["设备IP"].ToString().Trim(); // 192.168.0.1 + string deviceDB = devRow["DB"].ToString().Trim(); // DB1310, DB1311 + + // 提取纯DB号 ("DB1310" → "1310",若本身是数字则保持) + //string dbNumber = deviceDB.StartsWith("DB", StringComparison.OrdinalIgnoreCase) + // ? deviceDB.Substring(2) : deviceDB; + string dbNumber = deviceDB; + + foreach (DataRow tplRow in dtTemplate.Rows) + { + var newRow = dtTagMes.NewRow(); + for (int c = 0; c < dtTemplate.Columns.Count; c++) + newRow[c] = tplRow[c]; + + // 覆盖关键字段 + newRow["TagID"] = $"{stationNo}_{tplRow["TagID"].ToString().Trim()}"; + newRow["工位号"] = stationNo; + newRow["数据来源"] = dataSource; + newRow["IP"] = deviceIP; + newRow["DBName"] = dbNumber; + + dtTagMes.Rows.Add(newRow); + } + } + + return (dtTagMes, dtDevice); + } + + } +} diff --git a/SCADA/MainGuide/MW.PageDelayRefresh.cs b/SCADA/MainGuide/MW.PageDelayRefresh.cs new file mode 100644 index 0000000..21b55e1 --- /dev/null +++ b/SCADA/MainGuide/MW.PageDelayRefresh.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace MesWork +{ + /// + /// + /// + public partial class Temp { } + /// + /// 延时刷新(框架通用方法) + /// + public partial class MesWorkForm + { + // timer_OnLine_Show_Tick 已移至 MAIN_PAGE.cs 中统一管理 + + /// + /// 值处理函数 + /// + /// + /// + public static bool ValueT(string value) + { + bool success = false; + if (value == "true" | value == "1") + { + success = true; + } + return success; + } + + + + } +} diff --git a/SCADA/Pages/CrudHelper.cs b/SCADA/Pages/CrudHelper.cs new file mode 100644 index 0000000..206c176 --- /dev/null +++ b/SCADA/Pages/CrudHelper.cs @@ -0,0 +1,184 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using System.Drawing; +using System.Windows.Forms; + +namespace MesWork.Pages +{ + /// + /// CRUD页面通用辅助方法(搜索框交互、弹窗控件创建、Excel导出) + /// + public static class CrudHelper + { + // ==================================================================== + // 搜索框占位提示交互 + // ==================================================================== + + /// + /// 搜索框获得焦点时清除占位提示 + /// + public static void SearchBox_GotFocus(TextBox txt, string hint) + { + if (txt.Text == hint) { txt.Text = ""; txt.ForeColor = Color.FromArgb(31, 41, 55); } + } + + /// + /// 搜索框失去焦点时恢复占位提示 + /// + public static void SearchBox_LostFocus(TextBox txt, string hint) + { + if (string.IsNullOrWhiteSpace(txt.Text)) { txt.Text = hint; txt.ForeColor = Color.FromArgb(156, 163, 175); } + } + + /// + /// 搜索框回车触发搜索 + /// + public static bool SearchBox_KeyDown(KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) { e.SuppressKeyPress = true; return true; } + return false; + } + + /// + /// 获取搜索框的实际搜索关键词(排除占位提示) + /// + public static string GetSearchKeyword(TextBox txt, string hint) + { + return txt.Text == hint ? "" : txt.Text.Trim(); + } + + // ==================================================================== + // 编辑弹窗辅助 + // ==================================================================== + + /// + /// 创建标准编辑弹窗框架(统一样式 + 确定/取消按钮) + /// + public static Form CreateEditDialog(string title, int width, int height) + { + var dlg = new Form + { + Text = title, + Size = new Size(width, height), + StartPosition = FormStartPosition.CenterParent, + FormBorderStyle = FormBorderStyle.FixedDialog, + MaximizeBox = false, + MinimizeBox = false, + BackColor = Color.White, + Font = new Font("微软雅黑", 11F) + }; + return dlg; + } + + /// + /// 向弹窗添加确定/取消按钮 + /// + public static (Button btnOk, Button btnCancel) AddDialogButtons(Form dlg, ref int y) + { + y += 16; + var btnOk = new Button + { + Text = "确 定", BackColor = Color.FromArgb(74, 144, 217), ForeColor = Color.White, + FlatStyle = FlatStyle.Flat, Size = new Size(120, 36), Location = new Point(80, y), + DialogResult = DialogResult.OK + }; + btnOk.FlatAppearance.BorderSize = 0; + + var btnCancel = new Button + { + Text = "取 消", BackColor = Color.FromArgb(229, 231, 235), ForeColor = Color.FromArgb(55, 65, 81), + FlatStyle = FlatStyle.Flat, Size = new Size(120, 36), Location = new Point(220, y), + DialogResult = DialogResult.Cancel + }; + btnCancel.FlatAppearance.BorderSize = 0; + + dlg.Controls.Add(btnOk); + dlg.Controls.Add(btnCancel); + dlg.AcceptButton = btnOk; + dlg.CancelButton = btnCancel; + return (btnOk, btnCancel); + } + + /// + /// 向弹窗添加文本输入字段 + /// + public static TextBox AddTextField(Form dlg, string label, ref int y, string value, int labelX = 30, int inputX = 130, int inputWidth = 240, bool isPassword = false) + { + dlg.Controls.Add(new Label { Text = label, Location = new Point(labelX, y + 4), AutoSize = true }); + var txt = new TextBox { Text = value ?? "", Location = new Point(inputX, y), Size = new Size(inputWidth, 28), BorderStyle = BorderStyle.FixedSingle }; + if (isPassword) txt.PasswordChar = '*'; + dlg.Controls.Add(txt); + y += 42; + return txt; + } + + /// + /// 向弹窗添加下拉选择字段 + /// + public static ComboBox AddComboField(Form dlg, string label, ref int y, string[] items, string selected, int labelX = 30, int inputX = 130, int inputWidth = 240) + { + dlg.Controls.Add(new Label { Text = label, Location = new Point(labelX, y + 4), AutoSize = true }); + var cmb = new ComboBox { Location = new Point(inputX, y), Size = new Size(inputWidth, 28), DropDownStyle = ComboBoxStyle.DropDownList }; + cmb.Items.AddRange(items); + cmb.Text = selected ?? items[0]; + dlg.Controls.Add(cmb); + y += 42; + return cmb; + } + + // ==================================================================== + // 导出Excel通用方法 + // ==================================================================== + + /// + /// 通用的Excel导出流程(弹出保存对话框→查全量数据→NPOI导出→打开文件位置) + /// + /// Excel工作表名称(如"工件管理") + /// 默认文件名(如"工件管理",会自动加时间后缀) + /// 查询全量数据的委托,返回DataTable + /// 当前是否有数据可导出 + public static void ExportToExcel(string sheetName, string defaultFileName, Func queryAllData, bool hasData) + { + if (!hasData) + { + MessageBox.Show("没有数据可导出,请先查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + using (var sfd = new SaveFileDialog()) + { + sfd.Filter = "Excel 文件|*.xlsx"; + sfd.FileName = $"{defaultFileName}_{DateTime.Now:yyyyMMdd_HHmmss}.xlsx"; + sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + if (sfd.ShowDialog() == DialogResult.OK) + { + try + { + DataTable dt = queryAllData(); + if (dt != null && dt.Rows.Count > 0) + { + bool exported = NPOITest.ExeclHelper.DataTableToExcel(dt, sheetName, sfd.FileName); + if (exported) + { + MessageBox.Show($"导出成功!共 {dt.Rows.Count} 条记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + System.Diagnostics.Process.Start("explorer.exe", $"/select,\"{sfd.FileName}\""); + } + else + { + MessageBox.Show("导出失败,请检查文件是否被占用", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + else + { + MessageBox.Show("查询全量数据失败,请重试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + catch (Exception ex) + { + MessageBox.Show($"导出失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + } +} diff --git a/SCADA/Pages/PagerBar.cs b/SCADA/Pages/PagerBar.cs new file mode 100644 index 0000000..650065d --- /dev/null +++ b/SCADA/Pages/PagerBar.cs @@ -0,0 +1,177 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using System.Drawing; +using System.Windows.Forms; + +namespace MesWork.Pages +{ + /// + /// 通用分页状态栏控件 — 嵌入到任何页面底部 + /// 包含:记录数标签 | 每页条数下拉 | 上一页 | 页码信息 | 下一页 + /// + public class PagerBar : Panel + { + public event EventHandler PageChanged; + + private Label lbl_RecordCount; + private ComboBox cmb_PageSize; + private Button btn_Prev; + private Label lbl_PageInfo; + private Button btn_Next; + + private int _currentPage = 1; + private int _totalPage = 1; + private int _totalCount = 0; + private int _pageSize = 100; + + public int CurrentPage => _currentPage; + public int PageSize => _pageSize; + public int TotalCount => _totalCount; + + public PagerBar() + { + this.BackColor = Color.White; + this.Dock = DockStyle.Bottom; + this.Height = 40; + + var tbl = new TableLayoutPanel + { + Dock = DockStyle.Fill, + ColumnCount = 2, + RowCount = 1 + }; + tbl.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tbl.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tbl.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + this.Controls.Add(tbl); + + // 左侧 — 记录数 + lbl_RecordCount = new Label + { + AutoSize = true, + Anchor = AnchorStyles.Left, + Font = new Font("微软雅黑", 10F), + ForeColor = Color.FromArgb(55, 65, 81), + Margin = new Padding(16, 0, 0, 0), + Text = "共 0 条记录" + }; + tbl.Controls.Add(lbl_RecordCount, 0, 0); + + // 右侧 — 分页控件 (RightToLeft) + var flow = new FlowLayoutPanel + { + Dock = DockStyle.Fill, + FlowDirection = FlowDirection.RightToLeft, + WrapContents = false + }; + tbl.Controls.Add(flow, 1, 0); + + // 下一页 + btn_Next = CreatePageButton("下一页 ▶"); + btn_Next.Click += (s, e) => { if (_currentPage < _totalPage) { _currentPage++; PageChanged?.Invoke(this, EventArgs.Empty); } }; + flow.Controls.Add(btn_Next); + + // 页码信息 + lbl_PageInfo = new Label + { + AutoSize = true, + Font = new Font("微软雅黑", 10F), + ForeColor = Color.FromArgb(55, 65, 81), + Margin = new Padding(4, 10, 4, 0), + Text = "第 1 页 / 共 1 页" + }; + flow.Controls.Add(lbl_PageInfo); + + // 上一页 + btn_Prev = CreatePageButton("◀ 上一页"); + btn_Prev.Click += (s, e) => { if (_currentPage > 1) { _currentPage--; PageChanged?.Invoke(this, EventArgs.Empty); } }; + flow.Controls.Add(btn_Prev); + + // 每页条数下拉 + cmb_PageSize = new ComboBox + { + DropDownStyle = ComboBoxStyle.DropDownList, + Font = new Font("微软雅黑", 9F), + Size = new Size(70, 26), + Margin = new Padding(4, 7, 8, 0) + }; + cmb_PageSize.Items.AddRange(new object[] { "50", "100", "200", "500", "1000" }); + cmb_PageSize.SelectedItem = "100"; + cmb_PageSize.SelectedIndexChanged += (s, e) => + { + _pageSize = int.Parse(cmb_PageSize.Text); + _currentPage = 1; + PageChanged?.Invoke(this, EventArgs.Empty); + }; + flow.Controls.Add(cmb_PageSize); + + var lblSize = new Label + { + AutoSize = true, + Font = new Font("微软雅黑", 9F), + ForeColor = Color.FromArgb(100, 116, 139), + Margin = new Padding(4, 11, 0, 0), + Text = "每页" + }; + flow.Controls.Add(lblSize); + } + + /// + /// 重置到第1页(查询按钮调用) + /// + public void ResetPage() => _currentPage = 1; + + /// + /// 更新分页状态(SP调用后调用) + /// + public void UpdateState(SqlParameter pageCountParam, SqlParameter itemCountParam) + { + _totalPage = pageCountParam.Value != DBNull.Value ? Convert.ToInt32(pageCountParam.Value) : 1; + _totalCount = itemCountParam.Value != DBNull.Value ? Convert.ToInt32(itemCountParam.Value) : 0; + if (_totalPage < 1) _totalPage = 1; + + lbl_RecordCount.Text = $"共 {_totalCount} 条记录"; + lbl_PageInfo.Text = $"第 {_currentPage} 页 / 共 {_totalPage} 页"; + btn_Prev.Enabled = _currentPage > 1; + btn_Next.Enabled = _currentPage < _totalPage; + } + + /// + /// 简易更新(直接传总条数,不分页的模块用) + /// + public void UpdateCount(int count) + { + lbl_RecordCount.Text = $"共 {count} 条记录"; + } + + /// + /// 创建分页 Output 参数对 + /// + public static (SqlParameter pageCount, SqlParameter itemCount) CreateOutputParams() + { + return ( + new SqlParameter("@PageCount", SqlDbType.Int) { Direction = ParameterDirection.Output }, + new SqlParameter("@ItemCount", SqlDbType.Int) { Direction = ParameterDirection.Output } + ); + } + + private Button CreatePageButton(string text) + { + var btn = new Button + { + BackColor = Color.FromArgb(74, 144, 217), + Cursor = Cursors.Hand, + FlatStyle = FlatStyle.Flat, + Font = new Font("微软雅黑", 9F, FontStyle.Bold), + ForeColor = Color.White, + Margin = new Padding(4, 6, 4, 0), + Size = new Size(72, 28), + Text = text, + UseVisualStyleBackColor = false + }; + btn.FlatAppearance.BorderSize = 0; + return btn; + } + } +} diff --git a/SCADA/Pages/UC_LogRecord.Designer.cs b/SCADA/Pages/UC_LogRecord.Designer.cs new file mode 100644 index 0000000..564dafa --- /dev/null +++ b/SCADA/Pages/UC_LogRecord.Designer.cs @@ -0,0 +1,262 @@ +namespace MesWork.Pages +{ + partial class UC_LogRecord + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + components.Dispose(); + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); + this.pnl_Toolbar = new System.Windows.Forms.Panel(); + this.btn_Export = new System.Windows.Forms.Button(); + this.btn_Refresh = new System.Windows.Forms.Button(); + this.btn_Query = new System.Windows.Forms.Button(); + this.txt_Keyword = new System.Windows.Forms.TextBox(); + this.cmb_Type = new System.Windows.Forms.ComboBox(); + this.dtp_End = new System.Windows.Forms.DateTimePicker(); + this.lbl_To = new System.Windows.Forms.Label(); + this.dtp_Start = new System.Windows.Forms.DateTimePicker(); + this.dgv_Data = new System.Windows.Forms.DataGridView(); + this.pnl_Footer = new System.Windows.Forms.Panel(); + this.lbl_RecordCount = new System.Windows.Forms.Label(); + this.pnl_Toolbar.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).BeginInit(); + this.pnl_Footer.SuspendLayout(); + this.SuspendLayout(); + // + // pnl_Toolbar + // + this.pnl_Toolbar.BackColor = System.Drawing.Color.White; + this.pnl_Toolbar.Controls.Add(this.btn_Export); + this.pnl_Toolbar.Controls.Add(this.btn_Refresh); + this.pnl_Toolbar.Controls.Add(this.btn_Query); + this.pnl_Toolbar.Controls.Add(this.txt_Keyword); + this.pnl_Toolbar.Controls.Add(this.cmb_Type); + this.pnl_Toolbar.Controls.Add(this.dtp_End); + this.pnl_Toolbar.Controls.Add(this.lbl_To); + this.pnl_Toolbar.Controls.Add(this.dtp_Start); + this.pnl_Toolbar.Dock = System.Windows.Forms.DockStyle.Top; + this.pnl_Toolbar.Location = new System.Drawing.Point(0, 0); + this.pnl_Toolbar.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.pnl_Toolbar.Name = "pnl_Toolbar"; + this.pnl_Toolbar.Padding = new System.Windows.Forms.Padding(18, 12, 18, 12); + this.pnl_Toolbar.Size = new System.Drawing.Size(2730, 75); + this.pnl_Toolbar.TabIndex = 2; + // + // btn_Export + // + this.btn_Export.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(150)))), ((int)(((byte)(105))))); + this.btn_Export.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Export.FlatAppearance.BorderSize = 0; + this.btn_Export.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Export.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Export.ForeColor = System.Drawing.Color.White; + this.btn_Export.Location = new System.Drawing.Point(1305, 12); + this.btn_Export.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_Export.Name = "btn_Export"; + this.btn_Export.Size = new System.Drawing.Size(180, 48); + this.btn_Export.TabIndex = 0; + this.btn_Export.Text = "📥 导出Excel"; + this.btn_Export.UseVisualStyleBackColor = false; + this.btn_Export.Click += new System.EventHandler(this.btn_Export_Click); + // + // btn_Refresh + // + this.btn_Refresh.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(231)))), ((int)(((byte)(235))))); + this.btn_Refresh.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Refresh.FlatAppearance.BorderSize = 0; + this.btn_Refresh.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Refresh.Font = new System.Drawing.Font("微软雅黑", 10F); + this.btn_Refresh.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + this.btn_Refresh.Location = new System.Drawing.Point(1170, 12); + this.btn_Refresh.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_Refresh.Name = "btn_Refresh"; + this.btn_Refresh.Size = new System.Drawing.Size(120, 48); + this.btn_Refresh.TabIndex = 1; + this.btn_Refresh.Text = "↻ 刷新"; + this.btn_Refresh.UseVisualStyleBackColor = false; + this.btn_Refresh.Click += new System.EventHandler(this.btn_Refresh_Click); + // + // btn_Query + // + this.btn_Query.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(144)))), ((int)(((byte)(217))))); + this.btn_Query.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Query.FlatAppearance.BorderSize = 0; + this.btn_Query.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Query.Font = new System.Drawing.Font("微软雅黑", 10F); + this.btn_Query.ForeColor = System.Drawing.Color.White; + this.btn_Query.Location = new System.Drawing.Point(1035, 12); + this.btn_Query.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_Query.Name = "btn_Query"; + this.btn_Query.Size = new System.Drawing.Size(120, 48); + this.btn_Query.TabIndex = 2; + this.btn_Query.Text = "🔍 查询"; + this.btn_Query.UseVisualStyleBackColor = false; + this.btn_Query.Click += new System.EventHandler(this.btn_Query_Click); + // + // txt_Keyword + // + this.txt_Keyword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_Keyword.Font = new System.Drawing.Font("微软雅黑", 10F); + this.txt_Keyword.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(156)))), ((int)(((byte)(163)))), ((int)(((byte)(175))))); + this.txt_Keyword.Location = new System.Drawing.Point(712, 15); + this.txt_Keyword.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txt_Keyword.Name = "txt_Keyword"; + this.txt_Keyword.Size = new System.Drawing.Size(299, 34); + this.txt_Keyword.TabIndex = 3; + this.txt_Keyword.Text = "关键字搜索..."; + // + // cmb_Type + // + this.cmb_Type.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmb_Type.Font = new System.Drawing.Font("微软雅黑", 10F); + this.cmb_Type.Location = new System.Drawing.Point(480, 15); + this.cmb_Type.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.cmb_Type.Name = "cmb_Type"; + this.cmb_Type.Size = new System.Drawing.Size(208, 35); + this.cmb_Type.TabIndex = 4; + // + // dtp_End + // + this.dtp_End.Font = new System.Drawing.Font("微软雅黑", 10F); + this.dtp_End.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dtp_End.Location = new System.Drawing.Point(262, 15); + this.dtp_End.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.dtp_End.Name = "dtp_End"; + this.dtp_End.Size = new System.Drawing.Size(193, 34); + this.dtp_End.TabIndex = 5; + // + // lbl_To + // + this.lbl_To.AutoSize = true; + this.lbl_To.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_To.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + this.lbl_To.Location = new System.Drawing.Point(222, 21); + this.lbl_To.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbl_To.Name = "lbl_To"; + this.lbl_To.Size = new System.Drawing.Size(32, 27); + this.lbl_To.TabIndex = 6; + this.lbl_To.Text = "→"; + // + // dtp_Start + // + this.dtp_Start.Font = new System.Drawing.Font("微软雅黑", 10F); + this.dtp_Start.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dtp_Start.Location = new System.Drawing.Point(18, 15); + this.dtp_Start.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.dtp_Start.Name = "dtp_Start"; + this.dtp_Start.Size = new System.Drawing.Size(193, 34); + this.dtp_Start.TabIndex = 7; + // + // dgv_Data + // + this.dgv_Data.AllowUserToAddRows = false; + this.dgv_Data.AllowUserToDeleteRows = false; + dataGridViewCellStyle10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + this.dgv_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle10; + this.dgv_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dgv_Data.BackgroundColor = System.Drawing.Color.White; + this.dgv_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dgv_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SingleHorizontal; + dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle11.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(237)))), ((int)(((byte)(242))))); + dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + dataGridViewCellStyle11.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + dataGridViewCellStyle11.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(237)))), ((int)(((byte)(242))))); + dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgv_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + this.dgv_Data.ColumnHeadersHeight = 36; + dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle12.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 10F); + dataGridViewCellStyle12.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(219)))), ((int)(((byte)(234)))), ((int)(((byte)(254))))); + dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgv_Data.DefaultCellStyle = dataGridViewCellStyle12; + this.dgv_Data.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgv_Data.EnableHeadersVisualStyles = false; + this.dgv_Data.Font = new System.Drawing.Font("微软雅黑", 10F); + this.dgv_Data.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(237)))), ((int)(((byte)(242))))); + this.dgv_Data.Location = new System.Drawing.Point(0, 75); + this.dgv_Data.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.dgv_Data.Name = "dgv_Data"; + this.dgv_Data.ReadOnly = true; + this.dgv_Data.RowHeadersVisible = false; + this.dgv_Data.RowHeadersWidth = 62; + this.dgv_Data.RowTemplate.Height = 32; + this.dgv_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgv_Data.Size = new System.Drawing.Size(2730, 1371); + this.dgv_Data.TabIndex = 0; + // + // pnl_Footer + // + this.pnl_Footer.BackColor = System.Drawing.Color.White; + this.pnl_Footer.Controls.Add(this.lbl_RecordCount); + this.pnl_Footer.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnl_Footer.Location = new System.Drawing.Point(0, 1446); + this.pnl_Footer.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.pnl_Footer.Name = "pnl_Footer"; + this.pnl_Footer.Size = new System.Drawing.Size(2730, 54); + this.pnl_Footer.TabIndex = 1; + // + // lbl_RecordCount + // + this.lbl_RecordCount.AutoSize = true; + this.lbl_RecordCount.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_RecordCount.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + this.lbl_RecordCount.Location = new System.Drawing.Point(18, 9); + this.lbl_RecordCount.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbl_RecordCount.Name = "lbl_RecordCount"; + this.lbl_RecordCount.Size = new System.Drawing.Size(116, 27); + this.lbl_RecordCount.TabIndex = 0; + this.lbl_RecordCount.Text = "共 0 条记录"; + // + // UC_LogRecord + // + this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(245)))), ((int)(((byte)(247)))), ((int)(((byte)(250))))); + this.Controls.Add(this.dgv_Data); + this.Controls.Add(this.pnl_Footer); + this.Controls.Add(this.pnl_Toolbar); + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.Name = "UC_LogRecord"; + this.Size = new System.Drawing.Size(2730, 1500); + this.pnl_Toolbar.ResumeLayout(false); + this.pnl_Toolbar.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).EndInit(); + this.pnl_Footer.ResumeLayout(false); + this.pnl_Footer.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel pnl_Toolbar; + private System.Windows.Forms.DateTimePicker dtp_Start; + private System.Windows.Forms.Label lbl_To; + private System.Windows.Forms.DateTimePicker dtp_End; + private System.Windows.Forms.ComboBox cmb_Type; + private System.Windows.Forms.TextBox txt_Keyword; + private System.Windows.Forms.Button btn_Query; + private System.Windows.Forms.Button btn_Refresh; + private System.Windows.Forms.Button btn_Export; + private System.Windows.Forms.DataGridView dgv_Data; + private System.Windows.Forms.Panel pnl_Footer; + private System.Windows.Forms.Label lbl_RecordCount; + } +} diff --git a/SCADA/Pages/UC_LogRecord.cs b/SCADA/Pages/UC_LogRecord.cs new file mode 100644 index 0000000..3d54354 --- /dev/null +++ b/SCADA/Pages/UC_LogRecord.cs @@ -0,0 +1,209 @@ +using System; +using System.Data; +using System.Drawing; +using System.Windows.Forms; + +namespace MesWork.Pages +{ + /// + /// 日志查询页面 — 现代化风格,统一 CRUD 模块设计 + /// 直接查询 [记录_日志_项目运行日志] 表 + /// + public partial class UC_LogRecord : UserControl + { + private const string KEYWORD_HINT = "关键字搜索..."; + + public UC_LogRecord() + { + InitializeComponent(); + InitColumns(); + InitFilterData(); + // 绑定数据完成后自动着色 + dgv_Data.DataBindingComplete += dgv_Data_DataBindingComplete; + } + + private void InitColumns() + { + dgv_Data.AutoGenerateColumns = false; + dgv_Data.Columns.Clear(); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "AID", HeaderText = "AID", DataPropertyName = "AID", Visible = false }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "工位号", HeaderText = "工位号", DataPropertyName = "工位号", FillWeight = 70 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "类型", HeaderText = "类型", DataPropertyName = "类型", FillWeight = 70 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "请求时间", HeaderText = "请求时间", DataPropertyName = "请求时间", FillWeight = 100 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "请求内容", HeaderText = "请求内容", DataPropertyName = "请求内容", FillWeight = 200 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "响应时间", HeaderText = "响应时间", DataPropertyName = "响应时间", FillWeight = 100 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "响应内容", HeaderText = "响应内容", DataPropertyName = "响应内容", FillWeight = 200 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "CMD", HeaderText = "CMD", DataPropertyName = "CMD", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "FROM", HeaderText = "FROM", DataPropertyName = "FROM", FillWeight = 50 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "TO", HeaderText = "TO", DataPropertyName = "TO", FillWeight = 50 }); + } + + private void InitFilterData() + { + // 日志类型下拉 + cmb_Type.Items.Add("全部"); + foreach (var name in Enum.GetNames(typeof(Log_Type))) + cmb_Type.Items.Add(name); + cmb_Type.SelectedIndex = 0; + + // 日期范围 + dtp_End.Value = DateTime.Now.AddDays(1); + dtp_Start.Value = DateTime.Now.AddDays(-3); + + // 搜索框事件 + txt_Keyword.GotFocus += (s, e) => { if (txt_Keyword.Text == KEYWORD_HINT) { txt_Keyword.Text = ""; txt_Keyword.ForeColor = Color.FromArgb(31, 41, 55); } }; + txt_Keyword.LostFocus += (s, e) => { if (string.IsNullOrWhiteSpace(txt_Keyword.Text)) { txt_Keyword.Text = KEYWORD_HINT; txt_Keyword.ForeColor = Color.FromArgb(156, 163, 175); } }; + txt_Keyword.KeyDown += (s, e) => { if (e.KeyCode == Keys.Enter) { btn_Query_Click(s, e); e.SuppressKeyPress = true; } }; + } + + // ==================================================================== + // 查询 + // ==================================================================== + + private void btn_Query_Click(object sender, EventArgs e) + { + try + { + string sql = BuildQuerySql(); + DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, MesWorkForm.ConnectionString, out DataTable dt, out string err); + if (dt != null) + { + dgv_Data.DataSource = dt; + lbl_RecordCount.Text = $"共 {dt.Rows.Count} 条记录"; + } + } + catch (Exception ex) + { + MessageBox.Show($"查询失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + /// + /// 数据绑定完成后按日志类型着色(首次加载和每次查询都会触发) + /// + private void dgv_Data_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) + { + for (int i = 0; i < dgv_Data.Rows.Count; i++) + { + string typeStr = dgv_Data.Rows[i].Cells["类型"]?.Value?.ToString() ?? ""; + Color rowColor; + switch (typeStr) + { + case "ZK_Alarm": + case "ZK_Delete": + rowColor = Color.FromArgb(254, 226, 226); // 红底 + break; + case "ZK_Login": + rowColor = Color.FromArgb(220, 252, 231); // 绿底 + break; + case "ZK_Tip": + rowColor = Color.FromArgb(254, 249, 195); // 黄底 + break; + default: + rowColor = (i % 2 == 0) ? Color.White : Color.FromArgb(248, 250, 252); + break; + } + dgv_Data.Rows[i].DefaultCellStyle.BackColor = rowColor; + } + dgv_Data.ClearSelection(); + } + + /// + /// 导出 Excel(重新查询全量数据后导出) + /// + private void btn_Export_Click(object sender, EventArgs e) + { + if (dgv_Data.Rows.Count == 0) + { + MessageBox.Show("没有数据可导出,请先查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + using (var sfd = new SaveFileDialog()) + { + sfd.Filter = "Excel 文件|*.xlsx"; + sfd.FileName = $"运行日志_{DateTime.Now:yyyyMMdd_HHmmss}.xlsx"; + sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + if (sfd.ShowDialog() == DialogResult.OK) + { + try + { + string sql = BuildQuerySql(); + DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, MesWorkForm.ConnectionString, out DataTable dt, out string err); + + if (dt != null && dt.Rows.Count > 0) + { + bool exported = NPOITest.ExeclHelper.DataTableToExcel(dt, "运行日志", sfd.FileName); + if (exported) + { + MessageBox.Show($"导出成功!共 {dt.Rows.Count} 条记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + System.Diagnostics.Process.Start("explorer.exe", $"/select,\"{sfd.FileName}\""); + } + else + { + MessageBox.Show("导出失败,请检查文件是否被占用", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + else + { + MessageBox.Show("查询数据失败,请重试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + catch (Exception ex) + { + MessageBox.Show($"导出失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + /// + /// 根据当前筛选条件构建日志查询SQL(查询和导出共用) + /// + private string BuildQuerySql(bool includeAID = true) + { + var start = dtp_Start.Value; + var end = dtp_End.Value; + string keyword = txt_Keyword.Text == KEYWORD_HINT ? "" : txt_Keyword.Text.Trim(); + string logType = cmb_Type.Text == "全部" ? "" : cmb_Type.Text; + + string where = $" AND [请求时间] >= '{start:G}' AND [请求时间] < '{end:yyyy-MM-dd 23:59:59}'"; + if (!string.IsNullOrEmpty(keyword)) + where += $" AND ([请求内容] LIKE '%{keyword}%' OR [响应内容] LIKE '%{keyword}%' OR [工位号] LIKE '%{keyword}%')"; + if (!string.IsNullOrEmpty(logType)) + where += $" AND [日志类型] = '{logType}'"; + + string sql = + " SELECT [工位号] '工位号'" + + ",[日志类型] '类型'" + + ",[请求时间] '请求时间'" + + ",[请求内容] '请求内容'" + + ",[响应时间] '响应时间'" + + ",[响应内容] '响应内容'" + + ",[请求CMD] 'CMD'" + + ",[请求FROM] 'FROM'" + + ",[请求TO] 'TO'" + + (includeAID ? ",[AID] 'AID'" : "") + + " FROM [记录_日志_项目运行日志]" + + " WHERE 1=1 " + where + + " ORDER BY [请求时间] DESC"; + return sql; + } + + private void btn_Refresh_Click(object sender, EventArgs e) + { + cmb_Type.SelectedIndex = 0; + txt_Keyword.Text = KEYWORD_HINT; + txt_Keyword.ForeColor = Color.FromArgb(156, 163, 175); + dtp_Start.Value = DateTime.Now.AddDays(-3); + dtp_End.Value = DateTime.Now.AddDays(1); + btn_Query_Click(sender, e); + } + + protected override void OnVisibleChanged(EventArgs e) + { + base.OnVisibleChanged(e); + if (Visible && dgv_Data.DataSource == null) + btn_Query_Click(this, EventArgs.Empty); + } + } +} diff --git a/SCADA/Pages/UC_LogRecord.resx b/SCADA/Pages/UC_LogRecord.resx new file mode 100644 index 0000000..d58980a --- /dev/null +++ b/SCADA/Pages/UC_LogRecord.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SCADA/Pages/UC_Report.Designer.cs b/SCADA/Pages/UC_Report.Designer.cs new file mode 100644 index 0000000..6d46f4e --- /dev/null +++ b/SCADA/Pages/UC_Report.Designer.cs @@ -0,0 +1,207 @@ +namespace MesWork.Pages +{ + partial class UC_Report + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + components.Dispose(); + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + private void InitializeComponent() + { + this.pnl_QueryBar = new System.Windows.Forms.Panel(); + this.lbl_DateFrom = new System.Windows.Forms.Label(); + this.dtp_Start = new System.Windows.Forms.DateTimePicker(); + this.lbl_DateTo = new System.Windows.Forms.Label(); + this.dtp_End = new System.Windows.Forms.DateTimePicker(); + this.lbl_EngineNo = new System.Windows.Forms.Label(); + this.txt_EngineNo = new System.Windows.Forms.TextBox(); + this.lbl_ModelNo = new System.Windows.Forms.Label(); + this.txt_ModelNo = new System.Windows.Forms.TextBox(); + this.btn_Query = new System.Windows.Forms.Button(); + this.btn_Export = new System.Windows.Forms.Button(); + this.dgv_Data = new System.Windows.Forms.DataGridView(); + this.pnl_StatusBar = new System.Windows.Forms.Panel(); + this.pnl_QueryBar.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).BeginInit(); + this.SuspendLayout(); + // + // pnl_QueryBar — 查询条件栏 + // + this.pnl_QueryBar.BackColor = System.Drawing.Color.White; + this.pnl_QueryBar.Controls.Add(this.btn_Export); + this.pnl_QueryBar.Controls.Add(this.btn_Query); + this.pnl_QueryBar.Controls.Add(this.txt_ModelNo); + this.pnl_QueryBar.Controls.Add(this.lbl_ModelNo); + this.pnl_QueryBar.Controls.Add(this.txt_EngineNo); + this.pnl_QueryBar.Controls.Add(this.lbl_EngineNo); + this.pnl_QueryBar.Controls.Add(this.dtp_End); + this.pnl_QueryBar.Controls.Add(this.lbl_DateTo); + this.pnl_QueryBar.Controls.Add(this.dtp_Start); + this.pnl_QueryBar.Controls.Add(this.lbl_DateFrom); + this.pnl_QueryBar.Dock = System.Windows.Forms.DockStyle.Top; + this.pnl_QueryBar.Height = 56; + this.pnl_QueryBar.Name = "pnl_QueryBar"; + this.pnl_QueryBar.Padding = new System.Windows.Forms.Padding(16, 12, 16, 12); + // + // 日期范围 + // + this.lbl_DateFrom.AutoSize = true; + this.lbl_DateFrom.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_DateFrom.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_DateFrom.Location = new System.Drawing.Point(16, 17); + this.lbl_DateFrom.Name = "lbl_DateFrom"; + this.lbl_DateFrom.Text = "从"; + // + this.dtp_Start.Font = new System.Drawing.Font("微软雅黑", 10F); + this.dtp_Start.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dtp_Start.Location = new System.Drawing.Point(40, 13); + this.dtp_Start.Name = "dtp_Start"; + this.dtp_Start.Size = new System.Drawing.Size(130, 25); + // + this.lbl_DateTo.AutoSize = true; + this.lbl_DateTo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_DateTo.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_DateTo.Location = new System.Drawing.Point(178, 17); + this.lbl_DateTo.Name = "lbl_DateTo"; + this.lbl_DateTo.Text = "到"; + // + this.dtp_End.Font = new System.Drawing.Font("微软雅黑", 10F); + this.dtp_End.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dtp_End.Location = new System.Drawing.Point(200, 13); + this.dtp_End.Name = "dtp_End"; + this.dtp_End.Size = new System.Drawing.Size(130, 25); + // + // 发动机号 + // + this.lbl_EngineNo.AutoSize = true; + this.lbl_EngineNo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_EngineNo.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_EngineNo.Location = new System.Drawing.Point(360, 17); + this.lbl_EngineNo.Name = "lbl_EngineNo"; + this.lbl_EngineNo.Text = "发动机号"; + this.txt_EngineNo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_EngineNo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.txt_EngineNo.Location = new System.Drawing.Point(430, 13); + this.txt_EngineNo.Name = "txt_EngineNo"; + this.txt_EngineNo.Size = new System.Drawing.Size(160, 25); + // + // 机型号 + // + this.lbl_ModelNo.AutoSize = true; + this.lbl_ModelNo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_ModelNo.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_ModelNo.Location = new System.Drawing.Point(610, 17); + this.lbl_ModelNo.Name = "lbl_ModelNo"; + this.lbl_ModelNo.Text = "机型号"; + this.txt_ModelNo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_ModelNo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.txt_ModelNo.Location = new System.Drawing.Point(666, 13); + this.txt_ModelNo.Name = "txt_ModelNo"; + this.txt_ModelNo.Size = new System.Drawing.Size(160, 25); + // + // btn_Query — 查询 + // + this.btn_Query.BackColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.btn_Query.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Query.FlatAppearance.BorderSize = 0; + this.btn_Query.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Query.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Query.ForeColor = System.Drawing.Color.White; + this.btn_Query.Location = new System.Drawing.Point(850, 12); + this.btn_Query.Name = "btn_Query"; + this.btn_Query.Size = new System.Drawing.Size(88, 30); + this.btn_Query.Text = "🔍 查询"; + this.btn_Query.UseVisualStyleBackColor = false; + this.btn_Query.Click += new System.EventHandler(this.btn_Query_Click); + // + // btn_Export — 导出Excel + // + this.btn_Export.BackColor = System.Drawing.Color.FromArgb(5, 150, 105); + this.btn_Export.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Export.FlatAppearance.BorderSize = 0; + this.btn_Export.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Export.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Export.ForeColor = System.Drawing.Color.White; + this.btn_Export.Location = new System.Drawing.Point(950, 12); + this.btn_Export.Name = "btn_Export"; + this.btn_Export.Size = new System.Drawing.Size(104, 30); + this.btn_Export.Text = "📥 导出 Excel"; + this.btn_Export.UseVisualStyleBackColor = false; + this.btn_Export.Click += new System.EventHandler(this.btn_Export_Click); + // + // dgv_Data — 数据表格 + // + this.dgv_Data.AllowUserToAddRows = false; + this.dgv_Data.AllowUserToDeleteRows = false; + this.dgv_Data.AllowUserToResizeRows = false; + this.dgv_Data.BackgroundColor = System.Drawing.Color.White; + this.dgv_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dgv_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SingleHorizontal; + this.dgv_Data.ColumnHeadersHeight = 42; + this.dgv_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + this.dgv_Data.ColumnHeadersDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(232, 237, 242); + this.dgv_Data.ColumnHeadersDefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold); + this.dgv_Data.DefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(31, 41, 55); + this.dgv_Data.DefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 11F); + this.dgv_Data.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(219, 234, 254); + this.dgv_Data.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(248, 250, 252); + this.dgv_Data.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgv_Data.EnableHeadersVisualStyles = false; + this.dgv_Data.GridColor = System.Drawing.Color.FromArgb(229, 231, 235); + this.dgv_Data.MultiSelect = false; + this.dgv_Data.Name = "dgv_Data"; + this.dgv_Data.ReadOnly = true; + this.dgv_Data.RowHeadersVisible = false; + this.dgv_Data.RowTemplate.Height = 38; + this.dgv_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgv_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + // + // pnl_StatusBar — 占位(构造函数中会被PagerBar替换) + // + this.pnl_StatusBar.BackColor = System.Drawing.Color.White; + this.pnl_StatusBar.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnl_StatusBar.Height = 40; + this.pnl_StatusBar.Name = "pnl_StatusBar"; + // + // UC_Report + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(245, 247, 250); + this.Controls.Add(this.dgv_Data); + this.Controls.Add(this.pnl_StatusBar); + this.Controls.Add(this.pnl_QueryBar); + this.Name = "UC_Report"; + this.Size = new System.Drawing.Size(1820, 1000); + this.pnl_QueryBar.ResumeLayout(false); + this.pnl_QueryBar.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).EndInit(); + this.ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.Panel pnl_QueryBar; + private System.Windows.Forms.Label lbl_DateFrom; + private System.Windows.Forms.DateTimePicker dtp_Start; + private System.Windows.Forms.Label lbl_DateTo; + private System.Windows.Forms.DateTimePicker dtp_End; + private System.Windows.Forms.Label lbl_EngineNo; + private System.Windows.Forms.TextBox txt_EngineNo; + private System.Windows.Forms.Label lbl_ModelNo; + private System.Windows.Forms.TextBox txt_ModelNo; + private System.Windows.Forms.Button btn_Query; + private System.Windows.Forms.Button btn_Export; + private System.Windows.Forms.DataGridView dgv_Data; + private System.Windows.Forms.Panel pnl_StatusBar; + } +} diff --git a/SCADA/Pages/UC_Report.cs b/SCADA/Pages/UC_Report.cs new file mode 100644 index 0000000..96cb5a2 --- /dev/null +++ b/SCADA/Pages/UC_Report.cs @@ -0,0 +1,153 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using System.Windows.Forms; + +namespace MesWork.Pages +{ + /// + /// 报告查询页面 — 历史称重数据检索与 Excel 导出 + /// 对应存储过程:称重记录_分页查询(使用 sp_xt_pagesplit 真分页) + /// + public partial class UC_Report : UserControl + { + private PagerBar _pager; + + public UC_Report() + { + InitializeComponent(); + InitColumns(); + dtp_Start.Value = DateTime.Today.AddDays(-7); + dtp_End.Value = DateTime.Today; + // 用PagerBar替换原始pnl_StatusBar + _pager = new PagerBar(); + _pager.PageChanged += (s, e) => LoadData(); + this.Controls.Remove(pnl_StatusBar); + this.Controls.Add(_pager); + this.Controls.SetChildIndex(_pager, this.Controls.Count - 2); + } + + /// + /// 预设表格列 + /// + private void InitColumns() + { + dgv_Data.AutoGenerateColumns = false; + dgv_Data.Columns.Clear(); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "ID", HeaderText = "ID", DataPropertyName = "ID", Visible = false }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "发动机号", HeaderText = "发动机号", DataPropertyName = "发动机号", FillWeight = 100 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "机型号", HeaderText = "机型号", DataPropertyName = "机型号", FillWeight = 80 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "订单号", HeaderText = "订单号", DataPropertyName = "订单号", FillWeight = 80 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "称重类型", HeaderText = "称重类型", DataPropertyName = "称重类型", FillWeight = 70 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "托盘号", HeaderText = "托盘号", DataPropertyName = "托盘号", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "进站重量", HeaderText = "进站重量(KG)", DataPropertyName = "进站重量", FillWeight = 80 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "离站重量", HeaderText = "离站重量(KG)", DataPropertyName = "离站重量", FillWeight = 80 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "加油量", HeaderText = "加油量", DataPropertyName = "加油量", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "抽油量", HeaderText = "抽油量", DataPropertyName = "抽油量", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "放油量", HeaderText = "放油量", DataPropertyName = "放油量", FillWeight = 70 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "残留量", HeaderText = "残留量", DataPropertyName = "残留量", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "油密度", HeaderText = "油密度", DataPropertyName = "油密度", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "合格标志", HeaderText = "合格", DataPropertyName = "合格标志", FillWeight = 50 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "操作员", HeaderText = "操作员", DataPropertyName = "操作员", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "进站时间", HeaderText = "检测时间", DataPropertyName = "进站时间", FillWeight = 100 }); + } + + /// + /// 查询按钮:重置到第1页后查询 + /// + private void btn_Query_Click(object sender, EventArgs e) + { + _pager.ResetPage(); + LoadData(); + } + + /// + /// 核心查询方法 + /// + private void LoadData() + { + try + { + var (pageCountParam, itemCountParam) = PagerBar.CreateOutputParams(); + var parms = new SqlParameter[] + { + new SqlParameter("@发动机号", txt_EngineNo.Text.Trim()), + new SqlParameter("@机型号", txt_ModelNo.Text.Trim()), + new SqlParameter("@开始时间", dtp_Start.Value.ToString("yyyy-MM-dd")), + new SqlParameter("@结束时间", dtp_End.Value.AddDays(1).ToString("yyyy-MM-dd")), + new SqlParameter("@PageCurrent", _pager.CurrentPage), + new SqlParameter("@PageSize", _pager.PageSize), + pageCountParam, + itemCountParam + }; + SqlOperation.ExecuteStoredProcedure("称重记录_分页查询", parms, out DataTable dt, out string err); + if (dt != null) dgv_Data.DataSource = dt; + _pager.UpdateState(pageCountParam, itemCountParam); + } + catch (Exception ex) + { + MessageBox.Show($"查询失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + /// + /// 导出 Excel(重新查询全量数据后导出) + /// + private void btn_Export_Click(object sender, EventArgs e) + { + if (dgv_Data.Rows.Count == 0) + { + MessageBox.Show("没有数据可导出,请先查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + using (var sfd = new SaveFileDialog()) + { + sfd.Filter = "Excel 文件|*.xlsx"; + sfd.FileName = $"称重报告_{DateTime.Now:yyyyMMdd_HHmmss}.xlsx"; + sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + if (sfd.ShowDialog() == DialogResult.OK) + { + try + { + // 用当前查询条件重新查询全量数据(不受分页限制) + var (pageCountParam, itemCountParam) = PagerBar.CreateOutputParams(); + var parms = new SqlParameter[] + { + new SqlParameter("@发动机号", txt_EngineNo.Text.Trim()), + new SqlParameter("@机型号", txt_ModelNo.Text.Trim()), + new SqlParameter("@开始时间", dtp_Start.Value.ToString("yyyy-MM-dd")), + new SqlParameter("@结束时间", dtp_End.Value.AddDays(1).ToString("yyyy-MM-dd")), + new SqlParameter("@PageCurrent", 1), + new SqlParameter("@PageSize", 9999999), + pageCountParam, + itemCountParam + }; + SqlOperation.ExecuteStoredProcedure("称重记录_分页查询", parms, out DataTable dt, out string err); + + if (dt != null && dt.Rows.Count > 0) + { + bool exported = NPOITest.ExeclHelper.DataTableToExcel(dt, "称重记录", sfd.FileName); + if (exported) + { + MessageBox.Show($"导出成功!共 {dt.Rows.Count} 条记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + System.Diagnostics.Process.Start("explorer.exe", $"/select,\"{sfd.FileName}\""); + } + else + { + MessageBox.Show("导出失败,请检查文件是否被占用", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + else + { + MessageBox.Show("查询全量数据失败,请重试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + catch (Exception ex) + { + MessageBox.Show($"导出失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + } +} diff --git a/SCADA/Pages/UC_Report.resx b/SCADA/Pages/UC_Report.resx new file mode 100644 index 0000000..5236701 --- /dev/null +++ b/SCADA/Pages/UC_Report.resx @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + text/microsoft-resx + 2.0 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + diff --git a/SCADA/Pages/UC_StationRecord.Designer.cs b/SCADA/Pages/UC_StationRecord.Designer.cs new file mode 100644 index 0000000..fb685cd --- /dev/null +++ b/SCADA/Pages/UC_StationRecord.Designer.cs @@ -0,0 +1,186 @@ +namespace MesWork.Pages +{ + partial class UC_StationRecord + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + components.Dispose(); + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + private void InitializeComponent() + { + this.pnl_QueryBar = new System.Windows.Forms.Panel(); + this.lbl_DateFrom = new System.Windows.Forms.Label(); + this.dtp_Start = new System.Windows.Forms.DateTimePicker(); + this.lbl_DateTo = new System.Windows.Forms.Label(); + this.dtp_End = new System.Windows.Forms.DateTimePicker(); + this.lbl_EngineNo = new System.Windows.Forms.Label(); + this.txt_EngineNo = new System.Windows.Forms.TextBox(); + this.lbl_ModelNo = new System.Windows.Forms.Label(); + this.txt_ModelNo = new System.Windows.Forms.TextBox(); + this.btn_Query = new System.Windows.Forms.Button(); + this.btn_Export = new System.Windows.Forms.Button(); + this.dgv_Data = new System.Windows.Forms.DataGridView(); + this.pnl_StatusBar = new System.Windows.Forms.Panel(); + this.pnl_QueryBar.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).BeginInit(); + this.SuspendLayout(); + // pnl_QueryBar + this.pnl_QueryBar.BackColor = System.Drawing.Color.White; + this.pnl_QueryBar.Controls.Add(this.btn_Export); + this.pnl_QueryBar.Controls.Add(this.btn_Query); + this.pnl_QueryBar.Controls.Add(this.txt_ModelNo); + this.pnl_QueryBar.Controls.Add(this.lbl_ModelNo); + this.pnl_QueryBar.Controls.Add(this.txt_EngineNo); + this.pnl_QueryBar.Controls.Add(this.lbl_EngineNo); + this.pnl_QueryBar.Controls.Add(this.dtp_End); + this.pnl_QueryBar.Controls.Add(this.lbl_DateTo); + this.pnl_QueryBar.Controls.Add(this.dtp_Start); + this.pnl_QueryBar.Controls.Add(this.lbl_DateFrom); + this.pnl_QueryBar.Dock = System.Windows.Forms.DockStyle.Top; + this.pnl_QueryBar.Height = 56; + this.pnl_QueryBar.Name = "pnl_QueryBar"; + this.pnl_QueryBar.Padding = new System.Windows.Forms.Padding(16, 12, 16, 12); + // 日期范围 + this.lbl_DateFrom.AutoSize = true; + this.lbl_DateFrom.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_DateFrom.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_DateFrom.Location = new System.Drawing.Point(16, 17); + this.lbl_DateFrom.Name = "lbl_DateFrom"; + this.lbl_DateFrom.Text = "从"; + this.dtp_Start.Font = new System.Drawing.Font("微软雅黑", 10F); + this.dtp_Start.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dtp_Start.Location = new System.Drawing.Point(40, 13); + this.dtp_Start.Name = "dtp_Start"; + this.dtp_Start.Size = new System.Drawing.Size(130, 25); + this.lbl_DateTo.AutoSize = true; + this.lbl_DateTo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_DateTo.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_DateTo.Location = new System.Drawing.Point(178, 17); + this.lbl_DateTo.Name = "lbl_DateTo"; + this.lbl_DateTo.Text = "到"; + this.dtp_End.Font = new System.Drawing.Font("微软雅黑", 10F); + this.dtp_End.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dtp_End.Location = new System.Drawing.Point(200, 13); + this.dtp_End.Name = "dtp_End"; + this.dtp_End.Size = new System.Drawing.Size(130, 25); + // 发动机号 + this.lbl_EngineNo.AutoSize = true; + this.lbl_EngineNo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_EngineNo.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_EngineNo.Location = new System.Drawing.Point(360, 17); + this.lbl_EngineNo.Name = "lbl_EngineNo"; + this.lbl_EngineNo.Text = "发动机号"; + this.txt_EngineNo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_EngineNo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.txt_EngineNo.Location = new System.Drawing.Point(430, 13); + this.txt_EngineNo.Name = "txt_EngineNo"; + this.txt_EngineNo.Size = new System.Drawing.Size(160, 25); + // 机型号 + this.lbl_ModelNo.AutoSize = true; + this.lbl_ModelNo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_ModelNo.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_ModelNo.Location = new System.Drawing.Point(610, 17); + this.lbl_ModelNo.Name = "lbl_ModelNo"; + this.lbl_ModelNo.Text = "机型号"; + this.txt_ModelNo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_ModelNo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.txt_ModelNo.Location = new System.Drawing.Point(666, 13); + this.txt_ModelNo.Name = "txt_ModelNo"; + this.txt_ModelNo.Size = new System.Drawing.Size(160, 25); + // btn_Query + this.btn_Query.BackColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.btn_Query.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Query.FlatAppearance.BorderSize = 0; + this.btn_Query.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Query.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Query.ForeColor = System.Drawing.Color.White; + this.btn_Query.Location = new System.Drawing.Point(850, 12); + this.btn_Query.Name = "btn_Query"; + this.btn_Query.Size = new System.Drawing.Size(88, 30); + this.btn_Query.Text = "🔍 查询"; + this.btn_Query.UseVisualStyleBackColor = false; + this.btn_Query.Click += new System.EventHandler(this.btn_Query_Click); + // btn_Export — 导出Excel + this.btn_Export.BackColor = System.Drawing.Color.FromArgb(5, 150, 105); + this.btn_Export.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Export.FlatAppearance.BorderSize = 0; + this.btn_Export.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Export.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Export.ForeColor = System.Drawing.Color.White; + this.btn_Export.Location = new System.Drawing.Point(950, 12); + this.btn_Export.Name = "btn_Export"; + this.btn_Export.Size = new System.Drawing.Size(104, 30); + this.btn_Export.Text = "📥 导出 Excel"; + this.btn_Export.UseVisualStyleBackColor = false; + this.btn_Export.Click += new System.EventHandler(this.btn_Export_Click); + // dgv_Data + this.dgv_Data.AllowUserToAddRows = false; + this.dgv_Data.AllowUserToDeleteRows = false; + this.dgv_Data.AllowUserToResizeRows = false; + this.dgv_Data.BackgroundColor = System.Drawing.Color.White; + this.dgv_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dgv_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SingleHorizontal; + this.dgv_Data.ColumnHeadersHeight = 42; + this.dgv_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + this.dgv_Data.ColumnHeadersDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(232, 237, 242); + this.dgv_Data.ColumnHeadersDefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold); + this.dgv_Data.DefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(31, 41, 55); + this.dgv_Data.DefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 11F); + this.dgv_Data.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(219, 234, 254); + this.dgv_Data.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(248, 250, 252); + this.dgv_Data.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgv_Data.EnableHeadersVisualStyles = false; + this.dgv_Data.GridColor = System.Drawing.Color.FromArgb(229, 231, 235); + this.dgv_Data.MultiSelect = false; + this.dgv_Data.Name = "dgv_Data"; + this.dgv_Data.ReadOnly = true; + this.dgv_Data.RowHeadersVisible = false; + this.dgv_Data.RowTemplate.Height = 38; + this.dgv_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgv_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + // pnl_StatusBar + this.pnl_StatusBar.BackColor = System.Drawing.Color.White; + this.pnl_StatusBar.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnl_StatusBar.Height = 40; + this.pnl_StatusBar.Name = "pnl_StatusBar"; + // UC_StationRecord + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(245, 247, 250); + this.Controls.Add(this.dgv_Data); + this.Controls.Add(this.pnl_StatusBar); + this.Controls.Add(this.pnl_QueryBar); + this.Name = "UC_StationRecord"; + this.Size = new System.Drawing.Size(1820, 1000); + this.pnl_QueryBar.ResumeLayout(false); + this.pnl_QueryBar.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).EndInit(); + this.ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.Panel pnl_QueryBar; + private System.Windows.Forms.Label lbl_DateFrom; + private System.Windows.Forms.DateTimePicker dtp_Start; + private System.Windows.Forms.Label lbl_DateTo; + private System.Windows.Forms.DateTimePicker dtp_End; + private System.Windows.Forms.Label lbl_EngineNo; + private System.Windows.Forms.TextBox txt_EngineNo; + private System.Windows.Forms.Label lbl_ModelNo; + private System.Windows.Forms.TextBox txt_ModelNo; + private System.Windows.Forms.Button btn_Query; + private System.Windows.Forms.Button btn_Export; + private System.Windows.Forms.DataGridView dgv_Data; + private System.Windows.Forms.Panel pnl_StatusBar; + } +} diff --git a/SCADA/Pages/UC_StationRecord.cs b/SCADA/Pages/UC_StationRecord.cs new file mode 100644 index 0000000..beae597 --- /dev/null +++ b/SCADA/Pages/UC_StationRecord.cs @@ -0,0 +1,140 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using System.Windows.Forms; + +namespace MesWork.Pages +{ + /// + /// 过站记录查询页面 — 每个产品经过每个工位的明细记录 + /// 对应存储过程:过站记录_分页查询 + /// + public partial class UC_StationRecord : UserControl + { + private PagerBar _pager; + + public UC_StationRecord() + { + InitializeComponent(); + InitColumns(); + dtp_Start.Value = DateTime.Today.AddDays(-7); + dtp_End.Value = DateTime.Today; + _pager = new PagerBar(); + _pager.PageChanged += (s, e) => LoadData(); + this.Controls.Remove(pnl_StatusBar); + this.Controls.Add(_pager); + this.Controls.SetChildIndex(_pager, this.Controls.Count - 2); + } + + private void InitColumns() + { + dgv_Data.AutoGenerateColumns = false; + dgv_Data.Columns.Clear(); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "ID", HeaderText = "ID", DataPropertyName = "ID", Visible = false }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "发动机号", HeaderText = "发动机号", DataPropertyName = "发动机号", FillWeight = 100 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "机型号", HeaderText = "机型号", DataPropertyName = "机型号", FillWeight = 70 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "工单号", HeaderText = "订单号", DataPropertyName = "工单号", FillWeight = 80 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "工位号", HeaderText = "工位号", DataPropertyName = "工位号", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "工位名称", HeaderText = "工位名称", DataPropertyName = "工位名称", FillWeight = 70 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "到站时间", HeaderText = "到达时间", DataPropertyName = "到站时间", FillWeight = 110, + DefaultCellStyle = new DataGridViewCellStyle { Format = "yyyy/MM/dd HH:mm:ss" } }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "离站时间", HeaderText = "离开时间", DataPropertyName = "离站时间", FillWeight = 110, + DefaultCellStyle = new DataGridViewCellStyle { Format = "yyyy/MM/dd HH:mm:ss" } }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "停站时间", HeaderText = "在位(秒)", DataPropertyName = "停站时间", FillWeight = 55 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "称重重量", HeaderText = "称重重量(kg)", DataPropertyName = "称重重量", FillWeight = 80 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "加油量", HeaderText = "加油量", DataPropertyName = "加油量", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "抽油量", HeaderText = "抽油量", DataPropertyName = "抽油量", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "油密度", HeaderText = "油密度", DataPropertyName = "油密度", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "操作者", HeaderText = "操作员", DataPropertyName = "操作者", FillWeight = 60 }); + } + + private void btn_Query_Click(object sender, EventArgs e) + { + _pager.ResetPage(); + LoadData(); + } + + private void LoadData() + { + try + { + var (pageCountParam, itemCountParam) = PagerBar.CreateOutputParams(); + var parms = new SqlParameter[] + { + new SqlParameter("@发动机号", txt_EngineNo.Text.Trim()), + new SqlParameter("@机型号", txt_ModelNo.Text.Trim()), + new SqlParameter("@开始时间", dtp_Start.Value.ToString("yyyy-MM-dd")), + new SqlParameter("@结束时间", dtp_End.Value.AddDays(1).ToString("yyyy-MM-dd")), + new SqlParameter("@PageCurrent", _pager.CurrentPage), + new SqlParameter("@PageSize", _pager.PageSize), + pageCountParam, + itemCountParam + }; + SqlOperation.ExecuteStoredProcedure("过站记录_分页查询", parms, out DataTable dt, out string err); + if (dt != null) dgv_Data.DataSource = dt; + _pager.UpdateState(pageCountParam, itemCountParam); + } + catch (Exception ex) + { + MessageBox.Show($"查询失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void btn_Export_Click(object sender, EventArgs e) + { + if (dgv_Data.Rows.Count == 0) + { + MessageBox.Show("没有数据可导出,请先查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + using (var sfd = new SaveFileDialog()) + { + sfd.Filter = "Excel 文件|*.xlsx"; + sfd.FileName = $"过站记录_{DateTime.Now:yyyyMMdd_HHmmss}.xlsx"; + sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + if (sfd.ShowDialog() == DialogResult.OK) + { + try + { + // 用当前查询条件重新查询全量数据(不受分页限制) + var (pageCountParam, itemCountParam) = PagerBar.CreateOutputParams(); + var parms = new SqlParameter[] + { + new SqlParameter("@发动机号", txt_EngineNo.Text.Trim()), + new SqlParameter("@机型号", txt_ModelNo.Text.Trim()), + new SqlParameter("@开始时间", dtp_Start.Value.ToString("yyyy-MM-dd")), + new SqlParameter("@结束时间", dtp_End.Value.AddDays(1).ToString("yyyy-MM-dd")), + new SqlParameter("@PageCurrent", 1), + new SqlParameter("@PageSize", 9999999), + pageCountParam, + itemCountParam + }; + SqlOperation.ExecuteStoredProcedure("过站记录_分页查询", parms, out DataTable dt, out string err); + + if (dt != null && dt.Rows.Count > 0) + { + bool exported = NPOITest.ExeclHelper.DataTableToExcel(dt, "过站记录", sfd.FileName); + if (exported) + { + MessageBox.Show($"导出成功!共 {dt.Rows.Count} 条记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + System.Diagnostics.Process.Start("explorer.exe", $"/select,\"{sfd.FileName}\""); + } + else + { + MessageBox.Show("导出失败,请检查文件是否被占用", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + else + { + MessageBox.Show("查询全量数据失败,请重试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + catch (Exception ex) + { + MessageBox.Show($"导出失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + } +} diff --git a/SCADA/Pages/UC_Statistics.Designer.cs b/SCADA/Pages/UC_Statistics.Designer.cs new file mode 100644 index 0000000..d8b4e8f --- /dev/null +++ b/SCADA/Pages/UC_Statistics.Designer.cs @@ -0,0 +1,310 @@ +namespace MesWork.Pages +{ + partial class UC_Statistics + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + components.Dispose(); + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + private void InitializeComponent() + { + this.pnl_QueryBar = new System.Windows.Forms.Panel(); + this.lbl_DateFrom = new System.Windows.Forms.Label(); + this.dtp_Start = new System.Windows.Forms.DateTimePicker(); + this.lbl_DateTo = new System.Windows.Forms.Label(); + this.dtp_End = new System.Windows.Forms.DateTimePicker(); + this.txt_ModelNo = new System.Windows.Forms.TextBox(); + this.txt_OrderNo = new System.Windows.Forms.TextBox(); + this.btn_Analyze = new System.Windows.Forms.Button(); + this.btn_Export = new System.Windows.Forms.Button(); + this.pnl_ChartArea = new System.Windows.Forms.Panel(); + this.pnl_Chart = new System.Windows.Forms.Panel(); + this.lbl_ChartTitle = new System.Windows.Forms.Label(); + this.pnl_StatsCard = new System.Windows.Forms.Panel(); + this.lbl_StatsTitle = new System.Windows.Forms.Label(); + this.lbl_StatMax = new System.Windows.Forms.Label(); + this.lbl_StatMin = new System.Windows.Forms.Label(); + this.lbl_StatAvg = new System.Windows.Forms.Label(); + this.lbl_StatMedian = new System.Windows.Forms.Label(); + this.lbl_StatRange = new System.Windows.Forms.Label(); + this.lbl_StatVariance = new System.Windows.Forms.Label(); + this.lbl_StatStdDev = new System.Windows.Forms.Label(); + this.lbl_StatCount = new System.Windows.Forms.Label(); + this.dgv_Data = new System.Windows.Forms.DataGridView(); + this.pnl_QueryBar.SuspendLayout(); + this.pnl_ChartArea.SuspendLayout(); + this.pnl_Chart.SuspendLayout(); + this.pnl_StatsCard.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).BeginInit(); + this.SuspendLayout(); + // + // pnl_QueryBar — 查询栏(增高,两行布局) + // + this.pnl_QueryBar.BackColor = System.Drawing.Color.White; + this.pnl_QueryBar.Controls.Add(this.btn_Export); + this.pnl_QueryBar.Controls.Add(this.btn_Analyze); + this.pnl_QueryBar.Controls.Add(this.txt_OrderNo); + this.pnl_QueryBar.Controls.Add(this.txt_ModelNo); + this.pnl_QueryBar.Controls.Add(this.dtp_End); + this.pnl_QueryBar.Controls.Add(this.lbl_DateTo); + this.pnl_QueryBar.Controls.Add(this.dtp_Start); + this.pnl_QueryBar.Controls.Add(this.lbl_DateFrom); + this.pnl_QueryBar.Dock = System.Windows.Forms.DockStyle.Top; + this.pnl_QueryBar.Height = 56; + this.pnl_QueryBar.Name = "pnl_QueryBar"; + this.pnl_QueryBar.Padding = new System.Windows.Forms.Padding(16, 0, 16, 0); + // + // lbl_DateFrom + // + this.lbl_DateFrom.AutoSize = true; + this.lbl_DateFrom.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_DateFrom.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_DateFrom.Location = new System.Drawing.Point(16, 17); + this.lbl_DateFrom.Name = "lbl_DateFrom"; + this.lbl_DateFrom.Text = "从"; + // + // dtp_Start + // + this.dtp_Start.Font = new System.Drawing.Font("微软雅黑", 10F); + this.dtp_Start.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dtp_Start.Location = new System.Drawing.Point(40, 13); + this.dtp_Start.Name = "dtp_Start"; + this.dtp_Start.Size = new System.Drawing.Size(130, 25); + // + // lbl_DateTo + // + this.lbl_DateTo.AutoSize = true; + this.lbl_DateTo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_DateTo.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_DateTo.Location = new System.Drawing.Point(178, 17); + this.lbl_DateTo.Name = "lbl_DateTo"; + this.lbl_DateTo.Text = "到"; + // + // dtp_End + // + this.dtp_End.Font = new System.Drawing.Font("微软雅黑", 10F); + this.dtp_End.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dtp_End.Location = new System.Drawing.Point(200, 13); + this.dtp_End.Name = "dtp_End"; + this.dtp_End.Size = new System.Drawing.Size(130, 25); + // + // txt_ModelNo — 机型号筛选 + // + this.txt_ModelNo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_ModelNo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.txt_ModelNo.Location = new System.Drawing.Point(350, 13); + this.txt_ModelNo.Name = "txt_ModelNo"; + this.txt_ModelNo.Size = new System.Drawing.Size(140, 27); + // + // txt_OrderNo — 订单号筛选 + // + this.txt_OrderNo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_OrderNo.Font = new System.Drawing.Font("微软雅黑", 10F); + this.txt_OrderNo.Location = new System.Drawing.Point(500, 13); + this.txt_OrderNo.Name = "txt_OrderNo"; + this.txt_OrderNo.Size = new System.Drawing.Size(140, 27); + // + // btn_Analyze — 统计分析按钮 + // + this.btn_Analyze.BackColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.btn_Analyze.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Analyze.FlatAppearance.BorderSize = 0; + this.btn_Analyze.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Analyze.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Analyze.ForeColor = System.Drawing.Color.White; + this.btn_Analyze.Location = new System.Drawing.Point(660, 12); + this.btn_Analyze.Name = "btn_Analyze"; + this.btn_Analyze.Size = new System.Drawing.Size(110, 30); + this.btn_Analyze.Text = "📊 统计分析"; + this.btn_Analyze.UseVisualStyleBackColor = false; + this.btn_Analyze.Click += new System.EventHandler(this.btn_Analyze_Click); + // + // btn_Export — 导出数据按钮 + // + this.btn_Export.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Export.BackColor = System.Drawing.Color.FromArgb(5, 150, 105); + this.btn_Export.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Export.FlatAppearance.BorderSize = 0; + this.btn_Export.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Export.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Export.ForeColor = System.Drawing.Color.White; + this.btn_Export.Location = new System.Drawing.Point(1700, 12); + this.btn_Export.Name = "btn_Export"; + this.btn_Export.Size = new System.Drawing.Size(104, 30); + this.btn_Export.Text = "📥 导出数据"; + this.btn_Export.UseVisualStyleBackColor = false; + this.btn_Export.Click += new System.EventHandler(this.btn_Export_Click); + // + // pnl_ChartArea — 图表+统计卡片区域 + // + this.pnl_ChartArea.Dock = System.Windows.Forms.DockStyle.Top; + this.pnl_ChartArea.Height = 400; + this.pnl_ChartArea.Name = "pnl_ChartArea"; + this.pnl_ChartArea.Padding = new System.Windows.Forms.Padding(12, 8, 12, 8); + this.pnl_ChartArea.Controls.Add(this.pnl_Chart); + this.pnl_ChartArea.Controls.Add(this.pnl_StatsCard); + // + // pnl_Chart — 图表区域 + // + this.pnl_Chart.BackColor = System.Drawing.Color.White; + this.pnl_Chart.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnl_Chart.Name = "pnl_Chart"; + this.pnl_Chart.Padding = new System.Windows.Forms.Padding(16, 8, 16, 8); + this.pnl_Chart.Controls.Add(this.lbl_ChartTitle); + // + // lbl_ChartTitle + // + this.lbl_ChartTitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbl_ChartTitle.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold); + this.lbl_ChartTitle.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.lbl_ChartTitle.Height = 32; + this.lbl_ChartTitle.Name = "lbl_ChartTitle"; + this.lbl_ChartTitle.Text = "📈 机油残留量趋势分析"; + this.lbl_ChartTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // pnl_StatsCard — 右侧统计指标卡片 + // + this.pnl_StatsCard.BackColor = System.Drawing.Color.FromArgb(248, 250, 252); + this.pnl_StatsCard.Dock = System.Windows.Forms.DockStyle.Right; + this.pnl_StatsCard.Width = 260; + this.pnl_StatsCard.Name = "pnl_StatsCard"; + this.pnl_StatsCard.Padding = new System.Windows.Forms.Padding(20, 8, 20, 8); + this.pnl_StatsCard.Controls.Add(this.lbl_StatCount); + this.pnl_StatsCard.Controls.Add(this.lbl_StatStdDev); + this.pnl_StatsCard.Controls.Add(this.lbl_StatVariance); + this.pnl_StatsCard.Controls.Add(this.lbl_StatRange); + this.pnl_StatsCard.Controls.Add(this.lbl_StatMedian); + this.pnl_StatsCard.Controls.Add(this.lbl_StatAvg); + this.pnl_StatsCard.Controls.Add(this.lbl_StatMin); + this.pnl_StatsCard.Controls.Add(this.lbl_StatMax); + this.pnl_StatsCard.Controls.Add(this.lbl_StatsTitle); + // + // lbl_StatsTitle + // + this.lbl_StatsTitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbl_StatsTitle.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold); + this.lbl_StatsTitle.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.lbl_StatsTitle.Height = 36; + this.lbl_StatsTitle.Name = "lbl_StatsTitle"; + this.lbl_StatsTitle.Text = "📋 统计指标"; + this.lbl_StatsTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // 统计数值标签 + // + this.lbl_StatMax.AutoSize = true; this.lbl_StatMax.Font = new System.Drawing.Font("微软雅黑", 10.5F); + this.lbl_StatMax.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_StatMax.Location = new System.Drawing.Point(20, 50); this.lbl_StatMax.Name = "lbl_StatMax"; this.lbl_StatMax.Text = "最大值 —"; + + this.lbl_StatMin.AutoSize = true; this.lbl_StatMin.Font = new System.Drawing.Font("微软雅黑", 10.5F); + this.lbl_StatMin.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_StatMin.Location = new System.Drawing.Point(20, 82); this.lbl_StatMin.Name = "lbl_StatMin"; this.lbl_StatMin.Text = "最小值 —"; + + this.lbl_StatAvg.AutoSize = true; this.lbl_StatAvg.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold); + this.lbl_StatAvg.ForeColor = System.Drawing.Color.FromArgb(245, 158, 11); + this.lbl_StatAvg.Location = new System.Drawing.Point(20, 114); this.lbl_StatAvg.Name = "lbl_StatAvg"; this.lbl_StatAvg.Text = "平均值 —"; + + this.lbl_StatMedian.AutoSize = true; this.lbl_StatMedian.Font = new System.Drawing.Font("微软雅黑", 10.5F); + this.lbl_StatMedian.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_StatMedian.Location = new System.Drawing.Point(20, 146); this.lbl_StatMedian.Name = "lbl_StatMedian"; this.lbl_StatMedian.Text = "中位数 —"; + + this.lbl_StatRange.AutoSize = true; this.lbl_StatRange.Font = new System.Drawing.Font("微软雅黑", 10.5F); + this.lbl_StatRange.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_StatRange.Location = new System.Drawing.Point(20, 178); this.lbl_StatRange.Name = "lbl_StatRange"; this.lbl_StatRange.Text = "极差 —"; + + this.lbl_StatVariance.AutoSize = true; this.lbl_StatVariance.Font = new System.Drawing.Font("微软雅黑", 10.5F); + this.lbl_StatVariance.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_StatVariance.Location = new System.Drawing.Point(20, 210); this.lbl_StatVariance.Name = "lbl_StatVariance"; this.lbl_StatVariance.Text = "方差 —"; + + this.lbl_StatStdDev.AutoSize = true; this.lbl_StatStdDev.Font = new System.Drawing.Font("微软雅黑", 10.5F); + this.lbl_StatStdDev.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_StatStdDev.Location = new System.Drawing.Point(20, 242); this.lbl_StatStdDev.Name = "lbl_StatStdDev"; this.lbl_StatStdDev.Text = "标准差 —"; + + this.lbl_StatCount.AutoSize = true; this.lbl_StatCount.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold); + this.lbl_StatCount.ForeColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.lbl_StatCount.Location = new System.Drawing.Point(20, 282); this.lbl_StatCount.Name = "lbl_StatCount"; this.lbl_StatCount.Text = "样本数 0"; + // + // dgv_Data — 明细表 + // + this.dgv_Data.AllowUserToAddRows = false; + this.dgv_Data.AllowUserToDeleteRows = false; + this.dgv_Data.AllowUserToResizeRows = false; + this.dgv_Data.BackgroundColor = System.Drawing.Color.White; + this.dgv_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dgv_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SingleHorizontal; + this.dgv_Data.ColumnHeadersHeight = 40; + this.dgv_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + this.dgv_Data.ColumnHeadersDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(232, 237, 242); + this.dgv_Data.ColumnHeadersDefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.dgv_Data.ColumnHeadersDefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + this.dgv_Data.DefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(31, 41, 55); + this.dgv_Data.DefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 10F); + this.dgv_Data.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(219, 234, 254); + this.dgv_Data.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.DefaultCellStyle.Padding = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.dgv_Data.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(248, 250, 252); + this.dgv_Data.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgv_Data.EnableHeadersVisualStyles = false; + this.dgv_Data.GridColor = System.Drawing.Color.FromArgb(229, 231, 235); + this.dgv_Data.MultiSelect = false; + this.dgv_Data.Name = "dgv_Data"; + this.dgv_Data.ReadOnly = true; + this.dgv_Data.RowHeadersVisible = false; + this.dgv_Data.RowTemplate.Height = 36; + this.dgv_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgv_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + // + // UC_Statistics + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(245, 247, 250); + this.Controls.Add(this.dgv_Data); + this.Controls.Add(this.pnl_ChartArea); + this.Controls.Add(this.pnl_QueryBar); + this.Name = "UC_Statistics"; + this.Size = new System.Drawing.Size(1820, 1000); + this.pnl_QueryBar.ResumeLayout(false); + this.pnl_QueryBar.PerformLayout(); + this.pnl_ChartArea.ResumeLayout(false); + this.pnl_Chart.ResumeLayout(false); + this.pnl_StatsCard.ResumeLayout(false); + this.pnl_StatsCard.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).EndInit(); + this.ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.Panel pnl_QueryBar; + private System.Windows.Forms.Label lbl_DateFrom; + private System.Windows.Forms.DateTimePicker dtp_Start; + private System.Windows.Forms.Label lbl_DateTo; + private System.Windows.Forms.DateTimePicker dtp_End; + private System.Windows.Forms.TextBox txt_ModelNo; + private System.Windows.Forms.TextBox txt_OrderNo; + private System.Windows.Forms.Button btn_Analyze; + private System.Windows.Forms.Button btn_Export; + private System.Windows.Forms.Panel pnl_ChartArea; + private System.Windows.Forms.Panel pnl_Chart; + private System.Windows.Forms.Label lbl_ChartTitle; + private System.Windows.Forms.Panel pnl_StatsCard; + private System.Windows.Forms.Label lbl_StatsTitle; + private System.Windows.Forms.Label lbl_StatMax; + private System.Windows.Forms.Label lbl_StatMin; + private System.Windows.Forms.Label lbl_StatAvg; + private System.Windows.Forms.Label lbl_StatMedian; + private System.Windows.Forms.Label lbl_StatRange; + private System.Windows.Forms.Label lbl_StatVariance; + private System.Windows.Forms.Label lbl_StatStdDev; + private System.Windows.Forms.Label lbl_StatCount; + private System.Windows.Forms.DataGridView dgv_Data; + } +} diff --git a/SCADA/Pages/UC_Statistics.cs b/SCADA/Pages/UC_Statistics.cs new file mode 100644 index 0000000..9edf085 --- /dev/null +++ b/SCADA/Pages/UC_Statistics.cs @@ -0,0 +1,471 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Linq; +using System.Windows.Forms; + +namespace MesWork.Pages +{ + /// + /// 统计分析页面 — 残留量趋势分析 + 统计指标计算 + 明细数据 + /// 使用 GDI+ 绘制趋势折线图(含平均线 + 数据标签) + /// + public partial class UC_Statistics : UserControl + { + /// 图表数据缓存 + private List<(DateTime time, double value, string label)> _chartData = new List<(DateTime, double, string)>(); + /// 平均值(用于绘制参考线) + private double _avgValue = 0; + + // ─── 配色常量 ─── + private static readonly Color CLR_PRIMARY = Color.FromArgb(74, 144, 217); + private static readonly Color CLR_PRIMARY_DARK = Color.FromArgb(30, 58, 95); + private static readonly Color CLR_AVG_LINE = Color.FromArgb(245, 158, 11); // 橙色平均线 + private static readonly Color CLR_GRID = Color.FromArgb(236, 239, 243); + private static readonly Color CLR_TEXT = Color.FromArgb(55, 65, 81); + private static readonly Color CLR_TEXT_LIGHT = Color.FromArgb(107, 114, 128); + private static readonly Color CLR_DOT_FILL = Color.FromArgb(74, 144, 217); + private static readonly Color CLR_CARD_BG = Color.FromArgb(248, 250, 252); + + public UC_Statistics() + { + InitializeComponent(); + InitColumns(); + dtp_Start.Value = DateTime.Today.AddDays(-30); + dtp_End.Value = DateTime.Today; + // 订阅图表区域绘制 + pnl_Chart.Paint += pnl_Chart_Paint; + pnl_Chart.Resize += (s, ev) => pnl_Chart.Invalidate(); + + // 为筛选框加占位提示 + SetHint(txt_ModelNo, "机型号筛选..."); + SetHint(txt_OrderNo, "订单号筛选..."); + } + + private void SetHint(TextBox txt, string hint) + { + txt.Tag = hint; + txt.Text = hint; + txt.ForeColor = Color.FromArgb(156, 163, 175); + txt.GotFocus += (s, e) => { if (txt.Text == hint) { txt.Text = ""; txt.ForeColor = CLR_PRIMARY_DARK; } }; + txt.LostFocus += (s, e) => { if (string.IsNullOrWhiteSpace(txt.Text)) { txt.Text = hint; txt.ForeColor = Color.FromArgb(156, 163, 175); } }; + } + + private string GetHintValue(TextBox txt) + { + return txt.Text == txt.Tag?.ToString() ? "" : txt.Text.Trim(); + } + + /// + /// 预设明细表格列 + /// + private void InitColumns() + { + dgv_Data.AutoGenerateColumns = false; + dgv_Data.Columns.Clear(); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "序号", HeaderText = "序号", Width = 50, FillWeight = 30 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "ID", HeaderText = "ID", DataPropertyName = "ID", Visible = false }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "测试时间", HeaderText = "检测时间", DataPropertyName = "测试时间", FillWeight = 100 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "发动机号", HeaderText = "工件编号", DataPropertyName = "发动机号", FillWeight = 100 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "订单号", HeaderText = "订单号", DataPropertyName = "订单号", FillWeight = 80 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "机型号", HeaderText = "机型号", DataPropertyName = "机型号", FillWeight = 70 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "残留量", HeaderText = "机油残留(mg)", DataPropertyName = "残留量", FillWeight = 80 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "设备编号", HeaderText = "设备编号", DataPropertyName = "设备编号", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "操作员", HeaderText = "操作员", DataPropertyName = "操作员", FillWeight = 60 }); + } + + /// + /// 统计分析按钮 + /// + private void btn_Analyze_Click(object sender, EventArgs e) + { + try + { + var pageCountParam = new SqlParameter("@PageCount", SqlDbType.Int) { Direction = ParameterDirection.Output }; + var itemCountParam = new SqlParameter("@ItemCount", SqlDbType.Int) { Direction = ParameterDirection.Output }; + var parms = new SqlParameter[] + { + new SqlParameter("@发动机号", ""), + new SqlParameter("@机型号", GetHintValue(txt_ModelNo)), + new SqlParameter("@工单号", GetHintValue(txt_OrderNo)), + new SqlParameter("@开始时间", dtp_Start.Value.ToString("yyyy-MM-dd")), + new SqlParameter("@结束时间", dtp_End.Value.AddDays(1).ToString("yyyy-MM-dd")), + new SqlParameter("@PageCurrent", 1), + new SqlParameter("@PageSize", 9999), + pageCountParam, + itemCountParam + }; + SqlOperation.ExecuteStoredProcedure("称重记录_分页查询", parms, out DataTable dt, out string err); + + if (dt != null && dt.Rows.Count > 0) + { + dgv_Data.DataSource = dt; + FillRowNumbers(); + CalculateStatistics(dt); + BuildChartData(dt); + pnl_Chart.Invalidate(); + } + else + { + _chartData.Clear(); + ClearStatLabels(); + pnl_Chart.Invalidate(); + MessageBox.Show("查询范围内无数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + catch (Exception ex) + { + MessageBox.Show($"查询失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + /// + /// 填充表格序号列(与图表数据点编号对应) + /// 图表按时间升序排列,表格按ID降序,序号在数据排序后重新映射 + /// + private void FillRowNumbers() + { + // 表格数据按ID降序排列(最新在前),序号直接按行号赋值 + for (int i = 0; i < dgv_Data.Rows.Count; i++) + { + dgv_Data.Rows[i].Cells["序号"].Value = i + 1; + } + } + + /// + /// 从DataTable构建图表数据(确保所有行都被处理) + /// + private void BuildChartData(DataTable dt) + { + _chartData.Clear(); + // 查找时间列和数值列 + string timeCol = dt.Columns.Contains("进站时间") ? "进站时间" : + dt.Columns.Contains("测试时间") ? "测试时间" : null; + string valCol = dt.Columns.Contains("残油量") ? "残油量" : + dt.Columns.Contains("残留量") ? "残留量" : + dt.Columns.Contains("放油量") ? "放油量" : null; + string labelCol = dt.Columns.Contains("发动机号") ? "发动机号" : null; + + if (timeCol == null || valCol == null) return; + + foreach (DataRow row in dt.Rows) + { + DateTime t; + double v; + string lbl = labelCol != null ? row[labelCol]?.ToString() ?? "" : ""; + + // 时间解析:如果失败则使用当前时间递增 + if (!DateTime.TryParse(row[timeCol]?.ToString(), out t)) + t = DateTime.Now; + + // 数值解析:如果失败或为空,默认为0(也是有效数据点) + object rawVal = row[valCol]; + if (rawVal == null || rawVal == DBNull.Value || !double.TryParse(rawVal.ToString(), out v)) + v = 0; + + _chartData.Add((t, v, lbl)); + } + // 不排序,保持DataTable原始行顺序(与表格序号一致) + } + + /// + /// GDI+ 绘制折线图(增强版) + /// + private void pnl_Chart_Paint(object sender, PaintEventArgs e) + { + var g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; + + var rect = pnl_Chart.ClientRectangle; + int padL = 80, padR = 40, padT = 50, padB = 60; + int chartW = rect.Width - padL - padR; + int chartH = rect.Height - padT - padB; + + if (chartW < 50 || chartH < 50) return; + + // 绘制背景 + using (var bgBrush = new SolidBrush(Color.White)) + g.FillRectangle(bgBrush, rect); + + // 空数据提示 + if (_chartData.Count == 0) + { + using (var font = new Font("微软雅黑", 14F)) + using (var brush = new SolidBrush(Color.FromArgb(156, 163, 175))) + { + var msg = "📊 设置筛选条件后点击「统计分析」查看趋势图"; + var sz = g.MeasureString(msg, font); + g.DrawString(msg, font, brush, (rect.Width - sz.Width) / 2, (rect.Height - sz.Height) / 2); + } + return; + } + + // 计算数据范围 + double minVal = _chartData.Min(d => d.value); + double maxVal = _chartData.Max(d => d.value); + double range = maxVal - minVal; + if (range < 0.001) { range = Math.Max(Math.Abs(maxVal) * 0.2, 1); } + minVal -= range * 0.12; + maxVal += range * 0.12; + if (minVal < 0 && _chartData.Min(d => d.value) >= 0) minVal = 0; // 不让Y轴负数(如果原始数据非负) + + int totalPts = _chartData.Count; + + // ─── 绘制网格线和Y轴标签 ─── + using (var gridPen = new Pen(CLR_GRID, 1) { DashStyle = DashStyle.Dot }) + using (var axisFont = new Font("微软雅黑", 9F)) + using (var axisBrush = new SolidBrush(CLR_TEXT_LIGHT)) + using (var axisPen = new Pen(Color.FromArgb(200, 210, 220), 1)) + { + // Y轴线 + g.DrawLine(axisPen, padL, padT, padL, padT + chartH); + // X轴线 + g.DrawLine(axisPen, padL, padT + chartH, padL + chartW, padT + chartH); + + for (int i = 0; i <= 5; i++) + { + int y = padT + chartH - (int)(chartH * i / 5.0); + if (i > 0) g.DrawLine(gridPen, padL + 1, y, padL + chartW, y); + double val = minVal + (maxVal - minVal) * i / 5.0; + string valStr = val.ToString("F2"); + var sz = g.MeasureString(valStr, axisFont); + g.DrawString(valStr, axisFont, axisBrush, padL - sz.Width - 6, y - sz.Height / 2); + } + + // X轴标签 — 序号均匀排布(1, 2, 3...) + // 计算合适的标签间隔,避免过于密集 + int maxLabels = Math.Max(1, chartW / 40); // 每个标签至少40px空间 + int labelStep = Math.Max(1, (totalPts - 1) / Math.Max(maxLabels - 1, 1)); + // 如果数据点少于maxLabels,每个都显示 + if (totalPts <= maxLabels) labelStep = 1; + + for (int i = 0; i < totalPts; i += labelStep) + { + float xPos = totalPts == 1 ? padL + chartW / 2f + : padL + (float)chartW * i / (totalPts - 1); + string label = (i + 1).ToString(); + var sz = g.MeasureString(label, axisFont); + g.DrawString(label, axisFont, axisBrush, xPos - sz.Width / 2, padT + chartH + 8); + g.DrawLine(axisPen, (int)xPos, padT + chartH, (int)xPos, padT + chartH + 5); + } + // 确保最后一个序号显示 + if (totalPts > 1 && (totalPts - 1) % labelStep != 0) + { + float lastX = padL + chartW; + string lastLabel = totalPts.ToString(); + var lastSz = g.MeasureString(lastLabel, axisFont); + g.DrawString(lastLabel, axisFont, axisBrush, lastX - lastSz.Width / 2, padT + chartH + 8); + g.DrawLine(axisPen, (int)lastX, padT + chartH, (int)lastX, padT + chartH + 5); + } + } + + // ─── 计算所有数据点坐标(X轴按序号均匀排布)─── + var points = new PointF[totalPts]; + for (int i = 0; i < totalPts; i++) + { + float x = totalPts == 1 ? padL + chartW / 2f + : padL + (float)chartW * i / (totalPts - 1); + float y = padT + chartH - (float)(chartH * ((_chartData[i].value - minVal) / (maxVal - minVal))); + points[i] = new PointF(x, y); + } + + // ─── 渐变填充区域 ─── + if (points.Length >= 2) + { + using (var fillPath = new GraphicsPath()) + { + fillPath.AddLines(points); + fillPath.AddLine(points.Last(), new PointF(points.Last().X, padT + chartH)); + fillPath.AddLine(new PointF(points.Last().X, padT + chartH), new PointF(points.First().X, padT + chartH)); + fillPath.CloseFigure(); + using (var fillBrush = new LinearGradientBrush( + new Point(0, padT), new Point(0, padT + chartH), + Color.FromArgb(50, 74, 144, 217), Color.FromArgb(3, 74, 144, 217))) + { + g.FillPath(fillBrush, fillPath); + } + } + + // 折线(粗线+阴影效果) + using (var shadowPen = new Pen(Color.FromArgb(30, 74, 144, 217), 5f)) + { + shadowPen.LineJoin = LineJoin.Round; + g.DrawLines(shadowPen, points); + } + using (var linePen = new Pen(CLR_PRIMARY, 2.5f)) + { + linePen.LineJoin = LineJoin.Round; + g.DrawLines(linePen, points); + } + } + + // ─── 平均线(红色虚线 + 箭头 + 标签)─── + if (_chartData.Count > 0) + { + float avgY = padT + chartH - (float)(chartH * ((_avgValue - minVal) / (maxVal - minVal))); + if (avgY >= padT && avgY <= padT + chartH) + { + using (var avgPen = new Pen(CLR_AVG_LINE, 1.8f) { DashStyle = DashStyle.Dash }) + { + g.DrawLine(avgPen, padL, avgY, padL + chartW, avgY); + } + // 平均线标签(右侧带箭头标识) + using (var avgFont = new Font("微软雅黑", 9F, FontStyle.Bold)) + using (var avgBrush = new SolidBrush(CLR_AVG_LINE)) + { + string avgText = $"▶ 平均 {_avgValue:F2}"; + var sz = g.MeasureString(avgText, avgFont); + // 背景 + float lblX = padL + chartW - sz.Width - 4; + float lblY = avgY - sz.Height - 3; + using (var bgBrush = new SolidBrush(Color.FromArgb(220, 255, 255, 255))) + g.FillRectangle(bgBrush, lblX - 3, lblY, sz.Width + 6, sz.Height + 2); + g.DrawString(avgText, avgFont, avgBrush, lblX, lblY); + // 小三角箭头指向线 + var arrowPts = new PointF[] { + new PointF(padL + chartW + 2, avgY), + new PointF(padL + chartW + 10, avgY - 5), + new PointF(padL + chartW + 10, avgY + 5) + }; + g.FillPolygon(avgBrush, arrowPts); + } + } + } + + // ─── 数据点(带光晕效果)─── + for (int i = 0; i < points.Length; i++) + { + var pt = points[i]; + // 光晕 + using (var glowBrush = new SolidBrush(Color.FromArgb(40, 74, 144, 217))) + g.FillEllipse(glowBrush, pt.X - 8, pt.Y - 8, 16, 16); + // 白色底 + g.FillEllipse(Brushes.White, pt.X - 5, pt.Y - 5, 10, 10); + // 蓝色圆点 + using (var dotBrush = new SolidBrush(CLR_DOT_FILL)) + g.FillEllipse(dotBrush, pt.X - 4, pt.Y - 4, 8, 8); + // 数值标签(只有当数据点不太密时显示) + if (_chartData.Count <= 15) + { + using (var valFont = new Font("微软雅黑", 8F)) + using (var valBrush = new SolidBrush(CLR_PRIMARY_DARK)) + { + string valText = _chartData[i].value.ToString("F1"); + var sz = g.MeasureString(valText, valFont); + g.DrawString(valText, valFont, valBrush, pt.X - sz.Width / 2, pt.Y - sz.Height - 6); + } + } + } + + // ─── 图表右下角水印 ─── + using (var wmFont = new Font("微软雅黑", 8F)) + using (var wmBrush = new SolidBrush(Color.FromArgb(80, 156, 163, 175))) + { + string wm = $"共 {_chartData.Count} 个样本"; + var sz = g.MeasureString(wm, wmFont); + g.DrawString(wm, wmFont, wmBrush, padL + chartW - sz.Width, padT + 4); + } + } + + /// + /// 计算统计指标(基于残留量列) + /// + private void CalculateStatistics(DataTable dt) + { + var values = new List(); + string colName = dt.Columns.Contains("残油量") ? "残油量" : + dt.Columns.Contains("残留量") ? "残留量" : null; + if (colName == null) + { + foreach (DataColumn col in dt.Columns) + { + if (col.ColumnName.Contains("残留") || col.ColumnName.Contains("残油") || col.ColumnName.Contains("重量")) + { + colName = col.ColumnName; + break; + } + } + } + + if (colName != null) + { + foreach (DataRow row in dt.Rows) + { + object rawVal = row[colName]; + if (rawVal != null && rawVal != DBNull.Value && double.TryParse(rawVal.ToString(), out double v)) + values.Add(v); + else + values.Add(0); // 空值也算0,确保样本数一致 + } + } + + if (values.Count == 0) + { + ClearStatLabels(); + return; + } + + values.Sort(); + double max = values.Max(); + double min = values.Min(); + double avg = values.Average(); + _avgValue = avg; // 保存平均值用于绘图 + double median = values.Count % 2 == 0 + ? (values[values.Count / 2 - 1] + values[values.Count / 2]) / 2.0 + : values[values.Count / 2]; + double rangeVal = max - min; + double variance = values.Sum(v => Math.Pow(v - avg, 2)) / values.Count; + double stdDev = Math.Sqrt(variance); + + // 更新统计指标标签 + lbl_StatMax.Text = $"最大值 {max:F4}"; + lbl_StatMin.Text = $"最小值 {min:F4}"; + lbl_StatAvg.Text = $"平均值 {avg:F4}"; + lbl_StatMedian.Text = $"中位数 {median:F4}"; + lbl_StatRange.Text = $"极差 {rangeVal:F4}"; + lbl_StatVariance.Text = $"方差 {variance:F4}"; + lbl_StatStdDev.Text = $"标准差 {stdDev:F4}"; + lbl_StatCount.Text = $"样本数 {values.Count}"; + } + + private void ClearStatLabels() + { + lbl_StatMax.Text = "最大值 —"; + lbl_StatMin.Text = "最小值 —"; + lbl_StatAvg.Text = "平均值 —"; + lbl_StatMedian.Text = "中位数 —"; + lbl_StatRange.Text = "极差 —"; + lbl_StatVariance.Text = "方差 —"; + lbl_StatStdDev.Text = "标准差 —"; + lbl_StatCount.Text = "样本数 0"; + } + + /// + /// 导出数据 + /// + private void btn_Export_Click(object sender, EventArgs e) + { + CrudHelper.ExportToExcel("统计分析", "统计分析", () => + { + var (pageCountParam, itemCountParam) = PagerBar.CreateOutputParams(); + var parms = new SqlParameter[] + { + new SqlParameter("@发动机号", ""), + new SqlParameter("@机型号", GetHintValue(txt_ModelNo)), + new SqlParameter("@工单号", GetHintValue(txt_OrderNo)), + new SqlParameter("@开始时间", dtp_Start.Value.ToString("yyyy-MM-dd")), + new SqlParameter("@结束时间", dtp_End.Value.AddDays(1).ToString("yyyy-MM-dd")), + new SqlParameter("@PageCurrent", 1), + new SqlParameter("@PageSize", 9999999), + pageCountParam, itemCountParam + }; + SqlOperation.ExecuteStoredProcedure("称重记录_分页查询", parms, out DataTable dt, out string err); + return dt; + }, dgv_Data.Rows.Count > 0); + } + } +} diff --git a/SCADA/Pages/UC_Statistics.resx b/SCADA/Pages/UC_Statistics.resx new file mode 100644 index 0000000..5236701 --- /dev/null +++ b/SCADA/Pages/UC_Statistics.resx @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + text/microsoft-resx + 2.0 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + diff --git a/SCADA/Pages/UC_SystemSettings.Designer.cs b/SCADA/Pages/UC_SystemSettings.Designer.cs new file mode 100644 index 0000000..a88360b --- /dev/null +++ b/SCADA/Pages/UC_SystemSettings.Designer.cs @@ -0,0 +1,93 @@ +namespace MesWork.Pages +{ + partial class UC_SystemSettings + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + components.Dispose(); + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.pnl_Header = new System.Windows.Forms.Panel(); + this.lbl_Title = new System.Windows.Forms.Label(); + this.grp_Scanner1 = new System.Windows.Forms.GroupBox(); + this.grp_Scanner2 = new System.Windows.Forms.GroupBox(); + this.timer_Refresh = new System.Windows.Forms.Timer(this.components); + + this.SuspendLayout(); + // + // pnl_Header + // + this.pnl_Header.BackColor = System.Drawing.Color.White; + this.pnl_Header.Dock = System.Windows.Forms.DockStyle.Top; + this.pnl_Header.Height = 56; + this.pnl_Header.Padding = new System.Windows.Forms.Padding(24, 0, 0, 0); + this.pnl_Header.Name = "pnl_Header"; + this.pnl_Header.Controls.Add(this.lbl_Title); + // + // lbl_Title + // + this.lbl_Title.AutoSize = true; + this.lbl_Title.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Bold); + this.lbl_Title.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.lbl_Title.Location = new System.Drawing.Point(24, 14); + this.lbl_Title.Name = "lbl_Title"; + this.lbl_Title.Text = "系统设置"; + // + // grp_Scanner1 + // + this.grp_Scanner1.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold); + this.grp_Scanner1.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.grp_Scanner1.Location = new System.Drawing.Point(30, 76); + this.grp_Scanner1.Name = "grp_Scanner1"; + this.grp_Scanner1.Size = new System.Drawing.Size(700, 200); + this.grp_Scanner1.Text = " OP10 扫码枪 "; + // + // grp_Scanner2 + // + this.grp_Scanner2.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold); + this.grp_Scanner2.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.grp_Scanner2.Location = new System.Drawing.Point(30, 296); + this.grp_Scanner2.Name = "grp_Scanner2"; + this.grp_Scanner2.Size = new System.Drawing.Size(700, 200); + this.grp_Scanner2.Text = " OP20 扫码枪 "; + + // + // timer_Refresh + // + this.timer_Refresh.Interval = 1000; + this.timer_Refresh.Tick += new System.EventHandler(this.timer_Refresh_Tick); + // + // UC_SystemSettings + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(245, 247, 250); + this.Controls.Add(this.grp_Scanner1); + this.Controls.Add(this.grp_Scanner2); + + this.Controls.Add(this.pnl_Header); + this.Name = "UC_SystemSettings"; + this.Size = new System.Drawing.Size(1820, 1000); + this.ResumeLayout(false); + this.PerformLayout(); + } + + #endregion + + private System.Windows.Forms.Panel pnl_Header; + private System.Windows.Forms.Label lbl_Title; + private System.Windows.Forms.GroupBox grp_Scanner1; + private System.Windows.Forms.GroupBox grp_Scanner2; + private System.Windows.Forms.Timer timer_Refresh; + + } +} diff --git a/SCADA/Pages/UC_SystemSettings.cs b/SCADA/Pages/UC_SystemSettings.cs new file mode 100644 index 0000000..90f4563 --- /dev/null +++ b/SCADA/Pages/UC_SystemSettings.cs @@ -0,0 +1,238 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace MesWork.Pages +{ + /// + /// 系统设置页面 — 扫码枪连接管理 + /// + public partial class UC_SystemSettings : UserControl + { + // OP10 控件 + private ComboBox cmb_Com1; + private Button btn_Connect1, btn_Disconnect1, btn_ManualSend1; + private Label lbl_Status1, lbl_ScanTime1; + private TextBox txt_Barcode1; + + // OP20 控件 + private ComboBox cmb_Com2; + private Button btn_Connect2, btn_Disconnect2, btn_ManualSend2; + private Label lbl_Status2, lbl_ScanTime2; + private TextBox txt_Barcode2; + + public UC_SystemSettings() + { + InitializeComponent(); + + if (BarcodeManager.IsEnabled) + { + BuildScannerPanel(grp_Scanner1, "OP10", ref cmb_Com1, ref lbl_Status1, ref txt_Barcode1, ref lbl_ScanTime1, + ref btn_Connect1, ref btn_Disconnect1, ref btn_ManualSend1); + BuildScannerPanel(grp_Scanner2, "OP20", ref cmb_Com2, ref lbl_Status2, ref txt_Barcode2, ref lbl_ScanTime2, + ref btn_Connect2, ref btn_Disconnect2, ref btn_ManualSend2); + timer_Refresh.Start(); + } + else + { + BuildScannerPanel(grp_Scanner1, "OP10", ref cmb_Com1, ref lbl_Status1, ref txt_Barcode1, ref lbl_ScanTime1, + ref btn_Connect1, ref btn_Disconnect1, ref btn_ManualSend1); + BuildScannerPanel(grp_Scanner2, "OP20", ref cmb_Com2, ref lbl_Status2, ref txt_Barcode2, ref lbl_ScanTime2, + ref btn_Connect2, ref btn_Disconnect2, ref btn_ManualSend2); + grp_Scanner1.Enabled = false; + grp_Scanner2.Enabled = false; + } + } + + /// + /// 动态构建单个扫码枪面板的控件 + /// + private void BuildScannerPanel(GroupBox grp, string opName, + ref ComboBox cmb, ref Label lblStatus, ref TextBox txtBar, ref Label lblTime, + ref Button btnConn, ref Button btnDisc, ref Button btnSend) + { + var normalFont = new Font("微软雅黑", 10F); + var boldFont = new Font("微软雅黑", 10F, FontStyle.Bold); + int y1 = 35, y2 = 75, y3 = 115; + + // Row 1: COM口选择 + 连接/断开 + var lblCom = new Label { Text = "COM口:", Font = normalFont, ForeColor = Color.FromArgb(55, 65, 81), + Location = new Point(20, y1 + 4), AutoSize = true }; + grp.Controls.Add(lblCom); + + cmb = new ComboBox { Font = normalFont, Location = new Point(90, y1), Size = new Size(110, 28), + DropDownStyle = ComboBoxStyle.DropDownList }; + RefreshComPorts(cmb, opName); + grp.Controls.Add(cmb); + + // 局部变量捕获(ref参数不能在lambda中使用) + var localCmb = cmb; + var localTxtBar = txtBar; + + btnConn = new Button + { + Text = "🔗 连接", Font = boldFont, Size = new Size(90, 30), Location = new Point(215, y1 - 2), + BackColor = Color.FromArgb(74, 144, 217), ForeColor = Color.White, + FlatStyle = FlatStyle.Flat, Cursor = Cursors.Hand + }; + btnConn.FlatAppearance.BorderSize = 0; + btnConn.Click += (s, e) => DoConnect(opName, localCmb); + grp.Controls.Add(btnConn); + + btnDisc = new Button + { + Text = "⛔ 断开", Font = boldFont, Size = new Size(90, 30), Location = new Point(315, y1 - 2), + BackColor = Color.FromArgb(239, 68, 68), ForeColor = Color.White, + FlatStyle = FlatStyle.Flat, Cursor = Cursors.Hand + }; + btnDisc.FlatAppearance.BorderSize = 0; + btnDisc.Click += (s, e) => DoDisconnect(opName); + grp.Controls.Add(btnDisc); + + // 刷新COM口列表按钮 + var btnRefresh = new Button + { + Text = "🔄", Font = normalFont, Size = new Size(36, 30), Location = new Point(415, y1 - 2), + FlatStyle = FlatStyle.Flat, Cursor = Cursors.Hand, + BackColor = Color.FromArgb(229, 231, 235) + }; + btnRefresh.FlatAppearance.BorderSize = 0; + btnRefresh.Click += (s, e) => RefreshComPorts(localCmb, opName); + grp.Controls.Add(btnRefresh); + + lblStatus = new Label { Text = "● 未连接", Font = boldFont, ForeColor = Color.FromArgb(156, 163, 175), + Location = new Point(470, y1 + 4), AutoSize = true }; + grp.Controls.Add(lblStatus); + + // Row 2: 最近码值 + 手动发送 + var lblBar = new Label { Text = "码值:", Font = normalFont, ForeColor = Color.FromArgb(55, 65, 81), + Location = new Point(20, y2 + 4), AutoSize = true }; + grp.Controls.Add(lblBar); + + txtBar = new TextBox { Font = normalFont, Location = new Point(90, y2), Size = new Size(300, 28), + BorderStyle = BorderStyle.FixedSingle }; + localTxtBar = txtBar; // 更新局部变量 + grp.Controls.Add(txtBar); + + btnSend = new Button + { + Text = "📤 手动发送", Font = boldFont, Size = new Size(120, 30), Location = new Point(405, y2 - 2), + BackColor = Color.FromArgb(5, 150, 105), ForeColor = Color.White, + FlatStyle = FlatStyle.Flat, Cursor = Cursors.Hand + }; + btnSend.FlatAppearance.BorderSize = 0; + btnSend.Click += (s, e) => DoManualSend(opName, localTxtBar); + grp.Controls.Add(btnSend); + + // Row 3: 扫码时间 + var lblTimeLbl = new Label { Text = "扫码时间:", Font = normalFont, ForeColor = Color.FromArgb(55, 65, 81), + Location = new Point(20, y3 + 4), AutoSize = true }; + grp.Controls.Add(lblTimeLbl); + + lblTime = new Label { Text = "--", Font = normalFont, ForeColor = Color.FromArgb(31, 41, 55), + Location = new Point(110, y3 + 4), AutoSize = true }; + grp.Controls.Add(lblTime); + } + + // ── 操作方法 ── + + private void DoConnect(string opName, ComboBox cmb) + { + string com = cmb.SelectedItem?.ToString(); + if (string.IsNullOrEmpty(com)) + { + MessageBox.Show("请选择COM口", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + + BarcodeScanner scanner; + if (!BarcodeManager.Scanners.TryGetValue(opName, out scanner)) + { + scanner = new BarcodeScanner(opName, MesWorkForm.BarcodeBaudRate); + scanner.BarcodeReceived += (op, code) => BarcodeManager.ManualSend(op, code); + BarcodeManager.Scanners[opName] = scanner; + } + + bool ok = scanner.Connect(com); + MessageBox.Show(ok ? $"{opName} 扫码枪已连接 ({com})" : $"{opName} 连接失败,请检查COM口", + "连接结果", MessageBoxButtons.OK, ok ? MessageBoxIcon.Information : MessageBoxIcon.Warning); + } + + private void DoDisconnect(string opName) + { + if (BarcodeManager.Scanners.TryGetValue(opName, out var scanner)) + { + scanner.Disconnect(); + MessageBox.Show($"{opName} 扫码枪已断开", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void DoManualSend(string opName, TextBox txtBar) + { + string barcode = txtBar.Text.Trim(); + if (string.IsNullOrEmpty(barcode)) + { + MessageBox.Show("请输入条码值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + BarcodeManager.ManualSend(opName, barcode); + MessageBox.Show($"已手动发送条码:{barcode}\n工位:{opName}", "发送成功", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + + private void RefreshComPorts(ComboBox cmb, string opName) + { + cmb.Items.Clear(); + var ports = BarcodeManager.GetAvailablePorts(); + foreach (var p in ports) + cmb.Items.Add(p); + + // 自动选中当前配置的COM口或已连接的COM口 + if (BarcodeManager.Scanners.TryGetValue(opName, out var scanner) && !string.IsNullOrEmpty(scanner.ComPort)) + { + int idx = cmb.Items.IndexOf(scanner.ComPort); + if (idx >= 0) cmb.SelectedIndex = idx; + } + } + + // ── 定时刷新状态 ── + + private void timer_Refresh_Tick(object sender, EventArgs e) + { + RefreshScannerStatus("OP10", lbl_Status1, txt_Barcode1, lbl_ScanTime1); + RefreshScannerStatus("OP20", lbl_Status2, txt_Barcode2, lbl_ScanTime2); + } + + private void RefreshScannerStatus(string opName, Label lblStatus, TextBox txtBar, Label lblTime) + { + if (lblStatus == null) return; + + if (BarcodeManager.Scanners.TryGetValue(opName, out var scanner)) + { + if (scanner.IsConnected) + { + lblStatus.Text = $"● 已连接 ({scanner.ComPort})"; + lblStatus.ForeColor = Color.FromArgb(16, 185, 129); // 绿色 + } + else + { + lblStatus.Text = $"● 未连接 ({scanner.ComPort})"; + lblStatus.ForeColor = Color.FromArgb(239, 68, 68); // 红色 + } + + // 仅在有新扫码时更新(避免覆盖用户手动输入) + if (!string.IsNullOrEmpty(scanner.LastBarcode) && txtBar.Text != scanner.LastBarcode && !txtBar.Focused) + txtBar.Text = scanner.LastBarcode; + + lblTime.Text = scanner.LastScanTime.HasValue + ? scanner.LastScanTime.Value.ToString("yyyy-MM-dd HH:mm:ss") + : "--"; + } + else + { + lblStatus.Text = "● 未配置"; + lblStatus.ForeColor = Color.FromArgb(156, 163, 175); + lblTime.Text = "--"; + } + } + } +} diff --git a/SCADA/Pages/UC_ToolMgmt.Designer.cs b/SCADA/Pages/UC_ToolMgmt.Designer.cs new file mode 100644 index 0000000..e5c784f --- /dev/null +++ b/SCADA/Pages/UC_ToolMgmt.Designer.cs @@ -0,0 +1,253 @@ +namespace MesWork.Pages +{ + partial class UC_ToolMgmt + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + components.Dispose(); + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + private void InitializeComponent() + { + this.pnl_Toolbar = new System.Windows.Forms.Panel(); + this.txt_Search = new System.Windows.Forms.TextBox(); + this.btn_Search = new System.Windows.Forms.Button(); + this.btn_Add = new System.Windows.Forms.Button(); + this.btn_Edit = new System.Windows.Forms.Button(); + this.btn_Delete = new System.Windows.Forms.Button(); + this.btn_Refresh = new System.Windows.Forms.Button(); + this.btn_Export = new System.Windows.Forms.Button(); + this.dgv_Data = new System.Windows.Forms.DataGridView(); + this.pnl_StatusBar = new System.Windows.Forms.Panel(); + this.lbl_RecordCount = new System.Windows.Forms.Label(); + this.pnl_Toolbar.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).BeginInit(); + this.pnl_StatusBar.SuspendLayout(); + this.SuspendLayout(); + // + // pnl_Toolbar — 顶部工具栏 + // + this.pnl_Toolbar.BackColor = System.Drawing.Color.White; + this.pnl_Toolbar.Controls.Add(this.btn_Export); + this.pnl_Toolbar.Controls.Add(this.btn_Refresh); + this.pnl_Toolbar.Controls.Add(this.btn_Delete); + this.pnl_Toolbar.Controls.Add(this.btn_Edit); + this.pnl_Toolbar.Controls.Add(this.btn_Add); + this.pnl_Toolbar.Controls.Add(this.btn_Search); + this.pnl_Toolbar.Controls.Add(this.txt_Search); + this.pnl_Toolbar.Dock = System.Windows.Forms.DockStyle.Top; + this.pnl_Toolbar.Location = new System.Drawing.Point(0, 0); + this.pnl_Toolbar.Name = "pnl_Toolbar"; + this.pnl_Toolbar.Padding = new System.Windows.Forms.Padding(16, 12, 16, 12); + this.pnl_Toolbar.Size = new System.Drawing.Size(1820, 56); + this.pnl_Toolbar.TabIndex = 0; + // + // txt_Search — 搜索框 + // + this.txt_Search.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_Search.Font = new System.Drawing.Font("微软雅黑", 11F); + this.txt_Search.ForeColor = System.Drawing.Color.FromArgb(156, 163, 175); + this.txt_Search.Location = new System.Drawing.Point(16, 13); + this.txt_Search.Name = "txt_Search"; + this.txt_Search.Size = new System.Drawing.Size(280, 27); + this.txt_Search.TabIndex = 0; + this.txt_Search.Text = "输入工具名称搜索..."; + this.txt_Search.GotFocus += new System.EventHandler(this.txt_Search_GotFocus); + this.txt_Search.LostFocus += new System.EventHandler(this.txt_Search_LostFocus); + this.txt_Search.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_Search_KeyDown); + // + // btn_Search + // + this.btn_Search.BackColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.btn_Search.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Search.FlatAppearance.BorderSize = 0; + this.btn_Search.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Search.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Search.ForeColor = System.Drawing.Color.White; + this.btn_Search.Location = new System.Drawing.Point(306, 12); + this.btn_Search.Name = "btn_Search"; + this.btn_Search.Size = new System.Drawing.Size(80, 30); + this.btn_Search.TabIndex = 1; + this.btn_Search.Text = "🔍 搜索"; + this.btn_Search.UseVisualStyleBackColor = false; + this.btn_Search.Click += new System.EventHandler(this.btn_Search_Click); + // + // btn_Add + // + this.btn_Add.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Add.BackColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.btn_Add.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Add.FlatAppearance.BorderSize = 0; + this.btn_Add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Add.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Add.ForeColor = System.Drawing.Color.White; + this.btn_Add.Location = new System.Drawing.Point(1334, 12); + this.btn_Add.Name = "btn_Add"; + this.btn_Add.Size = new System.Drawing.Size(88, 30); + this.btn_Add.TabIndex = 2; + this.btn_Add.Text = "+ 新增"; + this.btn_Add.UseVisualStyleBackColor = false; + this.btn_Add.Click += new System.EventHandler(this.btn_Add_Click); + // + // btn_Edit + // + this.btn_Edit.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Edit.BackColor = System.Drawing.Color.FromArgb(245, 158, 11); + this.btn_Edit.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Edit.FlatAppearance.BorderSize = 0; + this.btn_Edit.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Edit.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Edit.ForeColor = System.Drawing.Color.White; + this.btn_Edit.Location = new System.Drawing.Point(1430, 12); + this.btn_Edit.Name = "btn_Edit"; + this.btn_Edit.Size = new System.Drawing.Size(88, 30); + this.btn_Edit.TabIndex = 3; + this.btn_Edit.Text = "✏ 修改"; + this.btn_Edit.UseVisualStyleBackColor = false; + this.btn_Edit.Click += new System.EventHandler(this.btn_Edit_Click); + // + // btn_Delete + // + this.btn_Delete.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Delete.BackColor = System.Drawing.Color.FromArgb(239, 68, 68); + this.btn_Delete.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Delete.FlatAppearance.BorderSize = 0; + this.btn_Delete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Delete.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Delete.ForeColor = System.Drawing.Color.White; + this.btn_Delete.Location = new System.Drawing.Point(1526, 12); + this.btn_Delete.Name = "btn_Delete"; + this.btn_Delete.Size = new System.Drawing.Size(88, 30); + this.btn_Delete.TabIndex = 4; + this.btn_Delete.Text = "✕ 删除"; + this.btn_Delete.UseVisualStyleBackColor = false; + this.btn_Delete.Click += new System.EventHandler(this.btn_Delete_Click); + // + // btn_Refresh + // + this.btn_Refresh.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Refresh.BackColor = System.Drawing.Color.FromArgb(107, 114, 128); + this.btn_Refresh.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Refresh.FlatAppearance.BorderSize = 0; + this.btn_Refresh.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Refresh.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Refresh.ForeColor = System.Drawing.Color.White; + this.btn_Refresh.Location = new System.Drawing.Point(1718, 12); + this.btn_Refresh.Name = "btn_Refresh"; + this.btn_Refresh.Size = new System.Drawing.Size(88, 30); + this.btn_Refresh.TabIndex = 5; + this.btn_Refresh.Text = "↻ 刷新"; + this.btn_Refresh.UseVisualStyleBackColor = false; + this.btn_Refresh.Click += new System.EventHandler(this.btn_Refresh_Click); + // + // btn_Export + // + this.btn_Export.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Export.BackColor = System.Drawing.Color.FromArgb(5, 150, 105); + this.btn_Export.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Export.FlatAppearance.BorderSize = 0; + this.btn_Export.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Export.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Export.ForeColor = System.Drawing.Color.White; + this.btn_Export.Location = new System.Drawing.Point(1622, 12); + this.btn_Export.Name = "btn_Export"; + this.btn_Export.Size = new System.Drawing.Size(88, 30); + this.btn_Export.TabIndex = 6; + this.btn_Export.Text = "📥 导出"; + this.btn_Export.UseVisualStyleBackColor = false; + this.btn_Export.Click += new System.EventHandler(this.btn_Export_Click); + // + // dgv_Data — 数据表格 + // + this.dgv_Data.AllowUserToAddRows = false; + this.dgv_Data.AllowUserToDeleteRows = false; + this.dgv_Data.AllowUserToResizeRows = false; + this.dgv_Data.BackgroundColor = System.Drawing.Color.White; + this.dgv_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dgv_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SingleHorizontal; + this.dgv_Data.ColumnHeadersHeight = 42; + this.dgv_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + this.dgv_Data.ColumnHeadersDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(232, 237, 242); + this.dgv_Data.ColumnHeadersDefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold); + this.dgv_Data.ColumnHeadersDefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + this.dgv_Data.DefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(31, 41, 55); + this.dgv_Data.DefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 11F); + this.dgv_Data.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(219, 234, 254); + this.dgv_Data.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.DefaultCellStyle.Padding = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.dgv_Data.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(248, 250, 252); + this.dgv_Data.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgv_Data.EnableHeadersVisualStyles = false; + this.dgv_Data.GridColor = System.Drawing.Color.FromArgb(229, 231, 235); + this.dgv_Data.MultiSelect = false; + this.dgv_Data.Name = "dgv_Data"; + this.dgv_Data.ReadOnly = true; + this.dgv_Data.RowHeadersVisible = false; + this.dgv_Data.RowTemplate.Height = 38; + this.dgv_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgv_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dgv_Data.TabIndex = 1; + this.dgv_Data.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgv_Data_CellDoubleClick); + // + // pnl_StatusBar — 底部状态栏 + // + this.pnl_StatusBar.BackColor = System.Drawing.Color.White; + this.pnl_StatusBar.Controls.Add(this.lbl_RecordCount); + this.pnl_StatusBar.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnl_StatusBar.Location = new System.Drawing.Point(0, 964); + this.pnl_StatusBar.Name = "pnl_StatusBar"; + this.pnl_StatusBar.Padding = new System.Windows.Forms.Padding(16, 6, 16, 6); + this.pnl_StatusBar.Size = new System.Drawing.Size(1820, 36); + this.pnl_StatusBar.TabIndex = 2; + // + // lbl_RecordCount + // + this.lbl_RecordCount.AutoSize = true; + this.lbl_RecordCount.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_RecordCount.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_RecordCount.Location = new System.Drawing.Point(16, 8); + this.lbl_RecordCount.Name = "lbl_RecordCount"; + this.lbl_RecordCount.Size = new System.Drawing.Size(82, 20); + this.lbl_RecordCount.TabIndex = 0; + this.lbl_RecordCount.Text = "共 0 条记录"; + // + // UC_ToolMgmt + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(245, 247, 250); + this.Controls.Add(this.dgv_Data); + this.Controls.Add(this.pnl_StatusBar); + this.Controls.Add(this.pnl_Toolbar); + this.Name = "UC_ToolMgmt"; + this.Size = new System.Drawing.Size(1820, 1000); + this.pnl_Toolbar.ResumeLayout(false); + this.pnl_Toolbar.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).EndInit(); + this.pnl_StatusBar.ResumeLayout(false); + this.pnl_StatusBar.PerformLayout(); + this.ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.Panel pnl_Toolbar; + private System.Windows.Forms.TextBox txt_Search; + private System.Windows.Forms.Button btn_Search; + private System.Windows.Forms.Button btn_Add; + private System.Windows.Forms.Button btn_Edit; + private System.Windows.Forms.Button btn_Delete; + private System.Windows.Forms.Button btn_Refresh; + private System.Windows.Forms.Button btn_Export; + private System.Windows.Forms.DataGridView dgv_Data; + private System.Windows.Forms.Panel pnl_StatusBar; + private System.Windows.Forms.Label lbl_RecordCount; + } +} diff --git a/SCADA/Pages/UC_ToolMgmt.cs b/SCADA/Pages/UC_ToolMgmt.cs new file mode 100644 index 0000000..dead41c --- /dev/null +++ b/SCADA/Pages/UC_ToolMgmt.cs @@ -0,0 +1,159 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using System.Drawing; +using System.Windows.Forms; + +namespace MesWork.Pages +{ + /// + /// 工具管理页面 — 传感器/工具校准和使用管理 + /// 对应存储过程:工具管理_分页查询、工具管理_新增、工具管理_修改、工具管理_删除 + /// + public partial class UC_ToolMgmt : UserControl + { + private const string SEARCH_HINT = "输入工具名称搜索..."; + private PagerBar _pager; + + public UC_ToolMgmt() + { + InitializeComponent(); + InitColumns(); + _pager = new PagerBar(); + _pager.PageChanged += (s, e) => LoadData(txt_Search.Text == SEARCH_HINT ? "" : txt_Search.Text.Trim()); + this.Controls.Remove(pnl_StatusBar); + this.Controls.Add(_pager); + this.Controls.SetChildIndex(_pager, this.Controls.Count - 2); + } + + /// + /// 预设表格列(确保无数据时也能看到表头结构) + /// + private void InitColumns() + { + dgv_Data.AutoGenerateColumns = false; + dgv_Data.Columns.Clear(); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "ID", HeaderText = "ID", DataPropertyName = "ID", Visible = false }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "工具名称", HeaderText = "工具名称", DataPropertyName = "工具名称", FillWeight = 110 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "说明", HeaderText = "说明", DataPropertyName = "说明", FillWeight = 120 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "校准值", HeaderText = "校准值", DataPropertyName = "校准值", FillWeight = 70 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "校准时间", HeaderText = "校准时间", DataPropertyName = "校准时间", FillWeight = 90 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "使用次数", HeaderText = "使用次数", DataPropertyName = "使用次数", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "使用次数变更时间", HeaderText = "次数变更时间", DataPropertyName = "使用次数变更时间", FillWeight = 90 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "创建时间", HeaderText = "创建时间", DataPropertyName = "创建时间", FillWeight = 90 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "修改时间", HeaderText = "修改时间", DataPropertyName = "修改时间", FillWeight = 90 }); + } + + public void LoadData(string keyword = "") + { + try + { + var (pageCountParam, itemCountParam) = PagerBar.CreateOutputParams(); + var parms = new SqlParameter[] + { + new SqlParameter("@工具名称", keyword ?? ""), + new SqlParameter("@PageCurrent", _pager.CurrentPage), + new SqlParameter("@PageSize", _pager.PageSize), + pageCountParam, + itemCountParam + }; + SqlOperation.ExecuteStoredProcedure("工具管理_分页查询", parms, out DataTable dt, out string err); + if (dt != null) dgv_Data.DataSource = dt; + _pager.UpdateState(pageCountParam, itemCountParam); + } + catch (Exception ex) + { + MessageBox.Show($"查询失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + // ── 搜索框交互 ── + private void txt_Search_GotFocus(object sender, EventArgs e) { CrudHelper.SearchBox_GotFocus(txt_Search, SEARCH_HINT); } + private void txt_Search_LostFocus(object sender, EventArgs e) { CrudHelper.SearchBox_LostFocus(txt_Search, SEARCH_HINT); } + private void txt_Search_KeyDown(object sender, KeyEventArgs e) { if (CrudHelper.SearchBox_KeyDown(e)) btn_Search_Click(sender, e); } + + // ── 按钮事件 ── + private void btn_Search_Click(object sender, EventArgs e) { _pager.ResetPage(); LoadData(txt_Search.Text == SEARCH_HINT ? "" : txt_Search.Text.Trim()); } + private void btn_Add_Click(object sender, EventArgs e) => ShowEditDialog(null); + private void btn_Edit_Click(object sender, EventArgs e) + { + if (dgv_Data.CurrentRow != null) ShowEditDialog(dgv_Data.CurrentRow); + else MessageBox.Show("请先选择一条记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + private void btn_Delete_Click(object sender, EventArgs e) + { + if (dgv_Data.CurrentRow == null) { MessageBox.Show("请先选择一条记录", "提示"); return; } + string name = dgv_Data.CurrentRow.Cells["工具名称"]?.Value?.ToString() ?? ""; + if (MessageBox.Show($"确认删除工具「{name}」?", "确认删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) + { + try + { + var parms = new SqlParameter[] { new SqlParameter("@ID", int.Parse(dgv_Data.CurrentRow.Cells["ID"]?.Value?.ToString() ?? "0")) }; + SqlOperation.ExecuteStoredProcedure("工具管理_删除", parms, out string err); + LoadData(); + } + catch (Exception ex) { MessageBox.Show($"删除失败:{ex.Message}"); } + } + } + private void btn_Refresh_Click(object sender, EventArgs e) { _pager.ResetPage(); LoadData(""); } + private void dgv_Data_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) btn_Edit_Click(sender, e); } + + /// + /// 新增/修改弹窗 + /// + private void ShowEditDialog(DataGridViewRow row) + { + bool isEdit = row != null; + using (var dlg = CrudHelper.CreateEditDialog(isEdit ? "修改工具" : "新增工具", 420, 380)) + { + int y = 20; + var txtName = CrudHelper.AddTextField(dlg, "工具名称:", ref y, isEdit ? row.Cells["工具名称"]?.Value?.ToString() : ""); + var txtDesc = CrudHelper.AddTextField(dlg, "说明:", ref y, isEdit ? row.Cells["说明"]?.Value?.ToString() : ""); + var txtCalVal = CrudHelper.AddTextField(dlg, "校准值:", ref y, isEdit ? row.Cells["校准值"]?.Value?.ToString() : "0"); + var txtCalTime = CrudHelper.AddTextField(dlg, "校准时间:", ref y, isEdit ? row.Cells["校准时间"]?.Value?.ToString() : DateTime.Now.ToString("yyyy-MM-dd")); + var txtUseCnt = CrudHelper.AddTextField(dlg, "使用次数:", ref y, isEdit ? row.Cells["使用次数"]?.Value?.ToString() : "0"); + CrudHelper.AddDialogButtons(dlg, ref y); + + if (dlg.ShowDialog() == DialogResult.OK) + { + try + { + string sp = isEdit ? "工具管理_编辑" : "工具管理_增加"; + var pList = new System.Collections.Generic.List + { + new SqlParameter("@工具名称", txtName.Text.Trim()), + new SqlParameter("@说明", txtDesc.Text.Trim()), + new SqlParameter("@校准值", txtCalVal.Text.Trim()), + new SqlParameter("@校准时间", DateTime.Parse(txtCalTime.Text)), + new SqlParameter("@使用次数", int.Parse(txtUseCnt.Text)) + }; + if (isEdit) pList.Insert(0, new SqlParameter("@ID", int.Parse(row.Cells["ID"]?.Value?.ToString() ?? "0"))); + SqlOperation.ExecuteStoredProcedure(sp, pList.ToArray(), out string err); + LoadData(); + } + catch (Exception ex) { MessageBox.Show($"保存失败:{ex.Message}"); } + } + } + } + + private void btn_Export_Click(object sender, EventArgs e) + { + CrudHelper.ExportToExcel("工具管理", "工具管理", () => + { + string keyword = CrudHelper.GetSearchKeyword(txt_Search, SEARCH_HINT); + var (pageCountParam, itemCountParam) = PagerBar.CreateOutputParams(); + var parms = new SqlParameter[] + { + new SqlParameter("@工具名称", keyword), + new SqlParameter("@PageCurrent", 1), + new SqlParameter("@PageSize", 9999999), + pageCountParam, itemCountParam + }; + SqlOperation.ExecuteStoredProcedure("工具管理_分页查询", parms, out DataTable dt, out string err); + return dt; + }, dgv_Data.Rows.Count > 0); + } + + protected override void OnVisibleChanged(EventArgs e) { base.OnVisibleChanged(e); if (Visible && dgv_Data.DataSource == null) LoadData(); } + } +} diff --git a/SCADA/Pages/UC_ToolMgmt.resx b/SCADA/Pages/UC_ToolMgmt.resx new file mode 100644 index 0000000..5236701 --- /dev/null +++ b/SCADA/Pages/UC_ToolMgmt.resx @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + text/microsoft-resx + 2.0 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + diff --git a/SCADA/Pages/UC_UserMgmt.Designer.cs b/SCADA/Pages/UC_UserMgmt.Designer.cs new file mode 100644 index 0000000..69b248e --- /dev/null +++ b/SCADA/Pages/UC_UserMgmt.Designer.cs @@ -0,0 +1,233 @@ +namespace MesWork.Pages +{ + partial class UC_UserMgmt + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + components.Dispose(); + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + private void InitializeComponent() + { + this.pnl_Toolbar = new System.Windows.Forms.Panel(); + this.txt_Search = new System.Windows.Forms.TextBox(); + this.btn_Search = new System.Windows.Forms.Button(); + this.btn_Add = new System.Windows.Forms.Button(); + this.btn_Edit = new System.Windows.Forms.Button(); + this.btn_Delete = new System.Windows.Forms.Button(); + this.btn_Refresh = new System.Windows.Forms.Button(); + this.dgv_Data = new System.Windows.Forms.DataGridView(); + this.pnl_StatusBar = new System.Windows.Forms.Panel(); + this.lbl_RecordCount = new System.Windows.Forms.Label(); + this.pnl_Toolbar.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).BeginInit(); + this.pnl_StatusBar.SuspendLayout(); + this.SuspendLayout(); + // + // pnl_Toolbar — 顶部工具栏 + // + this.pnl_Toolbar.BackColor = System.Drawing.Color.White; + this.pnl_Toolbar.Controls.Add(this.btn_Refresh); + this.pnl_Toolbar.Controls.Add(this.btn_Delete); + this.pnl_Toolbar.Controls.Add(this.btn_Edit); + this.pnl_Toolbar.Controls.Add(this.btn_Add); + this.pnl_Toolbar.Controls.Add(this.btn_Search); + this.pnl_Toolbar.Controls.Add(this.txt_Search); + this.pnl_Toolbar.Dock = System.Windows.Forms.DockStyle.Top; + this.pnl_Toolbar.Location = new System.Drawing.Point(0, 0); + this.pnl_Toolbar.Name = "pnl_Toolbar"; + this.pnl_Toolbar.Padding = new System.Windows.Forms.Padding(16, 12, 16, 12); + this.pnl_Toolbar.Size = new System.Drawing.Size(1820, 56); + this.pnl_Toolbar.TabIndex = 0; + // + // txt_Search — 搜索框 + // + this.txt_Search.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_Search.Font = new System.Drawing.Font("微软雅黑", 11F); + this.txt_Search.ForeColor = System.Drawing.Color.FromArgb(156, 163, 175); + this.txt_Search.Location = new System.Drawing.Point(16, 13); + this.txt_Search.Name = "txt_Search"; + this.txt_Search.Size = new System.Drawing.Size(280, 27); + this.txt_Search.TabIndex = 0; + this.txt_Search.Text = "输入姓名搜索..."; + this.txt_Search.GotFocus += new System.EventHandler(this.txt_Search_GotFocus); + this.txt_Search.LostFocus += new System.EventHandler(this.txt_Search_LostFocus); + this.txt_Search.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_Search_KeyDown); + // + // btn_Search — 搜索按钮 + // + this.btn_Search.BackColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.btn_Search.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Search.FlatAppearance.BorderSize = 0; + this.btn_Search.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Search.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Search.ForeColor = System.Drawing.Color.White; + this.btn_Search.Location = new System.Drawing.Point(306, 12); + this.btn_Search.Name = "btn_Search"; + this.btn_Search.Size = new System.Drawing.Size(80, 30); + this.btn_Search.TabIndex = 1; + this.btn_Search.Text = "🔍 搜索"; + this.btn_Search.UseVisualStyleBackColor = false; + this.btn_Search.Click += new System.EventHandler(this.btn_Search_Click); + // + // btn_Add — 新增 + // + this.btn_Add.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Add.BackColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.btn_Add.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Add.FlatAppearance.BorderSize = 0; + this.btn_Add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Add.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Add.ForeColor = System.Drawing.Color.White; + this.btn_Add.Location = new System.Drawing.Point(1430, 12); + this.btn_Add.Name = "btn_Add"; + this.btn_Add.Size = new System.Drawing.Size(88, 30); + this.btn_Add.TabIndex = 2; + this.btn_Add.Text = "+ 新增"; + this.btn_Add.UseVisualStyleBackColor = false; + this.btn_Add.Click += new System.EventHandler(this.btn_Add_Click); + // + // btn_Edit — 修改 + // + this.btn_Edit.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Edit.BackColor = System.Drawing.Color.FromArgb(245, 158, 11); + this.btn_Edit.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Edit.FlatAppearance.BorderSize = 0; + this.btn_Edit.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Edit.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Edit.ForeColor = System.Drawing.Color.White; + this.btn_Edit.Location = new System.Drawing.Point(1526, 12); + this.btn_Edit.Name = "btn_Edit"; + this.btn_Edit.Size = new System.Drawing.Size(88, 30); + this.btn_Edit.TabIndex = 3; + this.btn_Edit.Text = "✏ 修改"; + this.btn_Edit.UseVisualStyleBackColor = false; + this.btn_Edit.Click += new System.EventHandler(this.btn_Edit_Click); + // + // btn_Delete — 删除 + // + this.btn_Delete.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Delete.BackColor = System.Drawing.Color.FromArgb(239, 68, 68); + this.btn_Delete.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Delete.FlatAppearance.BorderSize = 0; + this.btn_Delete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Delete.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Delete.ForeColor = System.Drawing.Color.White; + this.btn_Delete.Location = new System.Drawing.Point(1622, 12); + this.btn_Delete.Name = "btn_Delete"; + this.btn_Delete.Size = new System.Drawing.Size(88, 30); + this.btn_Delete.TabIndex = 4; + this.btn_Delete.Text = "✕ 删除"; + this.btn_Delete.UseVisualStyleBackColor = false; + this.btn_Delete.Click += new System.EventHandler(this.btn_Delete_Click); + // + // btn_Refresh — 刷新 + // + this.btn_Refresh.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Refresh.BackColor = System.Drawing.Color.FromArgb(107, 114, 128); + this.btn_Refresh.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Refresh.FlatAppearance.BorderSize = 0; + this.btn_Refresh.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Refresh.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Refresh.ForeColor = System.Drawing.Color.White; + this.btn_Refresh.Location = new System.Drawing.Point(1718, 12); + this.btn_Refresh.Name = "btn_Refresh"; + this.btn_Refresh.Size = new System.Drawing.Size(88, 30); + this.btn_Refresh.TabIndex = 5; + this.btn_Refresh.Text = "↻ 刷新"; + this.btn_Refresh.UseVisualStyleBackColor = false; + this.btn_Refresh.Click += new System.EventHandler(this.btn_Refresh_Click); + // + // dgv_Data — 数据表格 + // + this.dgv_Data.AllowUserToAddRows = false; + this.dgv_Data.AllowUserToDeleteRows = false; + this.dgv_Data.AllowUserToResizeRows = false; + this.dgv_Data.BackgroundColor = System.Drawing.Color.White; + this.dgv_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dgv_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SingleHorizontal; + this.dgv_Data.ColumnHeadersHeight = 42; + this.dgv_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + this.dgv_Data.ColumnHeadersDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(232, 237, 242); + this.dgv_Data.ColumnHeadersDefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold); + this.dgv_Data.ColumnHeadersDefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + this.dgv_Data.DefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(31, 41, 55); + this.dgv_Data.DefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 11F); + this.dgv_Data.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(219, 234, 254); + this.dgv_Data.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.DefaultCellStyle.Padding = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.dgv_Data.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(248, 250, 252); + this.dgv_Data.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgv_Data.EnableHeadersVisualStyles = false; + this.dgv_Data.GridColor = System.Drawing.Color.FromArgb(229, 231, 235); + this.dgv_Data.MultiSelect = false; + this.dgv_Data.Name = "dgv_Data"; + this.dgv_Data.ReadOnly = true; + this.dgv_Data.RowHeadersVisible = false; + this.dgv_Data.RowTemplate.Height = 38; + this.dgv_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgv_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dgv_Data.TabIndex = 1; + this.dgv_Data.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgv_Data_CellDoubleClick); + // + // pnl_StatusBar — 底部状态栏 + // + this.pnl_StatusBar.BackColor = System.Drawing.Color.White; + this.pnl_StatusBar.Controls.Add(this.lbl_RecordCount); + this.pnl_StatusBar.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnl_StatusBar.Location = new System.Drawing.Point(0, 964); + this.pnl_StatusBar.Name = "pnl_StatusBar"; + this.pnl_StatusBar.Padding = new System.Windows.Forms.Padding(16, 6, 16, 6); + this.pnl_StatusBar.Size = new System.Drawing.Size(1820, 36); + this.pnl_StatusBar.TabIndex = 2; + // + // lbl_RecordCount — 记录条数 + // + this.lbl_RecordCount.AutoSize = true; + this.lbl_RecordCount.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_RecordCount.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_RecordCount.Location = new System.Drawing.Point(16, 8); + this.lbl_RecordCount.Name = "lbl_RecordCount"; + this.lbl_RecordCount.Size = new System.Drawing.Size(82, 20); + this.lbl_RecordCount.TabIndex = 0; + this.lbl_RecordCount.Text = "共 0 条记录"; + // + // UC_UserMgmt + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(245, 247, 250); + this.Controls.Add(this.dgv_Data); + this.Controls.Add(this.pnl_StatusBar); + this.Controls.Add(this.pnl_Toolbar); + this.Name = "UC_UserMgmt"; + this.Size = new System.Drawing.Size(1820, 1000); + this.pnl_Toolbar.ResumeLayout(false); + this.pnl_Toolbar.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).EndInit(); + this.pnl_StatusBar.ResumeLayout(false); + this.pnl_StatusBar.PerformLayout(); + this.ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.Panel pnl_Toolbar; + private System.Windows.Forms.TextBox txt_Search; + private System.Windows.Forms.Button btn_Search; + private System.Windows.Forms.Button btn_Add; + private System.Windows.Forms.Button btn_Edit; + private System.Windows.Forms.Button btn_Delete; + private System.Windows.Forms.Button btn_Refresh; + private System.Windows.Forms.DataGridView dgv_Data; + private System.Windows.Forms.Panel pnl_StatusBar; + private System.Windows.Forms.Label lbl_RecordCount; + } +} diff --git a/SCADA/Pages/UC_UserMgmt.cs b/SCADA/Pages/UC_UserMgmt.cs new file mode 100644 index 0000000..330f0af --- /dev/null +++ b/SCADA/Pages/UC_UserMgmt.cs @@ -0,0 +1,167 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using System.Drawing; +using System.Windows.Forms; + +namespace MesWork.Pages +{ + /// + /// 用户管理页面 — CRUD 操作 + /// 对应存储过程:用户管理_查询、用户管理_增加、用户管理_编辑、用户管理_删除 + /// + public partial class UC_UserMgmt : UserControl + { + private const string SEARCH_HINT = "输入姓名搜索..."; + private PagerBar _pager; + + public UC_UserMgmt() + { + InitializeComponent(); + InitColumns(); + // 用PagerBar替换原始pnl_StatusBar + _pager = new PagerBar(); + _pager.PageChanged += (s, e) => LoadData(txt_Search.Text == SEARCH_HINT ? "" : txt_Search.Text.Trim()); + this.Controls.Remove(pnl_StatusBar); + this.Controls.Add(_pager); + this.Controls.SetChildIndex(_pager, this.Controls.Count - 2); + } + + /// + /// 预设表格列(工号/密码/姓名/性别/权限/创建时间/修改时间) + /// + private void InitColumns() + { + dgv_Data.AutoGenerateColumns = false; + dgv_Data.Columns.Clear(); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "ID", HeaderText = "ID", DataPropertyName = "ID", Visible = false }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "用户名", HeaderText = "工号", DataPropertyName = "用户名", FillWeight = 100 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "姓名", HeaderText = "姓名", DataPropertyName = "姓名", FillWeight = 100 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "性别", HeaderText = "性别", DataPropertyName = "性别", FillWeight = 50 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "权限", HeaderText = "权限", DataPropertyName = "权限", FillWeight = 60 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "创建时间", HeaderText = "创建时间", DataPropertyName = "创建时间", FillWeight = 100 }); + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "修改时间", HeaderText = "修改时间", DataPropertyName = "修改时间", FillWeight = 100 }); + } + + // ==================================================================== + // 数据加载 — SP: 用户管理_查询(@姓名) + // ==================================================================== + + public void LoadData(string keyword = "") + { + try + { + var (pageCountParam, itemCountParam) = PagerBar.CreateOutputParams(); + var parms = new SqlParameter[] + { + new SqlParameter("@姓名", keyword ?? ""), + new SqlParameter("@PageCurrent", _pager.CurrentPage), + new SqlParameter("@PageSize", _pager.PageSize), + pageCountParam, + itemCountParam + }; + SqlOperation.ExecuteStoredProcedure("用户管理_分页查询", parms, out DataTable dt, out string err); + if (dt != null) dgv_Data.DataSource = dt; + _pager.UpdateState(pageCountParam, itemCountParam); + } + catch (Exception ex) + { + MessageBox.Show($"查询失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + // ==================================================================== + // 搜索框交互 + // ==================================================================== + + private void txt_Search_GotFocus(object sender, EventArgs e) + { + CrudHelper.SearchBox_GotFocus(txt_Search, SEARCH_HINT); + } + + private void txt_Search_LostFocus(object sender, EventArgs e) + { + CrudHelper.SearchBox_LostFocus(txt_Search, SEARCH_HINT); + } + + private void txt_Search_KeyDown(object sender, KeyEventArgs e) + { + if (CrudHelper.SearchBox_KeyDown(e)) btn_Search_Click(sender, e); + } + + // ==================================================================== + // 按钮事件 + // ==================================================================== + + private void btn_Search_Click(object sender, EventArgs e) { _pager.ResetPage(); LoadData(txt_Search.Text == SEARCH_HINT ? "" : txt_Search.Text.Trim()); } + private void btn_Add_Click(object sender, EventArgs e) => ShowEditDialog(null); + private void btn_Edit_Click(object sender, EventArgs e) + { + if (dgv_Data.CurrentRow == null) { MessageBox.Show("请先选择一条记录", "提示"); return; } + ShowEditDialog(dgv_Data.CurrentRow); + } + + /// + /// 删除 — SP: 用户管理_删除(@ID) + /// + private void btn_Delete_Click(object sender, EventArgs e) + { + if (dgv_Data.CurrentRow == null) { MessageBox.Show("请先选择一条记录", "提示"); return; } + string name = dgv_Data.CurrentRow.Cells["姓名"]?.Value?.ToString() ?? ""; + if (MessageBox.Show($"确认删除用户「{name}」?", "确认删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) + { + try + { + var parms = new SqlParameter[] { new SqlParameter("@ID", int.Parse(dgv_Data.CurrentRow.Cells["ID"]?.Value?.ToString() ?? "0")) }; + SqlOperation.ExecuteStoredProcedure("用户管理_删除", parms, out string err); + LoadData(); + } + catch (Exception ex) { MessageBox.Show($"删除失败:{ex.Message}"); } + } + } + + private void btn_Refresh_Click(object sender, EventArgs e) { _pager.ResetPage(); LoadData(""); } + private void dgv_Data_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) btn_Edit_Click(sender, e); } + + // ==================================================================== + // 编辑弹窗 — SP: 用户管理_增加 / 用户管理_编辑 + // ==================================================================== + + private void ShowEditDialog(DataGridViewRow row) + { + bool isEdit = row != null; + using (var dlg = CrudHelper.CreateEditDialog(isEdit ? "修改用户" : "新增用户", 420, 380)) + { + int y = 20; + var txtJobNo = CrudHelper.AddTextField(dlg, "工号:", ref y, isEdit ? row.Cells["用户名"]?.Value?.ToString() : "", inputX: 110, inputWidth: 260); + var txtPwd = CrudHelper.AddTextField(dlg, "密码:", ref y, "", inputX: 110, inputWidth: 260, isPassword: true); + var txtName = CrudHelper.AddTextField(dlg, "姓名:", ref y, isEdit ? row.Cells["姓名"]?.Value?.ToString() : "", inputX: 110, inputWidth: 260); + var cmbGender = CrudHelper.AddComboField(dlg, "性别:", ref y, new[] { "男", "女" }, isEdit ? row.Cells["性别"]?.Value?.ToString() : "男", inputX: 110, inputWidth: 260); + var cmbPerm = CrudHelper.AddComboField(dlg, "权限:", ref y, new[] { "管理", "操作", "查看" }, isEdit ? row.Cells["权限"]?.Value?.ToString() : "操作", inputX: 110, inputWidth: 260); + CrudHelper.AddDialogButtons(dlg, ref y); + + if (dlg.ShowDialog(this) == DialogResult.OK) + { + try + { + string sp = isEdit ? "用户管理_编辑" : "用户管理_增加"; + var pList = new System.Collections.Generic.List + { + new SqlParameter("@用户名", txtJobNo.Text.Trim()), + new SqlParameter("@密码", txtPwd.Text), + new SqlParameter("@姓名", txtName.Text.Trim()), + new SqlParameter("@性别", cmbGender.Text), + new SqlParameter("@权限", cmbPerm.Text) + }; + if (isEdit) pList.Insert(0, new SqlParameter("@ID", int.Parse(row.Cells["ID"]?.Value?.ToString() ?? "0"))); + SqlOperation.ExecuteStoredProcedure(sp, pList.ToArray(), out string err); + LoadData(); + } + catch (Exception ex) { MessageBox.Show($"保存失败:{ex.Message}"); } + } + } + } + + protected override void OnVisibleChanged(EventArgs e) { base.OnVisibleChanged(e); if (Visible && dgv_Data.DataSource == null) LoadData(); } + } +} diff --git a/SCADA/Pages/UC_UserMgmt.resx b/SCADA/Pages/UC_UserMgmt.resx new file mode 100644 index 0000000..5236701 --- /dev/null +++ b/SCADA/Pages/UC_UserMgmt.resx @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + text/microsoft-resx + 2.0 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + diff --git a/SCADA/Pages/UC_Weighing.Designer.cs b/SCADA/Pages/UC_Weighing.Designer.cs new file mode 100644 index 0000000..96bee70 --- /dev/null +++ b/SCADA/Pages/UC_Weighing.Designer.cs @@ -0,0 +1,1955 @@ +namespace MesWork.Pages + +{ + + partial class UC_Weighing + + { + + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + + { + + if (disposing && (components != null)) + + components.Dispose(); + + base.Dispose(disposing); + + } + + #region 组件设计器生成的代码 + + private void InitializeComponent() + + { + + this.pnl_Stations = new System.Windows.Forms.Panel(); + + this.pnl_Station2 = new System.Windows.Forms.Panel(); + + this.lbl_S2_AlarmVal = new System.Windows.Forms.Label(); + + this.lbl_S2_AlarmLabel = new System.Windows.Forms.Label(); + + this.lbl_S2_Info2 = new System.Windows.Forms.Label(); + + this.lbl_S2_Info1 = new System.Windows.Forms.Label(); + + this.lbl_S2_DensityVal = new System.Windows.Forms.Label(); + + this.lbl_S2_ExtractOilVal = new System.Windows.Forms.Label(); + + this.lbl_S2_OilReleaseVal = new System.Windows.Forms.Label(); + + this.lbl_S2_ResidualOilVal = new System.Windows.Forms.Label(); + + this.lbl_S2_QualityVal = new System.Windows.Forms.Label(); + this.pnl_S2_WaterBox = new System.Windows.Forms.Panel(); + this.lbl_S2_WaterTitle = new System.Windows.Forms.Label(); + this.lbl_S2_WaterUnit = new System.Windows.Forms.Label(); + this.pnl_S2_MetricBox = new System.Windows.Forms.Panel(); + this.pnl_S2_DensityBox = new System.Windows.Forms.Panel(); + this.lbl_S2_DensityTitle = new System.Windows.Forms.Label(); + this.lbl_S2_DensityUnit = new System.Windows.Forms.Label(); + this.pnl_S2_AddOilBox = new System.Windows.Forms.Panel(); + this.lbl_S2_AddOilTitle = new System.Windows.Forms.Label(); + this.lbl_S2_AddOilUnit = new System.Windows.Forms.Label(); + this.pnl_S2_ExtractOilBox = new System.Windows.Forms.Panel(); + this.lbl_S2_ExtractOilTitle = new System.Windows.Forms.Label(); + this.lbl_S2_ExtractOilUnit = new System.Windows.Forms.Label(); + this.pnl_S2_OilReleaseBox = new System.Windows.Forms.Panel(); + this.lbl_S2_OilReleaseTitle = new System.Windows.Forms.Label(); + this.lbl_S2_OilReleaseUnit = new System.Windows.Forms.Label(); + this.pnl_S2_ResidualOilBox = new System.Windows.Forms.Panel(); + this.lbl_S2_ResidualOilTitle = new System.Windows.Forms.Label(); + this.lbl_S2_ResidualOilUnit = new System.Windows.Forms.Label(); + this.pnl_S2_QualityBox = new System.Windows.Forms.Panel(); + this.lbl_S2_QualityTitle = new System.Windows.Forms.Label(); + this.lbl_S2_WeightTitle = new System.Windows.Forms.Label(); + + this.pnl_S2_WeightBox = new System.Windows.Forms.Panel(); + + this.lbl_S2_WeightUnit = new System.Windows.Forms.Label(); + + this.lbl_S2_Weight = new System.Windows.Forms.Label(); + + this.lbl_S2_PalletVal = new System.Windows.Forms.Label(); + + this.lbl_S2_PalletLabel = new System.Windows.Forms.Label(); + + this.lbl_S2_OrderVal = new System.Windows.Forms.Label(); + + this.lbl_S2_OrderLabel = new System.Windows.Forms.Label(); + + this.lbl_S2_ModelVal = new System.Windows.Forms.Label(); + + this.lbl_S2_ModelLabel = new System.Windows.Forms.Label(); + + this.lbl_S2_EngineVal = new System.Windows.Forms.Label(); + + this.lbl_S2_EngineLabel = new System.Windows.Forms.Label(); + + this.pnl_S2_Header = new System.Windows.Forms.Panel(); + + this.lbl_S2_Title = new System.Windows.Forms.Label(); + + this.pnl_Station1 = new System.Windows.Forms.Panel(); + + this.lbl_S1_AlarmVal = new System.Windows.Forms.Label(); + + this.lbl_S1_AlarmLabel = new System.Windows.Forms.Label(); + + this.pnl_S1_WaterBox = new System.Windows.Forms.Panel(); + + this.lbl_S1_WaterTitle = new System.Windows.Forms.Label(); + + this.lbl_S1_WaterUnit = new System.Windows.Forms.Label(); + + this.lbl_S1_Info1 = new System.Windows.Forms.Label(); + + this.pnl_S1_MetricBox = new System.Windows.Forms.Panel(); + + this.pnl_S1_QualityBox = new System.Windows.Forms.Panel(); + + this.lbl_S1_QualityTitle = new System.Windows.Forms.Label(); + + this.lbl_S1_QualityVal = new System.Windows.Forms.Label(); + + this.pnl_S1_ResidualOilBox = new System.Windows.Forms.Panel(); + + this.lbl_S1_ResidualOilTitle = new System.Windows.Forms.Label(); + + this.lbl_S1_ResidualOilUnit = new System.Windows.Forms.Label(); + + this.lbl_S1_ResidualOilVal = new System.Windows.Forms.Label(); + + this.pnl_S1_OilReleaseBox = new System.Windows.Forms.Panel(); + + this.lbl_S1_OilReleaseTitle = new System.Windows.Forms.Label(); + + this.lbl_S1_OilReleaseUnit = new System.Windows.Forms.Label(); + + this.lbl_S1_OilReleaseVal = new System.Windows.Forms.Label(); + + this.pnl_S1_DensityBox = new System.Windows.Forms.Panel(); + + this.lbl_S1_DensityTitle = new System.Windows.Forms.Label(); + + this.lbl_S1_DensityUnit = new System.Windows.Forms.Label(); + + this.lbl_S1_DensityVal = new System.Windows.Forms.Label(); + + this.pnl_S1_ExtractOilBox = new System.Windows.Forms.Panel(); + + this.lbl_S1_ExtractOilTitle = new System.Windows.Forms.Label(); + + this.lbl_S1_ExtractOilUnit = new System.Windows.Forms.Label(); + + this.lbl_S1_ExtractOilVal = new System.Windows.Forms.Label(); + + this.pnl_S1_AddOilBox = new System.Windows.Forms.Panel(); + + this.lbl_S1_AddOilTitle = new System.Windows.Forms.Label(); + + this.lbl_S1_AddOilUnit = new System.Windows.Forms.Label(); + + this.lbl_S1_Info2 = new System.Windows.Forms.Label(); + + this.pnl_S1_WeightBox = new System.Windows.Forms.Panel(); + + this.lbl_S1_WeightUnit = new System.Windows.Forms.Label(); + + this.lbl_S1_Weight = new System.Windows.Forms.Label(); + + this.lbl_S1_PalletVal = new System.Windows.Forms.Label(); + + this.lbl_S1_PalletLabel = new System.Windows.Forms.Label(); + + this.lbl_S1_OrderVal = new System.Windows.Forms.Label(); + + this.lbl_S1_OrderLabel = new System.Windows.Forms.Label(); + + this.lbl_S1_ModelVal = new System.Windows.Forms.Label(); + + this.lbl_S1_ModelLabel = new System.Windows.Forms.Label(); + + this.lbl_S1_EngineVal = new System.Windows.Forms.Label(); + + this.lbl_S1_EngineLabel = new System.Windows.Forms.Label(); + + this.pnl_S1_Header = new System.Windows.Forms.Panel(); + + this.lbl_S1_Title = new System.Windows.Forms.Label(); + + this.pnl_Log = new System.Windows.Forms.Panel(); + + this.txt_Log = new System.Windows.Forms.TextBox(); + + this.lbl_LogTitle = new System.Windows.Forms.Label(); + + this.label1 = new System.Windows.Forms.Label(); + + this.pnl_Stations.SuspendLayout(); + + this.pnl_Station2.SuspendLayout(); + + this.pnl_S2_WaterBox.SuspendLayout(); + + this.pnl_S2_MetricBox.SuspendLayout(); + + this.pnl_S2_WeightBox.SuspendLayout(); + + this.pnl_S2_Header.SuspendLayout(); + + this.pnl_Station1.SuspendLayout(); + + this.pnl_S1_MetricBox.SuspendLayout(); + + this.pnl_S1_WeightBox.SuspendLayout(); + + this.pnl_S1_Header.SuspendLayout(); + + this.pnl_Log.SuspendLayout(); + + this.SuspendLayout(); + + // + + // pnl_Stations + + // + + this.pnl_Stations.Controls.Add(this.pnl_Station2); + + this.pnl_Stations.Controls.Add(this.pnl_Station1); + + this.pnl_Stations.Dock = System.Windows.Forms.DockStyle.Fill; + + this.pnl_Stations.Location = new System.Drawing.Point(0, 0); + + this.pnl_Stations.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + + this.pnl_Stations.Name = "pnl_Stations"; + + this.pnl_Stations.Padding = new System.Windows.Forms.Padding(18, 18, 18, 18); + + this.pnl_Stations.Size = new System.Drawing.Size(2730, 975); + + this.pnl_Stations.TabIndex = 0; + + // + + // pnl_Station2 + + // + + this.pnl_Station2.BackColor = System.Drawing.Color.White; + + this.pnl_Station2.Controls.Add(this.lbl_S2_AlarmVal); + + this.pnl_Station2.Controls.Add(this.lbl_S2_AlarmLabel); + + this.pnl_Station2.Controls.Add(this.lbl_S2_Info2); + + this.pnl_Station2.Controls.Add(this.lbl_S2_Info1); + + this.pnl_Station2.Controls.Add(this.pnl_S2_WaterBox); + + this.pnl_Station2.Controls.Add(this.pnl_S2_MetricBox); + + this.pnl_Station2.Controls.Add(this.pnl_S2_WeightBox); + + this.pnl_Station2.Controls.Add(this.lbl_S2_PalletVal); + + this.pnl_Station2.Controls.Add(this.lbl_S2_PalletLabel); + + this.pnl_Station2.Controls.Add(this.lbl_S2_OrderVal); + + this.pnl_Station2.Controls.Add(this.lbl_S2_OrderLabel); + + this.pnl_Station2.Controls.Add(this.lbl_S2_ModelVal); + + this.pnl_Station2.Controls.Add(this.lbl_S2_ModelLabel); + + this.pnl_Station2.Controls.Add(this.lbl_S2_EngineVal); + + this.pnl_Station2.Controls.Add(this.lbl_S2_EngineLabel); + + this.pnl_Station2.Controls.Add(this.pnl_S2_Header); + + this.pnl_Station2.Dock = System.Windows.Forms.DockStyle.Fill; + + this.pnl_Station2.Location = new System.Drawing.Point(1323, 18); + + this.pnl_Station2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + + this.pnl_Station2.Name = "pnl_Station2"; + + this.pnl_Station2.Size = new System.Drawing.Size(1389, 939); + + this.pnl_Station2.TabIndex = 0; + + // + + // lbl_S2_AlarmVal + + // + + this.lbl_S2_AlarmVal.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_AlarmVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S2_AlarmVal.Location = new System.Drawing.Point(132, 504); + + this.lbl_S2_AlarmVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_AlarmVal.Name = "lbl_S2_AlarmVal"; + + this.lbl_S2_AlarmVal.Size = new System.Drawing.Size(600, 36); + + this.lbl_S2_AlarmVal.TabIndex = 0; + + this.lbl_S2_AlarmVal.Text = "无报警"; + + // + + // lbl_S2_AlarmLabel + + // + + this.lbl_S2_AlarmLabel.Font = new System.Drawing.Font("微软雅黑", 10.5F); + + this.lbl_S2_AlarmLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S2_AlarmLabel.Location = new System.Drawing.Point(30, 504); + + this.lbl_S2_AlarmLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_AlarmLabel.Name = "lbl_S2_AlarmLabel"; + + this.lbl_S2_AlarmLabel.Size = new System.Drawing.Size(98, 36); + + this.lbl_S2_AlarmLabel.TabIndex = 1; + + this.lbl_S2_AlarmLabel.Text = "报警:"; + + // + + // lbl_S2_Info2 + + // + + this.lbl_S2_Info2.AutoSize = true; + + this.lbl_S2_Info2.Font = new System.Drawing.Font("微软雅黑", 10.5F); + + this.lbl_S2_Info2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + + this.lbl_S2_Info2.Location = new System.Drawing.Point(390, 462); + + this.lbl_S2_Info2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_Info2.Name = "lbl_S2_Info2"; + + this.lbl_S2_Info2.Size = new System.Drawing.Size(119, 28); + + this.lbl_S2_Info2.TabIndex = 2; + + this.lbl_S2_Info2.Text = "加油量:—"; + + // + + // lbl_S2_Info1 + + // + + this.lbl_S2_Info1.AutoSize = true; + + this.lbl_S2_Info1.Font = new System.Drawing.Font("微软雅黑", 10.5F); + + this.lbl_S2_Info1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + + this.lbl_S2_Info1.Location = new System.Drawing.Point(30, 462); + + this.lbl_S2_Info1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_Info1.Name = "lbl_S2_Info1"; + + this.lbl_S2_Info1.Size = new System.Drawing.Size(119, 28); + + this.lbl_S2_Info1.TabIndex = 3; + + this.lbl_S2_Info1.Text = "水含量:—"; + + // + + // pnl_S2_WaterBox + + // + this.pnl_S2_WaterBox.BackColor = System.Drawing.Color.White; + this.pnl_S2_WaterBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnl_S2_WaterBox.Controls.Add(this.lbl_S2_WaterTitle); + this.pnl_S2_WaterBox.Controls.Add(this.lbl_S2_Info1); + this.pnl_S2_WaterBox.Controls.Add(this.lbl_S2_WaterUnit); + this.pnl_S2_WaterBox.Location = new System.Drawing.Point(390, 330); + this.pnl_S2_WaterBox.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.pnl_S2_WaterBox.Name = "pnl_S2_WaterBox"; + this.pnl_S2_WaterBox.Size = new System.Drawing.Size(389, 119); + this.pnl_S2_WaterBox.TabIndex = 4; + + // + + // lbl_S2_WaterTitle + + // + this.lbl_S2_WaterTitle.AutoSize = true; + this.lbl_S2_WaterTitle.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Bold); + this.lbl_S2_WaterTitle.Location = new System.Drawing.Point(15, 9); + this.lbl_S2_WaterTitle.Name = "lbl_S2_WaterTitle"; + this.lbl_S2_WaterTitle.Size = new System.Drawing.Size(100, 19); + this.lbl_S2_WaterTitle.TabIndex = 0; + this.lbl_S2_WaterTitle.Text = "水含量"; + + // + + // lbl_S2_WaterUnit + + // + this.lbl_S2_WaterUnit.AutoSize = true; + this.lbl_S2_WaterUnit.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold); + this.lbl_S2_WaterUnit.Location = new System.Drawing.Point(346, 82); + this.lbl_S2_WaterUnit.Name = "lbl_S2_WaterUnit"; + this.lbl_S2_WaterUnit.Size = new System.Drawing.Size(18, 19); + this.lbl_S2_WaterUnit.TabIndex = 1; + this.lbl_S2_WaterUnit.Text = "%"; + + // + + // pnl_S2_MetricBox + + // + this.pnl_S2_MetricBox.BackColor = System.Drawing.Color.White; + this.pnl_S2_MetricBox.Controls.Add(this.pnl_S2_DensityBox); + this.pnl_S2_MetricBox.Controls.Add(this.pnl_S2_AddOilBox); + this.pnl_S2_MetricBox.Controls.Add(this.pnl_S2_ExtractOilBox); + this.pnl_S2_MetricBox.Controls.Add(this.pnl_S2_OilReleaseBox); + this.pnl_S2_MetricBox.Controls.Add(this.pnl_S2_ResidualOilBox); + this.pnl_S2_MetricBox.Controls.Add(this.pnl_S2_QualityBox); + this.pnl_S2_MetricBox.Location = new System.Drawing.Point(30, 470); + this.pnl_S2_MetricBox.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.pnl_S2_MetricBox.Name = "pnl_S2_MetricBox"; + this.pnl_S2_MetricBox.Size = new System.Drawing.Size(1230, 150); + this.pnl_S2_MetricBox.TabIndex = 3; + + this.pnl_S2_DensityBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnl_S2_DensityBox.Controls.Add(this.lbl_S2_DensityTitle); + this.pnl_S2_DensityBox.Controls.Add(this.lbl_S2_DensityVal); + this.pnl_S2_DensityBox.Controls.Add(this.lbl_S2_DensityUnit); + this.pnl_S2_DensityBox.Location = new System.Drawing.Point(0, 0); + this.pnl_S2_DensityBox.Name = "pnl_S2_DensityBox"; + this.pnl_S2_DensityBox.Size = new System.Drawing.Size(389, 72); + this.lbl_S2_DensityTitle.Location = new System.Drawing.Point(15, 7); + this.lbl_S2_DensityTitle.Name = "lbl_S2_DensityTitle"; + this.lbl_S2_DensityTitle.Size = new System.Drawing.Size(120, 22); + this.lbl_S2_DensityTitle.Text = "油密度"; + this.lbl_S2_DensityVal.Location = new System.Drawing.Point(40, 22); + this.lbl_S2_DensityVal.Name = "lbl_S2_DensityVal"; + this.lbl_S2_DensityVal.Size = new System.Drawing.Size(260, 42); + this.lbl_S2_DensityVal.Text = "0.00"; + this.lbl_S2_DensityVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_S2_DensityUnit.Location = new System.Drawing.Point(320, 44); + this.lbl_S2_DensityUnit.Name = "lbl_S2_DensityUnit"; + this.lbl_S2_DensityUnit.Size = new System.Drawing.Size(60, 22); + this.lbl_S2_DensityUnit.Text = "KG/L"; + + this.pnl_S2_AddOilBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnl_S2_AddOilBox.Controls.Add(this.lbl_S2_AddOilTitle); + this.pnl_S2_AddOilBox.Controls.Add(this.lbl_S2_Info2); + this.pnl_S2_AddOilBox.Controls.Add(this.lbl_S2_AddOilUnit); + this.pnl_S2_AddOilBox.Location = new System.Drawing.Point(420, 0); + this.pnl_S2_AddOilBox.Name = "pnl_S2_AddOilBox"; + this.pnl_S2_AddOilBox.Size = new System.Drawing.Size(389, 72); + this.lbl_S2_AddOilTitle.Location = new System.Drawing.Point(15, 7); + this.lbl_S2_AddOilTitle.Name = "lbl_S2_AddOilTitle"; + this.lbl_S2_AddOilTitle.Size = new System.Drawing.Size(120, 22); + this.lbl_S2_AddOilTitle.Text = "加油量"; + this.lbl_S2_Info2.Location = new System.Drawing.Point(40, 22); + this.lbl_S2_Info2.Size = new System.Drawing.Size(260, 42); + this.lbl_S2_Info2.Text = "0.00"; + this.lbl_S2_Info2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_S2_AddOilUnit.Location = new System.Drawing.Point(342, 44); + this.lbl_S2_AddOilUnit.Name = "lbl_S2_AddOilUnit"; + this.lbl_S2_AddOilUnit.Size = new System.Drawing.Size(36, 22); + this.lbl_S2_AddOilUnit.Text = "L"; + + this.pnl_S2_ExtractOilBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnl_S2_ExtractOilBox.Controls.Add(this.lbl_S2_ExtractOilTitle); + this.pnl_S2_ExtractOilBox.Controls.Add(this.lbl_S2_ExtractOilVal); + this.pnl_S2_ExtractOilBox.Controls.Add(this.lbl_S2_ExtractOilUnit); + this.pnl_S2_ExtractOilBox.Location = new System.Drawing.Point(840, 0); + this.pnl_S2_ExtractOilBox.Name = "pnl_S2_ExtractOilBox"; + this.pnl_S2_ExtractOilBox.Size = new System.Drawing.Size(389, 72); + this.lbl_S2_ExtractOilTitle.Location = new System.Drawing.Point(15, 7); + this.lbl_S2_ExtractOilTitle.Name = "lbl_S2_ExtractOilTitle"; + this.lbl_S2_ExtractOilTitle.Size = new System.Drawing.Size(120, 22); + this.lbl_S2_ExtractOilTitle.Text = "抽油量"; + this.lbl_S2_ExtractOilVal.Location = new System.Drawing.Point(40, 22); + this.lbl_S2_ExtractOilVal.Name = "lbl_S2_ExtractOilVal"; + this.lbl_S2_ExtractOilVal.Size = new System.Drawing.Size(260, 42); + this.lbl_S2_ExtractOilVal.Text = "0.00"; + this.lbl_S2_ExtractOilVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_S2_ExtractOilUnit.Location = new System.Drawing.Point(342, 44); + this.lbl_S2_ExtractOilUnit.Name = "lbl_S2_ExtractOilUnit"; + this.lbl_S2_ExtractOilUnit.Size = new System.Drawing.Size(36, 22); + this.lbl_S2_ExtractOilUnit.Text = "L"; + + this.pnl_S2_OilReleaseBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnl_S2_OilReleaseBox.Controls.Add(this.lbl_S2_OilReleaseTitle); + this.pnl_S2_OilReleaseBox.Controls.Add(this.lbl_S2_OilReleaseVal); + this.pnl_S2_OilReleaseBox.Controls.Add(this.lbl_S2_OilReleaseUnit); + this.pnl_S2_OilReleaseBox.Location = new System.Drawing.Point(0, 78); + this.pnl_S2_OilReleaseBox.Name = "pnl_S2_OilReleaseBox"; + this.pnl_S2_OilReleaseBox.Size = new System.Drawing.Size(389, 72); + this.lbl_S2_OilReleaseTitle.Location = new System.Drawing.Point(15, 7); + this.lbl_S2_OilReleaseTitle.Name = "lbl_S2_OilReleaseTitle"; + this.lbl_S2_OilReleaseTitle.Size = new System.Drawing.Size(120, 22); + this.lbl_S2_OilReleaseTitle.Text = "放油量"; + this.lbl_S2_OilReleaseVal.Location = new System.Drawing.Point(40, 22); + this.lbl_S2_OilReleaseVal.Name = "lbl_S2_OilReleaseVal"; + this.lbl_S2_OilReleaseVal.Size = new System.Drawing.Size(260, 42); + this.lbl_S2_OilReleaseVal.Text = "0.00"; + this.lbl_S2_OilReleaseVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_S2_OilReleaseUnit.Location = new System.Drawing.Point(342, 44); + this.lbl_S2_OilReleaseUnit.Name = "lbl_S2_OilReleaseUnit"; + this.lbl_S2_OilReleaseUnit.Size = new System.Drawing.Size(36, 22); + this.lbl_S2_OilReleaseUnit.Text = "L"; + + this.pnl_S2_ResidualOilBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnl_S2_ResidualOilBox.Controls.Add(this.lbl_S2_ResidualOilTitle); + this.pnl_S2_ResidualOilBox.Controls.Add(this.lbl_S2_ResidualOilVal); + this.pnl_S2_ResidualOilBox.Controls.Add(this.lbl_S2_ResidualOilUnit); + this.pnl_S2_ResidualOilBox.Location = new System.Drawing.Point(420, 78); + this.pnl_S2_ResidualOilBox.Name = "pnl_S2_ResidualOilBox"; + this.pnl_S2_ResidualOilBox.Size = new System.Drawing.Size(389, 72); + this.lbl_S2_ResidualOilTitle.Location = new System.Drawing.Point(15, 7); + this.lbl_S2_ResidualOilTitle.Name = "lbl_S2_ResidualOilTitle"; + this.lbl_S2_ResidualOilTitle.Size = new System.Drawing.Size(120, 22); + this.lbl_S2_ResidualOilTitle.Text = "残油量"; + this.lbl_S2_ResidualOilVal.Location = new System.Drawing.Point(40, 22); + this.lbl_S2_ResidualOilVal.Name = "lbl_S2_ResidualOilVal"; + this.lbl_S2_ResidualOilVal.Size = new System.Drawing.Size(260, 42); + this.lbl_S2_ResidualOilVal.Text = "0.00"; + this.lbl_S2_ResidualOilVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lbl_S2_ResidualOilUnit.Location = new System.Drawing.Point(342, 44); + this.lbl_S2_ResidualOilUnit.Name = "lbl_S2_ResidualOilUnit"; + this.lbl_S2_ResidualOilUnit.Size = new System.Drawing.Size(36, 22); + this.lbl_S2_ResidualOilUnit.Text = "L"; + + this.pnl_S2_QualityBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnl_S2_QualityBox.Controls.Add(this.lbl_S2_QualityTitle); + this.pnl_S2_QualityBox.Controls.Add(this.lbl_S2_QualityVal); + this.pnl_S2_QualityBox.Location = new System.Drawing.Point(840, 78); + this.pnl_S2_QualityBox.Name = "pnl_S2_QualityBox"; + this.pnl_S2_QualityBox.Size = new System.Drawing.Size(389, 72); + this.lbl_S2_QualityTitle.Location = new System.Drawing.Point(15, 7); + this.lbl_S2_QualityTitle.Name = "lbl_S2_QualityTitle"; + this.lbl_S2_QualityTitle.Size = new System.Drawing.Size(120, 22); + this.lbl_S2_QualityTitle.Text = "合格结果"; + this.lbl_S2_QualityVal.Location = new System.Drawing.Point(40, 22); + this.lbl_S2_QualityVal.Name = "lbl_S2_QualityVal"; + this.lbl_S2_QualityVal.Size = new System.Drawing.Size(260, 42); + this.lbl_S2_QualityVal.Text = "--"; + this.lbl_S2_QualityVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + // pnl_S2_WeightBox + + // + + this.pnl_S2_WeightBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + + this.pnl_S2_WeightBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + this.pnl_S2_WeightBox.Controls.Add(this.lbl_S2_WeightTitle); + + this.pnl_S2_WeightBox.Controls.Add(this.lbl_S2_WeightUnit); + + this.pnl_S2_WeightBox.Controls.Add(this.lbl_S2_Weight); + + this.pnl_S2_WeightBox.Location = new System.Drawing.Point(30, 330); + + this.pnl_S2_WeightBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + + this.pnl_S2_WeightBox.Name = "pnl_S2_WeightBox"; + + this.pnl_S2_WeightBox.Size = new System.Drawing.Size(539, 119); + + this.pnl_S2_WeightBox.TabIndex = 4; + + // + + // lbl_S2_WeightUnit + + // + + this.lbl_S2_WeightUnit.Font = new System.Drawing.Font("微软雅黑", 16F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_WeightUnit.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S2_WeightUnit.Location = new System.Drawing.Point(417, 36); + + this.lbl_S2_WeightUnit.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_WeightUnit.Name = "lbl_S2_WeightUnit"; + + this.lbl_S2_WeightUnit.Size = new System.Drawing.Size(90, 72); + + this.lbl_S2_WeightUnit.TabIndex = 0; + + this.lbl_S2_WeightUnit.Text = "KG"; + + this.lbl_S2_WeightUnit.TextAlign = System.Drawing.ContentAlignment.BottomLeft; + + // + + // lbl_S2_Weight + + // + + this.lbl_S2_Weight.Font = new System.Drawing.Font("Consolas", 42F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_Weight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + + this.lbl_S2_Weight.Location = new System.Drawing.Point(6, 6); + + this.lbl_S2_Weight.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_Weight.Name = "lbl_S2_Weight"; + + this.lbl_S2_Weight.Size = new System.Drawing.Size(405, 108); + + this.lbl_S2_Weight.TabIndex = 1; + + this.lbl_S2_Weight.Text = "0.00"; + + this.lbl_S2_Weight.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + + // + + // lbl_S2_PalletVal + + // + + this.lbl_S2_PalletVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_PalletVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + + this.lbl_S2_PalletVal.Location = new System.Drawing.Point(780, 132); + + this.lbl_S2_PalletVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_PalletVal.Name = "lbl_S2_PalletVal"; + + this.lbl_S2_PalletVal.Size = new System.Drawing.Size(450, 45); + + this.lbl_S2_PalletVal.TabIndex = 5; + + this.lbl_S2_PalletVal.Text = "—"; + + // + + // lbl_S2_PalletLabel + + // + + this.lbl_S2_PalletLabel.Font = new System.Drawing.Font("微软雅黑", 12.5F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_PalletLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S2_PalletLabel.Location = new System.Drawing.Point(645, 132); + + this.lbl_S2_PalletLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_PalletLabel.Name = "lbl_S2_PalletLabel"; + + this.lbl_S2_PalletLabel.Size = new System.Drawing.Size(128, 45); + + this.lbl_S2_PalletLabel.TabIndex = 6; + + this.lbl_S2_PalletLabel.Text = "托盘号:"; + + // + + // lbl_S2_OrderVal + + // + + this.lbl_S2_OrderVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_OrderVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + + this.lbl_S2_OrderVal.Location = new System.Drawing.Point(177, 132); + + this.lbl_S2_OrderVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_OrderVal.Name = "lbl_S2_OrderVal"; + + this.lbl_S2_OrderVal.Size = new System.Drawing.Size(420, 45); + + this.lbl_S2_OrderVal.TabIndex = 7; + + this.lbl_S2_OrderVal.Text = "—"; + + // + + // lbl_S2_OrderLabel + + // + + this.lbl_S2_OrderLabel.Font = new System.Drawing.Font("微软雅黑", 12.5F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_OrderLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S2_OrderLabel.Location = new System.Drawing.Point(30, 132); + + this.lbl_S2_OrderLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_OrderLabel.Name = "lbl_S2_OrderLabel"; + + this.lbl_S2_OrderLabel.Size = new System.Drawing.Size(128, 45); + + this.lbl_S2_OrderLabel.TabIndex = 8; + + this.lbl_S2_OrderLabel.Text = "订单号:"; + + // + + // lbl_S2_ModelVal + + // + + this.lbl_S2_ModelVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_ModelVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + + this.lbl_S2_ModelVal.Location = new System.Drawing.Point(780, 81); + + this.lbl_S2_ModelVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_ModelVal.Name = "lbl_S2_ModelVal"; + + this.lbl_S2_ModelVal.Size = new System.Drawing.Size(450, 45); + + this.lbl_S2_ModelVal.TabIndex = 9; + + this.lbl_S2_ModelVal.Text = "—"; + + // + + // lbl_S2_ModelLabel + + // + + this.lbl_S2_ModelLabel.Font = new System.Drawing.Font("微软雅黑", 12.5F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_ModelLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S2_ModelLabel.Location = new System.Drawing.Point(645, 81); + + this.lbl_S2_ModelLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_ModelLabel.Name = "lbl_S2_ModelLabel"; + + this.lbl_S2_ModelLabel.Size = new System.Drawing.Size(128, 45); + + this.lbl_S2_ModelLabel.TabIndex = 10; + + this.lbl_S2_ModelLabel.Text = "机型号:"; + + // + + // lbl_S2_EngineVal + + // + + this.lbl_S2_EngineVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_EngineVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + + this.lbl_S2_EngineVal.Location = new System.Drawing.Point(177, 81); + + this.lbl_S2_EngineVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_EngineVal.Name = "lbl_S2_EngineVal"; + + this.lbl_S2_EngineVal.Size = new System.Drawing.Size(420, 45); + + this.lbl_S2_EngineVal.TabIndex = 11; + + this.lbl_S2_EngineVal.Text = "—"; + + // + + // lbl_S2_EngineLabel + + // + + this.lbl_S2_EngineLabel.Font = new System.Drawing.Font("微软雅黑", 12.5F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_EngineLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S2_EngineLabel.Location = new System.Drawing.Point(30, 81); + + this.lbl_S2_EngineLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_EngineLabel.Name = "lbl_S2_EngineLabel"; + + this.lbl_S2_EngineLabel.Size = new System.Drawing.Size(142, 45); + + this.lbl_S2_EngineLabel.TabIndex = 12; + + this.lbl_S2_EngineLabel.Text = "发动机号:"; + + // + + // pnl_S2_Header + + // + + this.pnl_S2_Header.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(148)))), ((int)(((byte)(136))))); + + this.pnl_S2_Header.Controls.Add(this.lbl_S2_Title); + + this.pnl_S2_Header.Dock = System.Windows.Forms.DockStyle.Top; + + this.pnl_S2_Header.Location = new System.Drawing.Point(0, 0); + + this.pnl_S2_Header.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + + this.pnl_S2_Header.Name = "pnl_S2_Header"; + + this.pnl_S2_Header.Size = new System.Drawing.Size(1389, 63); + + this.pnl_S2_Header.TabIndex = 13; + + // + + // lbl_S2_Title + + // + + this.lbl_S2_Title.Dock = System.Windows.Forms.DockStyle.Fill; + + this.lbl_S2_Title.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Bold); + + this.lbl_S2_Title.ForeColor = System.Drawing.Color.White; + + this.lbl_S2_Title.Location = new System.Drawing.Point(0, 0); + + this.lbl_S2_Title.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S2_Title.Name = "lbl_S2_Title"; + + this.lbl_S2_Title.Padding = new System.Windows.Forms.Padding(24, 0, 0, 0); + + this.lbl_S2_Title.Size = new System.Drawing.Size(1389, 63); + + this.lbl_S2_Title.TabIndex = 0; + + this.lbl_S2_Title.Text = "工位2 — 放油后称重"; + + this.lbl_S2_Title.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + + // + + // pnl_Station1 + + // + + this.pnl_Station1.BackColor = System.Drawing.Color.White; + + this.pnl_Station1.Controls.Add(this.lbl_S1_AlarmVal); + + this.pnl_Station1.Controls.Add(this.lbl_S1_AlarmLabel); + + this.pnl_Station1.Controls.Add(this.lbl_S1_Info1); + + this.pnl_Station1.Controls.Add(this.pnl_S1_MetricBox); + + this.pnl_Station1.Controls.Add(this.pnl_S1_WeightBox); + + this.pnl_Station1.Controls.Add(this.lbl_S1_PalletVal); + + this.pnl_Station1.Controls.Add(this.lbl_S1_PalletLabel); + + this.pnl_Station1.Controls.Add(this.lbl_S1_OrderVal); + + this.pnl_Station1.Controls.Add(this.lbl_S1_OrderLabel); + + this.pnl_Station1.Controls.Add(this.lbl_S1_ModelVal); + + this.pnl_Station1.Controls.Add(this.lbl_S1_ModelLabel); + + this.pnl_Station1.Controls.Add(this.lbl_S1_EngineVal); + + this.pnl_Station1.Controls.Add(this.lbl_S1_EngineLabel); + + this.pnl_Station1.Controls.Add(this.pnl_S1_Header); + + this.pnl_Station1.Dock = System.Windows.Forms.DockStyle.Left; + + this.pnl_Station1.Location = new System.Drawing.Point(18, 18); + + this.pnl_Station1.Margin = new System.Windows.Forms.Padding(0, 0, 18, 0); + + this.pnl_Station1.Name = "pnl_Station1"; + + this.pnl_Station1.Size = new System.Drawing.Size(1305, 939); + + this.pnl_Station1.TabIndex = 1; + + // + + // lbl_S1_AlarmVal + + // + + this.lbl_S1_AlarmVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_AlarmVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S1_AlarmVal.Location = new System.Drawing.Point(180, 768); + + this.lbl_S1_AlarmVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_AlarmVal.Name = "lbl_S1_AlarmVal"; + + this.lbl_S1_AlarmVal.Size = new System.Drawing.Size(1080, 42); + + this.lbl_S1_AlarmVal.TabIndex = 0; + + this.lbl_S1_AlarmVal.Text = "无报警"; + + // + + // lbl_S1_AlarmLabel + + // + + this.lbl_S1_AlarmLabel.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_AlarmLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S1_AlarmLabel.Location = new System.Drawing.Point(30, 768); + + this.lbl_S1_AlarmLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_AlarmLabel.Name = "lbl_S1_AlarmLabel"; + + this.lbl_S1_AlarmLabel.Size = new System.Drawing.Size(112, 42); + + this.lbl_S1_AlarmLabel.TabIndex = 1; + + this.lbl_S1_AlarmLabel.Text = "报警:"; + + // + + // lbl_S1_Info1 + + // + + this.lbl_S1_Info1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + + this.lbl_S1_Info1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + this.lbl_S1_Info1.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_Info1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + + this.lbl_S1_Info1.Location = new System.Drawing.Point(660, 375); + + this.lbl_S1_Info1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_Info1.Name = "lbl_S1_Info1"; + + this.lbl_S1_Info1.Size = new System.Drawing.Size(599, 164); + + this.lbl_S1_Info1.TabIndex = 2; + + this.lbl_S1_Info1.Text = "水含量:0.00"; + + this.lbl_S1_Info1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + // + + // pnl_S1_MetricBox + + // + + this.pnl_S1_MetricBox.BackColor = System.Drawing.Color.White; + + this.pnl_S1_MetricBox.Controls.Add(this.lbl_S1_QualityVal); + + this.pnl_S1_MetricBox.Controls.Add(this.lbl_S1_ResidualOilVal); + + this.pnl_S1_MetricBox.Controls.Add(this.lbl_S1_OilReleaseVal); + + this.pnl_S1_MetricBox.Controls.Add(this.lbl_S1_DensityVal); + + this.pnl_S1_MetricBox.Controls.Add(this.lbl_S1_ExtractOilVal); + + this.pnl_S1_MetricBox.Controls.Add(this.lbl_S1_Info2); + + this.pnl_S1_MetricBox.Location = new System.Drawing.Point(30, 570); + + this.pnl_S1_MetricBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + + this.pnl_S1_MetricBox.Name = "pnl_S1_MetricBox"; + + this.pnl_S1_MetricBox.Size = new System.Drawing.Size(1230, 174); + + this.pnl_S1_MetricBox.TabIndex = 3; + + // + + // lbl_S1_QualityVal + + // + + this.lbl_S1_QualityVal.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + + this.lbl_S1_QualityVal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + this.lbl_S1_QualityVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_QualityVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + + this.lbl_S1_QualityVal.Location = new System.Drawing.Point(840, 93); + + this.lbl_S1_QualityVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_QualityVal.Name = "lbl_S1_QualityVal"; + + this.lbl_S1_QualityVal.Size = new System.Drawing.Size(389, 80); + + this.lbl_S1_QualityVal.TabIndex = 0; + + this.lbl_S1_QualityVal.Text = "合格结果:--"; + + this.lbl_S1_QualityVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + // + + // lbl_S1_ResidualOilVal + + // + + this.lbl_S1_ResidualOilVal.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + + this.lbl_S1_ResidualOilVal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + this.lbl_S1_ResidualOilVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_ResidualOilVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + + this.lbl_S1_ResidualOilVal.Location = new System.Drawing.Point(420, 93); + + this.lbl_S1_ResidualOilVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_ResidualOilVal.Name = "lbl_S1_ResidualOilVal"; + + this.lbl_S1_ResidualOilVal.Size = new System.Drawing.Size(389, 80); + + this.lbl_S1_ResidualOilVal.TabIndex = 1; + + this.lbl_S1_ResidualOilVal.Text = "残油量:0.00"; + + this.lbl_S1_ResidualOilVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + // + + // lbl_S1_OilReleaseVal + + // + + this.lbl_S1_OilReleaseVal.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + + this.lbl_S1_OilReleaseVal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + this.lbl_S1_OilReleaseVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_OilReleaseVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + + this.lbl_S1_OilReleaseVal.Location = new System.Drawing.Point(0, 93); + + this.lbl_S1_OilReleaseVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_OilReleaseVal.Name = "lbl_S1_OilReleaseVal"; + + this.lbl_S1_OilReleaseVal.Size = new System.Drawing.Size(389, 80); + + this.lbl_S1_OilReleaseVal.TabIndex = 2; + + this.lbl_S1_OilReleaseVal.Text = "放油量:0.00"; + + this.lbl_S1_OilReleaseVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + // + + // lbl_S1_DensityVal + + // + + this.lbl_S1_DensityVal.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + + this.lbl_S1_DensityVal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + this.lbl_S1_DensityVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_DensityVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + + this.lbl_S1_DensityVal.Location = new System.Drawing.Point(0, 0); + + this.lbl_S1_DensityVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_DensityVal.Name = "lbl_S1_DensityVal"; + + this.lbl_S1_DensityVal.Size = new System.Drawing.Size(389, 80); + + this.lbl_S1_DensityVal.TabIndex = 3; + + this.lbl_S1_DensityVal.Text = "油密度:0.00"; + + this.lbl_S1_DensityVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + // + + // lbl_S1_ExtractOilVal + + // + + this.lbl_S1_ExtractOilVal.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + + this.lbl_S1_ExtractOilVal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + this.lbl_S1_ExtractOilVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_ExtractOilVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + + this.lbl_S1_ExtractOilVal.Location = new System.Drawing.Point(840, 0); + + this.lbl_S1_ExtractOilVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_ExtractOilVal.Name = "lbl_S1_ExtractOilVal"; + + this.lbl_S1_ExtractOilVal.Size = new System.Drawing.Size(389, 80); + + this.lbl_S1_ExtractOilVal.TabIndex = 4; + + this.lbl_S1_ExtractOilVal.Text = "抽油量:0.00"; + + this.lbl_S1_ExtractOilVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + // + + // lbl_S1_Info2 + + // + + this.lbl_S1_Info2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + + this.lbl_S1_Info2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + this.lbl_S1_Info2.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_Info2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + + this.lbl_S1_Info2.Location = new System.Drawing.Point(420, 0); + + this.lbl_S1_Info2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_Info2.Name = "lbl_S1_Info2"; + + this.lbl_S1_Info2.Size = new System.Drawing.Size(389, 80); + + this.lbl_S1_Info2.TabIndex = 5; + + this.lbl_S1_Info2.Text = "加油量:0.00"; + + this.lbl_S1_Info2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + // + + // pnl_S1_WeightBox + + // + + this.pnl_S1_WeightBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + + this.pnl_S1_WeightBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + + this.pnl_S1_WeightBox.Controls.Add(this.label1); + + this.pnl_S1_WeightBox.Controls.Add(this.lbl_S1_WeightUnit); + + this.pnl_S1_WeightBox.Controls.Add(this.lbl_S1_Weight); + + this.pnl_S1_WeightBox.Location = new System.Drawing.Point(30, 375); + + this.pnl_S1_WeightBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + + this.pnl_S1_WeightBox.Name = "pnl_S1_WeightBox"; + + this.pnl_S1_WeightBox.Size = new System.Drawing.Size(599, 164); + + this.pnl_S1_WeightBox.TabIndex = 4; + + // + + // lbl_S1_WeightUnit + + // + + this.lbl_S1_WeightUnit.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_WeightUnit.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S1_WeightUnit.Location = new System.Drawing.Point(456, 60); + + this.lbl_S1_WeightUnit.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_WeightUnit.Name = "lbl_S1_WeightUnit"; + + this.lbl_S1_WeightUnit.Size = new System.Drawing.Size(135, 87); + + this.lbl_S1_WeightUnit.TabIndex = 0; + + this.lbl_S1_WeightUnit.Text = "KG"; + + this.lbl_S1_WeightUnit.TextAlign = System.Drawing.ContentAlignment.BottomLeft; + + // + + // lbl_S1_Weight + + // + + this.lbl_S1_Weight.Font = new System.Drawing.Font("Consolas", 54F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_Weight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + + this.lbl_S1_Weight.Location = new System.Drawing.Point(114, 9); + + this.lbl_S1_Weight.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_Weight.Name = "lbl_S1_Weight"; + + this.lbl_S1_Weight.Size = new System.Drawing.Size(327, 144); + + this.lbl_S1_Weight.TabIndex = 1; + + this.lbl_S1_Weight.Text = "0.00"; + + this.lbl_S1_Weight.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + + // + + // lbl_S1_PalletVal + + // + + this.lbl_S1_PalletVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_PalletVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + + this.lbl_S1_PalletVal.Location = new System.Drawing.Point(780, 132); + + this.lbl_S1_PalletVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_PalletVal.Name = "lbl_S1_PalletVal"; + + this.lbl_S1_PalletVal.Size = new System.Drawing.Size(450, 45); + + this.lbl_S1_PalletVal.TabIndex = 5; + + this.lbl_S1_PalletVal.Text = "—"; + + // + + // lbl_S1_PalletLabel + + // + + this.lbl_S1_PalletLabel.Font = new System.Drawing.Font("微软雅黑", 12.5F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_PalletLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S1_PalletLabel.Location = new System.Drawing.Point(645, 132); + + this.lbl_S1_PalletLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_PalletLabel.Name = "lbl_S1_PalletLabel"; + + this.lbl_S1_PalletLabel.Size = new System.Drawing.Size(128, 45); + + this.lbl_S1_PalletLabel.TabIndex = 6; + + this.lbl_S1_PalletLabel.Text = "托盘号:"; + + // + + // lbl_S1_OrderVal + + // + + this.lbl_S1_OrderVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_OrderVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + + this.lbl_S1_OrderVal.Location = new System.Drawing.Point(177, 132); + + this.lbl_S1_OrderVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_OrderVal.Name = "lbl_S1_OrderVal"; + + this.lbl_S1_OrderVal.Size = new System.Drawing.Size(420, 45); + + this.lbl_S1_OrderVal.TabIndex = 7; + + this.lbl_S1_OrderVal.Text = "—"; + + // + + // lbl_S1_OrderLabel + + // + + this.lbl_S1_OrderLabel.Font = new System.Drawing.Font("微软雅黑", 12.5F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_OrderLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S1_OrderLabel.Location = new System.Drawing.Point(30, 132); + + this.lbl_S1_OrderLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_OrderLabel.Name = "lbl_S1_OrderLabel"; + + this.lbl_S1_OrderLabel.Size = new System.Drawing.Size(128, 45); + + this.lbl_S1_OrderLabel.TabIndex = 8; + + this.lbl_S1_OrderLabel.Text = "订单号:"; + + // + + // lbl_S1_ModelVal + + // + + this.lbl_S1_ModelVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_ModelVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + + this.lbl_S1_ModelVal.Location = new System.Drawing.Point(780, 81); + + this.lbl_S1_ModelVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_ModelVal.Name = "lbl_S1_ModelVal"; + + this.lbl_S1_ModelVal.Size = new System.Drawing.Size(450, 45); + + this.lbl_S1_ModelVal.TabIndex = 9; + + this.lbl_S1_ModelVal.Text = "—"; + + // + + // lbl_S1_ModelLabel + + // + + this.lbl_S1_ModelLabel.Font = new System.Drawing.Font("微软雅黑", 12.5F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_ModelLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S1_ModelLabel.Location = new System.Drawing.Point(645, 81); + + this.lbl_S1_ModelLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_ModelLabel.Name = "lbl_S1_ModelLabel"; + + this.lbl_S1_ModelLabel.Size = new System.Drawing.Size(128, 45); + + this.lbl_S1_ModelLabel.TabIndex = 10; + + this.lbl_S1_ModelLabel.Text = "机型号:"; + + // + + // lbl_S1_EngineVal + + // + + this.lbl_S1_EngineVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_EngineVal.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + + this.lbl_S1_EngineVal.Location = new System.Drawing.Point(177, 81); + + this.lbl_S1_EngineVal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_EngineVal.Name = "lbl_S1_EngineVal"; + + this.lbl_S1_EngineVal.Size = new System.Drawing.Size(420, 45); + + this.lbl_S1_EngineVal.TabIndex = 11; + + this.lbl_S1_EngineVal.Text = "—"; + + // + + // lbl_S1_EngineLabel + + // + + this.lbl_S1_EngineLabel.Font = new System.Drawing.Font("微软雅黑", 12.5F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_EngineLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + + this.lbl_S1_EngineLabel.Location = new System.Drawing.Point(30, 81); + + this.lbl_S1_EngineLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_EngineLabel.Name = "lbl_S1_EngineLabel"; + + this.lbl_S1_EngineLabel.Size = new System.Drawing.Size(142, 45); + + this.lbl_S1_EngineLabel.TabIndex = 12; + + this.lbl_S1_EngineLabel.Text = "发动机号:"; + + // + + // pnl_S1_Header + + // + + this.pnl_S1_Header.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(144)))), ((int)(((byte)(217))))); + + this.pnl_S1_Header.Controls.Add(this.lbl_S1_Title); + + this.pnl_S1_Header.Dock = System.Windows.Forms.DockStyle.Top; + + this.pnl_S1_Header.Location = new System.Drawing.Point(0, 0); + + this.pnl_S1_Header.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + + this.pnl_S1_Header.Name = "pnl_S1_Header"; + + this.pnl_S1_Header.Size = new System.Drawing.Size(1305, 63); + + this.pnl_S1_Header.TabIndex = 13; + + // + + // lbl_S1_Title + + // + + this.lbl_S1_Title.Dock = System.Windows.Forms.DockStyle.Fill; + + this.lbl_S1_Title.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Bold); + + this.lbl_S1_Title.ForeColor = System.Drawing.Color.White; + + this.lbl_S1_Title.Location = new System.Drawing.Point(0, 0); + + this.lbl_S1_Title.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_S1_Title.Name = "lbl_S1_Title"; + + this.lbl_S1_Title.Padding = new System.Windows.Forms.Padding(24, 0, 0, 0); + + this.lbl_S1_Title.Size = new System.Drawing.Size(1305, 63); + + this.lbl_S1_Title.TabIndex = 0; + + this.lbl_S1_Title.Text = "工位1 — 放油前称重"; + + this.lbl_S1_Title.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + + // + + // pnl_Log + + // + + this.pnl_Log.BackColor = System.Drawing.Color.White; + + this.pnl_Log.Controls.Add(this.txt_Log); + + this.pnl_Log.Controls.Add(this.lbl_LogTitle); + + this.pnl_Log.Dock = System.Windows.Forms.DockStyle.Bottom; + + this.pnl_Log.Location = new System.Drawing.Point(0, 975); + + this.pnl_Log.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + + this.pnl_Log.Name = "pnl_Log"; + + this.pnl_Log.Padding = new System.Windows.Forms.Padding(24, 6, 24, 12); + + this.pnl_Log.Size = new System.Drawing.Size(2730, 525); + + this.pnl_Log.TabIndex = 1; + + // + + // txt_Log + + // + + this.txt_Log.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + + this.txt_Log.BorderStyle = System.Windows.Forms.BorderStyle.None; + + this.txt_Log.Dock = System.Windows.Forms.DockStyle.Fill; + + this.txt_Log.Font = new System.Drawing.Font("Consolas", 10F); + + this.txt_Log.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(65)))), ((int)(((byte)(81))))); + + this.txt_Log.Location = new System.Drawing.Point(24, 48); + + this.txt_Log.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + + this.txt_Log.Multiline = true; + + this.txt_Log.Name = "txt_Log"; + + this.txt_Log.ReadOnly = true; + + this.txt_Log.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + + this.txt_Log.Size = new System.Drawing.Size(2682, 465); + + this.txt_Log.TabIndex = 0; + + // + + // lbl_LogTitle + + // + + this.lbl_LogTitle.Dock = System.Windows.Forms.DockStyle.Top; + + this.lbl_LogTitle.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold); + + this.lbl_LogTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + + this.lbl_LogTitle.Location = new System.Drawing.Point(24, 6); + + this.lbl_LogTitle.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + + this.lbl_LogTitle.Name = "lbl_LogTitle"; + + this.lbl_LogTitle.Size = new System.Drawing.Size(2682, 42); + + this.lbl_LogTitle.TabIndex = 1; + + this.lbl_LogTitle.Text = "操作消息"; + + this.lbl_LogTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + + // + + // label1 + + // + + this.label1.AutoSize = true; + + this.label1.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); + + this.label1.Location = new System.Drawing.Point(15, 9); + + this.label1.Name = "label1"; + + this.label1.Size = new System.Drawing.Size(137, 30); + + this.label1.TabIndex = 2; + + this.label1.Text = "实时重量"; + + // + + // S2设计器预览布局:与S1保持同一套静态预览结构 + + // + + this.pnl_Station2.Controls.Remove(this.pnl_S2_WaterBox); + this.pnl_Station2.Controls.Add(this.lbl_S2_Info1); + this.pnl_Station2.Controls.Add(this.pnl_S2_MetricBox); + this.pnl_Station2.Controls.Add(this.pnl_S2_WeightBox); + this.pnl_Station2.Controls.Add(this.lbl_S2_AlarmLabel); + this.pnl_Station2.Controls.Add(this.lbl_S2_AlarmVal); + + this.pnl_S2_MetricBox.Controls.Clear(); + this.pnl_S2_MetricBox.Controls.Add(this.lbl_S2_QualityVal); + this.pnl_S2_MetricBox.Controls.Add(this.lbl_S2_ResidualOilVal); + this.pnl_S2_MetricBox.Controls.Add(this.lbl_S2_OilReleaseVal); + this.pnl_S2_MetricBox.Controls.Add(this.lbl_S2_DensityVal); + this.pnl_S2_MetricBox.Controls.Add(this.lbl_S2_ExtractOilVal); + this.pnl_S2_MetricBox.Controls.Add(this.lbl_S2_Info2); + + this.pnl_S2_WeightBox.Location = new System.Drawing.Point(30, 375); + this.pnl_S2_WeightBox.Size = new System.Drawing.Size(599, 164); + + this.lbl_S2_WeightTitle.AutoSize = true; + this.lbl_S2_WeightTitle.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold); + this.lbl_S2_WeightTitle.Location = new System.Drawing.Point(15, 9); + this.lbl_S2_WeightTitle.Size = new System.Drawing.Size(137, 30); + this.lbl_S2_WeightTitle.Text = "实时重量"; + + this.lbl_S2_Weight.Font = new System.Drawing.Font("Consolas", 54F, System.Drawing.FontStyle.Bold); + this.lbl_S2_Weight.Location = new System.Drawing.Point(114, 9); + this.lbl_S2_Weight.Size = new System.Drawing.Size(327, 144); + this.lbl_S2_Weight.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + + this.lbl_S2_WeightUnit.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Bold); + this.lbl_S2_WeightUnit.Location = new System.Drawing.Point(456, 60); + this.lbl_S2_WeightUnit.Size = new System.Drawing.Size(135, 87); + this.lbl_S2_WeightUnit.TextAlign = System.Drawing.ContentAlignment.BottomLeft; + + this.lbl_S2_Info1.AutoSize = false; + this.lbl_S2_Info1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + this.lbl_S2_Info1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lbl_S2_Info1.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Bold); + this.lbl_S2_Info1.Location = new System.Drawing.Point(660, 375); + this.lbl_S2_Info1.Size = new System.Drawing.Size(599, 164); + this.lbl_S2_Info1.Text = "水含量:0.00"; + this.lbl_S2_Info1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + this.pnl_S2_MetricBox.Location = new System.Drawing.Point(30, 570); + this.pnl_S2_MetricBox.Size = new System.Drawing.Size(1230, 174); + + this.lbl_S2_DensityVal.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + this.lbl_S2_DensityVal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lbl_S2_DensityVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.lbl_S2_DensityVal.Location = new System.Drawing.Point(0, 0); + this.lbl_S2_DensityVal.Size = new System.Drawing.Size(389, 80); + this.lbl_S2_DensityVal.Text = "油密度:0.00"; + this.lbl_S2_DensityVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + this.lbl_S2_Info2.AutoSize = false; + this.lbl_S2_Info2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + this.lbl_S2_Info2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lbl_S2_Info2.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.lbl_S2_Info2.Location = new System.Drawing.Point(420, 0); + this.lbl_S2_Info2.Size = new System.Drawing.Size(389, 80); + this.lbl_S2_Info2.Text = "加油量:0.00"; + this.lbl_S2_Info2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + this.lbl_S2_ExtractOilVal.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + this.lbl_S2_ExtractOilVal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lbl_S2_ExtractOilVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.lbl_S2_ExtractOilVal.Location = new System.Drawing.Point(840, 0); + this.lbl_S2_ExtractOilVal.Size = new System.Drawing.Size(389, 80); + this.lbl_S2_ExtractOilVal.Text = "抽油量:0.00"; + this.lbl_S2_ExtractOilVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + this.lbl_S2_OilReleaseVal.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + this.lbl_S2_OilReleaseVal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lbl_S2_OilReleaseVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.lbl_S2_OilReleaseVal.Location = new System.Drawing.Point(0, 93); + this.lbl_S2_OilReleaseVal.Size = new System.Drawing.Size(389, 80); + this.lbl_S2_OilReleaseVal.Text = "放油量:0.00"; + this.lbl_S2_OilReleaseVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + this.lbl_S2_ResidualOilVal.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + this.lbl_S2_ResidualOilVal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lbl_S2_ResidualOilVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.lbl_S2_ResidualOilVal.Location = new System.Drawing.Point(420, 93); + this.lbl_S2_ResidualOilVal.Size = new System.Drawing.Size(389, 80); + this.lbl_S2_ResidualOilVal.Text = "残油量:0.00"; + this.lbl_S2_ResidualOilVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + this.lbl_S2_QualityVal.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + this.lbl_S2_QualityVal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lbl_S2_QualityVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.lbl_S2_QualityVal.Location = new System.Drawing.Point(840, 93); + this.lbl_S2_QualityVal.Size = new System.Drawing.Size(389, 80); + this.lbl_S2_QualityVal.Text = "合格结果:--"; + this.lbl_S2_QualityVal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + + this.lbl_S2_AlarmLabel.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.lbl_S2_AlarmLabel.Location = new System.Drawing.Point(30, 768); + this.lbl_S2_AlarmLabel.Size = new System.Drawing.Size(112, 42); + + this.lbl_S2_AlarmVal.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Bold); + this.lbl_S2_AlarmVal.Location = new System.Drawing.Point(180, 768); + this.lbl_S2_AlarmVal.Size = new System.Drawing.Size(1080, 42); + this.lbl_S2_AlarmVal.Text = "无报警"; + + // + + // UC_Weighing + + // + + this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F); + + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(245)))), ((int)(((byte)(247)))), ((int)(((byte)(250))))); + + this.Controls.Add(this.pnl_Stations); + + this.Controls.Add(this.pnl_Log); + + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + + this.Name = "UC_Weighing"; + + this.Size = new System.Drawing.Size(2730, 1500); + + this.pnl_Stations.ResumeLayout(false); + + this.pnl_Station2.ResumeLayout(false); + + this.pnl_Station2.PerformLayout(); + + this.pnl_S2_WaterBox.ResumeLayout(false); + + this.pnl_S2_WaterBox.PerformLayout(); + + this.pnl_S2_MetricBox.ResumeLayout(false); + + this.pnl_S2_WeightBox.ResumeLayout(false); + + this.pnl_S2_WeightBox.PerformLayout(); + + this.pnl_S2_Header.ResumeLayout(false); + + this.pnl_Station1.ResumeLayout(false); + + this.pnl_S1_MetricBox.ResumeLayout(false); + + this.pnl_S1_WeightBox.ResumeLayout(false); + + this.pnl_S1_WeightBox.PerformLayout(); + + this.pnl_S1_Header.ResumeLayout(false); + + this.pnl_Log.ResumeLayout(false); + + this.pnl_Log.PerformLayout(); + + this.ResumeLayout(false); + + } + + #endregion + + // ── 工位容器 ── + + private System.Windows.Forms.Panel pnl_Stations; + + // ── 工位1 ── + + private System.Windows.Forms.Panel pnl_Station1; + + private System.Windows.Forms.Panel pnl_S1_Header; + + private System.Windows.Forms.Label lbl_S1_Title; + + private System.Windows.Forms.Label lbl_S1_EngineLabel; + + private System.Windows.Forms.Label lbl_S1_EngineVal; + + private System.Windows.Forms.Label lbl_S1_ModelLabel; + + private System.Windows.Forms.Label lbl_S1_ModelVal; + + private System.Windows.Forms.Label lbl_S1_OrderLabel; + + private System.Windows.Forms.Label lbl_S1_OrderVal; + + private System.Windows.Forms.Label lbl_S1_PalletLabel; + + private System.Windows.Forms.Label lbl_S1_PalletVal; + + private System.Windows.Forms.Panel pnl_S1_WeightBox; + + private System.Windows.Forms.Label lbl_S1_Weight; + + private System.Windows.Forms.Label lbl_S1_WeightUnit; + + private System.Windows.Forms.Panel pnl_S1_MetricBox; + + private System.Windows.Forms.Panel pnl_S1_WaterBox; + + private System.Windows.Forms.Label lbl_S1_WaterTitle; + + private System.Windows.Forms.Label lbl_S1_WaterUnit; + + private System.Windows.Forms.Panel pnl_S1_AddOilBox; + + private System.Windows.Forms.Label lbl_S1_AddOilTitle; + + private System.Windows.Forms.Label lbl_S1_AddOilUnit; + + private System.Windows.Forms.Panel pnl_S1_ExtractOilBox; + + private System.Windows.Forms.Label lbl_S1_ExtractOilTitle; + + private System.Windows.Forms.Label lbl_S1_ExtractOilUnit; + + private System.Windows.Forms.Panel pnl_S1_DensityBox; + + private System.Windows.Forms.Label lbl_S1_DensityTitle; + + private System.Windows.Forms.Label lbl_S1_DensityUnit; + + private System.Windows.Forms.Panel pnl_S1_OilReleaseBox; + + private System.Windows.Forms.Label lbl_S1_OilReleaseTitle; + + private System.Windows.Forms.Label lbl_S1_OilReleaseUnit; + + private System.Windows.Forms.Panel pnl_S1_ResidualOilBox; + + private System.Windows.Forms.Label lbl_S1_ResidualOilTitle; + + private System.Windows.Forms.Label lbl_S1_ResidualOilUnit; + + private System.Windows.Forms.Panel pnl_S1_QualityBox; + + private System.Windows.Forms.Label lbl_S1_QualityTitle; + + private System.Windows.Forms.Label lbl_S1_Info1; + + private System.Windows.Forms.Label lbl_S1_Info2; + + private System.Windows.Forms.Label lbl_S1_ExtractOilVal; + + private System.Windows.Forms.Label lbl_S1_DensityVal; + + private System.Windows.Forms.Label lbl_S1_OilReleaseVal; + + private System.Windows.Forms.Label lbl_S1_ResidualOilVal; + + private System.Windows.Forms.Label lbl_S1_QualityVal; + + private System.Windows.Forms.Label lbl_S1_AlarmLabel; + + private System.Windows.Forms.Label lbl_S1_AlarmVal; + + // ── 工位2 ── + + private System.Windows.Forms.Panel pnl_Station2; + + private System.Windows.Forms.Panel pnl_S2_Header; + + private System.Windows.Forms.Label lbl_S2_Title; + + private System.Windows.Forms.Label lbl_S2_EngineLabel; + + private System.Windows.Forms.Label lbl_S2_EngineVal; + + private System.Windows.Forms.Label lbl_S2_ModelLabel; + + private System.Windows.Forms.Label lbl_S2_ModelVal; + + private System.Windows.Forms.Label lbl_S2_OrderLabel; + + private System.Windows.Forms.Label lbl_S2_OrderVal; + + private System.Windows.Forms.Label lbl_S2_PalletLabel; + + private System.Windows.Forms.Label lbl_S2_PalletVal; + + private System.Windows.Forms.Panel pnl_S2_WeightBox; + + private System.Windows.Forms.Label lbl_S2_WeightTitle; + + private System.Windows.Forms.Label lbl_S2_Weight; + + private System.Windows.Forms.Label lbl_S2_WeightUnit; + + private System.Windows.Forms.Panel pnl_S2_WaterBox; + + private System.Windows.Forms.Label lbl_S2_WaterTitle; + + private System.Windows.Forms.Label lbl_S2_WaterUnit; + + private System.Windows.Forms.Panel pnl_S2_MetricBox; + + private System.Windows.Forms.Panel pnl_S2_DensityBox; + + private System.Windows.Forms.Label lbl_S2_DensityTitle; + + private System.Windows.Forms.Label lbl_S2_DensityUnit; + + private System.Windows.Forms.Panel pnl_S2_AddOilBox; + + private System.Windows.Forms.Label lbl_S2_AddOilTitle; + + private System.Windows.Forms.Label lbl_S2_AddOilUnit; + + private System.Windows.Forms.Panel pnl_S2_ExtractOilBox; + + private System.Windows.Forms.Label lbl_S2_ExtractOilTitle; + + private System.Windows.Forms.Label lbl_S2_ExtractOilUnit; + + private System.Windows.Forms.Panel pnl_S2_OilReleaseBox; + + private System.Windows.Forms.Label lbl_S2_OilReleaseTitle; + + private System.Windows.Forms.Label lbl_S2_OilReleaseUnit; + + private System.Windows.Forms.Panel pnl_S2_ResidualOilBox; + + private System.Windows.Forms.Label lbl_S2_ResidualOilTitle; + + private System.Windows.Forms.Label lbl_S2_ResidualOilUnit; + + private System.Windows.Forms.Panel pnl_S2_QualityBox; + + private System.Windows.Forms.Label lbl_S2_QualityTitle; + + private System.Windows.Forms.Label lbl_S2_Info1; + + private System.Windows.Forms.Label lbl_S2_Info2; + + private System.Windows.Forms.Label lbl_S2_DensityVal; + + private System.Windows.Forms.Label lbl_S2_ExtractOilVal; + + private System.Windows.Forms.Label lbl_S2_OilReleaseVal; + + private System.Windows.Forms.Label lbl_S2_ResidualOilVal; + + private System.Windows.Forms.Label lbl_S2_QualityVal; + + private System.Windows.Forms.Label lbl_S2_AlarmLabel; + + private System.Windows.Forms.Label lbl_S2_AlarmVal; + + // ── 操作日志 ── + + private System.Windows.Forms.Panel pnl_Log; + + private System.Windows.Forms.Label lbl_LogTitle; + + private System.Windows.Forms.TextBox txt_Log; + + private System.Windows.Forms.Label label1; + + } + +} diff --git a/SCADA/Pages/UC_Weighing.cs b/SCADA/Pages/UC_Weighing.cs new file mode 100644 index 0000000..574cfe4 --- /dev/null +++ b/SCADA/Pages/UC_Weighing.cs @@ -0,0 +1,924 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; +using DC_A95; +using MesWork; + +namespace MesWork.Pages +{ + /// + /// 称重作业页面 — 双工位实时称重监控 + /// 信号灯12个(4×3),500ms轮询PLC数据 + /// + public partial class UC_Weighing : UserControl + { + // ── 信号灯名称(12个 = 4×3网格)── + private static readonly string[] SignalNames = + { + "工件到位", "读取完成", "开始称重", "称重完成", + "请求工作", "允许工作", "请求保存", "保存完成", + "等待放行", "PLC心跳", "PC心跳", "合格标志" + }; + + /// 信号灯对应的 tagTypeCodeID + private static readonly int[] SignalTagCodes = + { + 2, // 工件到位 + 100001, // 读取完成 + 100002, // 开始称重 + 100003, // 称重完成 + 44, // 请求工作 + 66, // 允许工作 + 19, // 请求保存 + 20, // 保存完成 + 100004, // 等待放行 + 14, // PLC心跳 + 15, // PC心跳 + 21 // 合格标志 (Int: 0=无, 1=合格, 2=不合格) + }; + + private static readonly Color C_SignalOn = Color.FromArgb(16, 185, 129); // 绿色 + private static readonly Color C_SignalOff = Color.FromArgb(209, 213, 219); // 灰色 + private static readonly Color C_SignalBad = Color.FromArgb(239, 68, 68); // 红色(不合格) + + /// 报警代码文本映射 + private static readonly string[] AlarmCodeTexts = + { + "无报警", // 0 + "获取工厂数据接口调用失败", // 1 + "上传工厂数据接口调用失败", // 2 + "发动机号错误" // 3 + }; + + /// 工位1 信号灯面板 [0-11] + private Panel[] _s1Signals; + /// 工位2 信号灯面板 [0-11] + private Panel[] _s2Signals; + + /// PLC数据轮询定时器 500ms + private Timer _tmrPLC; + + /// 工位1的opName (如OP10) + private string _op1; + /// 工位2的opName (如OP20) + private string _op2; + + private bool _isApplyingMetricLayout; + + public UC_Weighing() + { + InitializeComponent(); + if (IsInDesignMode()) + { + ApplyDesignerPreviewLayout(); + ApplyWeighingType(); + return; + } + Resize += (s, e) => ApplyMetricCardLayout(); + pnl_Stations.Resize += (s, e) => ApplyMetricCardLayout(); + ApplyMetricCardLayout(); + InitSignalLights(); + ApplyWeighingType(); + InitPLCTimer(); + } + + private void ApplyMetricCardLayout() + { + if (IsInDesignMode() || _isApplyingMetricLayout || pnl_Stations.ClientSize.Width <= 0) + return; + + _isApplyingMetricLayout = true; + try + { + int logHeight = Math.Max(210, Math.Min(280, Height / 4)); + if (pnl_Log.Height != logHeight) + pnl_Log.Height = logHeight; + + pnl_Stations.Padding = new Padding(12, 12, 12, 10); + + int availableWidth = pnl_Stations.ClientSize.Width - pnl_Stations.Padding.Left - pnl_Stations.Padding.Right; + int stationGap = 14; + int stationWidth = Math.Max(620, (availableWidth - stationGap) / 2); + pnl_Station1.Width = stationWidth; + + LayoutStationHeaderSection( + pnl_Station1, + pnl_S1_Header, + lbl_S1_Title, + lbl_S1_EngineLabel, + lbl_S1_EngineVal, + lbl_S1_ModelLabel, + lbl_S1_ModelVal, + lbl_S1_OrderLabel, + lbl_S1_OrderVal, + lbl_S1_PalletLabel, + lbl_S1_PalletVal); + LayoutStationHeaderSection( + pnl_Station2, + pnl_S2_Header, + lbl_S2_Title, + lbl_S2_EngineLabel, + lbl_S2_EngineVal, + lbl_S2_ModelLabel, + lbl_S2_ModelVal, + lbl_S2_OrderLabel, + lbl_S2_OrderVal, + lbl_S2_PalletLabel, + lbl_S2_PalletVal); + + LayoutStationMetricCards( + pnl_Station1, + pnl_S1_WeightBox, + label1, + lbl_S1_Weight, + lbl_S1_WeightUnit, + pnl_S1_WaterBox, + lbl_S1_WaterTitle, + lbl_S1_Info1, + lbl_S1_WaterUnit, + pnl_S1_MetricBox, + pnl_S1_DensityBox, + lbl_S1_DensityTitle, + lbl_S1_DensityVal, + lbl_S1_DensityUnit, + pnl_S1_AddOilBox, + lbl_S1_AddOilTitle, + lbl_S1_Info2, + lbl_S1_AddOilUnit, + pnl_S1_ExtractOilBox, + lbl_S1_ExtractOilTitle, + lbl_S1_ExtractOilVal, + lbl_S1_ExtractOilUnit, + pnl_S1_OilReleaseBox, + lbl_S1_OilReleaseTitle, + lbl_S1_OilReleaseVal, + lbl_S1_OilReleaseUnit, + pnl_S1_ResidualOilBox, + lbl_S1_ResidualOilTitle, + lbl_S1_ResidualOilVal, + lbl_S1_ResidualOilUnit, + pnl_S1_QualityBox, + lbl_S1_QualityTitle, + lbl_S1_QualityVal); + LayoutStationMetricCards( + pnl_Station2, + pnl_S2_WeightBox, + lbl_S2_WeightTitle, + lbl_S2_Weight, + lbl_S2_WeightUnit, + pnl_S2_WaterBox, + lbl_S2_WaterTitle, + lbl_S2_Info1, + lbl_S2_WaterUnit, + pnl_S2_MetricBox, + pnl_S2_DensityBox, + lbl_S2_DensityTitle, + lbl_S2_DensityVal, + lbl_S2_DensityUnit, + pnl_S2_AddOilBox, + lbl_S2_AddOilTitle, + lbl_S2_Info2, + lbl_S2_AddOilUnit, + pnl_S2_ExtractOilBox, + lbl_S2_ExtractOilTitle, + lbl_S2_ExtractOilVal, + lbl_S2_ExtractOilUnit, + pnl_S2_OilReleaseBox, + lbl_S2_OilReleaseTitle, + lbl_S2_OilReleaseVal, + lbl_S2_OilReleaseUnit, + pnl_S2_ResidualOilBox, + lbl_S2_ResidualOilTitle, + lbl_S2_ResidualOilVal, + lbl_S2_ResidualOilUnit, + pnl_S2_QualityBox, + lbl_S2_QualityTitle, + lbl_S2_QualityVal); + + ConfigureAlarmLine(pnl_Station1, lbl_S1_AlarmLabel, lbl_S1_AlarmVal); + ConfigureAlarmLine(pnl_Station2, lbl_S2_AlarmLabel, lbl_S2_AlarmVal); + } + finally + { + _isApplyingMetricLayout = false; + } + } + + private void LayoutStationMetricCards( + Panel station, + Panel weightBox, + Label weightTitle, + Label weightValue, + Label weightUnit, + Panel waterBox, + Label waterTitle, + Label waterValue, + Label waterUnit, + Panel metricBox, + Panel densityBox, + Label densityTitle, + Label densityValue, + Label densityUnit, + Panel addOilBox, + Label addOilTitle, + Label addOilValue, + Label addOilUnit, + Panel extractOilBox, + Label extractOilTitle, + Label extractOilValue, + Label extractOilUnit, + Panel oilReleaseBox, + Label oilReleaseTitle, + Label oilReleaseValue, + Label oilReleaseUnit, + Panel residualOilBox, + Label residualOilTitle, + Label residualOilValue, + Label residualOilUnit, + Panel qualityBox, + Label qualityTitle, + Label qualityValue) + { + int margin = 20; + int gap = 16; + int stationWidth = Math.Max(620, station.ClientSize.Width); + int contentWidth = Math.Max(560, stationWidth - margin * 2); + int topCardWidth = Math.Max(250, (contentWidth - gap) / 2); + int metricCardWidth = Math.Max(165, (contentWidth - gap * 2) / 3); + int weightY = 262; + int metricY = 408; + int metricRowGap = 12; + + ConfigureWeightCard(weightBox, weightTitle, weightValue, weightUnit, topCardWidth, 128, 41F); + weightBox.Location = new Point(margin, weightY); + ConfigureMetricCard(station, waterBox, waterTitle, waterValue, waterUnit, "水含量", "%", margin + topCardWidth + gap, weightY, topCardWidth, 128, 28F); + + metricBox.BackColor = Color.White; + metricBox.Location = new Point(margin, metricY); + metricBox.Size = new Size(contentWidth, 160); + if (metricBox.Parent != station) + station.Controls.Add(metricBox); + + ConfigureMetricCard(metricBox, densityBox, densityTitle, densityValue, densityUnit, "油密度", "KG/L", 0, 0, metricCardWidth, 74, 18F); + ConfigureMetricCard(metricBox, addOilBox, addOilTitle, addOilValue, addOilUnit, "加油量", "L", metricCardWidth + gap, 0, metricCardWidth, 74, 18F); + ConfigureMetricCard(metricBox, extractOilBox, extractOilTitle, extractOilValue, extractOilUnit, "抽油量", "L", (metricCardWidth + gap) * 2, 0, metricCardWidth, 74, 18F); + ConfigureMetricCard(metricBox, oilReleaseBox, oilReleaseTitle, oilReleaseValue, oilReleaseUnit, "放油量", "L", 0, 74 + metricRowGap, metricCardWidth, 74, 18F); + ConfigureMetricCard(metricBox, residualOilBox, residualOilTitle, residualOilValue, residualOilUnit, "残油量", "L", metricCardWidth + gap, 74 + metricRowGap, metricCardWidth, 74, 18F); + ConfigureMetricCard(metricBox, qualityBox, qualityTitle, qualityValue, null, "合格结果", "", (metricCardWidth + gap) * 2, 74 + metricRowGap, metricCardWidth, 74, 18F); + } + + private void LayoutStationHeaderSection( + Panel station, + Panel headerPanel, + Label titleLabel, + Label engineLabel, + Label engineValue, + Label modelLabel, + Label modelValue, + Label orderLabel, + Label orderValue, + Label palletLabel, + Label palletValue) + { + int margin = 20; + int columnGap = 26; + int labelWidth = 94; + int valueGap = 6; + int headerHeight = 44; + int rowHeight = 38; + int topY = headerHeight + 12; + int contentWidth = Math.Max(560, station.ClientSize.Width - margin * 2); + int columnWidth = (contentWidth - columnGap) / 2; + int valueWidth = Math.Max(120, columnWidth - labelWidth - valueGap); + + headerPanel.Height = headerHeight; + titleLabel.Font = new Font("微软雅黑", 12.5F, FontStyle.Bold); + titleLabel.Padding = new Padding(18, 0, 0, 0); + + ConfigureInfoPair(engineLabel, engineValue, margin, topY, labelWidth, valueWidth, rowHeight); + ConfigureInfoPair(modelLabel, modelValue, margin + columnWidth + columnGap, topY, labelWidth, valueWidth, rowHeight); + ConfigureInfoPair(orderLabel, orderValue, margin, topY + rowHeight, labelWidth, valueWidth, rowHeight); + ConfigureInfoPair(palletLabel, palletValue, margin + columnWidth + columnGap, topY + rowHeight, labelWidth, valueWidth, rowHeight); + } + + private void ConfigureAlarmLine(Panel station, Label alarmLabel, Label alarmValue) + { + int y = 590; + alarmLabel.Font = new Font("微软雅黑", 11.5F, FontStyle.Bold); + alarmLabel.ForeColor = Color.FromArgb(107, 114, 128); + alarmLabel.Location = new Point(20, y); + alarmLabel.Size = new Size(96, 34); + alarmLabel.BringToFront(); + + alarmValue.Font = new Font("微软雅黑", 11.5F, FontStyle.Bold); + alarmValue.Location = new Point(116, y); + alarmValue.Size = new Size(Math.Max(240, station.ClientSize.Width - 136), 34); + alarmValue.BringToFront(); + } + + private void ConfigureWeightCard(System.Windows.Forms.Panel panel, System.Windows.Forms.Label titleLabel, System.Windows.Forms.Label valueLabel, System.Windows.Forms.Label unitLabel, int width, int height, float valueFontSize) + { + panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + panel.Size = new System.Drawing.Size(width, height); + + titleLabel.AutoSize = false; + titleLabel.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Bold); + titleLabel.ForeColor = System.Drawing.Color.Black; + titleLabel.Location = new System.Drawing.Point(14, 8); + titleLabel.Size = new System.Drawing.Size(178, 30); + titleLabel.Text = "实时重量"; + titleLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + if (titleLabel.Parent != panel) + panel.Controls.Add(titleLabel); + + valueLabel.AutoSize = false; + valueLabel.Font = new System.Drawing.Font("Consolas", valueFontSize, System.Drawing.FontStyle.Bold); + valueLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + valueLabel.Location = new System.Drawing.Point(34, 20); + valueLabel.Size = new System.Drawing.Size(Math.Max(150, width - 122), height - 40); + valueLabel.Text = "0.00"; + valueLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + if (valueLabel.Parent != panel) + panel.Controls.Add(valueLabel); + + unitLabel.AutoSize = false; + unitLabel.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Bold); + unitLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + unitLabel.Location = new System.Drawing.Point(width - 82, height - 44); + unitLabel.Size = new System.Drawing.Size(66, 34); + unitLabel.Text = "KG"; + unitLabel.TextAlign = System.Drawing.ContentAlignment.BottomRight; + if (unitLabel.Parent != panel) + panel.Controls.Add(unitLabel); + unitLabel.BringToFront(); + titleLabel.BringToFront(); + } + + private void ConfigureMetricCard(System.Windows.Forms.Control parent, System.Windows.Forms.Panel panel, System.Windows.Forms.Label titleLabel, System.Windows.Forms.Label valueLabel, System.Windows.Forms.Label unitLabel, string title, string unit, int x, int y, int width, int height, float valueFontSize) + { + panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(250)))), ((int)(((byte)(252))))); + panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + panel.Location = new System.Drawing.Point(x, y); + panel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + panel.Size = new System.Drawing.Size(width, height); + if (panel.Parent != parent) + parent.Controls.Add(panel); + + titleLabel.AutoSize = false; + titleLabel.Font = new System.Drawing.Font("宋体", height >= 100 ? 14F : 10.5F, System.Drawing.FontStyle.Bold); + titleLabel.ForeColor = System.Drawing.Color.Black; + titleLabel.Location = new System.Drawing.Point(12, 7); + titleLabel.Size = new System.Drawing.Size(width - 24, height >= 100 ? 30 : 22); + titleLabel.Text = title; + titleLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + if (titleLabel.Parent != panel) + panel.Controls.Add(titleLabel); + + valueLabel.AutoSize = false; + valueLabel.BorderStyle = System.Windows.Forms.BorderStyle.None; + valueLabel.BackColor = panel.BackColor; + valueLabel.Font = new System.Drawing.Font("微软雅黑", valueFontSize, System.Drawing.FontStyle.Bold); + valueLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(58)))), ((int)(((byte)(95))))); + int unitWidth = unit == "KG/L" ? 66 : 38; + int valueRightPadding = unitLabel == null ? 16 : unitWidth + 24; + valueLabel.Location = new System.Drawing.Point(20, height >= 100 ? 24 : 20); + valueLabel.Size = new System.Drawing.Size(Math.Max(72, width - 20 - valueRightPadding), height >= 100 ? height - 40 : height - 24); + valueLabel.Text = NormalizeMetricValue(valueLabel.Text); + valueLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + if (valueLabel.Parent != panel) + panel.Controls.Add(valueLabel); + + if (unitLabel != null) + { + unitLabel.AutoSize = false; + unitLabel.Font = new System.Drawing.Font("微软雅黑", height >= 100 ? 18F : 11F, System.Drawing.FontStyle.Bold); + unitLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(114)))), ((int)(((byte)(128))))); + unitLabel.Location = new System.Drawing.Point(width - unitWidth - 12, height - (height >= 100 ? 42 : 28)); + unitLabel.Size = new System.Drawing.Size(unitWidth, height >= 100 ? 30 : 20); + unitLabel.Text = unit; + unitLabel.TextAlign = System.Drawing.ContentAlignment.BottomRight; + if (unitLabel.Parent != panel) + panel.Controls.Add(unitLabel); + unitLabel.BringToFront(); + } + + titleLabel.BringToFront(); + } + + private void ConfigureInfoPair(Label titleLabel, Label valueLabel, int x, int y, int titleWidth, int valueWidth, int height) + { + titleLabel.Font = new Font("微软雅黑", 12F, FontStyle.Bold); + titleLabel.ForeColor = Color.FromArgb(107, 114, 128); + titleLabel.Location = new Point(x, y); + titleLabel.Size = new Size(titleWidth, height); + titleLabel.TextAlign = ContentAlignment.MiddleLeft; + + valueLabel.Font = new Font("微软雅黑", 13F, FontStyle.Bold); + valueLabel.ForeColor = Color.FromArgb(30, 58, 95); + valueLabel.Location = new Point(x + titleWidth + 6, y); + valueLabel.Size = new Size(valueWidth, height); + valueLabel.TextAlign = ContentAlignment.MiddleLeft; + } + + private string NormalizeMetricValue(string text) + { + if (string.IsNullOrWhiteSpace(text)) + return "0.00"; + + int colonIndex = text.IndexOf(':'); + if (colonIndex >= 0 && colonIndex < text.Length - 1) + text = text.Substring(colonIndex + 1).Trim(); + + text = text.Trim(); + return text == "—" ? "0.00" : text; + } + + /// + /// 根据 App.config 中的 WeighingType 配置切换工位标题 + /// + private void ApplyWeighingType() + { + // 优先从Excel配置读取工位显示名(OpName → "OP10 — 称重位1") + var names = MesWorkForm.StationDisplayNames; + var opNames = MesWorkForm.StationOpNames; + string wType = System.Configuration.ConfigurationManager.AppSettings["WeighingType"] ?? "Hanging"; + bool isGround = wType.Equals("Ground", StringComparison.OrdinalIgnoreCase); + + string dn1 = null, dn2 = null; + string title1 = opNames.Count >= 1 && names.TryGetValue(opNames[0], out dn1) + ? dn1 + : (isGround ? "工位1 — 地面称重" : "工位1 — 放油前称重"); + + string title2 = opNames.Count >= 2 && names.TryGetValue(opNames[1], out dn2) + ? dn2 + : (isGround ? "工位2 — 地面称重" : "工位2 — 放油后称重"); + + lbl_S1_Title.Text = title1; + lbl_S2_Title.Text = title2; + } + + // ==================================================================== + // 信号灯创建(12个 = 4列×3行) + // ==================================================================== + + private void InitSignalLights() + { + _s1Signals = CreateSignalGrid(pnl_Station1, 20, 136, 198, 36, 22, 12.5F); + _s2Signals = CreateSignalGrid(pnl_Station2, 20, 136, 198, 36, 22, 12.5F); + } + + private Panel[] CreateSignalGrid(Panel parent, int startX, int startY) + { + return CreateSignalGrid(parent, startX, startY, 200, 32, 20, 10F); + } + + private Panel[] CreateSignalGrid(Panel parent, int startX, int startY, int colSpacing, int rowSpacing, int dotSize, float fontSize) + { + var signals = new Panel[12]; + for (int i = 0; i < 12; i++) + { + int col = i % 4; + int row = i / 4; + int x = startX + col * colSpacing; + int y = startY + row * rowSpacing; + + var dot = new Panel + { + BackColor = C_SignalOff, + Location = new Point(x, y + 2), + Size = new Size(dotSize, dotSize), + Name = $"sig_{parent.Name}_{i}" + }; + dot.Paint += (s, e) => + { + var p = (Panel)s; + e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + using (var brush = new SolidBrush(p.BackColor)) + { + e.Graphics.Clear(p.Parent.BackColor); + e.Graphics.FillEllipse(brush, 0, 0, p.Width - 1, p.Height - 1); + } + }; + + var lbl = new Label + { + Text = SignalNames[i], + Font = new Font("微软雅黑", fontSize, FontStyle.Bold), + ForeColor = Color.FromArgb(55, 65, 81), + Location = new Point(x + dotSize + 8, y), + AutoSize = true + }; + + parent.Controls.Add(dot); + parent.Controls.Add(lbl); + signals[i] = dot; + } + return signals; + } + + private bool IsInDesignMode() + { + return LicenseManager.UsageMode == LicenseUsageMode.Designtime || DesignMode || (Site?.DesignMode ?? false); + } + + private void ApplyDesignerPreviewLayout() + { + MirrorDesignerStationLayout( + pnl_Station2, + pnl_S2_WeightBox, + lbl_S2_WeightTitle, + lbl_S2_Weight, + lbl_S2_WeightUnit, + lbl_S2_Info1, + pnl_S2_MetricBox, + lbl_S2_DensityVal, + lbl_S2_Info2, + lbl_S2_ExtractOilVal, + lbl_S2_OilReleaseVal, + lbl_S2_ResidualOilVal, + lbl_S2_QualityVal, + lbl_S2_AlarmLabel, + lbl_S2_AlarmVal); + } + + private void MirrorDesignerStationLayout( + Panel station, + Panel weightBox, + Label weightTitle, + Label weightValue, + Label weightUnit, + Label waterValue, + Panel metricBox, + Label densityValue, + Label addOilValue, + Label extractOilValue, + Label oilReleaseValue, + Label residualOilValue, + Label qualityValue, + Label alarmLabel, + Label alarmValue) + { + station.Controls.Remove(pnl_S2_WaterBox); + station.Controls.Add(waterValue); + station.Controls.Add(metricBox); + station.Controls.Add(weightBox); + station.Controls.Add(alarmLabel); + station.Controls.Add(alarmValue); + + metricBox.Controls.Clear(); + metricBox.Controls.Add(qualityValue); + metricBox.Controls.Add(residualOilValue); + metricBox.Controls.Add(oilReleaseValue); + metricBox.Controls.Add(densityValue); + metricBox.Controls.Add(extractOilValue); + metricBox.Controls.Add(addOilValue); + + weightBox.Location = new Point(30, 401); + weightBox.Size = new Size(599, 164); + weightTitle.Location = new Point(15, 9); + weightTitle.Size = new Size(137, 30); + weightTitle.Font = new Font("宋体", 15F, FontStyle.Bold); + weightTitle.Text = "实时重量"; + weightTitle.AutoSize = true; + weightValue.Location = new Point(114, 9); + weightValue.Size = new Size(327, 144); + weightValue.Font = new Font("Consolas", 54F, FontStyle.Bold); + weightValue.TextAlign = ContentAlignment.MiddleRight; + weightUnit.Location = new Point(456, 60); + weightUnit.Size = new Size(135, 87); + weightUnit.Font = new Font("微软雅黑", 20F, FontStyle.Bold); + weightUnit.TextAlign = ContentAlignment.BottomLeft; + + waterValue.BackColor = Color.FromArgb(248, 250, 252); + waterValue.BorderStyle = BorderStyle.FixedSingle; + waterValue.Font = new Font("微软雅黑", 18F, FontStyle.Bold); + waterValue.Location = new Point(660, 401); + waterValue.Size = new Size(599, 164); + waterValue.Text = "水含量:0.00"; + waterValue.TextAlign = ContentAlignment.MiddleCenter; + waterValue.AutoSize = false; + + metricBox.Location = new Point(30, 594); + metricBox.Size = new Size(1230, 174); + metricBox.BackColor = Color.White; + + ConfigureDesignerMetricLabel(densityValue, "油密度:0.00", 0, 0); + ConfigureDesignerMetricLabel(addOilValue, "加油量:0.00", 420, 0); + ConfigureDesignerMetricLabel(extractOilValue, "抽油量:0.00", 840, 0); + ConfigureDesignerMetricLabel(oilReleaseValue, "放油量:0.00", 0, 93); + ConfigureDesignerMetricLabel(residualOilValue, "残油量:0.00", 420, 93); + ConfigureDesignerMetricLabel(qualityValue, "合格结果:--", 840, 93); + + alarmLabel.Font = new Font("微软雅黑", 13F, FontStyle.Bold); + alarmLabel.Location = new Point(30, 792); + alarmLabel.Size = new Size(112, 42); + alarmValue.Font = new Font("微软雅黑", 13F, FontStyle.Bold); + alarmValue.Location = new Point(180, 792); + alarmValue.Size = new Size(1080, 42); + alarmValue.Text = "无报警"; + } + + private void ConfigureDesignerMetricLabel(Label label, string text, int x, int y) + { + label.BackColor = Color.FromArgb(248, 250, 252); + label.BorderStyle = BorderStyle.FixedSingle; + label.Font = new Font("微软雅黑", 13F, FontStyle.Bold); + label.ForeColor = Color.FromArgb(55, 65, 81); + label.Location = new Point(x, y); + label.Size = new Size(389, 80); + label.Text = text; + label.TextAlign = ContentAlignment.MiddleCenter; + label.AutoSize = false; + } + + // ==================================================================== + // PLC 轮询定时器 — 500ms + // ==================================================================== + + private void InitPLCTimer() + { + _tmrPLC = new Timer { Interval = 500 }; + _tmrPLC.Tick += TmrPLC_Tick; + var tmrDelay = new Timer { Interval = 3000 }; + tmrDelay.Tick += (s, e) => + { + tmrDelay.Stop(); + tmrDelay.Dispose(); + + var ops = MesWorkForm.StationOpNames; + if (ops != null && ops.Count >= 2) + { + _op1 = ops[0]; + _op2 = ops[1]; + } + else if (ops != null && ops.Count == 1) + { + _op1 = ops[0]; + _op2 = ops[0]; + } + + if (!string.IsNullOrEmpty(_op1)) + { + _tmrPLC.Start(); + AppendLog($"PLC配置读取,工位1={_op1},工位2={_op2 ?? "无"}"); + } + else + { + AppendLog("未检测到设备工位配置,PLC轮询未启动"); + } + }; + tmrDelay.Start(); + } + + private void TmrPLC_Tick(object sender, EventArgs e) + { + try + { + if (!string.IsNullOrEmpty(_op1)) + PollStation(1, _op1, _s1Signals, + lbl_S1_Weight, lbl_S1_Info1, lbl_S1_Info2, + lbl_S1_PalletVal, lbl_S1_AlarmVal); + + if (!string.IsNullOrEmpty(_op2)) + PollStation(2, _op2, _s2Signals, + lbl_S2_Weight, lbl_S2_Info1, lbl_S2_Info2, + lbl_S2_PalletVal, lbl_S2_AlarmVal); + } + catch { } + } + + /// + /// 轮询单个工位的所有PLC数据 + /// + private void PollStation(int station, string opName, Panel[] signals, + Label lblWeight, Label lblWater, Label lblOil, + Label lblPallet, Label lblAlarm) + { + try + { + // ── 前11个布尔信号灯 ── + for (int i = 0; i < 11; i++) + { + try + { + var val = PlcLinkForm.ReadPLC(SignalTagCodes[i], opName); + bool active = val != null && val.ToString().ToLower() + .Replace("true", "1").Replace("false", "0") == "1"; + var newColor = active ? C_SignalOn : C_SignalOff; + if (signals[i].BackColor != newColor) + { + signals[i].BackColor = newColor; + signals[i].Invalidate(); + } + } + catch { } + } + + // ── 第12个:合格标志(21) — Int类型特殊处理 ── + try + { + var qVal = PlcLinkForm.ReadPLC(21, opName); + int qFlag = qVal != null ? Convert.ToInt32(qVal) : 0; + Color qColor = qFlag == 1 ? C_SignalOn : (qFlag == 2 ? C_SignalBad : C_SignalOff); + if (signals[11].BackColor != qColor) + { + signals[11].BackColor = qColor; + signals[11].Invalidate(); + } + var lblQuality = station == 1 ? lbl_S1_QualityVal : lbl_S2_QualityVal; + lblQuality.Text = qFlag == 1 ? "合格" : (qFlag == 2 ? "不合格" : "--"); + lblQuality.ForeColor = qFlag == 2 ? C_SignalBad : Color.FromArgb(30, 58, 95); + } + catch { } + + // ── 实时重量(100220) ── + try + { + var wv = PlcLinkForm.ReadPLC(100220, opName); + if (wv != null) + { + string newTxt = Convert.ToDouble(wv).ToString("F2"); + if (lblWeight.Text != newTxt) lblWeight.Text = newTxt; + } + } + catch { } + + // ── 水含量(100180) ── + try + { + var sv = PlcLinkForm.ReadPLC(100180, opName); + if (sv != null) + lblWater.Text = Convert.ToDouble(sv).ToString("F2"); + } + catch { } + + // ── 托盘号(80) ── + try + { + var pv = PlcLinkForm.ReadPLC(80, opName); + if (pv != null) + { + string pt = PLC_R.GetString_CleanGarbled(pv); + if (!string.IsNullOrEmpty(pt)) lblPallet.Text = pt; + } + } + catch { } + + // ── 报警代码(112) — Int → 文本映射 ── + try + { + var av = PlcLinkForm.ReadPLC(112, opName); + int alarmCode = av != null ? Convert.ToInt32(av) : 0; + string alarmText = alarmCode >= 0 && alarmCode < AlarmCodeTexts.Length + ? AlarmCodeTexts[alarmCode] : $"未知({alarmCode})"; + lblAlarm.Text = alarmText; + lblAlarm.ForeColor = alarmCode > 0 + ? Color.FromArgb(239, 68, 68) // 红色 + : Color.FromArgb(107, 114, 128); // 灰色 + } + catch { } + } + catch { } + } + + // ==================================================================== + // 公共方法 — 供 PLC 通信层 / MIS_Funtion 调用 + // ==================================================================== + + public void UpdateSignal(int station, int index, bool active) + { + var sigs = station == 1 ? _s1Signals : _s2Signals; + if (sigs != null && index >= 0 && index < sigs.Length) + { + sigs[index].BackColor = active ? C_SignalOn : C_SignalOff; + sigs[index].Invalidate(); + } + } + + public void UpdateWeight(int station, double weight) + { + var lbl = station == 1 ? lbl_S1_Weight : lbl_S2_Weight; + if (lbl.InvokeRequired) + lbl.Invoke(new Action(() => lbl.Text = weight.ToString("F2"))); + else + lbl.Text = weight.ToString("F2"); + } + + public void UpdateStationInfo(int station, string engineNo, string modelNo, string orderNo) + { + Action act = () => + { + if (station == 1) + { + lbl_S1_EngineVal.Text = engineNo ?? "—"; + lbl_S1_ModelVal.Text = modelNo ?? "—"; + lbl_S1_OrderVal.Text = orderNo ?? "—"; + } + else + { + lbl_S2_EngineVal.Text = engineNo ?? "—"; + lbl_S2_ModelVal.Text = modelNo ?? "—"; + lbl_S2_OrderVal.Text = orderNo ?? "—"; + } + }; + if (InvokeRequired) Invoke(act); else act(); + } + + /// + /// 更新加油量显示 + /// + public void UpdateOilInfo(int station, decimal addOilQty, decimal extractOilQty) + { + UpdateOilInfo(station, addOilQty, extractOilQty, 0, 0, 0); + } + + /// + /// 更新称重指标显示 + /// + public void UpdateOilInfo(int station, decimal addOilQty, decimal extractOilQty, decimal density, decimal oilReleaseQty, decimal residualOilQty) + { + Action act = () => + { + if (station == 1) + { + lbl_S1_Info2.Text = addOilQty.ToString("F2"); + lbl_S1_ExtractOilVal.Text = extractOilQty.ToString("F2"); + lbl_S1_DensityVal.Text = density.ToString("F4"); + lbl_S1_OilReleaseVal.Text = oilReleaseQty.ToString("F2"); + lbl_S1_ResidualOilVal.Text = residualOilQty.ToString("F2"); + } + else + { + lbl_S2_Info2.Text = addOilQty.ToString("F2"); + lbl_S2_ExtractOilVal.Text = extractOilQty.ToString("F2"); + lbl_S2_DensityVal.Text = density.ToString("F4"); + lbl_S2_OilReleaseVal.Text = oilReleaseQty.ToString("F2"); + lbl_S2_ResidualOilVal.Text = residualOilQty.ToString("F2"); + } + }; + if (InvokeRequired) Invoke(act); else act(); + } + + /// + /// 更新放油量和残油量显示 + /// + public void UpdateOilResult(int station, decimal oilReleaseQty, decimal residualOilQty) + { + Action act = () => + { + if (station == 1) + { + lbl_S1_OilReleaseVal.Text = oilReleaseQty.ToString("F2"); + lbl_S1_ResidualOilVal.Text = residualOilQty.ToString("F2"); + } + else + { + lbl_S2_OilReleaseVal.Text = oilReleaseQty.ToString("F2"); + lbl_S2_ResidualOilVal.Text = residualOilQty.ToString("F2"); + } + }; + if (InvokeRequired) Invoke(act); else act(); + } + + public void UpdateAuxInfo(int station, string info1, string info2) + { + if (station == 1) + { + lbl_S1_Info1.Text = info1 ?? ""; + lbl_S1_Info2.Text = info2 ?? ""; + } + else + { + lbl_S2_Info1.Text = info1 ?? ""; + lbl_S2_Info2.Text = info2 ?? ""; + } + } + + /// + /// 追加操作日志(线程安全) + /// + public void AppendLog(string msg) + { + if (txt_Log == null) return; + if (txt_Log.InvokeRequired) + { + txt_Log.Invoke(new Action(() => AppendLog(msg))); + return; + } + if (txt_Log.Text.Length > 50000) + txt_Log.Text = txt_Log.Text.Substring(0, 30000); + txt_Log.Text = $"{DateTime.Now:HH:mm:ss} {msg}\r\n{txt_Log.Text}"; + } + + /// 获取工位序号 + public int GetStationIndex(string opName) + { + if (opName == _op1) return 1; + if (opName == _op2) return 2; + return 1; + } + } +} diff --git a/SCADA/Pages/UC_Weighing.resx b/SCADA/Pages/UC_Weighing.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SCADA/Pages/UC_Weighing.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SCADA/Pages/UC_WorkpieceMgmt.Designer.cs b/SCADA/Pages/UC_WorkpieceMgmt.Designer.cs new file mode 100644 index 0000000..a1cc4fa --- /dev/null +++ b/SCADA/Pages/UC_WorkpieceMgmt.Designer.cs @@ -0,0 +1,253 @@ +namespace MesWork.Pages +{ + partial class UC_WorkpieceMgmt + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + components.Dispose(); + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + private void InitializeComponent() + { + this.pnl_Toolbar = new System.Windows.Forms.Panel(); + this.txt_Search = new System.Windows.Forms.TextBox(); + this.btn_Search = new System.Windows.Forms.Button(); + this.btn_Add = new System.Windows.Forms.Button(); + this.btn_Edit = new System.Windows.Forms.Button(); + this.btn_Delete = new System.Windows.Forms.Button(); + this.btn_Refresh = new System.Windows.Forms.Button(); + this.btn_Export = new System.Windows.Forms.Button(); + this.dgv_Data = new System.Windows.Forms.DataGridView(); + this.pnl_StatusBar = new System.Windows.Forms.Panel(); + this.lbl_RecordCount = new System.Windows.Forms.Label(); + this.pnl_Toolbar.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).BeginInit(); + this.pnl_StatusBar.SuspendLayout(); + this.SuspendLayout(); + // + // pnl_Toolbar — 顶部工具栏 + // + this.pnl_Toolbar.BackColor = System.Drawing.Color.White; + this.pnl_Toolbar.Controls.Add(this.btn_Export); + this.pnl_Toolbar.Controls.Add(this.btn_Refresh); + this.pnl_Toolbar.Controls.Add(this.btn_Delete); + this.pnl_Toolbar.Controls.Add(this.btn_Edit); + this.pnl_Toolbar.Controls.Add(this.btn_Add); + this.pnl_Toolbar.Controls.Add(this.btn_Search); + this.pnl_Toolbar.Controls.Add(this.txt_Search); + this.pnl_Toolbar.Dock = System.Windows.Forms.DockStyle.Top; + this.pnl_Toolbar.Location = new System.Drawing.Point(0, 0); + this.pnl_Toolbar.Name = "pnl_Toolbar"; + this.pnl_Toolbar.Padding = new System.Windows.Forms.Padding(16, 12, 16, 12); + this.pnl_Toolbar.Size = new System.Drawing.Size(1820, 56); + this.pnl_Toolbar.TabIndex = 0; + // + // txt_Search — 搜索框 + // + this.txt_Search.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txt_Search.Font = new System.Drawing.Font("微软雅黑", 11F); + this.txt_Search.ForeColor = System.Drawing.Color.FromArgb(156, 163, 175); + this.txt_Search.Location = new System.Drawing.Point(16, 13); + this.txt_Search.Name = "txt_Search"; + this.txt_Search.Size = new System.Drawing.Size(280, 27); + this.txt_Search.TabIndex = 0; + this.txt_Search.Text = "输入机型号搜索..."; + this.txt_Search.GotFocus += new System.EventHandler(this.txt_Search_GotFocus); + this.txt_Search.LostFocus += new System.EventHandler(this.txt_Search_LostFocus); + this.txt_Search.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_Search_KeyDown); + // + // btn_Search + // + this.btn_Search.BackColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.btn_Search.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Search.FlatAppearance.BorderSize = 0; + this.btn_Search.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Search.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Search.ForeColor = System.Drawing.Color.White; + this.btn_Search.Location = new System.Drawing.Point(306, 12); + this.btn_Search.Name = "btn_Search"; + this.btn_Search.Size = new System.Drawing.Size(80, 30); + this.btn_Search.TabIndex = 1; + this.btn_Search.Text = "🔍 搜索"; + this.btn_Search.UseVisualStyleBackColor = false; + this.btn_Search.Click += new System.EventHandler(this.btn_Search_Click); + // + // btn_Add + // + this.btn_Add.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Add.BackColor = System.Drawing.Color.FromArgb(74, 144, 217); + this.btn_Add.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Add.FlatAppearance.BorderSize = 0; + this.btn_Add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Add.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Add.ForeColor = System.Drawing.Color.White; + this.btn_Add.Location = new System.Drawing.Point(1334, 12); + this.btn_Add.Name = "btn_Add"; + this.btn_Add.Size = new System.Drawing.Size(88, 30); + this.btn_Add.TabIndex = 2; + this.btn_Add.Text = "+ 新增"; + this.btn_Add.UseVisualStyleBackColor = false; + this.btn_Add.Click += new System.EventHandler(this.btn_Add_Click); + // + // btn_Edit + // + this.btn_Edit.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Edit.BackColor = System.Drawing.Color.FromArgb(245, 158, 11); + this.btn_Edit.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Edit.FlatAppearance.BorderSize = 0; + this.btn_Edit.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Edit.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Edit.ForeColor = System.Drawing.Color.White; + this.btn_Edit.Location = new System.Drawing.Point(1430, 12); + this.btn_Edit.Name = "btn_Edit"; + this.btn_Edit.Size = new System.Drawing.Size(88, 30); + this.btn_Edit.TabIndex = 3; + this.btn_Edit.Text = "✏ 修改"; + this.btn_Edit.UseVisualStyleBackColor = false; + this.btn_Edit.Click += new System.EventHandler(this.btn_Edit_Click); + // + // btn_Delete + // + this.btn_Delete.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Delete.BackColor = System.Drawing.Color.FromArgb(239, 68, 68); + this.btn_Delete.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Delete.FlatAppearance.BorderSize = 0; + this.btn_Delete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Delete.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Delete.ForeColor = System.Drawing.Color.White; + this.btn_Delete.Location = new System.Drawing.Point(1526, 12); + this.btn_Delete.Name = "btn_Delete"; + this.btn_Delete.Size = new System.Drawing.Size(88, 30); + this.btn_Delete.TabIndex = 4; + this.btn_Delete.Text = "✕ 删除"; + this.btn_Delete.UseVisualStyleBackColor = false; + this.btn_Delete.Click += new System.EventHandler(this.btn_Delete_Click); + // + // btn_Refresh + // + this.btn_Refresh.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Refresh.BackColor = System.Drawing.Color.FromArgb(107, 114, 128); + this.btn_Refresh.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Refresh.FlatAppearance.BorderSize = 0; + this.btn_Refresh.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Refresh.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Refresh.ForeColor = System.Drawing.Color.White; + this.btn_Refresh.Location = new System.Drawing.Point(1718, 12); + this.btn_Refresh.Name = "btn_Refresh"; + this.btn_Refresh.Size = new System.Drawing.Size(88, 30); + this.btn_Refresh.TabIndex = 5; + this.btn_Refresh.Text = "↻ 刷新"; + this.btn_Refresh.UseVisualStyleBackColor = false; + this.btn_Refresh.Click += new System.EventHandler(this.btn_Refresh_Click); + // + // btn_Export + // + this.btn_Export.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; + this.btn_Export.BackColor = System.Drawing.Color.FromArgb(5, 150, 105); + this.btn_Export.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_Export.FlatAppearance.BorderSize = 0; + this.btn_Export.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_Export.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold); + this.btn_Export.ForeColor = System.Drawing.Color.White; + this.btn_Export.Location = new System.Drawing.Point(1622, 12); + this.btn_Export.Name = "btn_Export"; + this.btn_Export.Size = new System.Drawing.Size(88, 30); + this.btn_Export.TabIndex = 6; + this.btn_Export.Text = "📥 导出"; + this.btn_Export.UseVisualStyleBackColor = false; + this.btn_Export.Click += new System.EventHandler(this.btn_Export_Click); + // + // dgv_Data — 数据表格 + // + this.dgv_Data.AllowUserToAddRows = false; + this.dgv_Data.AllowUserToDeleteRows = false; + this.dgv_Data.AllowUserToResizeRows = false; + this.dgv_Data.BackgroundColor = System.Drawing.Color.White; + this.dgv_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dgv_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SingleHorizontal; + this.dgv_Data.ColumnHeadersHeight = 42; + this.dgv_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + this.dgv_Data.ColumnHeadersDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(232, 237, 242); + this.dgv_Data.ColumnHeadersDefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold); + this.dgv_Data.ColumnHeadersDefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + this.dgv_Data.DefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(31, 41, 55); + this.dgv_Data.DefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 11F); + this.dgv_Data.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.FromArgb(219, 234, 254); + this.dgv_Data.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.FromArgb(30, 58, 95); + this.dgv_Data.DefaultCellStyle.Padding = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.dgv_Data.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(248, 250, 252); + this.dgv_Data.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgv_Data.EnableHeadersVisualStyles = false; + this.dgv_Data.GridColor = System.Drawing.Color.FromArgb(229, 231, 235); + this.dgv_Data.MultiSelect = false; + this.dgv_Data.Name = "dgv_Data"; + this.dgv_Data.ReadOnly = true; + this.dgv_Data.RowHeadersVisible = false; + this.dgv_Data.RowTemplate.Height = 38; + this.dgv_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgv_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dgv_Data.TabIndex = 1; + this.dgv_Data.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgv_Data_CellDoubleClick); + // + // pnl_StatusBar — 底部状态栏 + // + this.pnl_StatusBar.BackColor = System.Drawing.Color.White; + this.pnl_StatusBar.Controls.Add(this.lbl_RecordCount); + this.pnl_StatusBar.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnl_StatusBar.Location = new System.Drawing.Point(0, 964); + this.pnl_StatusBar.Name = "pnl_StatusBar"; + this.pnl_StatusBar.Padding = new System.Windows.Forms.Padding(16, 6, 16, 6); + this.pnl_StatusBar.Size = new System.Drawing.Size(1820, 36); + this.pnl_StatusBar.TabIndex = 2; + // + // lbl_RecordCount + // + this.lbl_RecordCount.AutoSize = true; + this.lbl_RecordCount.Font = new System.Drawing.Font("微软雅黑", 10F); + this.lbl_RecordCount.ForeColor = System.Drawing.Color.FromArgb(55, 65, 81); + this.lbl_RecordCount.Location = new System.Drawing.Point(16, 8); + this.lbl_RecordCount.Name = "lbl_RecordCount"; + this.lbl_RecordCount.Size = new System.Drawing.Size(82, 20); + this.lbl_RecordCount.TabIndex = 0; + this.lbl_RecordCount.Text = "共 0 条记录"; + // + // UC_WorkpieceMgmt + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.FromArgb(245, 247, 250); + this.Controls.Add(this.dgv_Data); + this.Controls.Add(this.pnl_StatusBar); + this.Controls.Add(this.pnl_Toolbar); + this.Name = "UC_WorkpieceMgmt"; + this.Size = new System.Drawing.Size(1820, 1000); + this.pnl_Toolbar.ResumeLayout(false); + this.pnl_Toolbar.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Data)).EndInit(); + this.pnl_StatusBar.ResumeLayout(false); + this.pnl_StatusBar.PerformLayout(); + this.ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.Panel pnl_Toolbar; + private System.Windows.Forms.TextBox txt_Search; + private System.Windows.Forms.Button btn_Search; + private System.Windows.Forms.Button btn_Add; + private System.Windows.Forms.Button btn_Edit; + private System.Windows.Forms.Button btn_Delete; + private System.Windows.Forms.Button btn_Refresh; + private System.Windows.Forms.Button btn_Export; + private System.Windows.Forms.DataGridView dgv_Data; + private System.Windows.Forms.Panel pnl_StatusBar; + private System.Windows.Forms.Label lbl_RecordCount; + } +} diff --git a/SCADA/Pages/UC_WorkpieceMgmt.cs b/SCADA/Pages/UC_WorkpieceMgmt.cs new file mode 100644 index 0000000..8d0ae31 --- /dev/null +++ b/SCADA/Pages/UC_WorkpieceMgmt.cs @@ -0,0 +1,654 @@ +using System; + + + +using System.Data; + + + +using System.Data.SqlClient; + + + +using System.Drawing; + + + +using System.Windows.Forms; + + + + + + + +namespace MesWork.Pages + + + +{ + + + + /// + + + + /// 工件管理页面 — 各机型参数维护(加油量/抽油量/密度) + + + + /// 对应存储过程:工件管理_查询、工件管理_增加、工件管理_编辑、工件管理_删除 + + + + /// + + + + public partial class UC_WorkpieceMgmt : UserControl + + + + { + + + + private const string SEARCH_HINT = "输入机型号搜索..."; + + + + private PagerBar _pager; + + + + + + + + public UC_WorkpieceMgmt() + + + + { + + + + InitializeComponent(); + + + + InitColumns(); + + + + _pager = new PagerBar(); + + + + _pager.PageChanged += (s, e) => LoadData(txt_Search.Text == SEARCH_HINT ? "" : txt_Search.Text.Trim()); + + + + this.Controls.Remove(pnl_StatusBar); + + + + this.Controls.Add(_pager); + + + + this.Controls.SetChildIndex(_pager, this.Controls.Count - 2); + + + + } + + + + + + + + /// + + + + /// 预设表格列(确保无数据时也能看到表头结构) + + + + /// + + + + private void InitColumns() + + + + { + + + + dgv_Data.AutoGenerateColumns = false; + + + + dgv_Data.Columns.Clear(); + + + + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "ID", HeaderText = "ID", DataPropertyName = "ID", Visible = false }); + + + + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "机型号", HeaderText = "机型号", DataPropertyName = "机型号", FillWeight = 120 }); + + + + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "说明", HeaderText = "说明", DataPropertyName = "说明", FillWeight = 130 }); + + + + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "加油量", HeaderText = "加油量(L)", DataPropertyName = "加油量", FillWeight = 70 }); + + + + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "抽油量", HeaderText = "抽油量(L)", DataPropertyName = "抽油量", FillWeight = 70 }); + + + + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "密度", HeaderText = "密度(kg/L)", DataPropertyName = "密度", FillWeight = 70 }); + + + + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "残油量上限", HeaderText = "残油量上限(L)", DataPropertyName = "残油量上限", FillWeight = 70 }); + + + + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "残油量下限", HeaderText = "残油量下限(L)", DataPropertyName = "残油量下限", FillWeight = 70 }); + + + + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "创建时间", HeaderText = "创建时间", DataPropertyName = "创建时间", FillWeight = 100 }); + + + + dgv_Data.Columns.Add(new DataGridViewTextBoxColumn { Name = "修改时间", HeaderText = "修改时间", DataPropertyName = "修改时间", FillWeight = 100 }); + + + + } + + + + + + + + public void LoadData(string keyword = "") + + + + { + + + + try + + + + { + + + + var (pageCountParam, itemCountParam) = PagerBar.CreateOutputParams(); + + + + var parms = new SqlParameter[] + + + + { + + + + new SqlParameter("@机型号", keyword ?? ""), + + + + new SqlParameter("@PageCurrent", _pager.CurrentPage), + + + + new SqlParameter("@PageSize", _pager.PageSize), + + + + pageCountParam, + + + + itemCountParam + + + + }; + + + + SqlOperation.ExecuteStoredProcedure("工件管理_分页查询", parms, out DataTable dt, out string err); + + + + if (dt != null) dgv_Data.DataSource = dt; + + + + _pager.UpdateState(pageCountParam, itemCountParam); + + + + } + + + + catch (Exception ex) + + + + { + + + + MessageBox.Show($"查询失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + + + + } + + + + } + + + + + + + + // ── 搜索框交互 ── + + + + private void txt_Search_GotFocus(object sender, EventArgs e) { CrudHelper.SearchBox_GotFocus(txt_Search, SEARCH_HINT); } + + + + private void txt_Search_LostFocus(object sender, EventArgs e) { CrudHelper.SearchBox_LostFocus(txt_Search, SEARCH_HINT); } + + + + private void txt_Search_KeyDown(object sender, KeyEventArgs e) { if (CrudHelper.SearchBox_KeyDown(e)) btn_Search_Click(sender, e); } + + + + + + + + // ── 按钮事件 ── + + + + private void btn_Search_Click(object sender, EventArgs e) { _pager.ResetPage(); LoadData(txt_Search.Text == SEARCH_HINT ? "" : txt_Search.Text.Trim()); } + + + + private void btn_Add_Click(object sender, EventArgs e) => ShowEditDialog(null); + + + + private void btn_Edit_Click(object sender, EventArgs e) + + + + { + + + + if (dgv_Data.CurrentRow != null) ShowEditDialog(dgv_Data.CurrentRow); + + + + else MessageBox.Show("请先选择一条记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + + + + } + + + + private void btn_Delete_Click(object sender, EventArgs e) + + + + { + + + + if (dgv_Data.CurrentRow == null) { MessageBox.Show("请先选择一条记录", "提示"); return; } + + + + string name = dgv_Data.CurrentRow.Cells["机型号"]?.Value?.ToString() ?? ""; + + + + if (MessageBox.Show($"确认删除工件「{name}」?", "确认删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) + + + + { + + + + try + + + + { + + + + var parms = new SqlParameter[] { new SqlParameter("@ID", int.Parse(dgv_Data.CurrentRow.Cells["ID"]?.Value?.ToString() ?? "0")) }; + + + + SqlOperation.ExecuteStoredProcedure("工件管理_删除", parms, out string err); + + + + LoadData(); + + + + } + + + + catch (Exception ex) { MessageBox.Show($"删除失败:{ex.Message}"); } + + + + } + + + + } + + + + private void btn_Refresh_Click(object sender, EventArgs e) { _pager.ResetPage(); LoadData(""); } + + + + private void dgv_Data_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) btn_Edit_Click(sender, e); } + + + + + + + + /// + + + + /// 新增/修改弹窗 + + + + /// + + + + private void ShowEditDialog(DataGridViewRow row) + + + + { + + + + bool isEdit = row != null; + + + + using (var dlg = CrudHelper.CreateEditDialog(isEdit ? "修改工件" : "新增工件", 500, 450)) + + + + { + + + + int y = 20; + + + + var txtModel = CrudHelper.AddTextField(dlg, "机型号:", ref y, isEdit ? row.Cells["机型号"]?.Value?.ToString() : "", inputX: 170, inputWidth: 280); + + + + var txtDesc = CrudHelper.AddTextField(dlg, "说明:", ref y, isEdit ? row.Cells["说明"]?.Value?.ToString() : "", inputX: 170, inputWidth: 280); + + + + var txtOilIn = CrudHelper.AddTextField(dlg, "加油量(L):", ref y, isEdit ? row.Cells["加油量"]?.Value?.ToString() : "0", inputX: 170, inputWidth: 280); + + + + var txtOilOut = CrudHelper.AddTextField(dlg, "抽油量(L):", ref y, isEdit ? row.Cells["抽油量"]?.Value?.ToString() : "0", inputX: 170, inputWidth: 280); + + + + var txtDensity = CrudHelper.AddTextField(dlg, "密度(kg/L):", ref y, isEdit ? row.Cells["密度"]?.Value?.ToString() : "0.85", inputX: 170, inputWidth: 280); + + + + var txtOilMax = CrudHelper.AddTextField(dlg, "残油量上限(L):", ref y, isEdit ? row.Cells["残油量上限"]?.Value?.ToString() : "0", inputX: 170, inputWidth: 280); + + + + var txtOilMin = CrudHelper.AddTextField(dlg, "残油量下限(L):", ref y, isEdit ? row.Cells["残油量下限"]?.Value?.ToString() : "0", inputX: 170, inputWidth: 280); + + + + CrudHelper.AddDialogButtons(dlg, ref y); + + + + + + + + if (dlg.ShowDialog() == DialogResult.OK) + + + + { + + + + try + + + + { + + + + string sp = isEdit ? "工件管理_编辑" : "工件管理_增加"; + + + + var pList = new System.Collections.Generic.List + + + + { + + + + new SqlParameter("@机型号", txtModel.Text.Trim()), + + + + new SqlParameter("@说明", txtDesc.Text.Trim()), + + + + new SqlParameter("@加油量", decimal.Parse(txtOilIn.Text)), + + + + new SqlParameter("@抽油量", decimal.Parse(txtOilOut.Text)), + + + + new SqlParameter("@密度", decimal.Parse(txtDensity.Text)), + + + + new SqlParameter("@残油量上限", decimal.Parse(txtOilMax.Text)), + + + + new SqlParameter("@残油量下限", decimal.Parse(txtOilMin.Text)) + + + + }; + + + + if (isEdit) pList.Insert(0, new SqlParameter("@ID", int.Parse(row.Cells["ID"]?.Value?.ToString() ?? "0"))); + + + + SqlOperation.ExecuteStoredProcedure(sp, pList.ToArray(), out string err); + + + + LoadData(); + + + + } + + + + catch (Exception ex) { MessageBox.Show($"保存失败:{ex.Message}"); } + + + + } + + + + } + + + + } + + + + + + + + private void btn_Export_Click(object sender, EventArgs e) + + + + { + + + + CrudHelper.ExportToExcel("工件管理", "工件管理", () => + + + + { + + + + string keyword = CrudHelper.GetSearchKeyword(txt_Search, SEARCH_HINT); + + + + var (pageCountParam, itemCountParam) = PagerBar.CreateOutputParams(); + + + + var parms = new SqlParameter[] + + + + { + + + + new SqlParameter("@机型号", keyword), + + + + new SqlParameter("@PageCurrent", 1), + + + + new SqlParameter("@PageSize", 9999999), + + + + pageCountParam, itemCountParam + + + + }; + + + + SqlOperation.ExecuteStoredProcedure("工件管理_分页查询", parms, out DataTable dt, out string err); + + + + return dt; + + + + }, dgv_Data.Rows.Count > 0); + + + + } + + + + + + + + protected override void OnVisibleChanged(EventArgs e) { base.OnVisibleChanged(e); if (Visible && dgv_Data.DataSource == null) LoadData(); } + + + + } + + + +} + diff --git a/SCADA/Pages/UC_WorkpieceMgmt.resx b/SCADA/Pages/UC_WorkpieceMgmt.resx new file mode 100644 index 0000000..5236701 --- /dev/null +++ b/SCADA/Pages/UC_WorkpieceMgmt.resx @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + text/microsoft-resx + 2.0 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + diff --git a/SCADA/Properties/AssemblyInfo.cs b/SCADA/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..58ca676 --- /dev/null +++ b/SCADA/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("MesWork")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MesWork")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("a8d0b4ef-e223-4b9a-b2d9-0156b7b8b073")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SCADA/Properties/Resources.Designer.cs b/SCADA/Properties/Resources.Designer.cs new file mode 100644 index 0000000..cd05a74 --- /dev/null +++ b/SCADA/Properties/Resources.Designer.cs @@ -0,0 +1,983 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace WC_GKJ_OIL.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WC_GKJ_OIL.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap _002_列表 { + get { + object obj = ResourceManager.GetObject("_002_列表", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap _0780fca3def52d8a02649c7aa2f8093a { + get { + object obj = ResourceManager.GetObject("_0780fca3def52d8a02649c7aa2f8093a", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap action_Cancel_16xLG { + get { + object obj = ResourceManager.GetObject("action_Cancel_16xLG", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon bitbug_favicon { + get { + object obj = ResourceManager.GetObject("bitbug_favicon", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon BOSS_数据管理 { + get { + object obj = ResourceManager.GetObject("BOSS_数据管理", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap BOSS_数据管理1 { + get { + object obj = ResourceManager.GetObject("BOSS_数据管理1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon excelICON { + get { + object obj = ResourceManager.GetObject("excelICON", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap HMI { + get { + object obj = ResourceManager.GetObject("HMI", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap JD { + get { + object obj = ResourceManager.GetObject("JD", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon jk { + get { + object obj = ResourceManager.GetObject("jk", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap MBE风格多色图标_密码 { + get { + object obj = ResourceManager.GetObject("MBE风格多色图标_密码", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap panlClose { + get { + object obj = ResourceManager.GetObject("panlClose", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap ssbj { + get { + object obj = ResourceManager.GetObject("ssbj", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap staticjd { + get { + object obj = ResourceManager.GetObject("staticjd", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 上传 { + get { + object obj = ResourceManager.GetObject("上传", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 上载 { + get { + object obj = ResourceManager.GetObject("上载", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 下载 { + get { + object obj = ResourceManager.GetObject("下载", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 业务 { + get { + object obj = ResourceManager.GetObject("业务", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 任务监控和查询 { + get { + object obj = ResourceManager.GetObject("任务监控和查询", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 保存 { + get { + object obj = ResourceManager.GetObject("保存", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 信息_记录 { + get { + object obj = ResourceManager.GetObject("信息_记录", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 关闭 { + get { + object obj = ResourceManager.GetObject("关闭", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 关闭系统 { + get { + object obj = ResourceManager.GetObject("关闭系统", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 写入托盘 { + get { + object obj = ResourceManager.GetObject("写入托盘", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon 分布图 { + get { + object obj = ResourceManager.GetObject("分布图", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 分布图1 { + get { + object obj = ResourceManager.GetObject("分布图1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 列表 { + get { + object obj = ResourceManager.GetObject("列表", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 列表2 { + get { + object obj = ResourceManager.GetObject("列表2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 删除 { + get { + object obj = ResourceManager.GetObject("删除", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 刷新 { + get { + object obj = ResourceManager.GetObject("刷新", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 动态数据查询 { + get { + object obj = ResourceManager.GetObject("动态数据查询", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 合作 { + get { + object obj = ResourceManager.GetObject("合作", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 图表_柱 { + get { + object obj = ResourceManager.GetObject("图表_柱", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 图表_线_通用_统计 { + get { + object obj = ResourceManager.GetObject("图表_线_通用_统计", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 图表_饼 { + get { + object obj = ResourceManager.GetObject("图表_饼", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 增加 { + get { + object obj = ResourceManager.GetObject("增加", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 备份_复制 { + get { + object obj = ResourceManager.GetObject("备份_复制", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 审核_盖章 { + get { + object obj = ResourceManager.GetObject("审核_盖章", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 密码 { + get { + object obj = ResourceManager.GetObject("密码", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 导入 { + get { + object obj = ResourceManager.GetObject("导入", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 导出 { + get { + object obj = ResourceManager.GetObject("导出", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 工件信息 { + get { + object obj = ResourceManager.GetObject("工件信息", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 工作台 { + get { + object obj = ResourceManager.GetObject("工作台", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 工具 { + get { + object obj = ResourceManager.GetObject("工具", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 布局图 { + get { + object obj = ResourceManager.GetObject("布局图", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 帮助 { + get { + object obj = ResourceManager.GetObject("帮助", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 异常_危险 { + get { + object obj = ResourceManager.GetObject("异常_危险", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 手动打印 { + get { + object obj = ResourceManager.GetObject("手动打印", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 打印机 { + get { + object obj = ResourceManager.GetObject("打印机", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 按键分割线 { + get { + object obj = ResourceManager.GetObject("按键分割线", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 按键分割线浅 { + get { + object obj = ResourceManager.GetObject("按键分割线浅", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 搜索 { + get { + object obj = ResourceManager.GetObject("搜索", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 操作管理 { + get { + object obj = ResourceManager.GetObject("操作管理", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 文档 { + get { + object obj = ResourceManager.GetObject("文档", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 断开 { + get { + object obj = ResourceManager.GetObject("断开", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 断开状态 { + get { + object obj = ResourceManager.GetObject("断开状态", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 断开连接 { + get { + object obj = ResourceManager.GetObject("断开连接", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 新增_添加 { + get { + object obj = ResourceManager.GetObject("新增_添加", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon 日志 { + get { + object obj = ResourceManager.GetObject("日志", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 日志1 { + get { + object obj = ResourceManager.GetObject("日志1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 更多 { + get { + object obj = ResourceManager.GetObject("更多", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 权限角色管理 { + get { + object obj = ResourceManager.GetObject("权限角色管理", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 正确_成功 { + get { + object obj = ResourceManager.GetObject("正确_成功", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 添加 { + get { + object obj = ResourceManager.GetObject("添加", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 清洗信息 { + get { + object obj = ResourceManager.GetObject("清洗信息", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 用户_账号_我的 { + get { + object obj = ResourceManager.GetObject("用户_账号_我的", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 用户_账号_我的_未登录 { + get { + object obj = ResourceManager.GetObject("用户_账号_我的_未登录", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 登出2 { + get { + object obj = ResourceManager.GetObject("登出2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 登录 { + get { + object obj = ResourceManager.GetObject("登录", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 筛选 { + get { + object obj = ResourceManager.GetObject("筛选", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 系统管理 { + get { + object obj = ResourceManager.GetObject("系统管理", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 系统管理和监控服务 { + get { + object obj = ResourceManager.GetObject("系统管理和监控服务", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 组群_角色 { + get { + object obj = ResourceManager.GetObject("组群_角色", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 编辑_修改 { + get { + object obj = ResourceManager.GetObject("编辑_修改", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 能耗信息 { + get { + object obj = ResourceManager.GetObject("能耗信息", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 解锁 { + get { + object obj = ResourceManager.GetObject("解锁", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 记录2 { + get { + object obj = ResourceManager.GetObject("记录2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 质控管理 { + get { + object obj = ResourceManager.GetObject("质控管理", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 辅助_协助 { + get { + object obj = ResourceManager.GetObject("辅助_协助", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 返回2 { + get { + object obj = ResourceManager.GetObject("返回2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 进度_沙漏 { + get { + object obj = ResourceManager.GetObject("进度_沙漏", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 连接 { + get { + object obj = ResourceManager.GetObject("连接", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 连接状态 { + get { + object obj = ResourceManager.GetObject("连接状态", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 退出 { + get { + object obj = ResourceManager.GetObject("退出", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon 配置 { + get { + object obj = ResourceManager.GetObject("配置", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 配置1 { + get { + object obj = ResourceManager.GetObject("配置1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon 配置2 { + get { + object obj = ResourceManager.GetObject("配置2", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 配置21 { + get { + object obj = ResourceManager.GetObject("配置21", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 重新加载数据 { + get { + object obj = ResourceManager.GetObject("重新加载数据", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 锁定 { + get { + object obj = ResourceManager.GetObject("锁定", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 错误_失败 { + get { + object obj = ResourceManager.GetObject("错误_失败", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 零件管理 { + get { + object obj = ResourceManager.GetObject("零件管理", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/SCADA/Properties/Resources.resx b/SCADA/Properties/Resources.resx new file mode 100644 index 0000000..8048d82 --- /dev/null +++ b/SCADA/Properties/Resources.resx @@ -0,0 +1,397 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\icon\返回2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\HMI.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\列表2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\信息_记录.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\辅助_协助.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\更多.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\帮助.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\JD.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\配置2.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\BOSS-数据管理.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\重新加载数据.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\导出.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\MBE风格多色图标-密码.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\断开.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\excelICON.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\系统管理.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\关闭系统.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\登录.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\刷新.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\导入.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\零件管理.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\连接状态.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\操作管理.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\断开连接.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\按键分割线.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\任务监控和查询.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\分布图.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\系统管理和监控服务.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\ssbj.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\解锁.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\配置.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\002_列表.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\panlClose.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\文档.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\正确_成功.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\按键分割线浅.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\异常_危险.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\bitbug_favicon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\连接.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\图表_线_通用_统计.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\下载.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\搜索.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\上传.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\图表_柱.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\用户_账号_我的_未登录.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\工作台.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\新增_添加.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\分布图.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\动态数据查询.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\筛选.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\图表_饼.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\action_Cancel_16xLG.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\权限角色管理.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\0780fca3def52d8a02649c7aa2f8093a.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\编辑_修改.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\关闭.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\手动打印.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\上载.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\BOSS-数据管理.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\保存.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\列表.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\合作.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\断开状态.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\配置2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\日志.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\错误_失败.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\用户_账号_我的.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\业务.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\工具.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\jk.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\进度_沙漏.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\记录2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\质控管理.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\登出2.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\删除.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\添加.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\备份_复制.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\写入托盘.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\配置.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\日志.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\密码.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\锁定.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\staticjd.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\组群_角色.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\增加.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\打印机.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\审核_盖章.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\退出.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\布局图.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\工件信息.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\清洗信息.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icon\能耗信息.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/SCADA/Properties/Settings.Designer.cs b/SCADA/Properties/Settings.Designer.cs new file mode 100644 index 0000000..b24f89f --- /dev/null +++ b/SCADA/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace WC_GKJ_OIL.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/SCADA/Properties/Settings.settings b/SCADA/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/SCADA/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/SCADA/Resources/login_bg.png b/SCADA/Resources/login_bg.png new file mode 100644 index 0000000..feec865 Binary files /dev/null and b/SCADA/Resources/login_bg.png differ diff --git a/SCADA/WC_GKJ_OIL.csproj b/SCADA/WC_GKJ_OIL.csproj new file mode 100644 index 0000000..faa290c --- /dev/null +++ b/SCADA/WC_GKJ_OIL.csproj @@ -0,0 +1,363 @@ + + + + + Debug + AnyCPU + {A8D0B4EF-E223-4B9A-B2D9-0156B7B8B073} + WinExe + WC_GKJ_OIL + WC_GKJ_OIL + v4.8 + 512 + true + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + AnyCPU + true + full + false + ..\WC_GKJ_OIL_EXE\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + 任务管理.ico + + + + app.manifest + + + + ..\DLL\BasicData.dll + + + ..\DLL\BouncyCastle.Crypto.dll + + + ..\DLL\ConLink.dll + + + ..\DLL\ConLink19.dll + + + ..\DLL\DataLinkMesWork.dll + + + ..\DLL\DynamicExpresso.Core.dll + + + ..\DLL\ICSharpCode.SharpZipLib.dll + + + ..\DLL\MesWork.DeviceDriver.dll + + + ..\DLL\MesWork.MQTT.dll + + + ..\DLL\MQTTnet.dll + + + ..\DLL\MQTTnet.Extensions.ManagedClient.dll + + + ..\DLL\Newtonsoft.Json.dll + + + ..\DLL\NPOI.dll + + + ..\DLL\NPOI.OOXML.dll + + + ..\DLL\NPOI.OpenXml4Net.dll + + + ..\DLL\NPOI.OpenXmlFormats.dll + + + ..\DLL\Opc.Ua.Client.dll + + + ..\DLL\Opc.Ua.Configuration.dll + + + ..\DLL\Opc.Ua.Core.dll + + + ..\DLL\OpcUaHelper.dll + + + ..\DLL\Rhino3dm.dll + + + + False + ..\DLL\System.Buffers.dll + + + + + + + + + False + ..\DLL\System.Net.Http.Formatting.dll + + + False + ..\DLL\System.Runtime.CompilerServices.Unsafe.dll + + + + ..\DLL\System.Web.Cors.dll + + + ..\DLL\System.Web.Http.dll + + + ..\DLL\System.Web.Http.Cors.dll + + + ..\DLL\System.Web.Http.SelfHost.dll + + + + + + ..\DLL\Ubiety.Dns.Core.dll + + + ..\DLL\WeifenLuo.WinFormsUI.Docking.dll + + + ..\DLL\WeifenLuo.WinFormsUI.Docking.ThemeVS2015.dll + + + + + + Form + + + Frm_Login.cs + + + + + + + Form + + + Form + + + + + Form + + + Form + + + LogRecord.cs + + + + + + + Form + + + MAIN_PAGE.cs + + + + + + UserControl + + + UC_Weighing.cs + + + UserControl + + + UC_UserMgmt.cs + + + UserControl + + + UC_WorkpieceMgmt.cs + + + UserControl + + + UC_ToolMgmt.cs + + + Component + + + UserControl + + + UC_Report.cs + + + UserControl + + + UC_StationRecord.cs + + + UserControl + + + UC_Statistics.cs + + + + + UserControl + + + UC_SystemSettings.cs + + + UserControl + + + UC_LogRecord.cs + + + Frm_Login.cs + + + LogRecord.cs + + + MAIN_PAGE.cs + Designer + + + UC_Weighing.cs + + + UC_UserMgmt.cs + + + UC_WorkpieceMgmt.cs + + + UC_ToolMgmt.cs + + + UC_Report.cs + + + UC_Statistics.cs + + + UC_LogRecord.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + PreserveNewest + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + PreserveNewest + + + + + + + + False + Microsoft .NET Framework 4.6.1 %28x86 和 x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + {1ac112c4-2400-4d03-a26d-2e3ace6fe6d4} + 01_MW_Log + + + + + 0.20.0 + + + 3.8.1.5 + + + + \ No newline at end of file diff --git a/SCADA/WebApi/ApiTools.cs b/SCADA/WebApi/ApiTools.cs new file mode 100644 index 0000000..a51e14d --- /dev/null +++ b/SCADA/WebApi/ApiTools.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web.Http; +using System.Net.Http; +using System.Text.RegularExpressions; + +namespace WebApi +{ + public enum ResponseCode + { + Fail = 00000, + Success = 00200, + } + + public class ApiTools + { + private string msgModel = "{{\"code\":{0},\"message\":\"{1}\",\"result\":{2}}}"; + public ApiTools() + { + } + public HttpResponseMessage MsgFormat(ResponseCode code, string explanation, string result) + { + string r = @"^(\-|\+)?\d+(\.\d+)?$"; + string json = string.Empty; + if (Regex.IsMatch(result, r) || result.ToLower() == "true" || result.ToLower() == "false" || result == "[]" || result.Contains('{')) + { + json = string.Format(msgModel, (int)code, explanation, result); + } + else + { + if (result.Contains('"')) + { + json = string.Format(msgModel, (int)code, explanation, result); + } + else + { + json = string.Format(msgModel, (int)code, explanation, "\"" + result + "\""); + } + } + return new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") }; + } + } +} diff --git a/SCADA/WebApi/CallWebApi.cs b/SCADA/WebApi/CallWebApi.cs new file mode 100644 index 0000000..a836a40 --- /dev/null +++ b/SCADA/WebApi/CallWebApi.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace SlMesDbIterface +{ + public partial class MyHttpRequest { + + public static string MyPost(string url,string jsonStr) + { + string result = ""; + + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "text/html, application/xhtml+xml, application/json, */*"; + req.Proxy = null; + req.KeepAlive = false; + + byte[] data = Encoding.UTF8.GetBytes(jsonStr); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + + + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + Console.WriteLine(result); + + + } + catch (Exception err) + { + Console.WriteLine(" " + err.Message); + } + + return result; + } + + public static string MyPost(string url,Dictionary paramDict, string jsonStr) + { + string result = ""; + + try + { + StringBuilder builder = new StringBuilder(); + + builder.Append(url); + if (paramDict.Count > 0) + { + builder.Append("?"); + int i = 0; + foreach (var item in paramDict) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + } + + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(builder.ToString()); + req.Method = "POST"; + req.ContentType = "text/html, application/xhtml+xml, application/json, */*"; + req.Proxy = null; + req.KeepAlive = false; + + byte[] data = Encoding.UTF8.GetBytes(jsonStr); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + + + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + Console.WriteLine(result); + + + } + catch (Exception err) + { + Console.WriteLine(" " + err.Message); + } + + return result; + } + + public static string MyGet(string url, Dictionary paramDict) + { + string result = ""; + + StringBuilder builder = new StringBuilder(); + + builder.Append(url); + if (paramDict.Count > 0) + { + builder.Append("?"); + int i = 0; + foreach (var item in paramDict) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + } + + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(builder.ToString()); + req.Method = "GET"; + req.ContentType = "text/html, application/xhtml+xml, application/json, */*"; + req.Proxy = null; + req.KeepAlive = false; + + HttpWebResponse response = (HttpWebResponse)req.GetResponse(); + Stream rs = response.GetResponseStream(); + StreamReader sr = new StreamReader(rs, Encoding.UTF8); + result = sr.ReadToEnd(); + sr.Close(); + rs.Close(); + + return result; + } + + } +} diff --git a/SCADA/WebApi/HttpCli.cs b/SCADA/WebApi/HttpCli.cs new file mode 100644 index 0000000..cb7d4bc --- /dev/null +++ b/SCADA/WebApi/HttpCli.cs @@ -0,0 +1,362 @@ +using MesWork; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace PLMTEST +{ + public class HttpCli + { + + + /// + /// 指定Url地址使用Get 方式获取全部字符串 + /// + /// 请求链接地址 + /// + public static string Get(string url) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + try + { + //获取内容 + using (StreamReader reader = new StreamReader(stream)) + { + result = reader.ReadToEnd(); + } + } + finally + { + stream.Close(); + } + return result; + } + + public static void GetFile(string url,string path) + { + WebRequest request = WebRequest.Create(url); + WebResponse response = request.GetResponse(); + if (response.ContentType.ToLower().Length > 0) + { + using (Stream reader = response.GetResponseStream()) + { + using (FileStream writer = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)) + { + byte[] buffer = new byte[1024]; + int c = 0; + while ((c = reader.Read(buffer, 0, buffer.Length)) > 0) + { + writer.Write(buffer, 0, c); + } + } + } + //HttpContext + } + } + + public static byte[] GetFile_Bytes(string url) + { + byte[] bytesAll = null; + WebRequest request = WebRequest.Create(url); + WebResponse response = request.GetResponse(); + if (response.ContentType.ToLower().Length > 0) + { + using (Stream reader = response.GetResponseStream()) + { + MemoryStream ms = new MemoryStream(); + byte[] buffer = new byte[1024]; + while (true) + { + int sz = reader.Read(buffer, 0, 1024); + if (sz == 0) break; + ms.Write(buffer, 0, sz); + } + bytesAll = ms.ToArray(); + } + } + + //如是图片 + //System.Drawing.Image img = System.Drawing.Image.FromStream(ms); + + return bytesAll; + + } + + + + + + + + + + /// + /// 发送Get请求 + /// + /// 地址 + /// 请求参数定义 + /// + public static string Get(string url, Dictionary dic) + { + string result = ""; + StringBuilder builder = new StringBuilder(); + builder.Append(url); + if (dic.Count > 0) + { + builder.Append("?"); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + } + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(builder.ToString()); + //添加参数 + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + try + { + //获取内容 + using (StreamReader reader = new StreamReader(stream)) + { + result = reader.ReadToEnd(); + } + } + finally + { + stream.Close(); + } + return result; + } + + + + /// + /// 指定Post地址使用Get 方式获取全部字符串 + /// + /// 请求后台地址 + /// + public static string Post(string url) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + + + /// + /// 指定Post地址使用Get 方式获取全部字符串 + /// + /// 请求后台地址 + /// + public static string Post(string url, Dictionary dic) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/x-www-form-urlencoded"; + #region 添加Post 参数 + StringBuilder builder = new StringBuilder(); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + + /// + /// 指定Post地址使用Get 方式获取全部字符串 + /// + /// 请求后台地址 + /// Post提交数据内容(utf-8编码的) + /// + public static string Post_Authorization(string url, string content,out string error ) + { + string result = ""; + error = ""; + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Timeout = 30000; + req.Method = "POST"; + req.ContentType = "application/json"; + + // 添加自定义 Header + req.Headers.Add("Authorization", MesWorkForm.AuthorizationSet); + req.Headers.Add("uuid", Guid.NewGuid().ToString().ToUpper()); + + #region 添加Post 参数 + byte[] data = Encoding.UTF8.GetBytes(content); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + } + catch (Exception err) + { + error = $"WebApi Post请求调用错误:{err.Message}"; + } + + return result; + } + public static string Post(string url, string content, out string error) + { + string result = ""; + error = ""; + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Timeout = 30000; + req.Method = "POST"; + req.ContentType = "application/json"; + + #region 添加Post 参数 + byte[] data = Encoding.UTF8.GetBytes(content); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + } + catch (Exception err) + { + error = $"WebApi Post请求调用错误:{err.Message}"; + } + + return result; + } + + + + + /// + /// Http下载文件 + /// + /// 下载地址 + /// 存放完整路径(含文件名) + /// 每次多的大小 + /// 下载操作是否成功 + + public static bool DownLoadFiles(string uri, string filefullpath, int size = 1000000) + { + try + { + if (File.Exists(filefullpath)) + { + try + { + File.Delete(filefullpath); + } + catch (Exception ex) + { + return false; + } + } + + string fileDirectory = System.IO.Path.GetDirectoryName(filefullpath); + + if (!Directory.Exists(fileDirectory)) + { + Directory.CreateDirectory(fileDirectory); + } + + FileStream fs = new FileStream(filefullpath, FileMode.Create); + + byte[] buffer = new byte[size]; + + HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri); + + request.Timeout = 100000; + + request.AddRange((int)fs.Length); + + Stream ns = request.GetResponse().GetResponseStream(); + + long contentLength = request.GetResponse().ContentLength; + + int length = ns.Read(buffer, 0, buffer.Length); + + while (length > 0) + { + fs.Write(buffer,0 , length); + buffer = new byte[size]; + length = ns.Read(buffer, 0, buffer.Length); + } + + fs.Close(); + + return true; + } + catch (Exception ex) + { + return false; + } + + } + + + + + + } +} diff --git a/SCADA/WebApi/InitServer.cs b/SCADA/WebApi/InitServer.cs new file mode 100644 index 0000000..0a10dd5 --- /dev/null +++ b/SCADA/WebApi/InitServer.cs @@ -0,0 +1,147 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Net.Http.Formatting; +using System.Net.Http.Headers; +using System.Text; +using System.Web.Http; +using System.Web.Http.Cors; +using System.Web.Http.SelfHost; + +namespace WebApi +{ + /// + /// + /// + public class InitServer + { + /// + /// + /// + HttpSelfHostConfiguration config = null; + /// + /// + /// + HttpSelfHostServer server = null; + /// + /// + /// + /// + public InitServer(int port) + { + config = new HttpSelfHostConfiguration($"http://localhost:{port}"); + + config.EnableCors(new EnableCorsAttribute("*", "*", "*")); + + config.MapHttpAttributeRoutes(); + + //config.Routes.MapHttpRoute( + // name: "DefaultApi", + // routeTemplate: "api/{controller}/{id}", + // defaults: new { id = RouteParameter.Optional } + //); + + // 自定义路由匹配到action + config.Routes.MapHttpRoute( + name: "API Default", + routeTemplate: "api/{controller}/{action}/{id}", + defaults: new { id = RouteParameter.Optional } + ); + + server = new HttpSelfHostServer(config); + + server.OpenAsync().Wait(); + + } + /// + /// + /// + /// + + public void Close() + { + server.CloseAsync(); + } + /// + /// + /// + public class JsonContentNegotiator : IContentNegotiator + { + /// + /// + /// + private readonly JsonMediaTypeFormatter _jsonFormatter; + /// + /// + /// + /// + public JsonContentNegotiator(JsonMediaTypeFormatter formatter) + { + _jsonFormatter = formatter; + } + /// + /// + /// + /// + /// + /// + /// + public ContentNegotiationResult Negotiate(Type type, HttpRequestMessage request, IEnumerable formatters) + { + var result = new ContentNegotiationResult(_jsonFormatter, new MediaTypeHeaderValue("application/json")); + return result; + } + + public static string Postring1(string url, string token, Dictionary dic) + { + string results = ""; + //url = "http://172.16.22.15:8000/" + url; + + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/x-www-form-urlencoded"; + req.Headers.Add("Authorization", "Bearer " + token); + + StringBuilder builder = new StringBuilder(); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + req.ContentLength = data.Length; + try + { + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + results = reader.ReadToEnd(); + } + return results; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return e.Message; + throw; + } + + } + + + + } + } +} diff --git a/SCADA/_codex_verify/BasicData.dll b/SCADA/_codex_verify/BasicData.dll new file mode 100644 index 0000000..5008ace Binary files /dev/null and b/SCADA/_codex_verify/BasicData.dll differ diff --git a/SCADA/_codex_verify/BouncyCastle.Crypto.dll b/SCADA/_codex_verify/BouncyCastle.Crypto.dll new file mode 100644 index 0000000..0310983 Binary files /dev/null and b/SCADA/_codex_verify/BouncyCastle.Crypto.dll differ diff --git a/SCADA/_codex_verify/ConLink.dll b/SCADA/_codex_verify/ConLink.dll new file mode 100644 index 0000000..fa95f29 Binary files /dev/null and b/SCADA/_codex_verify/ConLink.dll differ diff --git a/SCADA/_codex_verify/ConLink19.dll b/SCADA/_codex_verify/ConLink19.dll new file mode 100644 index 0000000..05a03cc Binary files /dev/null and b/SCADA/_codex_verify/ConLink19.dll differ diff --git a/SCADA/_codex_verify/DataLinkMesWork.dll b/SCADA/_codex_verify/DataLinkMesWork.dll new file mode 100644 index 0000000..57fcd25 Binary files /dev/null and b/SCADA/_codex_verify/DataLinkMesWork.dll differ diff --git a/SCADA/_codex_verify/DynamicExpresso.Core.dll b/SCADA/_codex_verify/DynamicExpresso.Core.dll new file mode 100644 index 0000000..e150894 Binary files /dev/null and b/SCADA/_codex_verify/DynamicExpresso.Core.dll differ diff --git a/SCADA/_codex_verify/ICSharpCode.SharpZipLib.dll b/SCADA/_codex_verify/ICSharpCode.SharpZipLib.dll new file mode 100644 index 0000000..84e8c68 Binary files /dev/null and b/SCADA/_codex_verify/ICSharpCode.SharpZipLib.dll differ diff --git a/SCADA/_codex_verify/MQTTnet.Extensions.ManagedClient.dll b/SCADA/_codex_verify/MQTTnet.Extensions.ManagedClient.dll new file mode 100644 index 0000000..99035f6 Binary files /dev/null and b/SCADA/_codex_verify/MQTTnet.Extensions.ManagedClient.dll differ diff --git a/SCADA/_codex_verify/MQTTnet.dll b/SCADA/_codex_verify/MQTTnet.dll new file mode 100644 index 0000000..2951433 Binary files /dev/null and b/SCADA/_codex_verify/MQTTnet.dll differ diff --git a/SCADA/_codex_verify/MW_Log.dll b/SCADA/_codex_verify/MW_Log.dll new file mode 100644 index 0000000..cb2a7e0 Binary files /dev/null and b/SCADA/_codex_verify/MW_Log.dll differ diff --git a/SCADA/_codex_verify/MesWork.DeviceDriver.dll b/SCADA/_codex_verify/MesWork.DeviceDriver.dll new file mode 100644 index 0000000..730f828 Binary files /dev/null and b/SCADA/_codex_verify/MesWork.DeviceDriver.dll differ diff --git a/SCADA/_codex_verify/NPOI.OOXML.dll b/SCADA/_codex_verify/NPOI.OOXML.dll new file mode 100644 index 0000000..031d41d Binary files /dev/null and b/SCADA/_codex_verify/NPOI.OOXML.dll differ diff --git a/SCADA/_codex_verify/NPOI.OpenXml4Net.dll b/SCADA/_codex_verify/NPOI.OpenXml4Net.dll new file mode 100644 index 0000000..8da4ac2 Binary files /dev/null and b/SCADA/_codex_verify/NPOI.OpenXml4Net.dll differ diff --git a/SCADA/_codex_verify/NPOI.OpenXmlFormats.dll b/SCADA/_codex_verify/NPOI.OpenXmlFormats.dll new file mode 100644 index 0000000..4a8f87b Binary files /dev/null and b/SCADA/_codex_verify/NPOI.OpenXmlFormats.dll differ diff --git a/SCADA/_codex_verify/NPOI.dll b/SCADA/_codex_verify/NPOI.dll new file mode 100644 index 0000000..1a500e9 Binary files /dev/null and b/SCADA/_codex_verify/NPOI.dll differ diff --git a/SCADA/_codex_verify/Newtonsoft.Json.dll b/SCADA/_codex_verify/Newtonsoft.Json.dll new file mode 100644 index 0000000..7af125a Binary files /dev/null and b/SCADA/_codex_verify/Newtonsoft.Json.dll differ diff --git a/SCADA/_codex_verify/Opc.Ua.Client.dll b/SCADA/_codex_verify/Opc.Ua.Client.dll new file mode 100644 index 0000000..8874d8f Binary files /dev/null and b/SCADA/_codex_verify/Opc.Ua.Client.dll differ diff --git a/SCADA/_codex_verify/Opc.Ua.Configuration.dll b/SCADA/_codex_verify/Opc.Ua.Configuration.dll new file mode 100644 index 0000000..b3f3970 Binary files /dev/null and b/SCADA/_codex_verify/Opc.Ua.Configuration.dll differ diff --git a/SCADA/_codex_verify/Opc.Ua.Core.dll b/SCADA/_codex_verify/Opc.Ua.Core.dll new file mode 100644 index 0000000..ee01d0d Binary files /dev/null and b/SCADA/_codex_verify/Opc.Ua.Core.dll differ diff --git a/SCADA/_codex_verify/OpcUaHelper.dll b/SCADA/_codex_verify/OpcUaHelper.dll new file mode 100644 index 0000000..1409de0 Binary files /dev/null and b/SCADA/_codex_verify/OpcUaHelper.dll differ diff --git a/SCADA/_codex_verify/ReaLTaiizor.dll b/SCADA/_codex_verify/ReaLTaiizor.dll new file mode 100644 index 0000000..f465c26 Binary files /dev/null and b/SCADA/_codex_verify/ReaLTaiizor.dll differ diff --git a/SCADA/_codex_verify/Resources/login_bg.png b/SCADA/_codex_verify/Resources/login_bg.png new file mode 100644 index 0000000..feec865 Binary files /dev/null and b/SCADA/_codex_verify/Resources/login_bg.png differ diff --git a/SCADA/_codex_verify/Rhino3dm.dll b/SCADA/_codex_verify/Rhino3dm.dll new file mode 100644 index 0000000..76d1cb8 Binary files /dev/null and b/SCADA/_codex_verify/Rhino3dm.dll differ diff --git a/SCADA/_codex_verify/S7.Net.dll b/SCADA/_codex_verify/S7.Net.dll new file mode 100644 index 0000000..b4211db Binary files /dev/null and b/SCADA/_codex_verify/S7.Net.dll differ diff --git a/SCADA/_codex_verify/System.Buffers.dll b/SCADA/_codex_verify/System.Buffers.dll new file mode 100644 index 0000000..f2d83c5 Binary files /dev/null and b/SCADA/_codex_verify/System.Buffers.dll differ diff --git a/SCADA/_codex_verify/System.Memory.dll b/SCADA/_codex_verify/System.Memory.dll new file mode 100644 index 0000000..4617199 Binary files /dev/null and b/SCADA/_codex_verify/System.Memory.dll differ diff --git a/SCADA/_codex_verify/System.Net.Http.Formatting.dll b/SCADA/_codex_verify/System.Net.Http.Formatting.dll new file mode 100644 index 0000000..e9e80be Binary files /dev/null and b/SCADA/_codex_verify/System.Net.Http.Formatting.dll differ diff --git a/SCADA/_codex_verify/System.Numerics.Vectors.dll b/SCADA/_codex_verify/System.Numerics.Vectors.dll new file mode 100644 index 0000000..0865972 Binary files /dev/null and b/SCADA/_codex_verify/System.Numerics.Vectors.dll differ diff --git a/SCADA/_codex_verify/System.Runtime.CompilerServices.Unsafe.dll b/SCADA/_codex_verify/System.Runtime.CompilerServices.Unsafe.dll new file mode 100644 index 0000000..de9e124 Binary files /dev/null and b/SCADA/_codex_verify/System.Runtime.CompilerServices.Unsafe.dll differ diff --git a/SCADA/_codex_verify/System.Web.Cors.dll b/SCADA/_codex_verify/System.Web.Cors.dll new file mode 100644 index 0000000..6f3da24 Binary files /dev/null and b/SCADA/_codex_verify/System.Web.Cors.dll differ diff --git a/SCADA/_codex_verify/System.Web.Http.Cors.dll b/SCADA/_codex_verify/System.Web.Http.Cors.dll new file mode 100644 index 0000000..fd0b539 Binary files /dev/null and b/SCADA/_codex_verify/System.Web.Http.Cors.dll differ diff --git a/SCADA/_codex_verify/System.Web.Http.SelfHost.dll b/SCADA/_codex_verify/System.Web.Http.SelfHost.dll new file mode 100644 index 0000000..852728e Binary files /dev/null and b/SCADA/_codex_verify/System.Web.Http.SelfHost.dll differ diff --git a/SCADA/_codex_verify/System.Web.Http.dll b/SCADA/_codex_verify/System.Web.Http.dll new file mode 100644 index 0000000..7e3bd30 Binary files /dev/null and b/SCADA/_codex_verify/System.Web.Http.dll differ diff --git a/SCADA/_codex_verify/Ubiety.Dns.Core.dll b/SCADA/_codex_verify/Ubiety.Dns.Core.dll new file mode 100644 index 0000000..2f0c84e Binary files /dev/null and b/SCADA/_codex_verify/Ubiety.Dns.Core.dll differ diff --git a/SCADA/_codex_verify/WC_GKJ_OIL.exe b/SCADA/_codex_verify/WC_GKJ_OIL.exe new file mode 100644 index 0000000..edf6e02 Binary files /dev/null and b/SCADA/_codex_verify/WC_GKJ_OIL.exe differ diff --git a/SCADA/_codex_verify/WC_GKJ_OIL.exe.config b/SCADA/_codex_verify/WC_GKJ_OIL.exe.config new file mode 100644 index 0000000..6195a88 --- /dev/null +++ b/SCADA/_codex_verify/WC_GKJ_OIL.exe.config @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SCADA/_codex_verify/WeifenLuo.WinFormsUI.Docking.ThemeVS2015.dll b/SCADA/_codex_verify/WeifenLuo.WinFormsUI.Docking.ThemeVS2015.dll new file mode 100644 index 0000000..0dbf5f4 Binary files /dev/null and b/SCADA/_codex_verify/WeifenLuo.WinFormsUI.Docking.ThemeVS2015.dll differ diff --git a/SCADA/_codex_verify/WeifenLuo.WinFormsUI.Docking.dll b/SCADA/_codex_verify/WeifenLuo.WinFormsUI.Docking.dll new file mode 100644 index 0000000..e4b2787 Binary files /dev/null and b/SCADA/_codex_verify/WeifenLuo.WinFormsUI.Docking.dll differ diff --git a/SCADA/_codex_verify/log4net.config b/SCADA/_codex_verify/log4net.config new file mode 100644 index 0000000..d164c22 --- /dev/null +++ b/SCADA/_codex_verify/log4net.config @@ -0,0 +1,35 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SCADA/_codex_verify/log4net.dll b/SCADA/_codex_verify/log4net.dll new file mode 100644 index 0000000..8646b6f Binary files /dev/null and b/SCADA/_codex_verify/log4net.dll differ diff --git a/SCADA/_codex_verify/任务管理.ico b/SCADA/_codex_verify/任务管理.ico new file mode 100644 index 0000000..1ad3c11 Binary files /dev/null and b/SCADA/_codex_verify/任务管理.ico differ diff --git a/SCADA/app.manifest b/SCADA/app.manifest new file mode 100644 index 0000000..fd40114 --- /dev/null +++ b/SCADA/app.manifest @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SCADA/icon/002_列表.png b/SCADA/icon/002_列表.png new file mode 100644 index 0000000..81abc65 Binary files /dev/null and b/SCADA/icon/002_列表.png differ diff --git a/SCADA/icon/0780fca3def52d8a02649c7aa2f8093a.gif b/SCADA/icon/0780fca3def52d8a02649c7aa2f8093a.gif new file mode 100644 index 0000000..f27d4fa Binary files /dev/null and b/SCADA/icon/0780fca3def52d8a02649c7aa2f8093a.gif differ diff --git a/SCADA/icon/BOSS-数据管理.ico b/SCADA/icon/BOSS-数据管理.ico new file mode 100644 index 0000000..0cda236 Binary files /dev/null and b/SCADA/icon/BOSS-数据管理.ico differ diff --git a/SCADA/icon/BOSS-数据管理.png b/SCADA/icon/BOSS-数据管理.png new file mode 100644 index 0000000..eca58d7 Binary files /dev/null and b/SCADA/icon/BOSS-数据管理.png differ diff --git a/SCADA/icon/HMI.png b/SCADA/icon/HMI.png new file mode 100644 index 0000000..c059b57 Binary files /dev/null and b/SCADA/icon/HMI.png differ diff --git a/SCADA/icon/JD.png b/SCADA/icon/JD.png new file mode 100644 index 0000000..abe9aa8 Binary files /dev/null and b/SCADA/icon/JD.png differ diff --git a/SCADA/icon/MBE风格多色图标-密码.png b/SCADA/icon/MBE风格多色图标-密码.png new file mode 100644 index 0000000..e20eaa8 Binary files /dev/null and b/SCADA/icon/MBE风格多色图标-密码.png differ diff --git a/SCADA/icon/action_Cancel_16xLG.png b/SCADA/icon/action_Cancel_16xLG.png new file mode 100644 index 0000000..ac08d59 Binary files /dev/null and b/SCADA/icon/action_Cancel_16xLG.png differ diff --git a/SCADA/icon/bitbug_favicon.ico b/SCADA/icon/bitbug_favicon.ico new file mode 100644 index 0000000..4e9b14c Binary files /dev/null and b/SCADA/icon/bitbug_favicon.ico differ diff --git a/SCADA/icon/excelICON.ico b/SCADA/icon/excelICON.ico new file mode 100644 index 0000000..f7dcbf6 Binary files /dev/null and b/SCADA/icon/excelICON.ico differ diff --git a/SCADA/icon/jk.ico b/SCADA/icon/jk.ico new file mode 100644 index 0000000..fe585a8 Binary files /dev/null and b/SCADA/icon/jk.ico differ diff --git a/SCADA/icon/panlClose.png b/SCADA/icon/panlClose.png new file mode 100644 index 0000000..462a22f Binary files /dev/null and b/SCADA/icon/panlClose.png differ diff --git a/SCADA/icon/ssbj.png b/SCADA/icon/ssbj.png new file mode 100644 index 0000000..10dc152 Binary files /dev/null and b/SCADA/icon/ssbj.png differ diff --git a/SCADA/icon/staticjd.png b/SCADA/icon/staticjd.png new file mode 100644 index 0000000..f891867 Binary files /dev/null and b/SCADA/icon/staticjd.png differ diff --git a/SCADA/icon/上传.png b/SCADA/icon/上传.png new file mode 100644 index 0000000..6716d20 Binary files /dev/null and b/SCADA/icon/上传.png differ diff --git a/SCADA/icon/上载.jpg b/SCADA/icon/上载.jpg new file mode 100644 index 0000000..344b17d Binary files /dev/null and b/SCADA/icon/上载.jpg differ diff --git a/SCADA/icon/下载.png b/SCADA/icon/下载.png new file mode 100644 index 0000000..6122e35 Binary files /dev/null and b/SCADA/icon/下载.png differ diff --git a/SCADA/icon/业务.png b/SCADA/icon/业务.png new file mode 100644 index 0000000..f0adf1d Binary files /dev/null and b/SCADA/icon/业务.png differ diff --git a/SCADA/icon/任务监控和查询.png b/SCADA/icon/任务监控和查询.png new file mode 100644 index 0000000..ff8cca0 Binary files /dev/null and b/SCADA/icon/任务监控和查询.png differ diff --git a/SCADA/icon/保存.png b/SCADA/icon/保存.png new file mode 100644 index 0000000..97bd4dd Binary files /dev/null and b/SCADA/icon/保存.png differ diff --git a/SCADA/icon/信息_记录.png b/SCADA/icon/信息_记录.png new file mode 100644 index 0000000..e92f9b7 Binary files /dev/null and b/SCADA/icon/信息_记录.png differ diff --git a/SCADA/icon/关闭.png b/SCADA/icon/关闭.png new file mode 100644 index 0000000..b78aef6 Binary files /dev/null and b/SCADA/icon/关闭.png differ diff --git a/SCADA/icon/关闭系统.png b/SCADA/icon/关闭系统.png new file mode 100644 index 0000000..ffd64a8 Binary files /dev/null and b/SCADA/icon/关闭系统.png differ diff --git a/SCADA/icon/写入托盘.jpg b/SCADA/icon/写入托盘.jpg new file mode 100644 index 0000000..1a209b9 Binary files /dev/null and b/SCADA/icon/写入托盘.jpg differ diff --git a/SCADA/icon/分布图.ico b/SCADA/icon/分布图.ico new file mode 100644 index 0000000..d2bd021 Binary files /dev/null and b/SCADA/icon/分布图.ico differ diff --git a/SCADA/icon/分布图.png b/SCADA/icon/分布图.png new file mode 100644 index 0000000..c41710c Binary files /dev/null and b/SCADA/icon/分布图.png differ diff --git a/SCADA/icon/列表.png b/SCADA/icon/列表.png new file mode 100644 index 0000000..95df08c Binary files /dev/null and b/SCADA/icon/列表.png differ diff --git a/SCADA/icon/列表2.png b/SCADA/icon/列表2.png new file mode 100644 index 0000000..375743f Binary files /dev/null and b/SCADA/icon/列表2.png differ diff --git a/SCADA/icon/删除.png b/SCADA/icon/删除.png new file mode 100644 index 0000000..76903f0 Binary files /dev/null and b/SCADA/icon/删除.png differ diff --git a/SCADA/icon/刷新.png b/SCADA/icon/刷新.png new file mode 100644 index 0000000..98bf964 Binary files /dev/null and b/SCADA/icon/刷新.png differ diff --git a/SCADA/icon/动态数据查询.png b/SCADA/icon/动态数据查询.png new file mode 100644 index 0000000..ad87d56 Binary files /dev/null and b/SCADA/icon/动态数据查询.png differ diff --git a/SCADA/icon/合作.png b/SCADA/icon/合作.png new file mode 100644 index 0000000..973f7ea Binary files /dev/null and b/SCADA/icon/合作.png differ diff --git a/SCADA/icon/图表_柱.png b/SCADA/icon/图表_柱.png new file mode 100644 index 0000000..45d1aad Binary files /dev/null and b/SCADA/icon/图表_柱.png differ diff --git a/SCADA/icon/图表_线_通用_统计.png b/SCADA/icon/图表_线_通用_统计.png new file mode 100644 index 0000000..c39b497 Binary files /dev/null and b/SCADA/icon/图表_线_通用_统计.png differ diff --git a/SCADA/icon/图表_饼.png b/SCADA/icon/图表_饼.png new file mode 100644 index 0000000..ced794d Binary files /dev/null and b/SCADA/icon/图表_饼.png differ diff --git a/SCADA/icon/增加.png b/SCADA/icon/增加.png new file mode 100644 index 0000000..4bfbb6b Binary files /dev/null and b/SCADA/icon/增加.png differ diff --git a/SCADA/icon/备份_复制.png b/SCADA/icon/备份_复制.png new file mode 100644 index 0000000..9159178 Binary files /dev/null and b/SCADA/icon/备份_复制.png differ diff --git a/SCADA/icon/审核_盖章.png b/SCADA/icon/审核_盖章.png new file mode 100644 index 0000000..b0af2d4 Binary files /dev/null and b/SCADA/icon/审核_盖章.png differ diff --git a/SCADA/icon/密码.png b/SCADA/icon/密码.png new file mode 100644 index 0000000..5ddf103 Binary files /dev/null and b/SCADA/icon/密码.png differ diff --git a/SCADA/icon/导入.png b/SCADA/icon/导入.png new file mode 100644 index 0000000..95fd37f Binary files /dev/null and b/SCADA/icon/导入.png differ diff --git a/SCADA/icon/导出.png b/SCADA/icon/导出.png new file mode 100644 index 0000000..aad5f54 Binary files /dev/null and b/SCADA/icon/导出.png differ diff --git a/SCADA/icon/工件信息.png b/SCADA/icon/工件信息.png new file mode 100644 index 0000000..ca08d9f Binary files /dev/null and b/SCADA/icon/工件信息.png differ diff --git a/SCADA/icon/工作台.png b/SCADA/icon/工作台.png new file mode 100644 index 0000000..4d3ec97 Binary files /dev/null and b/SCADA/icon/工作台.png differ diff --git a/SCADA/icon/工具.png b/SCADA/icon/工具.png new file mode 100644 index 0000000..7383324 Binary files /dev/null and b/SCADA/icon/工具.png differ diff --git a/SCADA/icon/布局图.png b/SCADA/icon/布局图.png new file mode 100644 index 0000000..7d2ff19 Binary files /dev/null and b/SCADA/icon/布局图.png differ diff --git a/SCADA/icon/帮助.png b/SCADA/icon/帮助.png new file mode 100644 index 0000000..b2d7d6b Binary files /dev/null and b/SCADA/icon/帮助.png differ diff --git a/SCADA/icon/异常_危险.png b/SCADA/icon/异常_危险.png new file mode 100644 index 0000000..66bc688 Binary files /dev/null and b/SCADA/icon/异常_危险.png differ diff --git a/SCADA/icon/手动打印.png b/SCADA/icon/手动打印.png new file mode 100644 index 0000000..a682191 Binary files /dev/null and b/SCADA/icon/手动打印.png differ diff --git a/SCADA/icon/打印机.png b/SCADA/icon/打印机.png new file mode 100644 index 0000000..721dbc2 Binary files /dev/null and b/SCADA/icon/打印机.png differ diff --git a/SCADA/icon/按键分割线.png b/SCADA/icon/按键分割线.png new file mode 100644 index 0000000..f54e139 Binary files /dev/null and b/SCADA/icon/按键分割线.png differ diff --git a/SCADA/icon/按键分割线浅.png b/SCADA/icon/按键分割线浅.png new file mode 100644 index 0000000..db55df6 Binary files /dev/null and b/SCADA/icon/按键分割线浅.png differ diff --git a/SCADA/icon/搜索.png b/SCADA/icon/搜索.png new file mode 100644 index 0000000..2b2bbc1 Binary files /dev/null and b/SCADA/icon/搜索.png differ diff --git a/SCADA/icon/操作管理.jpg b/SCADA/icon/操作管理.jpg new file mode 100644 index 0000000..c2f4487 Binary files /dev/null and b/SCADA/icon/操作管理.jpg differ diff --git a/SCADA/icon/文档.png b/SCADA/icon/文档.png new file mode 100644 index 0000000..781a0b5 Binary files /dev/null and b/SCADA/icon/文档.png differ diff --git a/SCADA/icon/断开.png b/SCADA/icon/断开.png new file mode 100644 index 0000000..fe5b4e9 Binary files /dev/null and b/SCADA/icon/断开.png differ diff --git a/SCADA/icon/断开状态.png b/SCADA/icon/断开状态.png new file mode 100644 index 0000000..0ae6189 Binary files /dev/null and b/SCADA/icon/断开状态.png differ diff --git a/SCADA/icon/断开连接.png b/SCADA/icon/断开连接.png new file mode 100644 index 0000000..8221ffc Binary files /dev/null and b/SCADA/icon/断开连接.png differ diff --git a/SCADA/icon/新增_添加.png b/SCADA/icon/新增_添加.png new file mode 100644 index 0000000..2ad22a8 Binary files /dev/null and b/SCADA/icon/新增_添加.png differ diff --git a/SCADA/icon/日志.ico b/SCADA/icon/日志.ico new file mode 100644 index 0000000..37a300e Binary files /dev/null and b/SCADA/icon/日志.ico differ diff --git a/SCADA/icon/日志.png b/SCADA/icon/日志.png new file mode 100644 index 0000000..1ef853f Binary files /dev/null and b/SCADA/icon/日志.png differ diff --git a/SCADA/icon/更多.png b/SCADA/icon/更多.png new file mode 100644 index 0000000..eb498c7 Binary files /dev/null and b/SCADA/icon/更多.png differ diff --git a/SCADA/icon/权限角色管理.png b/SCADA/icon/权限角色管理.png new file mode 100644 index 0000000..8ab50e8 Binary files /dev/null and b/SCADA/icon/权限角色管理.png differ diff --git a/SCADA/icon/正确_成功.png b/SCADA/icon/正确_成功.png new file mode 100644 index 0000000..cd1e12d Binary files /dev/null and b/SCADA/icon/正确_成功.png differ diff --git a/SCADA/icon/添加.png b/SCADA/icon/添加.png new file mode 100644 index 0000000..47b1193 Binary files /dev/null and b/SCADA/icon/添加.png differ diff --git a/SCADA/icon/清洗信息.png b/SCADA/icon/清洗信息.png new file mode 100644 index 0000000..14eef19 Binary files /dev/null and b/SCADA/icon/清洗信息.png differ diff --git a/SCADA/icon/用户_账号_我的.png b/SCADA/icon/用户_账号_我的.png new file mode 100644 index 0000000..5768093 Binary files /dev/null and b/SCADA/icon/用户_账号_我的.png differ diff --git a/SCADA/icon/用户_账号_我的_未登录.png b/SCADA/icon/用户_账号_我的_未登录.png new file mode 100644 index 0000000..bf2ce2f Binary files /dev/null and b/SCADA/icon/用户_账号_我的_未登录.png differ diff --git a/SCADA/icon/登出2.jpg b/SCADA/icon/登出2.jpg new file mode 100644 index 0000000..23ab445 Binary files /dev/null and b/SCADA/icon/登出2.jpg differ diff --git a/SCADA/icon/登录.png b/SCADA/icon/登录.png new file mode 100644 index 0000000..f7b6826 Binary files /dev/null and b/SCADA/icon/登录.png differ diff --git a/SCADA/icon/筛选.png b/SCADA/icon/筛选.png new file mode 100644 index 0000000..ac98854 Binary files /dev/null and b/SCADA/icon/筛选.png differ diff --git a/SCADA/icon/系统管理.png b/SCADA/icon/系统管理.png new file mode 100644 index 0000000..136f392 Binary files /dev/null and b/SCADA/icon/系统管理.png differ diff --git a/SCADA/icon/系统管理和监控服务.png b/SCADA/icon/系统管理和监控服务.png new file mode 100644 index 0000000..dab233f Binary files /dev/null and b/SCADA/icon/系统管理和监控服务.png differ diff --git a/SCADA/icon/组群_角色.png b/SCADA/icon/组群_角色.png new file mode 100644 index 0000000..8e63df3 Binary files /dev/null and b/SCADA/icon/组群_角色.png differ diff --git a/SCADA/icon/编辑_修改.png b/SCADA/icon/编辑_修改.png new file mode 100644 index 0000000..a79662a Binary files /dev/null and b/SCADA/icon/编辑_修改.png differ diff --git a/SCADA/icon/能耗信息.png b/SCADA/icon/能耗信息.png new file mode 100644 index 0000000..504c367 Binary files /dev/null and b/SCADA/icon/能耗信息.png differ diff --git a/SCADA/icon/解锁.png b/SCADA/icon/解锁.png new file mode 100644 index 0000000..49f2ed1 Binary files /dev/null and b/SCADA/icon/解锁.png differ diff --git a/SCADA/icon/记录2.png b/SCADA/icon/记录2.png new file mode 100644 index 0000000..04674da Binary files /dev/null and b/SCADA/icon/记录2.png differ diff --git a/SCADA/icon/质控管理.png b/SCADA/icon/质控管理.png new file mode 100644 index 0000000..ad6a993 Binary files /dev/null and b/SCADA/icon/质控管理.png differ diff --git a/SCADA/icon/辅助_协助.png b/SCADA/icon/辅助_协助.png new file mode 100644 index 0000000..d96cb7b Binary files /dev/null and b/SCADA/icon/辅助_协助.png differ diff --git a/SCADA/icon/返回2.png b/SCADA/icon/返回2.png new file mode 100644 index 0000000..4978687 Binary files /dev/null and b/SCADA/icon/返回2.png differ diff --git a/SCADA/icon/进度_沙漏.png b/SCADA/icon/进度_沙漏.png new file mode 100644 index 0000000..87831fb Binary files /dev/null and b/SCADA/icon/进度_沙漏.png differ diff --git a/SCADA/icon/连接.png b/SCADA/icon/连接.png new file mode 100644 index 0000000..cc7650b Binary files /dev/null and b/SCADA/icon/连接.png differ diff --git a/SCADA/icon/连接状态.png b/SCADA/icon/连接状态.png new file mode 100644 index 0000000..ae8e8a1 Binary files /dev/null and b/SCADA/icon/连接状态.png differ diff --git a/SCADA/icon/退出.png b/SCADA/icon/退出.png new file mode 100644 index 0000000..ca2cb38 Binary files /dev/null and b/SCADA/icon/退出.png differ diff --git a/SCADA/icon/配置.ico b/SCADA/icon/配置.ico new file mode 100644 index 0000000..d028cc1 Binary files /dev/null and b/SCADA/icon/配置.ico differ diff --git a/SCADA/icon/配置.png b/SCADA/icon/配置.png new file mode 100644 index 0000000..e16ab0b Binary files /dev/null and b/SCADA/icon/配置.png differ diff --git a/SCADA/icon/配置2.ico b/SCADA/icon/配置2.ico new file mode 100644 index 0000000..45b4c44 Binary files /dev/null and b/SCADA/icon/配置2.ico differ diff --git a/SCADA/icon/配置2.png b/SCADA/icon/配置2.png new file mode 100644 index 0000000..e5e7dc5 Binary files /dev/null and b/SCADA/icon/配置2.png differ diff --git a/SCADA/icon/重新加载数据.png b/SCADA/icon/重新加载数据.png new file mode 100644 index 0000000..c98d847 Binary files /dev/null and b/SCADA/icon/重新加载数据.png differ diff --git a/SCADA/icon/锁定.png b/SCADA/icon/锁定.png new file mode 100644 index 0000000..df62914 Binary files /dev/null and b/SCADA/icon/锁定.png differ diff --git a/SCADA/icon/错误_失败.png b/SCADA/icon/错误_失败.png new file mode 100644 index 0000000..3b56a32 Binary files /dev/null and b/SCADA/icon/错误_失败.png differ diff --git a/SCADA/icon/零件管理.jpg b/SCADA/icon/零件管理.jpg new file mode 100644 index 0000000..44e6676 Binary files /dev/null and b/SCADA/icon/零件管理.jpg differ diff --git a/SCADA/manager_log/LogRecord.Designer.cs b/SCADA/manager_log/LogRecord.Designer.cs new file mode 100644 index 0000000..22f0efe --- /dev/null +++ b/SCADA/manager_log/LogRecord.Designer.cs @@ -0,0 +1,602 @@ + +namespace LogRecord +{ + partial class LogRecord : WeifenLuo.WinFormsUI.Docking.DockContent + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); + this.label11 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.txt_ResponseContext_3 = new System.Windows.Forms.TextBox(); + this.txt_RequestContext_3 = new System.Windows.Forms.TextBox(); + this.dtp_End = new System.Windows.Forms.DateTimePicker(); + this.dtp_Start = new System.Windows.Forms.DateTimePicker(); + this.cb_StationName = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.cb_Type = new System.Windows.Forms.ComboBox(); + this.btn_Refresh = new System.Windows.Forms.Button(); + this.dgv_Log = new System.Windows.Forms.DataGridView(); + this.工位号 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.类型 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.CMD = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.FROM = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.TO = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.请求时间 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.请求内容 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.TaskID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.响应时间 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.响应内容 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.AID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.cb_From = new System.Windows.Forms.ComboBox(); + this.label6 = new System.Windows.Forms.Label(); + this.cb_To = new System.Windows.Forms.ComboBox(); + this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.txt_TaskID = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.txt_Req = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.txt_Rsp = new System.Windows.Forms.TextBox(); + this.label_Count = new System.Windows.Forms.Label(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.panel1 = new System.Windows.Forms.Panel(); + this.panel2 = new System.Windows.Forms.Panel(); + this.panel3 = new System.Windows.Forms.Panel(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Log)).BeginInit(); + this.tableLayoutPanel1.SuspendLayout(); + this.panel1.SuspendLayout(); + this.panel2.SuspendLayout(); + this.panel3.SuspendLayout(); + this.SuspendLayout(); + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label11.Location = new System.Drawing.Point(915, 10); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(67, 14); + this.label11.TabIndex = 118; + this.label11.Text = "响应内容"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label12.Location = new System.Drawing.Point(9, 10); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(67, 14); + this.label12.TabIndex = 119; + this.label12.Text = "请求内容"; + // + // txt_ResponseContext_3 + // + this.txt_ResponseContext_3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txt_ResponseContext_3.Font = new System.Drawing.Font("宋体", 14F); + this.txt_ResponseContext_3.Location = new System.Drawing.Point(917, 28); + this.txt_ResponseContext_3.Multiline = true; + this.txt_ResponseContext_3.Name = "txt_ResponseContext_3"; + this.txt_ResponseContext_3.ReadOnly = true; + this.txt_ResponseContext_3.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txt_ResponseContext_3.Size = new System.Drawing.Size(631, 184); + this.txt_ResponseContext_3.TabIndex = 116; + // + // txt_RequestContext_3 + // + this.txt_RequestContext_3.Font = new System.Drawing.Font("宋体", 14F); + this.txt_RequestContext_3.Location = new System.Drawing.Point(10, 28); + this.txt_RequestContext_3.Multiline = true; + this.txt_RequestContext_3.Name = "txt_RequestContext_3"; + this.txt_RequestContext_3.ReadOnly = true; + this.txt_RequestContext_3.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txt_RequestContext_3.Size = new System.Drawing.Size(901, 184); + this.txt_RequestContext_3.TabIndex = 117; + // + // dtp_End + // + this.dtp_End.CustomFormat = "yyyy-MM-dd HH:mm:ss"; + this.dtp_End.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.dtp_End.Location = new System.Drawing.Point(242, 5); + this.dtp_End.Name = "dtp_End"; + this.dtp_End.Size = new System.Drawing.Size(150, 21); + this.dtp_End.TabIndex = 87; + // + // dtp_Start + // + this.dtp_Start.CustomFormat = "yyyy-MM-dd HH:mm:ss"; + this.dtp_Start.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.dtp_Start.Location = new System.Drawing.Point(52, 5); + this.dtp_Start.Name = "dtp_Start"; + this.dtp_Start.Size = new System.Drawing.Size(150, 21); + this.dtp_Start.TabIndex = 88; + // + // cb_StationName + // + this.cb_StationName.FormattingEnabled = true; + this.cb_StationName.Location = new System.Drawing.Point(487, 6); + this.cb_StationName.Name = "cb_StationName"; + this.cb_StationName.Size = new System.Drawing.Size(173, 20); + this.cb_StationName.TabIndex = 86; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(429, 8); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(52, 14); + this.label2.TabIndex = 82; + this.label2.Text = "工位号"; + // + // cb_Type + // + this.cb_Type.FormattingEnabled = true; + this.cb_Type.Location = new System.Drawing.Point(709, 6); + this.cb_Type.Name = "cb_Type"; + this.cb_Type.Size = new System.Drawing.Size(233, 20); + this.cb_Type.TabIndex = 81; + // + // btn_Refresh + // + this.btn_Refresh.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_Refresh.Location = new System.Drawing.Point(1301, 6); + this.btn_Refresh.Name = "btn_Refresh"; + this.btn_Refresh.Size = new System.Drawing.Size(109, 45); + this.btn_Refresh.TabIndex = 80; + this.btn_Refresh.Text = "查询"; + this.btn_Refresh.UseVisualStyleBackColor = false; + this.btn_Refresh.Click += new System.EventHandler(this.btn_Refresh_Click); + // + // dgv_Log + // + this.dgv_Log.AllowUserToAddRows = false; + this.dgv_Log.AllowUserToDeleteRows = false; + this.dgv_Log.AllowUserToResizeRows = false; + this.dgv_Log.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgv_Log.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + this.dgv_Log.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgv_Log.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.工位号, + this.类型, + this.CMD, + this.FROM, + this.TO, + this.请求时间, + this.请求内容, + this.TaskID, + this.响应时间, + this.响应内容, + this.AID}); + this.dgv_Log.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgv_Log.Location = new System.Drawing.Point(0, 0); + this.dgv_Log.MultiSelect = false; + this.dgv_Log.Name = "dgv_Log"; + this.dgv_Log.ReadOnly = true; + this.dgv_Log.RowHeadersVisible = false; + this.dgv_Log.RowTemplate.Height = 26; + this.dgv_Log.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgv_Log.Size = new System.Drawing.Size(1557, 488); + this.dgv_Log.TabIndex = 79; + this.dgv_Log.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgv_Log_CellClick); + // + // 工位号 + // + this.工位号.DataPropertyName = "工位号"; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold); + this.工位号.DefaultCellStyle = dataGridViewCellStyle2; + this.工位号.HeaderText = "工位号"; + this.工位号.Name = "工位号"; + this.工位号.ReadOnly = true; + this.工位号.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.工位号.Width = 150; + // + // 类型 + // + this.类型.DataPropertyName = "类型"; + dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold); + this.类型.DefaultCellStyle = dataGridViewCellStyle3; + this.类型.HeaderText = "类型"; + this.类型.Name = "类型"; + this.类型.ReadOnly = true; + this.类型.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.类型.Width = 200; + // + // CMD + // + this.CMD.DataPropertyName = "CMD"; + dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold); + this.CMD.DefaultCellStyle = dataGridViewCellStyle4; + this.CMD.HeaderText = "CMD"; + this.CMD.Name = "CMD"; + this.CMD.ReadOnly = true; + this.CMD.Visible = false; + this.CMD.Width = 260; + // + // FROM + // + this.FROM.DataPropertyName = "FROM"; + dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold); + this.FROM.DefaultCellStyle = dataGridViewCellStyle5; + this.FROM.HeaderText = "FROM"; + this.FROM.Name = "FROM"; + this.FROM.ReadOnly = true; + this.FROM.Width = 200; + // + // TO + // + this.TO.DataPropertyName = "TO"; + dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold); + this.TO.DefaultCellStyle = dataGridViewCellStyle6; + this.TO.HeaderText = "TO"; + this.TO.Name = "TO"; + this.TO.ReadOnly = true; + // + // 请求时间 + // + this.请求时间.DataPropertyName = "请求时间"; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold); + dataGridViewCellStyle7.Format = "G"; + this.请求时间.DefaultCellStyle = dataGridViewCellStyle7; + this.请求时间.HeaderText = "请求时间"; + this.请求时间.Name = "请求时间"; + this.请求时间.ReadOnly = true; + this.请求时间.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.请求时间.Width = 190; + // + // 请求内容 + // + this.请求内容.DataPropertyName = "请求内容"; + dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold); + dataGridViewCellStyle8.Format = "yyyy-MM-dd HH:mm:ss"; + dataGridViewCellStyle8.NullValue = null; + this.请求内容.DefaultCellStyle = dataGridViewCellStyle8; + this.请求内容.HeaderText = "请求内容"; + this.请求内容.Name = "请求内容"; + this.请求内容.ReadOnly = true; + this.请求内容.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.请求内容.Width = 600; + // + // TaskID + // + this.TaskID.DataPropertyName = "TaskID"; + dataGridViewCellStyle9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold); + this.TaskID.DefaultCellStyle = dataGridViewCellStyle9; + this.TaskID.HeaderText = "TaskID"; + this.TaskID.Name = "TaskID"; + this.TaskID.ReadOnly = true; + this.TaskID.Width = 320; + // + // 响应时间 + // + this.响应时间.DataPropertyName = "响应时间"; + dataGridViewCellStyle10.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold); + dataGridViewCellStyle10.Format = "yyyy-MM-dd HH:mm:ss"; + dataGridViewCellStyle10.NullValue = null; + this.响应时间.DefaultCellStyle = dataGridViewCellStyle10; + this.响应时间.HeaderText = "响应时间"; + this.响应时间.Name = "响应时间"; + this.响应时间.ReadOnly = true; + this.响应时间.Width = 190; + // + // 响应内容 + // + this.响应内容.DataPropertyName = "响应内容"; + dataGridViewCellStyle11.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold); + this.响应内容.DefaultCellStyle = dataGridViewCellStyle11; + this.响应内容.HeaderText = "响应内容"; + this.响应内容.Name = "响应内容"; + this.响应内容.ReadOnly = true; + // + // AID + // + this.AID.DataPropertyName = "AID"; + this.AID.HeaderText = "AID"; + this.AID.Name = "AID"; + this.AID.ReadOnly = true; + this.AID.Visible = false; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(214, 8); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(22, 14); + this.label4.TabIndex = 83; + this.label4.Text = "到"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(24, 8); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(22, 14); + this.label3.TabIndex = 84; + this.label3.Text = "从"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(666, 8); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(37, 14); + this.label1.TabIndex = 85; + this.label1.Text = "类型"; + // + // cb_From + // + this.cb_From.FormattingEnabled = true; + this.cb_From.Location = new System.Drawing.Point(52, 33); + this.cb_From.Name = "cb_From"; + this.cb_From.Size = new System.Drawing.Size(150, 20); + this.cb_From.TabIndex = 81; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label6.Location = new System.Drawing.Point(10, 37); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(39, 14); + this.label6.TabIndex = 85; + this.label6.Text = "FROM"; + // + // cb_To + // + this.cb_To.FormattingEnabled = true; + this.cb_To.Location = new System.Drawing.Point(242, 33); + this.cb_To.Name = "cb_To"; + this.cb_To.Size = new System.Drawing.Size(150, 20); + this.cb_To.TabIndex = 81; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label7.Location = new System.Drawing.Point(214, 37); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(23, 14); + this.label7.TabIndex = 85; + this.label7.Text = "TO"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label8.Location = new System.Drawing.Point(971, 8); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(55, 14); + this.label8.TabIndex = 85; + this.label8.Text = "TaskID"; + // + // txt_TaskID + // + this.txt_TaskID.Location = new System.Drawing.Point(1032, 5); + this.txt_TaskID.Name = "txt_TaskID"; + this.txt_TaskID.Size = new System.Drawing.Size(256, 21); + this.txt_TaskID.TabIndex = 120; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label9.Location = new System.Drawing.Point(414, 37); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(67, 14); + this.label9.TabIndex = 85; + this.label9.Text = "请求内容"; + // + // txt_Req + // + this.txt_Req.Location = new System.Drawing.Point(487, 32); + this.txt_Req.Name = "txt_Req"; + this.txt_Req.Size = new System.Drawing.Size(455, 21); + this.txt_Req.TabIndex = 120; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label10.Location = new System.Drawing.Point(959, 37); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(67, 14); + this.label10.TabIndex = 85; + this.label10.Text = "响应内容"; + // + // txt_Rsp + // + this.txt_Rsp.Location = new System.Drawing.Point(1032, 32); + this.txt_Rsp.Name = "txt_Rsp"; + this.txt_Rsp.Size = new System.Drawing.Size(256, 21); + this.txt_Rsp.TabIndex = 120; + // + // label_Count + // + this.label_Count.AutoSize = true; + this.label_Count.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label_Count.Location = new System.Drawing.Point(1350, 6); + this.label_Count.Name = "label_Count"; + this.label_Count.Size = new System.Drawing.Size(82, 14); + this.label_Count.TabIndex = 121; + this.label_Count.Text = "消息数量:"; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 1; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.panel2, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.panel3, 0, 2); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 65F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 227F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1563, 786); + this.tableLayoutPanel1.TabIndex = 123; + // + // panel1 + // + this.panel1.Controls.Add(this.label3); + this.panel1.Controls.Add(this.label2); + this.panel1.Controls.Add(this.cb_Type); + this.panel1.Controls.Add(this.txt_Rsp); + this.panel1.Controls.Add(this.txt_Req); + this.panel1.Controls.Add(this.cb_From); + this.panel1.Controls.Add(this.txt_TaskID); + this.panel1.Controls.Add(this.cb_To); + this.panel1.Controls.Add(this.cb_StationName); + this.panel1.Controls.Add(this.btn_Refresh); + this.panel1.Controls.Add(this.dtp_Start); + this.panel1.Controls.Add(this.label10); + this.panel1.Controls.Add(this.dtp_End); + this.panel1.Controls.Add(this.label7); + this.panel1.Controls.Add(this.label4); + this.panel1.Controls.Add(this.label9); + this.panel1.Controls.Add(this.label1); + this.panel1.Controls.Add(this.label6); + this.panel1.Controls.Add(this.label8); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(3, 3); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(1557, 59); + this.panel1.TabIndex = 0; + // + // panel2 + // + this.panel2.Controls.Add(this.dgv_Log); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.Location = new System.Drawing.Point(3, 68); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(1557, 488); + this.panel2.TabIndex = 1; + // + // panel3 + // + this.panel3.Controls.Add(this.label12); + this.panel3.Controls.Add(this.label11); + this.panel3.Controls.Add(this.txt_RequestContext_3); + this.panel3.Controls.Add(this.txt_ResponseContext_3); + this.panel3.Controls.Add(this.label_Count); + this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel3.Location = new System.Drawing.Point(3, 562); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(1557, 221); + this.panel3.TabIndex = 2; + // + // LogRecord + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1563, 786); + this.Controls.Add(this.tableLayoutPanel1); + this.Name = "LogRecord"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "日志"; + this.Load += new System.EventHandler(this.LogRecord_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgv_Log)).EndInit(); + this.tableLayoutPanel1.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.panel2.ResumeLayout(false); + this.panel3.ResumeLayout(false); + this.panel3.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.TextBox txt_ResponseContext_3; + private System.Windows.Forms.TextBox txt_RequestContext_3; + private System.Windows.Forms.DateTimePicker dtp_End; + private System.Windows.Forms.DateTimePicker dtp_Start; + private System.Windows.Forms.ComboBox cb_StationName; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ComboBox cb_Type; + private System.Windows.Forms.Button btn_Refresh; + private System.Windows.Forms.DataGridView dgv_Log; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox cb_From; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.ComboBox cb_To; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.TextBox txt_TaskID; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox txt_Req; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.TextBox txt_Rsp; + private System.Windows.Forms.Label label_Count; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.DataGridViewTextBoxColumn 工位号; + private System.Windows.Forms.DataGridViewTextBoxColumn 类型; + private System.Windows.Forms.DataGridViewTextBoxColumn CMD; + private System.Windows.Forms.DataGridViewTextBoxColumn FROM; + private System.Windows.Forms.DataGridViewTextBoxColumn TO; + private System.Windows.Forms.DataGridViewTextBoxColumn 请求时间; + private System.Windows.Forms.DataGridViewTextBoxColumn 请求内容; + private System.Windows.Forms.DataGridViewTextBoxColumn TaskID; + private System.Windows.Forms.DataGridViewTextBoxColumn 响应时间; + private System.Windows.Forms.DataGridViewTextBoxColumn 响应内容; + private System.Windows.Forms.DataGridViewTextBoxColumn AID; + } +} + diff --git a/SCADA/manager_log/LogRecord.cs b/SCADA/manager_log/LogRecord.cs new file mode 100644 index 0000000..b031a03 --- /dev/null +++ b/SCADA/manager_log/LogRecord.cs @@ -0,0 +1,312 @@ +using ExternalDataSync; +using MesWork; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; + +/// +/// 报警类型 +/// +public enum Log_Type +{ + /// + /// 报警 + /// + ZK_Alarm = 1, + /// + /// 登录 + /// + ZK_Login = 2, + /// + /// 提示 + /// + ZK_Tip = 3, + /// + /// MES处理信号 + /// + ZK_MesHandler = 4, + /// + /// 配方下载 + /// + ZK_DownloadRecipes = 5, + /// + /// 发动机上线 + /// + ZK_OnLine = 6, + /// + /// 发动机下线 + /// + ZK_OffLine = 7, + /// + /// MES请求接口的日志 + /// + ZK_Interface_MesReq = 8, + + /// + /// 1.AGV 请求进入 + /// + AGV_To_MES_agvCallback = 9, + /// + /// 删除 + /// 2025.11.25.0024.LLX + /// + ZK_Delete = 10, + + /// + /// 未定义 + /// + Undefined = 1000 + +} + + +public enum Log_FromAndTo +{ + /// + /// PLC + /// + PLC = 3, + /// + /// AGV(海康威视) + /// + HK_AGV = 4, + /// + /// LES(启明) + /// + WMS = 5, + /// + /// AGV(临工) + /// + ZK = 10, + /// + /// 未定义 + /// + Undefined = 1000 +} + + +namespace LogRecord +{ + /// + /// 日志处理 + /// + public partial class LogRecord + { + /// + /// 构造 + /// + public LogRecord() + { + InitializeComponent(); + //this.Width = _Width; + //this.Height = _Height; + cb_Type.DataSource = Enum.GetNames(typeof(Log_Type)); + cb_Type.Text = Log_Type.Undefined.ToString(); + cb_From.DataSource = Enum.GetNames(typeof(Log_FromAndTo)); + cb_From.Text = Log_FromAndTo.Undefined.ToString(); + cb_To.DataSource = Enum.GetNames(typeof(Log_FromAndTo)); + cb_To.Text = Log_FromAndTo.Undefined.ToString(); + + cb_StationName.Items.Add(""); + foreach (var stationName in MesWorkForm.opNameList) + { + cb_StationName.Items.Add(stationName); + } + cb_StationName.SelectedIndex = 0; + + var end = System.DateTime.Now.AddDays(1); + var start = end.AddDays(-3); + dtp_Start.Value = start; + dtp_End.Value = end; + + } + + + /// + /// 钩子 + /// + /// + /// + private void LogRecord_Load(object sender, EventArgs e) + { + } + + /// + /// + /// + /// + /// + /// + private void RowsColor(int row, Color color, DataGridView dgv) + { + var dt = (System.Data.DataTable)dgv.DataSource; + for (int i = 0; i < dt.Columns.Count; i++) + { + dgv.Rows[row].Cells[i].Style.BackColor = color; + } + } + + public static bool Insert_ScanLog_EleCraft(Log_Type LogType,string stationName, string Log_Content) + { + bool success = false; + var sql = +$" INSERT INTO [记录_日志_扫码发送电子工艺]([Log_Station],[Log_Type],[Log_Time],[Log_Content])" + +$" VALUES('{stationName}','{LogType.ToString()}',getdate(),'{Log_Content}')"; + success = DataLinkMesWork.SQLCommon.ExecuteSql(sql, MesWorkForm.ConnectionString, out string err2); + + return success; + } + + + /// + /// 手动刷新 + /// + /// + /// + private void btn_Refresh_Click(object sender, EventArgs e) + { + try + { + var start = dtp_Start.Value; + var end = dtp_End.Value; + var stationName = cb_StationName.Text; + var type = (Log_Type)Enum.Parse(typeof(Log_Type), cb_Type.Text); + var taskID = txt_TaskID.Text; + + var from = (Log_FromAndTo)Enum.Parse(typeof(Log_FromAndTo), cb_From.Text); + var to = (Log_FromAndTo)Enum.Parse(typeof(Log_FromAndTo), cb_To.Text); + var req = txt_Req.Text; + var rsp = txt_Rsp.Text; + + var whereStr = ""; + if (start != null & end != null) + { + whereStr = whereStr + $" AND [请求时间] >= '{start.ToString("G")}' AND [请求时间] < '{end.ToString("yyyy-MM-dd 23:59:59")}'"; + } + + if (!string.IsNullOrEmpty(stationName) && !string.IsNullOrEmpty(req)) + { + whereStr = whereStr + $" AND ([工位号] = '{stationName}' OR [请求内容] like '%{req}%')"; + } + else if (!string.IsNullOrEmpty(stationName)) + { + whereStr = whereStr + $" AND [工位号] = '{stationName}'"; + } + else if (!string.IsNullOrEmpty(req)) + { + whereStr = whereStr + $" AND [请求内容] like '%{req}%'"; + } + + if (type != Log_Type.Undefined) + { + whereStr = whereStr + $" AND [日志类型] = '{type.ToString()}'"; + } + if (!string.IsNullOrEmpty(taskID)) + { + whereStr = whereStr + $" AND [TaskID] like '%{taskID}%'"; + } + if (from != Log_FromAndTo.Undefined) + { + whereStr = whereStr + $" AND [请求FROM] like '%{from}%'"; + } + if (to != Log_FromAndTo.Undefined) + { + whereStr = whereStr + $" AND [请求TO] like '%{to}%'"; + } + if (!string.IsNullOrEmpty(rsp)) + { + whereStr = whereStr + $" AND [响应内容] like '%{rsp}%'"; + } + + + var sql = + $" SELECT " + + $" [工位号] '工位号'" + + $" ,[日志类型] '类型'" + + $" ,[请求时间] '请求时间'" + + $" ,[请求内容] '请求内容'" + + $" ,[响应时间] '响应时间'" + + $" ,[响应内容] '响应内容'" + + + $" ,[请求CMD] 'CMD'" + + $" ,[请求FROM] 'FROM'" + + $" ,[请求TO] 'TO'" + + $" ,[TaskID] 'TaskID'" + + $" ,[AID] 'AID'" + + + $" FROM [记录_日志_项目运行日志]" + + $" WHERE 1=1 {whereStr}" + + $" ORDER BY [请求时间] DESC"; + DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, MesWorkForm.ConnectionString, out DataTable dt, out string err2); + label_Count.Text = $"消息数量:{dt.Rows.Count}"; + dgv_Log.DataSource = dt; + + for (int i = 0; i < dt.Rows.Count; i++) + { + // Log_Type LogType = Log_Type.Undefined; + var LogTypeStr = ""; + try + { + LogTypeStr = dt.Rows[i]["类型"].ToString(); + // LogType = (Log_Type)Enum.Parse(typeof(Log_Type), LogTypeStr); + } + catch (Exception err) + { + MessageBox.Show($"填充日志类型,类型转换出错!{err.Message}"); + break; + } + switch (LogTypeStr) + { + case "ZK_Alarm": + case "ZK_Delete": + RowsColor(i, MesWorkForm.color_Red, dgv_Log); + break; + case "ZK_Login": + RowsColor(i, MesWorkForm.color_Green, dgv_Log); + break; + case "ZK_Tip": + RowsColor(i, MesWorkForm.color_Yellow, dgv_Log); + break; + default: + RowsColor(i, MesWorkForm.color_Grey, dgv_Log); + break; + } + } + dgv_Log.ClearSelection(); + //dgv_Log.CurrentCell = null; + //dgv_Log.Rows[0].Selected = false; + + } + catch (Exception err) + { + MessageBox.Show($"点击查询按钮产生的未预知错误:【{err.Message }】------{err.StackTrace}"); + } + } + + + private void dgv_Log_CellClick(object sender, DataGridViewCellEventArgs e) + { + try + { + var AID = dgv_Log.CurrentRow.Cells["AID"].Value.ToString(); + + var sql = $"SELECT [请求内容安全] FROM [记录_日志_项目运行日志] WHERE [AID] = '{AID}'"; + DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, MesWorkForm.ConnectionString, out DataTable dt, out string err2); + var reqStrSafe = dt.Rows[0][0].ToString(); + var reqStr = dgv_Log.CurrentRow.Cells["请求内容"].Value.ToString(); + txt_RequestContext_3.Text = reqStr; + txt_ResponseContext_3.Text = dgv_Log.CurrentRow.Cells["响应内容"].Value.ToString(); + } + catch (Exception err) + { + } + } + + + } +} + \ No newline at end of file diff --git a/SCADA/manager_log/LogRecord.resx b/SCADA/manager_log/LogRecord.resx new file mode 100644 index 0000000..5e26ac6 --- /dev/null +++ b/SCADA/manager_log/LogRecord.resx @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/SCADA/任务管理.ico b/SCADA/任务管理.ico new file mode 100644 index 0000000..1ad3c11 Binary files /dev/null and b/SCADA/任务管理.ico differ diff --git a/WC_GKJ_OIL_SLN.sln b/WC_GKJ_OIL_SLN.sln new file mode 100644 index 0000000..4376a3d --- /dev/null +++ b/WC_GKJ_OIL_SLN.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33530.505 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WC_GKJ_OIL", "SCADA\WC_GKJ_OIL.csproj", "{A8D0B4EF-E223-4B9A-B2D9-0156B7B8B073}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "01_MW_Log", "MW_Log\01_MW_Log.csproj", "{1AC112C4-2400-4D03-A26D-2E3ACE6FE6D4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A8D0B4EF-E223-4B9A-B2D9-0156B7B8B073}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A8D0B4EF-E223-4B9A-B2D9-0156B7B8B073}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A8D0B4EF-E223-4B9A-B2D9-0156B7B8B073}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A8D0B4EF-E223-4B9A-B2D9-0156B7B8B073}.Release|Any CPU.Build.0 = Release|Any CPU + {1AC112C4-2400-4D03-A26D-2E3ACE6FE6D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1AC112C4-2400-4D03-A26D-2E3ACE6FE6D4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1AC112C4-2400-4D03-A26D-2E3ACE6FE6D4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1AC112C4-2400-4D03-A26D-2E3ACE6FE6D4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {69A6FC91-6BE5-4336-BCE5-EF3A80318EBA} + EndGlobalSection +EndGlobal