94 lines
3.0 KiB
C#
94 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace RFIDServicePlate
|
|
{
|
|
/// <summary>
|
|
/// MainWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
System.Collections.ObjectModel.ObservableCollection<CommodityModel> CommodityList = new System.Collections.ObjectModel.ObservableCollection<CommodityModel>();
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void btn_Conn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var result = RFID.InitRFIDConn(2, "", "", "com1", "38400", "8E1");
|
|
text_Read.Text = result.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
text_Read.Text = ex.Message;
|
|
}
|
|
}
|
|
|
|
private void btn_Read_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
CommodityList = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Collections.ObjectModel.ObservableCollection<CommodityModel>>(
|
|
Newtonsoft.Json.JsonConvert.SerializeObject(ESSupport.Lib.SyBaseHelper.QueryOdbc(
|
|
@"SELECT A.COMMODITY_NAME AS CommodityName,
|
|
A.COMMODITY_RETAILPRICE AS CommodityPrice,
|
|
A.COMMODITY_CODE AS CommodityCode
|
|
FROM T_COMMODITYEX A
|
|
WHERE A.SERVERPARTCODE = '888888' AND A.ISVALID = 1").Tables[0]));
|
|
((this.FindName("DataGrid_RFID")) as DataGrid).ItemsSource = CommodityList;
|
|
var result = RFID.TryReadRFTag();
|
|
text_Read.Text = result;
|
|
if (!string.IsNullOrWhiteSpace(result))
|
|
{
|
|
var RFIDCommodityList = result.Split('@').ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
text_Read.Text = ex.Message;
|
|
}
|
|
}
|
|
|
|
private void btn_Write_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string str_Code = CommodityList[DataGrid_RFID.SelectedIndex].CommodityCode;
|
|
var result = RFID.TryWriteRFTag(str_Code);
|
|
text_Read.Text = result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
text_Read.Text = ex.Message;
|
|
}
|
|
}
|
|
|
|
private void btn_Close_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var result = RFID.Dis_pose();
|
|
text_Read.Text = result.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
text_Read.Text = ex.Message;
|
|
}
|
|
}
|
|
}
|
|
}
|