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.MaterialManage { class MaterialBarcodeAction : 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, "Pmt_material").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) { //List list = new List(); //for (int i=0; i< clientGridView.SelectedRows.Count; i++) //{ // Pmt_material material = new Pmt_material(); // material.Material_code = clientGridView.SelectedRows[i].Cells["Material_code"].Value as string; // material.Material_name = clientGridView.SelectedRows[i].Cells["Material_name"].Value as string; // list.Add(material); //} //BarcodeReport report = new BarcodeReport(); //report.DataSource = list; //ReportPrintTool tool = new ReportPrintTool(report); //tool.ShowPreview(); string code = clientGridView.SelectedRows[0].Cells["Material_code"].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; } } } }