예제 #1
0
        // Gets a full list of all customers ordered by lastname.
        // Fields: [LastName, FirstName] As FullName, ID
        private ErrorValue GetCustomers(Command command)
        {
            string sql = "SELECT LastName + ', ' + FirstName As FullName, ID FROM Customers Order By LastName";

            List <Customer> customers = new List <Customer>();

            using (var connection = new SqlConnection(CONNECTIONSTRING))
            {
                customers = connection.Query <Customer>(sql).ToList();
            }

            command.ReadValue = TcHmiSerializer.SerializeObject(customers);

            command.ExtensionResult = ExtensionErrorValue.HMI_EXT_SUCCESS;
            return(ErrorValue.HMI_SUCCESS);
        }
예제 #2
0
        private ErrorValue GetProducts(Command command)
        {
            string sql = "SELECT id, Title FROM Inventory";

            List <Product> product = new List <Product>();

            using (var connection = new SqlConnection(CONNECTIONSTRING))
            {
                product = connection.Query <Product>(sql).ToList();
            }

            command.ReadValue = TcHmiSerializer.SerializeObject(product);


            command.ExtensionResult = ExtensionErrorValue.HMI_EXT_SUCCESS;
            return(ErrorValue.HMI_SUCCESS);
        }