c# .net6 在线条码打印基于
条码打印基于: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_nowdatepublic 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;elsethis.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 装载窗体/// <summary>/// 装载窗体/// </summary>/// <param name="childFrom"></param>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<bool>((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<Processinformation> processinformations;//工序信息private Processinformation oldProcessinformation;//旧的工序信息public string errInfo;//错误信息public CfgBarCodeWkInfoFrm(){InitializeComponent();}#region 初始化界面private void InitWinFrmTable(){using (EFContext db = new EFContext()){this.processinformations = new List<Processinformation>();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> productNames;//产品名称private ProductNames oldproductName;private string ErrInfo;//错误信息public CfgProductInfoFrm(){InitializeComponent();}#region 初始化界面private void InitWinFrmTable(){using (EFContext db = new EFContext()){productNames = new List<ProductNames>();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<ConfigBarCodeOrderInfoEntity> configBarCodeOrderInfoEntities;//配置订单信息private ConfigBarCodeOrderInfoEntity oldconfigBarCodeOrderInfoEntity;//public string ErrInfo;//错误日志public CfgOrderInfoFrm(){InitializeComponent();this.InitWinFrmTable();}#region 初始化界面private void InitWinFrmTable(){using (EFContext db = new EFContext()){configBarCodeOrderInfoEntities = new List<ConfigBarCodeOrderInfoEntity>();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<Processinformation> processinformations;//工序信息private Processinformation oldProcessinformation;//旧的工序信息public string errInfo;//错误信息public CfgBarCodeWkInfoFrm(){InitializeComponent();}#region 初始化界面private void InitWinFrmTable(){using (EFContext db = new EFContext()){this.processinformations = new List<Processinformation>();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<ConfigBarCodeInfoEntity> configBarCodeInfoEntitys;//配置动态字段信息private ConfigBarCodeInfoEntity oldConfigBarCodeInfoEntity;//旧的配置动态字段信息public string errInfo;//错误信息public CfgBarCodeInfoFrm(){InitializeComponent();}#region 初始化界面private void InitWinFrmTable(){using (EFContext db = new EFContext()){this.configBarCodeInfoEntitys = new List<ConfigBarCodeInfoEntity>();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<ConfigBarCodePrintTemplate> configBarCodePrintTemplates;//斑码打印模板配置private ConfigBarCodePrintTemplate oldconfigBarCodePrintTemplate;//旧的模板配置信息public string errInfo;//错误日志public CfgBarCodePrintTemplateFrm(){InitializeComponent();this.InitWinFrmTable();}#region 初始化界面private void InitWinFrmTable(){using (EFContext db = new EFContext()){configBarCodePrintTemplates = new List<ConfigBarCodePrintTemplate>();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<FileServiceEntity> 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 上传日志/// <summary>/// 上传日志信息/// </summary>/// <param name=""></param>/// <param name="uploadFilePath">上传文件路径</param>/// <param name="fileName">上传文件名及路径</param>/// <returns></returns>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<string> callBack;private PrintConfigEntity pcEntity;private BarTender.Application btapp;//引用方法1private BarTender.Format btformat;//引用方法2public 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{/// <summary>/// 配置动态条码ID/// </summary>[Key][DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增public int ?cfBarCodeID { get; set; }/// <summary>/// 动态字段名称/// </summary>[Required]//不允许为空[StringLength(50)]public string? ConfigBarCodeName { get; set; }/// <summary>/// 项目描述/// </summary>[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
{/// <summary>/// 条码配置/// </summary>public class BarCodeCfig{/// <summary>/// 配置ID/// </summary>[Key][DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增public int ?CfigId { get; set; }/// <summary>/// 客户ID/// </summary>[ForeignKey("ClientId")]//设置导航属性//public ClientInfo? ClientInfo { get; set; }public int? ClientId { get; set; }//外键/// <summary>/// 产品ID/// </summary>[ForeignKey("ProductId")]//设置导航属性//public ProductNames? ProductNames { get; set; }public int? ProductId { get; set; }//外键/// <summary>/// 订单ID/// </summary>[ForeignKey("WorkOrderId")]//设置导航属性//public ProductNames? ProductNames { get; set; }public int? WorkOrderId { get; set; }//外键/// <summary>/// 工序ID/// </summary>[ForeignKey("PrsInfoID")]//设置导航属性//public Processinformation? Processinformation { get; set; }public int? PrsInfoID { get; set; }//外键/// <summary>/// 配置打印模板ID/// </summary>[Required]//不允许为空[ForeignKey("BarCodePrintId")]//打印模板ID//public ConfigBarCodeInfoEntity? ConfigBarCodeInfoEntity { get; set; }public int? BarCodePrintId { get; set; }//外键/// <summary>/// 配置参数值/// </summary>[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
{/// <summary>/// 配置打印模板/// </summary>public class ConfigBarCodePrintTemplate{/// <summary>/// 打印模板ID/// </summary>[Key][DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增public int BarCodePrintId { get; set; }/// <summary>/// 客户ID/// </summary>[ForeignKey("ClientId")]//设置导航属性//public ClientInfo? ClientInfo { get; set; }public int? ClientId { get; set; }//外键/// <summary>/// 工序ID/// </summary>[ForeignKey("PrsInfoID")]//设置导航属性//public Processinformation? Processinformation { get; set; }public int? PrsInfoID { get; set; }//外键/// <summary>/// 模板名称/// </summary>[Required][StringLength(100)]public string? TempateName { get; set; }/// <summary>/// 模板下载路径/// </summary>[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
{/// <summary>/// 配置打印模板/// </summary>public class ConfigBarCodePrintTemplate{/// <summary>/// 打印模板ID/// </summary>[Key][DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增public int BarCodePrintId { get; set; }/// <summary>/// 客户ID/// </summary>[ForeignKey("ClientId")]//设置导航属性//public ClientInfo? ClientInfo { get; set; }public int? ClientId { get; set; }//外键/// <summary>/// 工序ID/// </summary>[ForeignKey("PrsInfoID")]//设置导航属性//public Processinformation? Processinformation { get; set; }public int? PrsInfoID { get; set; }//外键/// <summary>/// 模板名称/// </summary>[Required][StringLength(100)]public string? TempateName { get; set; }/// <summary>/// 模板下载路径/// </summary>[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
{/// <summary>/// 配置打印模板/// </summary>public class ConfigBarCodePrintTemplate{/// <summary>/// 打印模板ID/// </summary>[Key][DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增public int BarCodePrintId { get; set; }/// <summary>/// 客户ID/// </summary>[ForeignKey("ClientId")]//设置导航属性//public ClientInfo? ClientInfo { get; set; }public int? ClientId { get; set; }//外键/// <summary>/// 工序ID/// </summary>[ForeignKey("PrsInfoID")]//设置导航属性//public Processinformation? Processinformation { get; set; }public int? PrsInfoID { get; set; }//外键/// <summary>/// 模板名称/// </summary>[Required][StringLength(100)]public string? TempateName { get; set; }/// <summary>/// 模板下载路径/// </summary>[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{/// <summary>/// 订单ID/// </summary>[Key][DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增public int WorkOrderId { get; set; }/// <summary>/// 产品ID/// </summary>[ForeignKey("ProductId")]//设置导航属性//public ProductNames? ProductNames { get; set; }public int? ProductId { get; set; }//外键/// <summary>/// 订单号/// </summary>[Required][StringLength(150)]public string ?OrderInfo { get; set; }/// <summary>/// 订单总数/// </summary>[Required]public int? OrderCount { get; set; }/// <summary>/// 外箱序号/// </summary>[Required][StringLength(100)]public string ?CartonSerialNumber { get; set; }/// <summary>/// 机身扫描总数/// </summary>[Required]public int? FuselageScanCount { get; set; } = 0;/// <summary>/// 彩盒扫描总数/// </summary>[Required]public int? GiftBoxScanCount { get; set; } = 0;/// <summary>/// 外箱扫描总数/// </summary>[Required]public int? MasterCartonScanCount { get; set; } = 0;/// <summary>/// 装箱绑码数/// </summary>[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
{/// <summary>/// 产品名称/// </summary>public class ProductNames{/// <summary>/// 产品ID/// </summary>[Key][DatabaseGenerated(DatabaseGeneratedOption.Identity)] //自增public int? ProductId { get; set; }/// <summary>/// 客户ID/// </summary>[ForeignKey("ClientId")]//设置导航属性//public ClientInfo? ClientInfo { get; set; }public int? ClientId { get; set; }//外键/// <summary>/// 产品名称/// </summary>[Required][StringLength(100)]public string? ProductName { get; set; }public DateTime? CreateTim { get; set; } = DateTime.Now;//创建时间}
}
相关文章:

c# .net6 在线条码打印基于
条码打印基于: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.Drawi…...
Hive SQL的编译过程
1.MapReduce实现基本SQL操作的原理 详细讲解SQL编译为MapReduce之前,我们先来看看MapReduce框架实现SQL基本操作的原理 1.1 Join的实现原理 select u.name, o.orderid from order o join user u on o.uid = u.uid; 在map的输出value中为不同表的数据打上tag标记,在reduce阶段…...

[架构之路-245/创业之路-76]:目标系统 - 纵向分层 - 企业信息化的呈现形态:常见企业信息化软件系统 - 企业资源管理计划ERP
目录 前言: 一、企业信息化的结果:常见企业信息化软件 1.1 企业资源管理计划 1.1.1 什么是ERP:企业最常用的信息管理系统 1.1.2 ERP的演进过程 1.1.3 EPR模块 1.1.4 EPR五个层级 1.1.5 企业EPR业务总体流程图 1.1.6 什么类型的企业需…...

数据库简史:多主数据库架构的由来和华为参天引擎的机遇
注:本文发表后,收到了很多后台反馈,其中关于大型机的早期成就不容省略。微调重发本文,纯属个人观点,错谬之处,仍然期待指正。 2023年10月13日,在北京举办的“2023金融业数据库技术大会"上&…...

C语言每日一练(二)
单链表经典算法专题 一、 单链表相关经典算法OJ题1:移除链表元素 解法一:在原链表中删除Node.nextnext的节点 typedef struct ListNode ListNode; struct ListNode* removeElements( ListNode* head, int val) {ListNode* pcur head;ListNode* pre h…...

HashJoin 在 Apache Arrow 和PostgreSQL 中的实现
文章目录 背景PostgreSQL HashJoin实现PG 执行器架构HashJoin 基本流程HashJoin 实现细节Join 类型HashJoin 的划分阶段HashJoin 的分批处理阶段JOIN 类型的状态机转换HashJoin 的投影和过滤 Arrow Acero HashJoin实现Acero 基本框架HashJoin 基本流程 总结 背景 近两个月转到…...

FL Studio21.2.0.3421最新汉化破解版中文解锁下载完整版本
音乐在人们心中的地位日益增高,近几年音乐选秀的节目更是层出不穷,喜爱音乐,创作音乐的朋友们也是越来越多,音乐的类型有很多,好比古典,流行,摇滚等等。对新手友好程度基本上在首位,…...

docker在java项目中打成tar包
docker在java项目中打成tar包 1、首先安装一个docker desktop 2、mvn install项目后,建立一个自己的dockerfile 这里我以我的代码举例,from 镜像,这里你也能打包好一个镜像的基础上,from打好的镜像,这里我们用openj…...

No175.精选前端面试题,享受每天的挑战和学习
🤍 前端开发工程师(主业)、技术博主(副业)、已过CET6 🍨 阿珊和她的猫_CSDN个人主页 🕠 牛客高级专题作者、在牛客打造高质量专栏《前端面试必备》 🍚 蓝桥云课签约作者、已在蓝桥云课上架的前后端实战课程《Vue.js 和 Egg.js 开发企业级健康管理项目》、《带你从入…...

【网安AIGC专题10.19】论文6:Java漏洞自动修复+数据集 VJBench+大语言模型、APR技术+代码转换方法+LLM和DL-APR模型的挑战与机会
How Effective Are Neural Networks for Fixing Security Vulnerabilities 写在最前面摘要贡献发现 介绍背景:漏洞修复需求和Java漏洞修复方向动机方法贡献 数据集先前的数据集和Java漏洞Benchmark数据集扩展要求数据处理工作最终数据集 VJBenchVJBench 与 Vul4J 的…...
解决国外镜像无法访问导致的R包无法安装问题
我自己的方法: install.packages("vcd", repos "https://mirrors.tuna.tsinghua.edu.cn/CRAN/") R包安装镜像设置的三种方法:R包安装镜像设置的三种方法 - 简书 更新了Rstudio后,出现 unable to access index for rep…...

【2021集创赛】Robei杯一等奖:基于Robei EDA工具的隔离病房看护机器人设计
本作品参与极术社区组织的有奖征集|秀出你的集创赛作品风采,免费电子产品等你拿~活动。 团队介绍 参赛单位:重庆交通大学 队伍名称:一丘之貉 指导老师:毕波 李艾星 参赛队员:郁航 张坤 秦衡 总决赛奖项:Robei杯一等奖…...
Python之函数-传实参的两种方式
Python之函数-传实参的两种方式 函数参数 函数在定义是要定义好形式参数,调用时也提供足够的实际参数,一般来说,形参和实参个数要一致(可变参数除外)。实参传参方式 1、位置传参 定义时def f(x, y, z), 调用使用 f(1, 3, 5)&am…...
Hive客户端和Beeline命令行的基本使用
本专栏案例数据集链接: https://download.csdn.net/download/shangjg03/88478038 1.Hive CLI 1.1 命令帮助Help 使用 `hive -H` 或者 `hive --help` 命令可以查看所有命令的帮助,显示如下: usage: hive-d,--define <key=value> Variable subsitution to ap…...
Ubuntu 22.04自动登录进入桌面
1.编辑gdm3配置文件 sudo vim /etc/gdm3/custom.conf 2.修改内容为 AutomaticLoginEnableTrue AutomaticLoginusername 3.查看和重启服务 # 查看服务状态 systemctl --user status gnome-remote-desktop.service # 重启服务 systemctl --user restart gnome-remote-deskt…...

C#__简单了解XML文档
/* XML(可扩展标记语言):用于传输和存储数据 XML文档:树结构;包含根元素 XML元素:从开始标签到结束标签的部分 XML语法规则: 1、所有XML元素都必须有结束标签 …...

云游数智农业世界,体验北斗时空智能
今日,2023年中国国际农业机械展览会在武汉正式拉开帷幕,众多与会者云集,各类农机产品纷呈,盛况空前。 千寻位置作为国家北斗地基增强系统的建设与运营方,在中国国际农业机械展览会上亮相,以「北斗时空智能 …...

C# 递归算法使用简介_常用整理
一、递归简介 递归算法是一种直接或者间接调用自身函数或者方法的算法。 递归算法的实质是把问题分解成规模缩小的同类问题的子问题,然后递归调用方法来表示问题的解。递归算法对解决一大类问题很有效,它可以使算法简洁和易于理解。 递归本质是循环&a…...

[Python]unittest-单元测试
目录 unittest的大致构成: Test Fixture Test Case-测试用例 Test Suite-测试套件 Test Runner 批量执行脚本 makeSuite() TestLoader discover() 用例的执行顺序 忽略用例执行 skip skipIf skipUnless 断言 HTML测试报告 错误截图 unittest是python中的单元测…...

Jetpack:021-Jetpack中的滑动列表
文章目录 1. 概念介绍2. 使用方法2.1 函数参数2.2 列表成员 3. 示例代码4. 内容扩展5. 内容总结 我们在上一章回中介绍了Jetpack中底部导航栏相关的内容,本章回中主要介绍 滑动列表。闲话休提,让我们一起Talk Android Jetpack吧! 1. 概念介绍…...

XCTF-web-easyupload
试了试php,php7,pht,phtml等,都没有用 尝试.user.ini 抓包修改将.user.ini修改为jpg图片 在上传一个123.jpg 用蚁剑连接,得到flag...

日语AI面试高效通关秘籍:专业解读与青柚面试智能助攻
在如今就业市场竞争日益激烈的背景下,越来越多的求职者将目光投向了日本及中日双语岗位。但是,一场日语面试往往让许多人感到步履维艰。你是否也曾因为面试官抛出的“刁钻问题”而心生畏惧?面对生疏的日语交流环境,即便提前恶补了…...

Vue3 + Element Plus + TypeScript中el-transfer穿梭框组件使用详解及示例
使用详解 Element Plus 的 el-transfer 组件是一个强大的穿梭框组件,常用于在两个集合之间进行数据转移,如权限分配、数据选择等场景。下面我将详细介绍其用法并提供一个完整示例。 核心特性与用法 基本属性 v-model:绑定右侧列表的值&…...

【第二十一章 SDIO接口(SDIO)】
第二十一章 SDIO接口 目录 第二十一章 SDIO接口(SDIO) 1 SDIO 主要功能 2 SDIO 总线拓扑 3 SDIO 功能描述 3.1 SDIO 适配器 3.2 SDIOAHB 接口 4 卡功能描述 4.1 卡识别模式 4.2 卡复位 4.3 操作电压范围确认 4.4 卡识别过程 4.5 写数据块 4.6 读数据块 4.7 数据流…...
css3笔记 (1) 自用
outline: none 用于移除元素获得焦点时默认的轮廓线 broder:0 用于移除边框 font-size:0 用于设置字体不显示 list-style: none 消除<li> 标签默认样式 margin: xx auto 版心居中 width:100% 通栏 vertical-align 作用于行内元素 / 表格单元格ÿ…...

pikachu靶场通关笔记22-1 SQL注入05-1-insert注入(报错法)
目录 一、SQL注入 二、insert注入 三、报错型注入 四、updatexml函数 五、源码审计 六、insert渗透实战 1、渗透准备 2、获取数据库名database 3、获取表名table 4、获取列名column 5、获取字段 本系列为通过《pikachu靶场通关笔记》的SQL注入关卡(共10关࿰…...
安卓基础(aar)
重新设置java21的环境,临时设置 $env:JAVA_HOME "D:\Android Studio\jbr" 查看当前环境变量 JAVA_HOME 的值 echo $env:JAVA_HOME 构建ARR文件 ./gradlew :private-lib:assembleRelease 目录是这样的: MyApp/ ├── app/ …...

JVM 内存结构 详解
内存结构 运行时数据区: Java虚拟机在运行Java程序过程中管理的内存区域。 程序计数器: 线程私有,程序控制流的指示器,分支、循环、跳转、异常处理、线程恢复等基础功能都依赖这个计数器完成。 每个线程都有一个程序计数…...
MySQL JOIN 表过多的优化思路
当 MySQL 查询涉及大量表 JOIN 时,性能会显著下降。以下是优化思路和简易实现方法: 一、核心优化思路 减少 JOIN 数量 数据冗余:添加必要的冗余字段(如订单表直接存储用户名)合并表:将频繁关联的小表合并成…...

宇树科技,改名了!
提到国内具身智能和机器人领域的代表企业,那宇树科技(Unitree)必须名列其榜。 最近,宇树科技的一项新变动消息在业界引发了不少关注和讨论,即: 宇树向其合作伙伴发布了一封公司名称变更函称,因…...