Example #1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            mtxCode.SelectAll();
            var key = shrink(mtxCode.Text);

            if (string.IsNullOrEmpty(key))
            {
                return;
            }

            Cursor = Cursors.WaitCursor;
            try {
                if (!ckHistory.Checked)
                {
                    var c = LableCode.QueryByLCode(key);
                    if (c != null)
                    {
                        showlabel(c);
                    }
                    else
                    {
                        showwarning(key, "当前运行数据");
                    }
                    lbx.Items.Insert(0, $"<当前运行数据>查询结果:");
                    lbx.Items.Insert(0, $"---------------------");
                }

                if (ckHistory.Checked)
                {
                    var c = LableCode.QueryByLCodeFromHis(key);
                    if (c != null && c.Count() != 0)
                    {
                        foreach (var obj in c)
                        {
                            showlabel(obj);
                        }
                    }
                    else
                    {
                        showwarning(key, "历史数据");
                    }

                    var count = c == null ? 0 : c.Count;
                    lbx.Items.Insert(0, $"<历史数据>查询结果({count}):");
                    lbx.Items.Insert(0, $"---------------------");
                }
            } finally { Cursor = Cursors.Default; }
        }