using DevExpress.XtraEditors; using DevExpress.XtraReports.UI; using ICSharpCode.Core; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.BinManage; using Mesnac.Action.ChemicalWeighing.Entity; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Printing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Mesnac.Action.ChemicalWeighing.Barrel { class BarcodeAction : ChemicalWeighingAction, IAction { #region 字段定义 private RuntimeParameter _runtime; private DbMCControl _clientGridControl = null; //物料信息控件 private DataGridView clientGridView = null; #endregion public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 this._runtime = runtime; DbMCControl materialDGV = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Hw_Barrel").FirstOrDefault(); if (materialDGV == null) { ICSharpCode.Core.LoggingService.Error("预览物料条码信息失败:未找到控件"); return; } this._clientGridControl = materialDGV; this.clientGridView = _clientGridControl.BaseControl as DataGridView; this.DoWork(); } /// /// 预览物料信息条码 /// protected void DoWork() { this._runtime.BaseControl.MCEnabled = false; try { if (clientGridView.SelectedRows.Count >= 1) { string code = clientGridView.SelectedRows[0].Cells["BarCode"].Value as string; FormBarcode frm=new FormBarcode(code); frm.ShowDialog(); } else { string msg2 = "请至少选择一条预览信息!"; MessageBox.Show(msg2, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { ICSharpCode.Core.LoggingService.Error("预览信息预览异常:" + ex.Message, ex); MessageBox.Show(ex.Message, Mesnac.Basic.LanguageHelper.WarnCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } finally { this._runtime.BaseControl.MCEnabled = true; } } } }