Example #1
0
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);
            MeasurementSystemSetting.LoadSystem(1);
            referencesMonitoring.Enabled = false;
            if (measurementJob != null)
            {
                measurementJob.Logout();
            }

            if (referencesProcess != null)
            {
                referencesProcess.StopProcess();
            }
            if (measurementProcess != null)
            {
                measurementProcess.StopProcess();
            }
            if (measurementController != null)
            {
                measurementController.Disconnect();
                measurementController.Dispose();
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var operStr = textBox2.Text.Trim();
            var sn      = textBox1.Text.ToUpper().Trim();
            var csn     = textBox3.Text.ToUpper().Trim();
            var pid     = cbProductID.SelectedValue.CastTo(Guid.Empty);

            if (pid == Guid.Empty)
            {
                AppFramework.Context.ShowError("请选择一个产品");
                return;
            }
            if (string.IsNullOrEmpty(operStr))
            {
                textBox2.Focus();
                textBox2.SelectAll();
                AppFramework.Context.ShowError("请输入操作员信息");
                return;
            }
            if (string.IsNullOrEmpty(sn))
            {
                textBox1.Focus();
                textBox1.SelectAll();
                return;
            }
            var db = MeasurementSystemSetting.GetDbManager();

            if (string.IsNullOrEmpty(csn))
            {
                var ccsn = db.ExecuteScalar(
                    new SqlQuery("SerialNumberInfo")
                    .Select("CustomerSN")
                    .Where("SN", sn)
                    .Where("ProductID", pid)
                    );

                if (ccsn != null)
                {
                    if (!AppFramework.Context.ShowConfirm($"{sn}已经绑定,是否重新绑定钢管号码?"))
                    {
                        textBox1.Clear();
                        textBox3.Clear();

                        textBox1.Focus();
                        textBox1.SelectAll();
                        return;
                    }
                    textBox3.Text = ccsn.ToString();
                }
                textBox3.Focus();
                textBox3.SelectAll();
                return;
            }

            var cid = db.ExecuteScalar(
                new SqlQuery("SerialNumberInfo")
                .Select("CustomerSN")
                .Where("CustomerSN", csn)
                );

            if (cid != null)
            {
                AppFramework.Context.ShowError($"钢管{cid}已经使用,请检查。");
                textBox3.Clear();

                textBox3.Focus();
                textBox3.SelectAll();
                return;
            }

            var sql = default(ISqlInstruction);
            var sid = db.ExecuteScalar(
                new SqlQuery("SerialNumberInfo")
                .Select("ItemID")
                .Where("SN", sn)
                .Where("ProductID", pid)
                );

            if (sid == null)
            {
                sql = new SqlInsert("SerialNumberInfo")
                      .InColumnValue("ItemID", Guid.NewGuid())
                      .InColumnValue("ProductID", pid)
                      .InColumnValue("SN", sn)
                      .InColumnValue("CustomerSN", csn);
            }
            else
            {
                sql = new SqlUpdate("SerialNumberInfo")
                      .Set("CustomerSN", csn)
                      .Where("ItemID", sid);
            }
            db.ExecuteNonQuery(sql);

            var row = testItem.NewRow();

            row["SN"]         = sn;
            row["CustomerSN"] = csn;
            row["Operator"]   = operStr;
            row["DateTime"]   = DateTime.Now;
            testItem.Rows.InsertAt(row, 0);
            textBox1.Clear();
            textBox3.Clear();

            textBox1.Focus();
            textBox1.SelectAll();
        }