Ejemplo n.º 1
0
        /// <summary>
        /// 开始波次
        /// </summary>
        /// <param name="waveNo"></param>
        private void SortWaveBegin(string waveNo)
        {
            if (!string.IsNullOrWhiteSpace(SlaveInfoService.SlaveInfo.WaveNo) && !SlaveInfoService.SlaveInfo.IsPrintOver)
            {
                SoundService.PlaySoundAsny(SoundType.WatitPrintOver);
                UpDownService.SetText("请等待打印完毕!");
                return;
            }

            var waveApi = WaveApiService.Get(waveNo);

            if (waveApi == null)
            {
                UpDownService.WaveNotfound(waveNo);
                Invoke((MethodInvoker) delegate()
                {
                    lblMsg.Text = $"未找到波次:{waveNo}";
                });

                return;
            }
            if (waveApi.Status == WaveStatus.Complete)
            {
                //var result = MessageBox.Show($"波次:{waveNo}已分拣完,是否重新分拣?", "提示",
                //          MessageBoxButtons.OKCancel);
                //if (result == DialogResult.OK)
                //{
                var slaveInfo = SlaveInfoService.GetSlaveInfo(o => o.WaveNo == waveNo);
                SlaveInfoService.DeleteSlaveInfo(slaveInfo);
                slaveInfo = WaveApiService.WaveApiTransformSlaveInfo(waveApi);
                UpDownService.BeginSort(slaveInfo);
                Invoke((MethodInvoker) delegate()
                {
                    lblMsg.Text = $"开始波次:{waveNo}";
                });
                //}
                return;
            }
            if (waveApi.Status == WaveStatus.Unwork)
            {
                var slaveInfo = WaveApiService.WaveApiTransformSlaveInfo(waveApi);
                if (slaveInfo != null)
                {
                    UpDownService.BeginSort(slaveInfo);
                    Invoke((MethodInvoker) delegate()
                    {
                        lblMsg.Text = $"开始波次:{waveNo}";
                    });
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 开始分拣
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void StarMenu_Click(object sender, EventArgs e)
 {
     try
     {
         if (ConnectBoard())
         {
             //检查是否有上次未分拨完的
             var slaveInfo = SlaveInfoService.GetSlaveInfo(o => !o.IsComplete);
             if (slaveInfo != null)
             {
                 var result = MessageBox.Show($"波次:{slaveInfo.WaveNo}未分拣完,是否继续?", "提示",
                                              MessageBoxButtons.OKCancel);
                 if (result == DialogResult.OK)
                 {
                     UpDownService.BeginSort(slaveInfo);
                     lblMsg.Text = $"开始波次:{slaveInfo.WaveNo}";
                 }
                 else
                 {
                     SlaveInfoService.DeleteSlaveInfo(slaveInfo);
                 }
             }
             try
             {
                 if (serialPort_Scan.IsOpen)
                 {
                     serialPort_Scan.Close();
                 }
                 serialPort_Scan.PortName = SysConfig.ScanPortName ?? "";
                 serialPort_Scan.Open();
             }
             catch (Exception ex) { LogHelper.SaveAsyn("开始分拣出错", ex); }
             txtInput.Enabled = true;
             txtInput.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         LogHelper.SaveAsyn("开始分拣出错", ex);
     }
 }