You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.5 KiB
C#

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 Mesnac.Action.ChemicalWeighing.Entity.material;
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.XlMaterialManage
{
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, "xl_material").FirstOrDefault();
if (materialDGV == null)
{
ICSharpCode.Core.LoggingService<MaterialBarcodeAction>.Error("预览物料条码信息失败:未找到控件");
return;
}
this._clientGridControl = materialDGV;
this.clientGridView = _clientGridControl.BaseControl as DataGridView;
this.DoWork();
}
/// <summary>
/// 预览物料信息条码
/// </summary>
protected void DoWork()
{
this._runtime.BaseControl.MCEnabled = false;
try
{
if (clientGridView.SelectedRows.Count >= 1)
{
//List<xl_material> list = new List<xl_material>();
//for (int i=0; i< clientGridView.SelectedRows.Count; i++)
//{
// xl_material material = new xl_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<MaterialBarcodeAction>.Error("物料信息打印预览异常:" + ex.Message, ex);
MessageBox.Show(ex.Message, Mesnac.Basic.LanguageHelper.WarnCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
finally
{
this._runtime.BaseControl.MCEnabled = true;
}
}
}
}