条码打印基于:BarTender、ORM EF架构
UI展示:
主页代码:
using NPOI.OpenXmlFormats.Spreadsheet;
using ServerSide.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PlantProcessControlSystem.BarCodePrint
{
//tss_nowdate
public partial class Main_BarCodePrint_Frm : Form
{
private System.Windows.Forms.Timer timer;
//1.声明自适应类实例
private AutoSizeFormClass asc = null;
private AutoSetControlSize ass = null;
public Main_BarCodePrint_Frm()
{
InitializeComponent();
ass = new AutoSetControlSize(this, this.Width, this.Height);
}
#region 窗体控件事件
private void btn_Close_Click(object sender, EventArgs e)
{
if (((Button)sender).Name == "btn_Close")//窗体关闭
{
//DialogResult result = MessageBox.Show("是否确认退出??","提醒",MessageBoxButtons.YesNo,MessageBoxIcon.Warning);
//if (result == DialogResult.Yes)
// Application.Exit();
//else
// return;
//this.Hide();//隐藏
//tlrm_Show.Enabled = true;//控件可使用
Environment.Exit(0);
//Application.Exit();
}
else if (((Button)sender).Name == "btn_WinMinSize")//窗体最小化
{
this.WindowState = FormWindowState.Minimized;
}
else if (((Button)sender).Name == "btn_WinMaxSize")//窗体最大化
{
if (this.WindowState == FormWindowState.Normal)
this.WindowState = FormWindowState.Maximized;
else
this.WindowState = FormWindowState.Normal;
}
}
#endregion
#region 时间同步
private void Timer_Tick(object sender, EventArgs e)
{
tss_nowdate.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
#endregion
#region 窗体加载
private void Main_BarCodePrint_Frm_Load(object sender, EventArgs e)
{
timer = new System.Windows.Forms.Timer();
timer.Interval = 1000;
timer.Tick += Timer_Tick;
timer.Enabled = true;
}
#endregion
#region 窗体移动
private Point mouseOff;//鼠标移动位置变量
private bool leftFlag;//标签是否为左键
private void Frm_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseOff = new Point(-e.X, -e.Y); //得到变量的值
leftFlag = true; //点击左键按下时标注为true;
}
}
private void Frm_MouseMove(object sender, MouseEventArgs e)
{
if (leftFlag)
{
Point mouseSet = Control.MousePosition;
mouseSet.Offset(mouseOff.X, mouseOff.Y); //设置移动后的位置
Location = mouseSet;
}
}
private void Frm_MouseUp(object sender, MouseEventArgs e)
{
if (leftFlag)
{
leftFlag = false;//释放鼠标后标注为false;
}
}
#endregion
#region 移动鼠标
private void MainFrm_Move(object sender, EventArgs e)
{
// 获取当前鼠标的坐标
Point cursorPosition = Cursor.Position;
TS_X.Text = cursorPosition.X.ToString();
TS_Y.Text = cursorPosition.Y.ToString();
tss_State.Text = "当前状态:操作";
}
#endregion
#region 装载窗体
///
/// 装载窗体
///
///
private void OpenForm(Form childFrom)
{
//首先判断容器中是否有其他的窗体
foreach (Control item in this.Panel_Winfrm.Controls)
{
if (item is Form)
{
((Form)item).Close();
}
}
//嵌入新的窗体
childFrom.TopLevel = false;//将子窗体设置成非顶级控件
// childFrom.FormBorderStyle = FormBorderStyle.None;//去掉窗体边框(目前不需要了)
childFrom.Parent = this.Panel_Winfrm;//设置窗体的容器
childFrom.Dock = DockStyle.Fill;//随着容器大小自动调整窗体大小(目前可能没有效果)
childFrom.Show();
}
#endregion
#region 窗体自适应
private void MainFrm_SizeChanged(object sender, EventArgs e)
{
asc = new AutoSizeFormClass(this);
asc.controlAutoSize(this);
}
private void MainFrm_Resize(object sender, EventArgs e)
{
ass.setControls((this.Width) / ass.X, (this.Height) / ass.Y, this);
}
#endregion
#region 树形菜单单击事件
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node.Text == "配置.客户信息")
{
CfgClientInfoFrm cfgClientInfoFrm = new CfgClientInfoFrm();
this.OpenForm(cfgClientInfoFrm);
}
else if (e.Node.Text == "配置.产品信息")
{
CfgProductInfoFrm cfgProductInfoFrm = new CfgProductInfoFrm();
this.OpenForm(cfgProductInfoFrm);
}
else if (e.Node.Text == "配置.订单信息")
{
CfgOrderInfoFrm cfgOrderInfoFrm = new CfgOrderInfoFrm();
this.OpenForm(cfgOrderInfoFrm);
}
else if (e.Node.Text == "配置.条码工序信息")
{
CfgBarCodeWkInfoFrm cfgBarCodeWkInfoFrm = new CfgBarCodeWkInfoFrm();
this.OpenForm(cfgBarCodeWkInfoFrm);
}
else if ((e.Node.Text == "在线.条码打印"))
{
OnLineBarCodePrintFrm onLineBarCodePrintFrm = new OnLineBarCodePrintFrm();
this.OpenForm(onLineBarCodePrintFrm);
}
else if (e.Node.Text == "配置.打印模板")
{
CfgBarCodePrintTemplateFrm cfgBarCodePrintTemplateFrm = new CfgBarCodePrintTemplateFrm();
this.OpenForm(cfgBarCodePrintTemplateFrm);
}
else if (e.Node.Text == "配置.条码打印参数")
{
CfgBarCodePrintInfoFrm cfgBarCodePrintInfoFrm = new CfgBarCodePrintInfoFrm();
cfgBarCodePrintInfoFrm.callBack += new Action((b) =>
{
if (b == false) this.Hide();
else this.Show();
});
this.OpenForm((cfgBarCodePrintInfoFrm));
}
else if (e.Node.Text == "配置.动态字段")
{
CfgBarCodeInfoFrm cfgBarCodeInfoFrm = new CfgBarCodeInfoFrm();
this.OpenForm(cfgBarCodeInfoFrm);
}
}
#endregion
}
}
using ServerSide.DAL;
using ServerSide.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PlantProcessControlSystem.BarCodePrint
{
public partial class CfgBarCodeWkInfoFrm : Form
{
private List processinformations;//工序信息
private Processinformation oldProcessinformation;//旧的工序信息
public string errInfo;//错误信息
public CfgBarCodeWkInfoFrm()
{
InitializeComponent();
}
#region 初始化界面
private void InitWinFrmTable()
{
using (EFContext db = new EFContext())
{
this.processinformations = new List();
this.processinformations = db!.Processinformation!.ToList();
this.dataSource.DataSource = processinformations;
txt_Process.Text = "";
txt_Process.Enabled = false;
}
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
this.dataSource.ClearSelection();
}
#endregion
#region 返回
private void btn_Result_Click(object sender, EventArgs e)
{
this.InitWinFrmTable();
this.pe_Processinfo.Visible = false;
}
#endregion
#region 添加
private void btn_Add_Click(object sender, EventArgs e)
{
this.lbl_ItemName.Text = "添加";
this.pe_Processinfo.Visible = true;
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
this.txt_Process.Text = "";
this.oldProcessinformation = null;
this.txt_Process.Enabled = true;
}
#endregion
#region 删除
private void btn_Del_Click(object sender, EventArgs e)
{
this.pe_Processinfo.Visible = true;
this.lbl_ItemName.Text = "删除";
this.txt_Process.Enabled = false;
this.btn_Save.Focus();
}
#endregion
#region 修改
private void btn_Rework_Click(object sender, EventArgs e)
{
this.pe_Processinfo.Visible = true;
this.lbl_ItemName.Text = "修改";
this.txt_Process.Enabled = true;
this.txt_Process.SelectAll();
this.txt_Process.Focus();
}
#endregion
#region 保存
private void btn_Save_Click(object sender, EventArgs e)
{
if (txt_Process.Text != string.Empty && txt_Process.Text.Length > 0)
{
using (EFContext db = new EFContext())
{
if (lbl_ItemName.Text == "添加")
{
Processinformation processinformation = new Processinformation
{
PrsName = txt_Process.Text
};
db?.Processinformation?.Add(processinformation);
}
else if (lbl_ItemName.Text == "修改")
{
db!.Processinformation!.ToList().ForEach((p) =>
{
if (p.PrsInfoID == oldProcessinformation.PrsInfoID)
p.PrsName = txt_Process.Text;
});
}
else if (lbl_ItemName.Text == "删除")
{
db?.Processinformation?.Remove(oldProcessinformation);
}
int result = db!.SaveChanges();
if (result <= 0)
MessageBox.Show("数据保存失败!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
this.pe_Processinfo.Visible = false;
this.InitWinFrmTable();
}
}
#endregion
#region 窗体加载
private void CfgBarCodeWkInfoFrm_Load(object sender, EventArgs e)
{
this.InitWinFrmTable();
this.dataSource.ClearSelection();
}
#endregion
#region 点击选择
private void dataSource_CellClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (e.RowIndex >= 0)
{
if (processinformations[e.RowIndex] != null)
{
this.oldProcessinformation = new Processinformation();
this.oldProcessinformation = processinformations[e.RowIndex];
this.btn_Del.Enabled = true;
this.btn_Rework.Enabled = true;
this.txt_Process.Text = processinformations[e.RowIndex].PrsName;
}
else
{
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
}
}
this.pe_Processinfo.Visible = false;
}
catch (Exception ex)
{
this.errInfo = string.Empty;
MessageBox.Show($@"{ex.Message}", "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
}
}
using ServerSide.DAL;
using ServerSide.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PlantProcessControlSystem.BarCodePrint
{
public partial class CfgProductInfoFrm : Form
{
private List productNames;//产品名称
private ProductNames oldproductName;
private string ErrInfo;//错误信息
public CfgProductInfoFrm()
{
InitializeComponent();
}
#region 初始化界面
private void InitWinFrmTable()
{
using (EFContext db = new EFContext())
{
productNames = new List();
productNames = db!.ProductNames!.ToList();
this.dataSource.DataSource = productNames;
cmb_Client.Items.Clear();
db!.ClientInfo!.ToList().ForEach((c) => cmb_Client.Items.Add(c.ClientName));
txt_ProductName.Text = "";
txt_ProductName.Enabled = false;
cmb_Client.Enabled = true;
}
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
this.dataSource.ClearSelection();
}
#endregion
#region 窗体加载
private void CfgProductInfoFrm_Load(object sender, EventArgs e)
{
this.InitWinFrmTable();
}
#endregion
#region 修改
private void btn_Rework_Click(object sender, EventArgs e)
{
this.pe_ProductInfo.Visible = true;
this.lbl_ItemName.Text = "修改";
this.txt_ProductName.SelectAll();
this.txt_ProductName.Focus();
}
#endregion
#region 册除
private void btn_Del_Click(object sender, EventArgs e)
{
this.pe_ProductInfo.Visible = true;
this.lbl_ItemName.Text = "删除";
this.txt_ProductName.Enabled = false;
this.cmb_Client.Enabled = false;
}
#endregion
#region 添加
private void btn_Add_Click(object sender, EventArgs e)
{
this.lbl_ItemName.Text = "添加";
this.pe_ProductInfo.Visible = true;
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
this.txt_ProductName.Text = "";
this.oldproductName = null;
}
#endregion
#region 返回
private void btn_Result_Click(object sender, EventArgs e)
{
this.InitWinFrmTable();
this.pe_ProductInfo.Visible = false;
}
#endregion
#region 保存
private void btn_Save_Click(object sender, EventArgs e)
{
if (txt_ProductName.Text != string.Empty && txt_ProductName.Text.Length > 0)
{
using (EFContext db = new EFContext())
{
if (lbl_ItemName.Text == "添加")
{
ProductNames productNames = new ProductNames
{
ClientId = db?.ClientInfo?.ToList()?.Where(c => c.ClientName == cmb_Client.Text)?.FirstOrDefault()?.ClientId,
ProductName = txt_ProductName.Text
};
db?.ProductNames?.Add(productNames);
}
else if (lbl_ItemName.Text == "修改")
{
oldproductName.ProductName = txt_ProductName.Text;
db?.ProductNames?.ToList().ForEach(p =>
{
if (p.ProductId == oldproductName.ProductId)
p.ProductName = txt_ProductName.Text;
});
}
else if (lbl_ItemName.Text == "删除")
{
db?.ProductNames?.Remove(oldproductName);
}
int result = db.SaveChanges();
if (result <= 0) MessageBox.Show("数据保存失败!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
this.pe_ProductInfo.Visible = false;
this.InitWinFrmTable();
}
#endregion
#region 选择客户名称
private void cmb_Client_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmb_Client.Text != string.Empty)
{
txt_ProductName.Enabled = true;
txt_ProductName.Focus();
}
}
#endregion
#region 点击选择
private void dataSource_CellClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (e.RowIndex >= 0)
{
if (productNames[e.RowIndex] != null)
{
//txt_UserName.Text = allAuthorizedUsers[e.RowIndex].UserName;
//txt_NickName.Text = allAuthorizedUsers[e.RowIndex].NickName;
//pte_Image.Image = ImageHelper.ByteToImage(allAuthorizedUsers[e.RowIndex].Picture);
//pnl_Edit.Visible = true;
using (EFContext db = new EFContext())
{
this.cmb_Client.Text = db?.ClientInfo?.ToList()?.Where(c => c?.ClientId == productNames[e.RowIndex]?.ClientId)?.FirstOrDefault()?.ClientName;
}
this.oldproductName = new ProductNames();
this.oldproductName = productNames[e.RowIndex];
this.btn_Del.Enabled = true;
this.btn_Rework.Enabled = true;
this.txt_ProductName.Text = productNames[e.RowIndex].ProductName;
//this.btn_Query.Enabled = true;
}
else
{
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
}
}
this.pe_ProductInfo.Visible = false;
}
catch (Exception ex)
{
//LogHelper.Error("授权信息", ex);
this.ErrInfo = string.Empty;
MessageBox.Show($@"{ex.Message}", "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
//WMessageBox wMessageBox = new WMessageBox(ex.Message, Color.Red);
}
}
#endregion
}
}
using NPOI.OpenXmlFormats.Spreadsheet;
using ServerSide.DAL;
using ServerSide.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PlantProcessControlSystem.BarCodePrint
{
public partial class CfgOrderInfoFrm : Form
{
private List configBarCodeOrderInfoEntities;//配置订单信息
private ConfigBarCodeOrderInfoEntity oldconfigBarCodeOrderInfoEntity;//
public string ErrInfo;//错误日志
public CfgOrderInfoFrm()
{
InitializeComponent();
this.InitWinFrmTable();
}
#region 初始化界面
private void InitWinFrmTable()
{
using (EFContext db = new EFContext())
{
configBarCodeOrderInfoEntities = new List();
db?.ConfigBarCodeOrderInfoEntity?.ToList().ForEach(c => configBarCodeOrderInfoEntities.Add(c));
dtgv_dataSource.DataSource = configBarCodeOrderInfoEntities;//数据源
cmb_ProductName.Text = "";//产品名称
cmb_ProductName.Items.Clear();
db?.ProductNames?.ToList().ForEach(p => cmb_ProductName.Items.Add(p.ProductName));
txt_OrderNum.Text = "";//订单号
txt_BoxNum.Text = "";//外箱序号
txt_OrderTotal.Text = "";//订单总数
cmb_Binding_Nbr.Text = "";//绑码数
cmb_Binding_Nbr.Items.Clear();
for (int i = 1; i <= 60; i++)
cmb_Binding_Nbr.Items.Add(i.ToString());
}
btn_Del.Enabled = false;//删除
btn_Rework.Enabled = false;//修改
btn_Query.Enabled = false;//查询
this.txt_OrderNum.Enabled = true;
this.cmb_ProductName.Enabled = true;
this.txt_BoxNum.Enabled = true;
this.txt_OrderTotal.Enabled = true;
this.cmb_Binding_Nbr.Enabled = true;
pe_OrderInfo.Visible = false;
}
#endregion
#region 添加
private void btn_Add_Click(object sender, EventArgs e)
{
this.lbl_ItemName.Text = "添加";
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
oldconfigBarCodeOrderInfoEntity = null;
this.InitWinFrmTable();
this.pe_OrderInfo.Visible = true;
}
#endregion
#region 删除
private void btn_Del_Click(object sender, EventArgs e)
{
this.lbl_ItemName.Text = "删除";
this.pe_OrderInfo.Visible = true;
this.txt_OrderNum.Enabled = false;
this.cmb_ProductName.Enabled = false;
this.txt_BoxNum.Enabled = false;
this.txt_OrderTotal.Enabled = false;
this.cmb_Binding_Nbr.Enabled = false;
}
#endregion
#region 修改
private void btn_Rework_Click(object sender, EventArgs e)
{
this.lbl_ItemName.Text = "修改";
this.txt_OrderNum.Enabled = true;
this.cmb_ProductName.Enabled = true;
this.txt_BoxNum.Enabled = true;
this.txt_OrderTotal.Enabled = true;
this.cmb_Binding_Nbr.Enabled = true;
this.pe_OrderInfo.Visible = true;
}
#endregion
#region 保存
private void btn_Save_Click(object sender, EventArgs e)
{
using (EFContext db = new EFContext())
{
if (txt_BoxNum.Text != string.Empty &&
txt_OrderNum.Text != string.Empty &&
txt_OrderTotal.Text != string.Empty &&
cmb_Binding_Nbr.Text != string.Empty &&
cmb_ProductName.Text != string.Empty)
{
if (this.lbl_ItemName.Text == "添加")
{
oldconfigBarCodeOrderInfoEntity = new ConfigBarCodeOrderInfoEntity
{
OrderInfo = txt_OrderNum.Text.Trim(),
ProductId = db?.ProductNames?.ToList()?.Where(p => p.ProductName == cmb_ProductName.Text)?.FirstOrDefault()?.ProductId,
OrderCount = Convert.ToInt32(txt_OrderTotal.Text.Trim()),
CartonSerialNumber = txt_BoxNum?.Text.Trim(),
PackingBindingCode = Convert.ToInt32(cmb_Binding_Nbr.Text.Trim()),
FuselageScanCount = 0,
GiftBoxScanCount = 0,
MasterCartonScanCount = 0
};
db?.ConfigBarCodeOrderInfoEntity?.Add(oldconfigBarCodeOrderInfoEntity);
}
else if (this.lbl_ItemName.Text == "修改")
{
db?.ConfigBarCodeOrderInfoEntity?.ToList().ForEach((c) =>
{
if (c.WorkOrderId == oldconfigBarCodeOrderInfoEntity.WorkOrderId)
{
c.OrderInfo = txt_OrderNum.Text.Trim();
c.ProductId = db?.ProductNames?.ToList()?.Where(p => p?.ProductName?.Trim() == cmb_ProductName.Text.Trim())?.FirstOrDefault()?.ProductId;
c.OrderCount = Convert.ToInt32(txt_OrderTotal.Text.Trim());
c.CartonSerialNumber = txt_BoxNum?.Text.Trim();
c.PackingBindingCode = Convert.ToInt32(cmb_Binding_Nbr?.Text.Trim());
}
});
}
else if (this.lbl_ItemName.Text == "删除")
{
db?.ConfigBarCodeOrderInfoEntity?.Remove(oldconfigBarCodeOrderInfoEntity);
}
int result = db!.SaveChanges();
if (result <= 0) MessageBox.Show("数据保存失败!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.pe_OrderInfo.Visible = false;
this.InitWinFrmTable();//初始化界面
}
}
}
#endregion
#region 表单选择
private void dtgv_dataSource_CellClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (e.RowIndex >= 0)
{
if (configBarCodeOrderInfoEntities[e.RowIndex] != null)
{
this.oldconfigBarCodeOrderInfoEntity = new ConfigBarCodeOrderInfoEntity();
this.oldconfigBarCodeOrderInfoEntity.WorkOrderId = configBarCodeOrderInfoEntities[e.RowIndex].WorkOrderId;
this.oldconfigBarCodeOrderInfoEntity.ProductId = configBarCodeOrderInfoEntities[e.RowIndex].ProductId;
this.oldconfigBarCodeOrderInfoEntity.OrderInfo = configBarCodeOrderInfoEntities[e.RowIndex].OrderInfo;
this.oldconfigBarCodeOrderInfoEntity.CartonSerialNumber = configBarCodeOrderInfoEntities[e.RowIndex].CartonSerialNumber;
this.oldconfigBarCodeOrderInfoEntity.OrderCount = configBarCodeOrderInfoEntities[e.RowIndex].OrderCount;
this.oldconfigBarCodeOrderInfoEntity.FuselageScanCount = configBarCodeOrderInfoEntities[e.RowIndex].FuselageScanCount;
this.oldconfigBarCodeOrderInfoEntity.GiftBoxScanCount = configBarCodeOrderInfoEntities[e.RowIndex].GiftBoxScanCount;
this.oldconfigBarCodeOrderInfoEntity.MasterCartonScanCount = configBarCodeOrderInfoEntities[e.RowIndex].MasterCartonScanCount;
this.oldconfigBarCodeOrderInfoEntity.PackingBindingCode = configBarCodeOrderInfoEntities[e.RowIndex].PackingBindingCode;
this.txt_OrderNum.Text = configBarCodeOrderInfoEntities[e.RowIndex].OrderInfo;//订单数
this.txt_OrderTotal.Text = configBarCodeOrderInfoEntities[e.RowIndex].OrderCount.ToString();//订单总数
using (EFContext db = new EFContext())
{
this.cmb_ProductName.Text = db?.ProductNames?.ToList()?.Where(p => p.ProductId == configBarCodeOrderInfoEntities[e.RowIndex].ProductId)?.FirstOrDefault()?.ProductName;//产品名称
}
this.txt_BoxNum.Text = configBarCodeOrderInfoEntities[e.RowIndex].CartonSerialNumber;//外箱
//this.txt_OrderTotal.Text = configBarCodeOrderInfoEntities[e.RowIndex].OrderCount.ToString();//订单总数
this.cmb_Binding_Nbr.Text = configBarCodeOrderInfoEntities[e.RowIndex].PackingBindingCode.ToString();//绑码数
}
}
this.pe_OrderInfo.Visible = false;
btn_Del.Enabled = e.RowIndex >= 0 ? true : false;
btn_Rework.Enabled = e.RowIndex >= 0 ? true : false;
}
catch (Exception ex)
{
this.ErrInfo = $@"{ex.Message}";
MessageBox.Show($@"{ex.Message}", "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
#region 返回
private void btn_Result_Click(object sender, EventArgs e)
{
this.pe_OrderInfo.Visible = false;
this.InitWinFrmTable();
}
#endregion
}
}
using ServerSide.DAL;
using ServerSide.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PlantProcessControlSystem.BarCodePrint
{
public partial class CfgBarCodeWkInfoFrm : Form
{
private List processinformations;//工序信息
private Processinformation oldProcessinformation;//旧的工序信息
public string errInfo;//错误信息
public CfgBarCodeWkInfoFrm()
{
InitializeComponent();
}
#region 初始化界面
private void InitWinFrmTable()
{
using (EFContext db = new EFContext())
{
this.processinformations = new List();
this.processinformations = db!.Processinformation!.ToList();
this.dataSource.DataSource = processinformations;
txt_Process.Text = "";
txt_Process.Enabled = false;
}
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
this.dataSource.ClearSelection();
}
#endregion
#region 返回
private void btn_Result_Click(object sender, EventArgs e)
{
this.InitWinFrmTable();
this.pe_Processinfo.Visible = false;
}
#endregion
#region 添加
private void btn_Add_Click(object sender, EventArgs e)
{
this.lbl_ItemName.Text = "添加";
this.pe_Processinfo.Visible = true;
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
this.txt_Process.Text = "";
this.oldProcessinformation = null;
this.txt_Process.Enabled = true;
}
#endregion
#region 删除
private void btn_Del_Click(object sender, EventArgs e)
{
this.pe_Processinfo.Visible = true;
this.lbl_ItemName.Text = "删除";
this.txt_Process.Enabled = false;
this.btn_Save.Focus();
}
#endregion
#region 修改
private void btn_Rework_Click(object sender, EventArgs e)
{
this.pe_Processinfo.Visible = true;
this.lbl_ItemName.Text = "修改";
this.txt_Process.Enabled = true;
this.txt_Process.SelectAll();
this.txt_Process.Focus();
}
#endregion
#region 保存
private void btn_Save_Click(object sender, EventArgs e)
{
if (txt_Process.Text != string.Empty && txt_Process.Text.Length > 0)
{
using (EFContext db = new EFContext())
{
if (lbl_ItemName.Text == "添加")
{
Processinformation processinformation = new Processinformation
{
PrsName = txt_Process.Text
};
db?.Processinformation?.Add(processinformation);
}
else if (lbl_ItemName.Text == "修改")
{
db!.Processinformation!.ToList().ForEach((p) =>
{
if (p.PrsInfoID == oldProcessinformation.PrsInfoID)
p.PrsName = txt_Process.Text;
});
}
else if (lbl_ItemName.Text == "删除")
{
db?.Processinformation?.Remove(oldProcessinformation);
}
int result = db!.SaveChanges();
if (result <= 0)
MessageBox.Show("数据保存失败!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
this.pe_Processinfo.Visible = false;
this.InitWinFrmTable();
}
}
#endregion
#region 窗体加载
private void CfgBarCodeWkInfoFrm_Load(object sender, EventArgs e)
{
this.InitWinFrmTable();
this.dataSource.ClearSelection();
}
#endregion
#region 点击选择
private void dataSource_CellClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (e.RowIndex >= 0)
{
if (processinformations[e.RowIndex] != null)
{
this.oldProcessinformation = new Processinformation();
this.oldProcessinformation = processinformations[e.RowIndex];
this.btn_Del.Enabled = true;
this.btn_Rework.Enabled = true;
this.txt_Process.Text = processinformations[e.RowIndex].PrsName;
}
else
{
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
}
}
this.pe_Processinfo.Visible = false;
}
catch (Exception ex)
{
this.errInfo = string.Empty;
MessageBox.Show($@"{ex.Message}", "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
}
}
using ServerSide.DAL;
using ServerSide.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PlantProcessControlSystem.BarCodePrint
{
public partial class CfgBarCodeInfoFrm : Form
{
private List configBarCodeInfoEntitys;//配置动态字段信息
private ConfigBarCodeInfoEntity oldConfigBarCodeInfoEntity;//旧的配置动态字段信息
public string errInfo;//错误信息
public CfgBarCodeInfoFrm()
{
InitializeComponent();
}
#region 初始化界面
private void InitWinFrmTable()
{
using (EFContext db = new EFContext())
{
this.configBarCodeInfoEntitys = new List();
this.configBarCodeInfoEntitys = db!.ConfigBarCodeInfoEntity!.ToList();
this.dataSource.DataSource = this.configBarCodeInfoEntitys;
txt_Process.Text = "";
txt_Process.Enabled = false;
txt_Description.Text = "";
txt_Description.Enabled = false;
}
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
this.dataSource.ClearSelection();
}
#endregion
#region 返回
private void btn_Result_Click(object sender, EventArgs e)
{
this.InitWinFrmTable();
this.pe_Processinfo.Visible = false;
}
#endregion
#region 添加
private void btn_Add_Click(object sender, EventArgs e)
{
this.lbl_ItemName.Text = "添加";
this.pe_Processinfo.Visible = true;
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
this.txt_Process.Text = "";
this.oldConfigBarCodeInfoEntity = null;
this.txt_Process.Enabled = true;
this.txt_Description.Enabled = true;
}
#endregion
#region 删除
private void btn_Del_Click(object sender, EventArgs e)
{
this.pe_Processinfo.Visible = true;
this.lbl_ItemName.Text = "删除";
this.txt_Process.Enabled = false;
this.txt_Description.Enabled = false;
this.btn_Save.Focus();
}
#endregion
#region 修改
private void btn_Rework_Click(object sender, EventArgs e)
{
this.pe_Processinfo.Visible = true;
this.lbl_ItemName.Text = "修改";
this.txt_Process.Enabled = true;
this.txt_Description.Enabled = true;
this.txt_Process.SelectAll();
this.txt_Process.Focus();
}
#endregion
#region 保存
private void btn_Save_Click(object sender, EventArgs e)
{
if ((txt_Process.Text != string.Empty && txt_Process.Text.Length > 0)&&
(txt_Description.Text!=string.Empty&&txt_Description.Text.Length>0))
{
using (EFContext db = new EFContext())
{
if (lbl_ItemName.Text == "添加")
{
ConfigBarCodeInfoEntity configBarCodeInfoEntity = new ConfigBarCodeInfoEntity
{
ConfigBarCodeName = txt_Process.Text,
ConfigDescription=txt_Description.Text
};
db?.ConfigBarCodeInfoEntity?.Add(configBarCodeInfoEntity);
}
else if (lbl_ItemName.Text == "修改")
{
db!.ConfigBarCodeInfoEntity!.ToList().ForEach((p) =>
{
if (p.cfBarCodeID == oldConfigBarCodeInfoEntity.cfBarCodeID)
{
p.ConfigBarCodeName = txt_Process.Text;
p.ConfigDescription=txt_Description.Text;
}
});
}
else if (lbl_ItemName.Text == "删除")
{
db?.ConfigBarCodeInfoEntity?.Remove(oldConfigBarCodeInfoEntity);
}
int result = db!.SaveChanges();
if (result <= 0)
MessageBox.Show("数据保存失败!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
this.pe_Processinfo.Visible = false;
this.InitWinFrmTable();
}
}
#endregion
#region 窗体加载
private void CfgBarCodeWkInfoFrm_Load(object sender, EventArgs e)
{
this.InitWinFrmTable();
this.dataSource.ClearSelection();
}
#endregion
#region 点击选择
private void dataSource_CellClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (e.RowIndex >= 0)
{
if (configBarCodeInfoEntitys[e.RowIndex] != null)
{
this.oldConfigBarCodeInfoEntity = new ConfigBarCodeInfoEntity();
this.oldConfigBarCodeInfoEntity = configBarCodeInfoEntitys[e.RowIndex];
this.btn_Del.Enabled = true;
this.btn_Rework.Enabled = true;
this.txt_Process.Text = configBarCodeInfoEntitys[e.RowIndex].ConfigBarCodeName;
this.txt_Description.Text = configBarCodeInfoEntitys[e.RowIndex].ConfigDescription;
}
else
{
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
}
}
this.pe_Processinfo.Visible = false;
}
catch (Exception ex)
{
this.errInfo = string.Empty;
MessageBox.Show($@"{ex.Message}", "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
}
}
using NPOI.SS.Formula.Functions;
using Org.BouncyCastle.Tls.Crypto;
using ServerSide.Common;
using ServerSide.DAL;
using ServerSide.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PlantProcessControlSystem
{
public partial class CfgBarCodePrintTemplateFrm : Form
{
private List configBarCodePrintTemplates;//斑码打印模板配置
private ConfigBarCodePrintTemplate oldconfigBarCodePrintTemplate;//旧的模板配置信息
public string errInfo;//错误日志
public CfgBarCodePrintTemplateFrm()
{
InitializeComponent();
this.InitWinFrmTable();
}
#region 初始化界面
private void InitWinFrmTable()
{
using (EFContext db = new EFContext())
{
configBarCodePrintTemplates = new List();
configBarCodePrintTemplates = db!.ConfigBarCodePrintTemplate!.ToList();
this.dataSource.DataSource = configBarCodePrintTemplates;
//客户信息
this.cmb_Client.Items.Clear();
db!.ClientInfo!.ToList()!.ForEach((c) =>
{
cmb_Client.Items.Add(c.ClientName);
});
this.cmb_Client.Text = "";
this.cmb_Client.Enabled = true;
//工序信息
this.cmb_Processinformation.Items.Clear();
db!.Processinformation!.ToList()!.ForEach(p =>
{
this.cmb_Processinformation.Items.Add(p.PrsName);
});
this.cmb_Processinformation.Text = "";
this.cmb_Processinformation.Enabled = true;
}
//this.gb_PrintModel.Visible = false;
this.txt_PrintTemplateDownPath.Text = "";
this.txt_TemplateName.Text = "";
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
this.dataSource.ClearSelection();
this.panel_Edit.Visible = false;
templateName = string.Empty;
}
#endregion
#region 选择文档
//private List fileServiceModels;
private FileProcesService fProcesService;
private string selectFileName;//选择文件名称
private void btn_Example_Click(object sender, EventArgs e)
{
selectFileName = string.Empty;
this.txt_PrintTemplateDownPath.Text = "";
fProcesService = new FileProcesService();
fProcesService.SelectFile(out selectFileName, "所有文件(*.btw) | *.btw");
string[] arrayStr = selectFileName.Split('\\');
if (this.UploadFile(selectFileName, arrayStr[arrayStr.Length - 1]))//上传模板
{
txt_PrintTemplateDownPath.Text = templateName;//上传模板文件全路径
txt_TemplateName.Text = arrayStr[arrayStr.Length - 1];//上传模板名称
}
}
#endregion
#region 返回
private void btn_Result_Click(object sender, EventArgs e)
{
this.panel_Edit.Visible = false;
this.InitWinFrmTable();
}
#endregion
#region 添加
private void btn_Add_Click(object sender, EventArgs e)
{
this.lbl_ItemName.Text = "添加";
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
this.InitWinFrmTable();
this.panel_Edit.Visible = true;
}
#endregion
#region 删除
private void btn_Del_Click(object sender, EventArgs e)
{
this.lbl_ItemName.Text = "删除";
this.panel_Edit.Visible = true;
this.cmb_Client.Enabled = false;
this.txt_PrintTemplateDownPath.Enabled = false;
this.txt_TemplateName.Enabled = false;
this.cmb_Processinformation.Enabled = false;
}
#endregion
#region 修改
private void btn_Rework_Click(object sender, EventArgs e)
{
this.lbl_ItemName.Text = "修改";
//this.txt_TemplateName.Enabled = true;
//this.txt_PrintTemplateDownPath.Enabled = true;
this.cmb_Client.Enabled = true;
//this.InitWinFrmTable();
this.panel_Edit.Visible = true;
}
#endregion
#region 表单点击事件
private void dataSource_CellClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (e.RowIndex >= 0)
{
if (configBarCodePrintTemplates[e.RowIndex] != null)
{
this.oldconfigBarCodePrintTemplate = new ConfigBarCodePrintTemplate();
this.oldconfigBarCodePrintTemplate = configBarCodePrintTemplates[e.RowIndex];
this.btn_Del.Enabled = true;
this.btn_Rework.Enabled = true;
using (EFContext db = new EFContext())
{
this.cmb_Client.Text = db?.ClientInfo?.ToList()?.Where(c => c.ClientId == configBarCodePrintTemplates[e.RowIndex].ClientId)?.FirstOrDefault()?.ClientName;
this.cmb_Processinformation.Text = db?.Processinformation?.ToList()?.Where(p => p.PrsInfoID == this.oldconfigBarCodePrintTemplate.PrsInfoID)?.FirstOrDefault()?.PrsName;
}
this.txt_TemplateName.Text = this.oldconfigBarCodePrintTemplate.TempateName;//打印模板名称
this.txt_PrintTemplateDownPath.Text = this.oldconfigBarCodePrintTemplate.TempateDownPath;//打印模板下载路径
}
else
{
this.btn_Del.Enabled = false;
this.btn_Rework.Enabled = false;
}
}
}
catch (Exception ex)
{
this.errInfo = string.Empty;
MessageBox.Show($@"{ex.Message}", "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
#region 保存
private void btn_Save_Click(object sender, EventArgs e)
{
if (cmb_Client.Text != string.Empty &&
txt_TemplateName.Text != string.Empty &&
txt_PrintTemplateDownPath.Text != string.Empty &&
cmb_Processinformation.Text != string.Empty)
{
using (EFContext db = new EFContext())
{
if (lbl_ItemName.Text == "添加")
{
ConfigBarCodePrintTemplate cfgbptemplate = new ConfigBarCodePrintTemplate
{
ClientId = db?.ClientInfo?.ToList().Where(c => c.ClientName == cmb_Client.Text)?.FirstOrDefault()?.ClientId,
PrsInfoID = db?.Processinformation?.ToList().Where(p => p.PrsName == cmb_Processinformation.Text.Trim())?.FirstOrDefault()?.PrsInfoID,
TempateDownPath = txt_PrintTemplateDownPath.Text.Trim(),
TempateName = txt_TemplateName.Text.Trim()
};
db?.ConfigBarCodePrintTemplate?.Add(cfgbptemplate);
}
else if (lbl_ItemName.Text == "修改")
{
db?.ConfigBarCodePrintTemplate?.ToList().ForEach(c =>
{
if (c.BarCodePrintId == oldconfigBarCodePrintTemplate.BarCodePrintId)
{
c.ClientId = db?.ClientInfo?.ToList()?.Where(c => c.ClientName == cmb_Client.Text)?.FirstOrDefault()?.ClientId;//客户
c.TempateDownPath = txt_PrintTemplateDownPath.Text.Trim();
c.TempateName = txt_TemplateName.Text.Trim();
}
});
}
else if (lbl_ItemName.Text == "删除")
{
db?.ConfigBarCodePrintTemplate?.Remove(oldconfigBarCodePrintTemplate);
}
int result = db!.SaveChanges();
if (result <= 0)
MessageBox.Show("数据保存失败!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
this.panel_Edit.Visible = false;
this.InitWinFrmTable();//初始化界面
}
}
#endregion
#region 上传日志
///
/// 上传日志信息
///
///
/// 上传文件路径
/// 上传文件名及路径
///
public bool UploadLog(string uploadFilePath, string fileName, string processFile,bool isLogPass=false)
{
try
{
if(uploadFilePath!=string.Empty&&fileName!=string.Empty)
{
string networkPath = string.Empty;
if (!File.Exists(@"\\10.2.2.163\Data\PASS.OK"))
{
NetworkShareConnect mess = new NetworkShareConnect();
if (mess.connectToShare(networkPath, "test", "Admin123") != "OK")
{
MessageBox.Show($@"{networkPath}:服务器连接失败", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
if (isLogPass)//是PASS
{
if (!Directory.Exists($@"\\10.2.2.163\data\LOG\PASS\{processFile}\{DateTime.Now.ToString("yyyyMMdd")}"))
Directory.CreateDirectory($@"\\10.2.2.163\data\LOG\{processFile}\PASS\{DateTime.Now.ToString("yyyyMMdd")}");//创建文件夹
System.IO.File.Copy(uploadFilePath, $@"\\10.2.2.163\data\LOG\{processFile}\PASS\{DateTime.Now.ToString("yyyyMMdd")}\{fileName}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.log");
if (System.IO.File.Exists($@"\\10.2.2.163\data\LOG\{processFile}\PASS\{DateTime.Now.ToString("yyyyMMdd")}\{fileName}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.log"))
return true;
}
else if (!isLogPass)//是FAIL
{
if (!Directory.Exists($@"\\10.2.2.163\data\LOG\{processFile}\FAIL\{DateTime.Now.ToString("yyyyMMdd")}"))
Directory.CreateDirectory($@"\\10.2.2.163\data\LOG\{processFile}\FAIL\{DateTime.Now.ToString("yyyyMMdd")}");//创建文件夹
System.IO.File.Copy(uploadFilePath, $@"\\10.2.2.163\data\LOG\{processFile}\FAIL\{DateTime.Now.ToString("yyyyMMdd")}\{fileName}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.FA");
if (System.IO.File.Exists($@"\\10.2.2.163\data\LOG\{processFile}\FAIL\{DateTime.Now.ToString("yyyyMMdd")}\{fileName}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.FA"))
return true;
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return false;
}
#endregion
#region 上传模板
private string templateName = string.Empty;
private bool UploadFile(string uploadFilePath, string fileName)
{
try
{
if (uploadFilePath != string.Empty)
{
string networkPath = string.Empty;
//networkPath = $@"\\10.2.2.163\BarCode\{cmb_Processinformation.Text}\{fileName}";
networkPath = $@"\\10.2.2.163\BarCode\{cmb_Processinformation.Text}";
if (!File.Exists(@"\\10.2.2.163\Data\PASS.OK"))
{
NetworkShareConnect mess = new NetworkShareConnect();
if (mess.connectToShare(networkPath, "test", "Admin123") != "OK")
{
MessageBox.Show($@"{networkPath}:服务器连接失败", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
if (System.IO.File.Exists($@"\\10.2.2.163\BarCode\{cmb_Processinformation.Text}\{fileName}"))
System.IO.File.Delete($@"\\10.2.2.163\BarCode\{cmb_Processinformation.Text}\{fileName}");
if (System.IO.File.Exists($@"\\10.2.2.163\BarCode\{cmb_Processinformation.Text}\{fileName}"))
{
MessageBox.Show($"打印模板:{fileName}名称在服务器中已存在", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
else
{
//MessageBox.Show(txt_PrintModelSample.Text);
//MessageBox.Show(networkPath);
System.IO.File.Copy(uploadFilePath, $@"\\10.2.2.163\BarCode\{cmb_Processinformation.Text}\{fileName}");
if (System.IO.File.Exists($@"\\10.2.2.163\BarCode\{cmb_Processinformation.Text}\{fileName}") == true)
{
templateName = $@"\\10.2.2.163\BarCode\{cmb_Processinformation.Text}\{fileName}";
return true;
}
else
{
MessageBox.Show($"打印模板:{fileName}上传服务器失败", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return false;
}
#endregion
}
}
1.条码打印实现类
using ServerSide.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServerSide.Common
{
public class BarTenderHelper
{
public event Action callBack;
private PrintConfigEntity pcEntity;
private BarTender.Application btapp;//引用方法1
private BarTender.Format btformat;//引用方法2
public BarTenderHelper(PrintConfigEntity pcfEntity)
{
this.pcEntity= pcfEntity;
}
#region 条码打印
public Boolean BarTenderPrint()
{
try
{
this.btapp = new BarTender.Application();
this.btformat = this.btapp.Formats.Open(this.pcEntity.PTemplate, false, "");//设置模板文件
this.btformat.PrintSetup.NumberSerializedLabels = Convert.ToInt32(this.pcEntity.PCount);//设置打印份数
this.pcEntity.ScanDt.ForEach((d) => {
this.btformat.SetNamedSubStringValue(d.BarCodeName, d.BarCodeString);
});
this.btformat.PrintOut(true,Convert.ToBoolean(this.pcEntity.IsShowPrint));//打印提示
this.btapp.Quit(BarTender.BtSaveOptions.btPromptSave);//退出并改变BarTender模板
return true;
}
catch (Exception ex)
{
this.callBack(ex.Message);
return false;
}
}
#endregion
}
}
实体类:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServerSide.Models
{
#region 配置动态字段信息
public class ConfigBarCodeInfoEntity
{
///
/// 配置动态条码ID
///
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增
public int ?cfBarCodeID { get; set; }
///
/// 动态字段名称
///
[Required]//不允许为空
[StringLength(50)]
public string? ConfigBarCodeName { get; set; }
///
/// 项目描述
///
[Required]
[StringLength(80)]
public string? ConfigDescription { get; set; }
public DateTime? CreateTim { get; set; } = DateTime.Now;//创建时间
}
#endregion
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServerSide.Models
{
///
/// 条码配置
///
public class BarCodeCfig
{
///
/// 配置ID
///
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增
public int ?CfigId { get; set; }
///
/// 客户ID
///
[ForeignKey("ClientId")]//设置导航属性
//public ClientInfo? ClientInfo { get; set; }
public int? ClientId { get; set; }//外键
///
/// 产品ID
///
[ForeignKey("ProductId")]//设置导航属性
//public ProductNames? ProductNames { get; set; }
public int? ProductId { get; set; }//外键
///
/// 订单ID
///
[ForeignKey("WorkOrderId")]//设置导航属性
//public ProductNames? ProductNames { get; set; }
public int? WorkOrderId { get; set; }//外键
///
/// 工序ID
///
[ForeignKey("PrsInfoID")]//设置导航属性
//public Processinformation? Processinformation { get; set; }
public int? PrsInfoID { get; set; }//外键
///
/// 配置打印模板ID
///
[Required]//不允许为空
[ForeignKey("BarCodePrintId")]//打印模板ID
//public ConfigBarCodeInfoEntity? ConfigBarCodeInfoEntity { get; set; }
public int? BarCodePrintId { get; set; }//外键
///
/// 配置参数值
///
[StringLength(255)]
public string? CfgArgsValue { get; set; }
public DateTime? CreateTim { get; set; } = DateTime.Now;//创建时间
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServerSide.Models
{
///
/// 配置打印模板
///
public class ConfigBarCodePrintTemplate
{
///
/// 打印模板ID
///
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增
public int BarCodePrintId { get; set; }
///
/// 客户ID
///
[ForeignKey("ClientId")]//设置导航属性
//public ClientInfo? ClientInfo { get; set; }
public int? ClientId { get; set; }//外键
///
/// 工序ID
///
[ForeignKey("PrsInfoID")]//设置导航属性
//public Processinformation? Processinformation { get; set; }
public int? PrsInfoID { get; set; }//外键
///
/// 模板名称
///
[Required]
[StringLength(100)]
public string? TempateName { get; set; }
///
/// 模板下载路径
///
[Required]
[StringLength(255)]
public string? TempateDownPath { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServerSide.Models
{
///
/// 配置打印模板
///
public class ConfigBarCodePrintTemplate
{
///
/// 打印模板ID
///
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增
public int BarCodePrintId { get; set; }
///
/// 客户ID
///
[ForeignKey("ClientId")]//设置导航属性
//public ClientInfo? ClientInfo { get; set; }
public int? ClientId { get; set; }//外键
///
/// 工序ID
///
[ForeignKey("PrsInfoID")]//设置导航属性
//public Processinformation? Processinformation { get; set; }
public int? PrsInfoID { get; set; }//外键
///
/// 模板名称
///
[Required]
[StringLength(100)]
public string? TempateName { get; set; }
///
/// 模板下载路径
///
[Required]
[StringLength(255)]
public string? TempateDownPath { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServerSide.Models
{
///
/// 配置打印模板
///
public class ConfigBarCodePrintTemplate
{
///
/// 打印模板ID
///
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增
public int BarCodePrintId { get; set; }
///
/// 客户ID
///
[ForeignKey("ClientId")]//设置导航属性
//public ClientInfo? ClientInfo { get; set; }
public int? ClientId { get; set; }//外键
///
/// 工序ID
///
[ForeignKey("PrsInfoID")]//设置导航属性
//public Processinformation? Processinformation { get; set; }
public int? PrsInfoID { get; set; }//外键
///
/// 模板名称
///
[Required]
[StringLength(100)]
public string? TempateName { get; set; }
///
/// 模板下载路径
///
[Required]
[StringLength(255)]
public string? TempateDownPath { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServerSide.Models
{
#region 配置打印的订单信息
public class ConfigBarCodeOrderInfoEntity
{
///
/// 订单ID
///
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增
public int WorkOrderId { get; set; }
///
/// 产品ID
///
[ForeignKey("ProductId")]//设置导航属性
//public ProductNames? ProductNames { get; set; }
public int? ProductId { get; set; }//外键
///
/// 订单号
///
[Required]
[StringLength(150)]
public string ?OrderInfo { get; set; }
///
/// 订单总数
///
[Required]
public int? OrderCount { get; set; }
///
/// 外箱序号
///
[Required]
[StringLength(100)]
public string ?CartonSerialNumber { get; set; }
///
/// 机身扫描总数
///
[Required]
public int? FuselageScanCount { get; set; } = 0;
///
/// 彩盒扫描总数
///
[Required]
public int? GiftBoxScanCount { get; set; } = 0;
///
/// 外箱扫描总数
///
[Required]
public int? MasterCartonScanCount { get; set; } = 0;
///
/// 装箱绑码数
///
[Required]
public int PackingBindingCode { get; set; } = 1;
public DateTime? CreateTim { get; set; } = DateTime.Now;//创建时间
}
#endregion
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServerSide.Models
{
///
/// 产品名称
///
public class ProductNames
{
///
/// 产品ID
///
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增
public int? ProductId { get; set; }
///
/// 客户ID
///
[ForeignKey("ClientId")]//设置导航属性
//public ClientInfo? ClientInfo { get; set; }
public int? ClientId { get; set; }//外键
///
/// 产品名称
///
[Required]
[StringLength(100)]
public string? ProductName { get; set; }
public DateTime? CreateTim { get; set; } = DateTime.Now;//创建时间
}
}