Exemple #1
0
        public GoodsManagementSubsystem()
        {
            InitializeComponent();

            //行状态事件,用户添加新行时进行标记
            dgvAddItem.UserAddedRow += (x, y) => isAdd = true;

            //窗体加载时的动作
            this.Load += (x, y) =>
            {
                serialPort    = new PL2303();
                DGVDataSource = USDataAccess.Select("select id as 商品代码,name as 商品名,price as 价格,manufacturer as 生产厂家,productiondate as 生产日期,validuntil as 有效期,count(commodityId) as 库存数 from  [terminal] as t1 join [commodity] as t2 on t1.commodityId = t2.id group by commodityId;");
            };

            //串口随窗体焦点改变而开/关
            this.Activated  += (x, y) => { serialPort?.Open(); timerBindingCard.Enabled = true; };
            this.Deactivate += (x, y) => { serialPort?.Close(); timerBindingCard.Enabled = false; };

            //记录输入的查询内容
            tbConditionAtMgr.LostFocus     += (x, y) => queryCondition = $"'{tbConditionAtMgr.Text}'";
            tbConditionAtDel.LostFocus     += (x, y) => queryCondition = $"'{tbConditionAtDel.Text}'";
            tbConditionAtBinding.LostFocus += (x, y) => queryCondition = $"'{tbConditionAtBinding.Text}'";

            //输入时自动清空原有内容
            tbConditionAtMgr.Click     += (x, y) => tbConditionAtMgr.Text = "";
            tbConditionAtDel.Click     += (x, y) => tbConditionAtDel.Text = "";
            tbConditionAtBinding.Click += (x, y) => tbConditionAtBinding.Text = "";
        }
        public SmartShelvesTerminal()
        {
            InitializeComponent();

            //debug
            USDataAccess.Delete("delete from [terminal] where tid = 0;");

            //登记并显示货柜
            curTid = USDataAccess.Select("select distinct [tid] from [terminal] where [tid] != 0;").Rows.Count + 1;

            //相关事件
            tbQueryCondition.Click += (x, y) => tbQueryCondition.Text = "";
            this.Load += (x, y) =>
            {
                serialPort            = new PL2303();
                dgvDisplay.DataSource = USDataAccess.Select($"select tid as 所在货柜, name as 商品名, price as 价格, manufacturer as 生产厂家, productiondate as 生产日期, validuntil as 有效期, count(commodityId) as 库存数 from[terminal] as t1 join[commodity] as t2 on t1.commodityId = t2.id and tid = {curTid} group by commodityId;");
            };
            this.Activated  += (x, y) => { serialPort?.Open(); timerSerialPort.Enabled = true; };
            this.Deactivate += (x, y) => { serialPort?.Close(); timerSerialPort.Enabled = false; };
        }