c# .net6 在线条码打印基于

这篇具有很好参考价值的文章主要介绍了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_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 装载窗体
        /// <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
    }
}

c# .net6 在线条码打印基于,C# 窗体,c#,.net,java

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
    }
}

c# .net6 在线条码打印基于,C# 窗体,c#,.net,java

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
    }
}

c# .net6 在线条码打印基于,C# 窗体,c#,.net,java

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
    }
}

c# .net6 在线条码打印基于,C# 窗体,c#,.net,java

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
    }
}

c# .net6 在线条码打印基于,C# 窗体,c#,.net,java

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
    }
}

c# .net6 在线条码打印基于,C# 窗体,c#,.net,java

c# .net6 在线条码打印基于,C# 窗体,c#,.net,java

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

    }
}

c# .net6 在线条码打印基于,C# 窗体,c#,.net,java

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;//引用方法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
    }
}

实体类:文章来源地址https://www.toymoban.com/news/detail-716157.html

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 在线条码打印基于的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • C# .Net6 指定WSDL, 生成Webservice,调用该接口服务

    IDE: Microsoft Visual Studio Community 2022 (64 位) 平台:.Net6 协议:Soap协议 Xml格式 需要开发一个前置机程序, 用于和硬件程序交互, 已知条件是:嵌入式同事提供另一个约定好的*.wsdl文件作为双方通信的Webservice接口协议,对方是服务端,前置机是客户端 使用BasicHttpBinding 通过WS

    2024年02月04日
    浏览(51)
  • 【C#】【命名空间(namespace)】.NET6.0后支持的顶级语句使用问题

    创建C#项目且使用.Net6.0以上的版本时,默认code会使用顶级语句形式: 1、略去static void Main(String[ ] args)主方法入口; 2、隐式使用(即隐藏且根据代码所需要的类自动调用)其他命名空间(包括): using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Net

    2024年02月08日
    浏览(46)
  • 无条码商品新建商品档案,搭配蓝牙便携打印机移动打印条码标签

    null 无条码商品的商品档案新建,并打印条码标签,即可实现仓库条码管理,扫码入库,出库,盘点等操作。, 视频播放量 1、弹幕量 0、点赞数 0、投硬币枚数 0、收藏人数 0、转发人数 0, 视频作者 汉码盘点机PDA, 作者简介 ,相关视频:条码标签打印,蓝牙便携打印机的设置,

    2024年02月14日
    浏览(49)
  • 基于.NET6搭建WebAPI项目

     点击运行后自动打开浏览器,看到如下信息: 系统启动日志如下: 此数据对用户不友好。 nuget安装  Microsoft.AspNetCore.Mvc.NewtonsoftJson   安装成功:  只需要在Program.cs 文件下添加几行代码 找到 builder.Services.AddControllers()   代码如下:  测试结果如下: 打开Xml文件生成,右键

    2023年04月08日
    浏览(48)
  • 基于.NET6的自定义中间件

    中间件基础: 在.net6.0在请求在响应给请求者之前会通过请求管道再处理服务端的逻辑然后再响应给请求者,而请求管道则是由一系列中间件组成的有点类似于过滤器,为了更直观的了解,我们请看下图:  它可以决定是否将请求传递给请求管道中下一个中间件,也可以处理下一个中

    2023年04月27日
    浏览(42)
  • C# Asp.Net6 MVC,Log4net NLog 日志插件应用 及Windows、Liux环境下程序发布

    connected Services 服务依赖(第三方) Properties 文件下 launchSettings.json 项目启动配置文件 wwwroad 存放静态文件 依赖项 管理Nuget程序包 appsettings.json 配置文件 C 业务逻辑运算–调用其他的服务做业务逻辑 M 实体对象,保存数据,数据传输 V 视图,表现层 第一步:寻找log4net 程序包

    2024年02月14日
    浏览(52)
  • 基于.Net6使用YoloV8的分割模型

    在目标检测一文中,我们学习了如何处理Onnx模型,并的到目标检测结果,在此基础上,本文实现基于.Net平台的实例分割任务。 执行YoloV8的分割任务后可以得到分割.pt模型。由于Python基本不用于工业软件的部署,最终还是希望能在.Net平台使用训练好的模型进行预测。我们可以

    2024年02月09日
    浏览(34)
  • .NET6: 开发基于WPF的摩登三维工业软件 (7)

    Python微信订餐小程序课程视频 https://edu.csdn.net/course/detail/36074 Python实战量化交易理财系统 https://edu.csdn.net/course/detail/35475 做为一个摩登的工业软件,提供可编程的脚本能力是必不可少的能力。脚本既可以方便用户进行二次开发,也对方便对程序进行自动化测试。本文将结合

    2024年02月05日
    浏览(46)
  • 基于asp.netCoreWebApi的webSocket通信示例(net6)

    背景:     在阿里云服务器中搭建了常规的tcp server服务(基于.net framework 4.0)。用以实现远程控制家里的鱼缸灯,办公室的电脑开关机等功能。客户端采用PC桌面端和微信小程序端。     服务端:tcp server(基于.net framework 4.0)     客户端:PC桌面端软件(.net winform)、微信小程序

    2023年04月22日
    浏览(48)
  • 基于.net6的WPF程序使用SignalR进行通信

    之前写的SignalR通信,是基于.net6api,BS和CS进行通信的。 .net6API使用SignalR+vue3聊天+WPF聊天_signalr wpf_故里2130的博客-CSDN博客 今天写一篇关于CS客户端的SignalR通信,后台服务使用.net6api 。其实和之前写的差不多,主要在于服务端以后台进程的方式存在,而客户端以exe方式存在,

    2024年02月16日
    浏览(52)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包