FrmRFIPEdit.cs 2.8 KB

using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OnlineStore.AssemblyLine
{
    internal partial class FrmRFIPEdit : FrmBase
    {  
        internal FrmRFIPEdit( )
        { 
            InitializeComponent();
        }
        private Dictionary<string, string> rfMap = new Dictionary<string, string>();
        private void FrmPwd_Load(object sender, EventArgs e)
        {
            comboxType.Items.Clear();
            foreach (EquipBase b in LineManager.Line.AllEquipMap.Values)
            {
                string key = b.Name + "-托盘RF";
                string value = TrayManager.GetRFIP(b.DeviceID);
                rfMap.Add(key, value);
                comboxType.Items.Add(key);
            }
            comboxType.SelectedIndex = 0;
            comType.SelectedIndex = 0;
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            string ip = txtIP.Text;
            int type = comType.SelectedIndex+1;
            int value = (int)numNum.Value;
            DialogResult result = MessageBox.Show( "确定将【"+comboxType.Text+"】当前的托盘编号定为【"+value+"】?", "确定提示", MessageBoxButtons.OKCancel);
            if (result.Equals(DialogResult.OK))
            {
                RFIPManager.WriteData(ip, new RFIPData(value, type));
            }
        }

        private void btnBack_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string ip = txtIP.Text;
           RFIPData data= RFIPManager.ReadData(ip);
            string resul = "";
            if (data != null)
            {
                resul = data.ToStr();
            }
            MessageBox.Show("读取到数据:" + resul);
        }

        private void comboxType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboxType.SelectedIndex >= 0)
            {
                string V = rfMap[comboxType.Text];
                if (!txtIP.Text.Equals(V))
                {
                    txtIP.Text = V;
                }
            }
        }

        private void btnFind_Click(object sender, EventArgs e)
        {
            string ip = txtIP.Text;
            bool result = RFIPManager.FindRFID(ip);
            if (result)
            {
                lblHas.Text = "有标签";
                lblHas.ForeColor = Color.Green;
            }
            else
            {
                lblHas.Text = "无标签";
                lblHas.ForeColor = Color.Red;
            }
        }
    }
}