using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tie_Yards__Program.Common;
using Tie_Yards__Program.Models;
using Tie_Yards_Program.UI;
namespace Tie_Yards__Program.UI
{
public partial class MainForm : DevExpress.XtraEditors.XtraForm
{
OrderinfoMode orderinfoMode;
Process process = null;
TieYards_BarcodeMode tieYards_BarcodeMode;
int ConfigMode = 0;
bool State = false;//命令行执行状态
public MainForm()
{
InitializeComponent();
}
/// <summary>
/// 订单配置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void bt_OrderCofig_Click(object sender, EventArgs e)
{
lb_Mac.Text = "N/A";
txt_Sn.Text = "";
txt_Sn.Enabled = false;
bt_start.Enabled = false;
Login login = Login.CreateInstance();
login.CallBack += Login_CallBack;
this.Hide();
login.Show();
ConfigMode = 1;
}
/// <summary>
/// 登陆回写
/// </summary>
/// <param name="obj"></param>
///
int State_s = 0;
private void Login_CallBack(string obj)
{
if (ConfigMode == 1&& obj == "OK")
{
OrderWinForm orderWinForm = OrderWinForm.CreateInstance(this.Text);
orderWinForm.CallBack += OrderWinForm_CallBack;
this.Hide();
orderWinForm.Show();
State_s = 1;
}
else if (ConfigMode == 2&& obj == "OK")
{
OrderSetWinForm orderSetWinForm = OrderSetWinForm.CreateInstance(this.Text);
orderSetWinForm.CallBack += OrderSetWinForm_CallBack;
this.Hide();
orderSetWinForm.Show();
State_s = 1;
}
else
{
if(State_s ==0)
this.Show();
}
}
/// <summary>
/// 订单配置项重写事件
/// </summary>
private void OrderWinForm_CallBack()
{
State_s = 0;
this.Show();
}
private void MainForm_Load(object sender, EventArgs e)
{
}
/// <summary>
/// 参数设置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void bt_ArgsSet_Click(object sender, EventArgs e)
{
lb_Mac.Text = "N/A";
txt_Sn.Text = "";
txt_Sn.Enabled = false;
bt_start.Enabled = false;
Login login = Login.CreateInstance();
login.CallBack += Login_CallBack;
this.Hide();
login.Show();
ConfigMode = 2;
}
/// <summary>
/// 设置订单信息回写事件
/// </summary>
/// <param name="obj"></param>
private void OrderSetWinForm_CallBack(Models.OrderinfoMode obj)
{
if (obj.OrderNumber!=null)
{
lb_QtNum.Text = obj.QtCount.ToString();
bt_start.Enabled = true;
orderinfoMode = new OrderinfoMode(obj);
}
this.Show();
State_s = 0;
}
//开始测试
private void bt_start_Click(object sender, EventArgs e)
{
bt_start.Enabled = false;
txt_Sn.Enabled = true;
txt_Sn.Focus();
}
/// <summary>
/// 条码键入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txt_Sn_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
if (txt_Sn.Text.Contains(orderinfoMode.SnPrefix))
{
try
{
richEditControl1.Text = "";
tieYards_BarcodeMode = new TieYards_BarcodeMode();//创建条码组合类
tieYards_BarcodeMode.SN = txt_Sn.Text.Trim();//获取SN
Control.CheckForIllegalCrossThreadCalls = false;
process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.WorkingDirectory = ".";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
process.Start();
process.BeginOutputReadLine();
//this.richEditControl1.Text = "";
process.StandardInput.WriteLine(orderinfoMode.GetMacCmd);//);
txt_ShowInfo.Text = "Mac检测、读取、转换...";
timer1.Enabled = true;
}
catch (Exception ex)
{
LogHelper<MainForm>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
}
}
else
{
//ShowLog($@"输入的SN:{txt_Sn.Text}不满足条码规则",Color.Red,"SN条码规则验证Fail!!");
txt_ShowInfo.Text = "SN条码规则验证Fail!!";
txt_ShowInfo.ForeColor = Color.Red;
txt_Sn.SelectAll();
}
}
}
/// <summary>
/// 输出窗口
/// </summary>
/// <param name="sendingProcess"></param>
/// <param name="outLine"></param>
///
private static readonly object SequenceLock = new object();
private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
try
{
if (!string.IsNullOrEmpty(outLine.Data))
{
lock (SequenceLock)
{
Task task = new Task(new Action(() =>
{
this.richEditControl1.Invoke(new Action(() => {
this.richEditControl1.Document.InsertHtmlText(this.richEditControl1.Document.Range.End, $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ")}{outLine.Data}<br/>");
//设置坐标位置,并没有滚动
this.richEditControl1.Document.CaretPosition = this.richEditControl1.Document.Range.End;
this.richEditControl1.ScrollToCaret();//执行滚动//State = true;
}));
}));
task.Start();
}
}
}
catch (Exception ex)
{
LogHelper<MainForm>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
}
}
/// <summary>
/// Log记录
/// </summary>
/// <param name="Str"></param>
/// <param name="Item"></param>
private void ShowLog(String Str, Color Item,string Showinfo)
{
this.richEditControl1.Text = "";
this.richEditControl1.Appearance.Text.ForeColor = Item;
this.richEditControl1.Document.InsertHtmlText(this.richEditControl1.Document.Range.End, $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ")}{Str}<br/>");
//设置坐标位置,并没有滚动
this.richEditControl1.Document.CaretPosition = this.richEditControl1.Document.Range.End;
this.richEditControl1.ScrollToCaret();//执行滚动
txt_ShowInfo.ForeColor = Item;
txt_ShowInfo.Text = Showinfo;
txt_Sn.SelectAll();
txt_Sn.Focus();
}
//按下键盘时产生
private void txt_Sn_KeyDown(object sender, KeyEventArgs e)
{
txt_ShowInfo.Text = "SN条码录入...";
txt_ShowInfo.ForeColor = Color.PowderBlue;//设置原始颜色
lb_Mac.Text = "N/A";
}
/// <summary>
/// 时针检查Mac是否读取正常
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
///
object ss="pass";
private void timer1_Tick(object sender, EventArgs e)
{
try
{
lock (ss)
{
if (File.Exists(orderinfoMode.GetBinNa))
{
tieYards_BarcodeMode.Mac = ConvertMacBinFileName(orderinfoMode.GetBinNa);
if (tieYards_BarcodeMode.Mac != null || tieYards_BarcodeMode.Mac != string.Empty)
{
lb_Mac.Text = tieYards_BarcodeMode.Mac;//设置Mac
lb_QtNum.Text = (Convert.ToInt32(lb_QtNum.Text) + 1).ToString();//设置扫描数
XmlHelpers xmlHelpers = new XmlHelpers("Config.xml");
orderinfoMode.QtCount = Convert.ToInt32(lb_QtNum.Text);
if (xmlHelpers.UpdateNode(orderinfoMode))
{
List<TieYards_BarcodeMode> dd = new List<TieYards_BarcodeMode>();
CvsHelper cvsHelper = new CvsHelper($@"./log/{orderinfoMode.OrderNumber}.csv");
if (File.Exists($@"./log/{orderinfoMode.OrderNumber}.csv"))
{
if (cvsHelper.LineRead(ref dd))
{
dd.Add(new TieYards_BarcodeMode() { Mac = tieYards_BarcodeMode.Mac, SN = tieYards_BarcodeMode.SN });
if (cvsHelper.CsvWriteAllData(dd))
{
//ShowLog($@"Mac:{tieYards_BarcodeMode.Mac}+SN:{tieYards_BarcodeMode.SN}绑码测试成功!!", Color.Green, "绑码测试Pass!!");
txt_ShowInfo.Text = $@"Mac:{tieYards_BarcodeMode.Mac}" + "绑码测试Pass!!";
txt_ShowInfo.ForeColor = Color.Green;
}
else
{
//ShowLog($@"Mac:{tieYards_BarcodeMode.Mac}+SN:{tieYards_BarcodeMode.SN}绑码测试失败!!", Color.Red, "绑码测试Fail!!");
txt_ShowInfo.Text = $@"Mac:{tieYards_BarcodeMode.Mac}" + "绑码测试Fail!!";
txt_ShowInfo.ForeColor = Color.Red;
}
}
}
else
{
if (cvsHelper.CsvFieldByfieldWrite(new TieYards_BarcodeMode() { Mac = tieYards_BarcodeMode.Mac, SN = tieYards_BarcodeMode.SN }))
{
//ShowLog($@"Mac:{tieYards_BarcodeMode.Mac}+SN:{tieYards_BarcodeMode.SN}绑码测试成功!!", Color.Green, "绑码测试Pass!!");
txt_ShowInfo.Text = $@"Mac:{tieYards_BarcodeMode.Mac}" + "绑码测试Pass!!";
txt_ShowInfo.ForeColor = Color.Green;
}
else
{
//ShowLog($@"Mac:{tieYards_BarcodeMode.Mac}+SN:{tieYards_BarcodeMode.SN}绑码测试失败!!", Color.Red, "绑码测试Fail!!");
txt_ShowInfo.Text = $@"Mac:{tieYards_BarcodeMode.Mac}" + "绑码测试Fail!!";
txt_ShowInfo.ForeColor = Color.Red;
}
}
}
else
{
txt_ShowInfo.Text = "更新绑码数据Fail!!";
txt_ShowInfo.ForeColor = Color.Red;
txt_Sn.SelectAll();
txt_Sn.Focus();
}
}
else
{
txt_ShowInfo.Text = "Mac转换Fail!!";
txt_ShowInfo.ForeColor = Color.Red;
txt_Sn.SelectAll();
txt_Sn.Focus();
}
}
else
{
txt_ShowInfo.Text = "Mac检测Fail!!";
txt_ShowInfo.ForeColor = Color.Red;
txt_Sn.SelectAll();
txt_Sn.Focus();
}
File.Delete(orderinfoMode.GetBinNa);//删除文件
timer1.Enabled = false;
}
}
catch (Exception ex)
{
LogHelper<MainForm>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
}
}
/// <summary>
/// 将二进制文件转换为16进制
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
private string ConvertMacBinFileName(string filename)
{
string result =string.Empty;
try
{
if (File.Exists(filename))
{
byte[] b = File.ReadAllBytes(filename);
foreach (byte bt in b)
{
result += Convert.ToString(bt, 16);
}
}
}
catch (Exception ex)
{
txt_ShowInfo.Text = "Mac读取Fail!!";
txt_ShowInfo.ForeColor = Color.Red;
txt_Sn.SelectAll();
txt_Sn.Focus();
LogHelper<MainForm>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
}
return result;
}
}
}
namespace Tie_Yards__Program.UI
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.splitContainerControl1 = new DevExpress.XtraEditors.SplitContainerControl();
this.splitContainerControl2 = new DevExpress.XtraEditors.SplitContainerControl();
this.txt_Sn = new DevExpress.XtraEditors.TextEdit();
this.lb_Mac = new DevExpress.XtraEditors.LabelControl();
this.labelControl3 = new DevExpress.XtraEditors.LabelControl();
this.labelControl1 = new DevExpress.XtraEditors.LabelControl();
this.txt_ShowInfo = new DevExpress.XtraEditors.TextEdit();
this.groupControl1 = new DevExpress.XtraEditors.GroupControl();
this.richEditControl1 = new DevExpress.XtraRichEdit.RichEditControl();
this.groupControl2 = new DevExpress.XtraEditors.GroupControl();
this.lb_QtNum = new DevExpress.XtraEditors.LabelControl();
this.bt_ArgsSet = new DevExpress.XtraEditors.SimpleButton();
this.bt_OrderCofig = new DevExpress.XtraEditors.SimpleButton();
this.bt_start = new DevExpress.XtraEditors.SimpleButton();
this.timer1 = new System.Windows.Forms.Timer(this.components);
((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).BeginInit();
this.splitContainerControl1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainerControl2)).BeginInit();
this.splitContainerControl2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.txt_Sn.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txt_ShowInfo.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.groupControl1)).BeginInit();
this.groupControl1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.groupControl2)).BeginInit();
this.groupControl2.SuspendLayout();
this.SuspendLayout();
//
// splitContainerControl1
//
this.splitContainerControl1.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple;
this.splitContainerControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainerControl1.Location = new System.Drawing.Point(0, 0);
this.splitContainerControl1.Name = "splitContainerControl1";
this.splitContainerControl1.Panel1.Controls.Add(this.splitContainerControl2);
this.splitContainerControl1.Panel1.Text = "Panel1";
this.splitContainerControl1.Panel2.Controls.Add(this.groupControl2);
this.splitContainerControl1.Panel2.Controls.Add(this.bt_ArgsSet);
this.splitContainerControl1.Panel2.Controls.Add(this.bt_OrderCofig);
this.splitContainerControl1.Panel2.Controls.Add(this.bt_start);
this.splitContainerControl1.Panel2.Text = "Panel2";
this.splitContainerControl1.Size = new System.Drawing.Size(1127, 635);
this.splitContainerControl1.SplitterPosition = 942;
this.splitContainerControl1.TabIndex = 0;
this.splitContainerControl1.Text = "splitContainerControl1";
//
// splitContainerControl2
//
this.splitContainerControl2.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple;
this.splitContainerControl2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainerControl2.Horizontal = false;
this.splitContainerControl2.Location = new System.Drawing.Point(0, 0);
this.splitContainerControl2.Name = "splitContainerControl2";
this.splitContainerControl2.Panel1.Controls.Add(this.txt_Sn);
this.splitContainerControl2.Panel1.Controls.Add(this.lb_Mac);
this.splitContainerControl2.Panel1.Controls.Add(this.labelControl3);
this.splitContainerControl2.Panel1.Controls.Add(this.labelControl1);
this.splitContainerControl2.Panel1.Controls.Add(this.txt_ShowInfo);
this.splitContainerControl2.Panel1.Text = "Panel1";
this.splitContainerControl2.Panel2.Controls.Add(this.groupControl1);
this.splitContainerControl2.Panel2.Text = "Panel2";
this.splitContainerControl2.Size = new System.Drawing.Size(942, 631);
this.splitContainerControl2.SplitterPosition = 139;
this.splitContainerControl2.TabIndex = 0;
this.splitContainerControl2.Text = "splitContainerControl2";
//
// txt_Sn
//
this.txt_Sn.Enabled = false;
this.txt_Sn.Location = new System.Drawing.Point(353, 27);
this.txt_Sn.Name = "txt_Sn";
this.txt_Sn.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_Sn.Properties.Appearance.Options.UseFont = true;
this.txt_Sn.Properties.AppearanceDisabled.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txt_Sn.Properties.AppearanceDisabled.Options.UseFont = true;
this.txt_Sn.Size = new System.Drawing.Size(573, 24);
this.txt_Sn.TabIndex = 0;
this.txt_Sn.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_Sn_KeyDown);
this.txt_Sn.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txt_Sn_KeyPress);
//
// lb_Mac
//
this.lb_Mac.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lb_Mac.Appearance.Options.UseFont = true;
this.lb_Mac.AppearanceDisabled.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lb_Mac.AppearanceDisabled.Options.UseFont = true;
this.lb_Mac.Location = new System.Drawing.Point(107, 30);
this.lb_Mac.Name = "lb_Mac";
this.lb_Mac.Size = new System.Drawing.Size(23, 18);
this.lb_Mac.TabIndex = 2;
this.lb_Mac.Text = "N/A";
//
// labelControl3
//
this.labelControl3.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.labelControl3.Appearance.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl3.Appearance.Options.UseBackColor = true;
this.labelControl3.Appearance.Options.UseFont = true;
this.labelControl3.AppearanceDisabled.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl3.AppearanceDisabled.Options.UseFont = true;
this.labelControl3.Location = new System.Drawing.Point(224, 28);
this.labelControl3.Name = "labelControl3";
this.labelControl3.Size = new System.Drawing.Size(123, 22);
this.labelControl3.TabIndex = 2;
this.labelControl3.Text = "扫描SN条形码:";
//
// labelControl1
//
this.labelControl1.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.labelControl1.Appearance.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl1.Appearance.Options.UseBackColor = true;
this.labelControl1.Appearance.Options.UseFont = true;
this.labelControl1.AppearanceDisabled.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl1.AppearanceDisabled.Options.UseFont = true;
this.labelControl1.Location = new System.Drawing.Point(3, 28);
this.labelControl1.Name = "labelControl1";
this.labelControl1.Size = new System.Drawing.Size(97, 22);
this.labelControl1.TabIndex = 2;
this.labelControl1.Text = "MacAddress:";
//
// txt_ShowInfo
//
this.txt_ShowInfo.EditValue = "Waiting to start...";
this.txt_ShowInfo.Enabled = false;
this.txt_ShowInfo.Location = new System.Drawing.Point(2, 71);
this.txt_ShowInfo.Name = "txt_ShowInfo";
this.txt_ShowInfo.Properties.Appearance.BackColor = System.Drawing.Color.Black;
this.txt_ShowInfo.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_ShowInfo.Properties.Appearance.ForeColor = System.Drawing.Color.PowderBlue;
this.txt_ShowInfo.Properties.Appearance.Options.UseBackColor = true;
this.txt_ShowInfo.Properties.Appearance.Options.UseFont = true;
this.txt_ShowInfo.Properties.Appearance.Options.UseForeColor = true;
this.txt_ShowInfo.Properties.Appearance.Options.UseTextOptions = true;
this.txt_ShowInfo.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
this.txt_ShowInfo.Properties.AppearanceDisabled.Font = new System.Drawing.Font("方正姚体", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_ShowInfo.Properties.AppearanceDisabled.Options.UseFont = true;
this.txt_ShowInfo.Properties.AppearanceDisabled.Options.UseTextOptions = true;
this.txt_ShowInfo.Properties.AppearanceDisabled.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
this.txt_ShowInfo.Size = new System.Drawing.Size(935, 60);
this.txt_ShowInfo.TabIndex = 3;
//
// groupControl1
//
this.groupControl1.Appearance.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupControl1.Appearance.Options.UseFont = true;
this.groupControl1.AppearanceCaption.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupControl1.AppearanceCaption.Options.UseFont = true;
this.groupControl1.Controls.Add(this.richEditControl1);
this.groupControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupControl1.Location = new System.Drawing.Point(0, 0);
this.groupControl1.Name = "groupControl1";
this.groupControl1.Size = new System.Drawing.Size(938, 483);
this.groupControl1.TabIndex = 0;
this.groupControl1.Text = "日志";
//
// richEditControl1
//
this.richEditControl1.ActiveViewType = DevExpress.XtraRichEdit.RichEditViewType.Simple;
this.richEditControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richEditControl1.LayoutUnit = DevExpress.XtraRichEdit.DocumentLayoutUnit.Pixel;
this.richEditControl1.Location = new System.Drawing.Point(2, 29);
this.richEditControl1.Name = "richEditControl1";
this.richEditControl1.ReadOnly = true;
this.richEditControl1.Size = new System.Drawing.Size(934, 452);
this.richEditControl1.TabIndex = 0;
//
// groupControl2
//
this.groupControl2.Appearance.Font = new System.Drawing.Font("方正姚体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupControl2.Appearance.Options.UseFont = true;
this.groupControl2.AppearanceCaption.Font = new System.Drawing.Font("方正姚体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupControl2.AppearanceCaption.Options.UseFont = true;
this.groupControl2.CaptionLocation = DevExpress.Utils.Locations.Top;
this.groupControl2.Controls.Add(this.lb_QtNum);
this.groupControl2.GroupStyle = DevExpress.Utils.GroupStyle.Light;
this.groupControl2.Location = new System.Drawing.Point(8, 266);
this.groupControl2.Name = "groupControl2";
this.groupControl2.Size = new System.Drawing.Size(162, 100);
this.groupControl2.TabIndex = 2;
this.groupControl2.Text = "数量";
//
// lb_QtNum
//
this.lb_QtNum.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.lb_QtNum.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lb_QtNum.Appearance.Options.UseBackColor = true;
this.lb_QtNum.Appearance.Options.UseFont = true;
this.lb_QtNum.Location = new System.Drawing.Point(69, 47);
this.lb_QtNum.Name = "lb_QtNum";
this.lb_QtNum.Size = new System.Drawing.Size(23, 18);
this.lb_QtNum.TabIndex = 0;
this.lb_QtNum.Text = "N/A";
//
// bt_ArgsSet
//
this.bt_ArgsSet.Appearance.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.bt_ArgsSet.Appearance.Options.UseFont = true;
this.bt_ArgsSet.Location = new System.Drawing.Point(4, 47);
this.bt_ArgsSet.Name = "bt_ArgsSet";
this.bt_ArgsSet.Size = new System.Drawing.Size(169, 43);
this.bt_ArgsSet.TabIndex = 2;
this.bt_ArgsSet.Text = "参数设置";
this.bt_ArgsSet.Click += new System.EventHandler(this.bt_ArgsSet_Click);
//
// bt_OrderCofig
//
this.bt_OrderCofig.Appearance.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.bt_OrderCofig.Appearance.Options.UseFont = true;
this.bt_OrderCofig.Location = new System.Drawing.Point(4, 2);
this.bt_OrderCofig.Name = "bt_OrderCofig";
this.bt_OrderCofig.Size = new System.Drawing.Size(169, 43);
this.bt_OrderCofig.TabIndex = 1;
this.bt_OrderCofig.Text = "订单配置";
this.bt_OrderCofig.Click += new System.EventHandler(this.bt_OrderCofig_Click);
//
// bt_start
//
this.bt_start.Appearance.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.bt_start.Appearance.Options.UseFont = true;
this.bt_start.Enabled = false;
this.bt_start.Location = new System.Drawing.Point(4, 561);
this.bt_start.Name = "bt_start";
this.bt_start.Size = new System.Drawing.Size(165, 68);
this.bt_start.TabIndex = 3;
this.bt_start.Text = "开始";
this.bt_start.Click += new System.EventHandler(this.bt_start_Click);
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1127, 635);
this.Controls.Add(this.splitContainerControl1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "BarcodeAcquisitionAndBindingTool V1.00";
this.Load += new System.EventHandler(this.MainForm_Load);
((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).EndInit();
this.splitContainerControl1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainerControl2)).EndInit();
this.splitContainerControl2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.txt_Sn.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txt_ShowInfo.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.groupControl1)).EndInit();
this.groupControl1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.groupControl2)).EndInit();
this.groupControl2.ResumeLayout(false);
this.groupControl2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private DevExpress.XtraEditors.SplitContainerControl splitContainerControl1;
private DevExpress.XtraEditors.SplitContainerControl splitContainerControl2;
private DevExpress.XtraEditors.GroupControl groupControl1;
private DevExpress.XtraRichEdit.RichEditControl richEditControl1;
private DevExpress.XtraEditors.TextEdit txt_ShowInfo;
private DevExpress.XtraEditors.LabelControl lb_Mac;
private DevExpress.XtraEditors.LabelControl labelControl1;
private DevExpress.XtraEditors.LabelControl labelControl3;
private DevExpress.XtraEditors.TextEdit txt_Sn;
private DevExpress.XtraEditors.SimpleButton bt_ArgsSet;
private DevExpress.XtraEditors.SimpleButton bt_OrderCofig;
private DevExpress.XtraEditors.SimpleButton bt_start;
private DevExpress.XtraEditors.GroupControl groupControl2;
private DevExpress.XtraEditors.LabelControl lb_QtNum;
private System.Windows.Forms.Timer timer1;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Tie_Yards__Program.Models;
using Tie_Yards__Program.Common;
namespace Tie_Yards__Program.UI
{
public partial class OrderSetWinForm : DevExpress.XtraEditors.XtraForm
{
int index= 0;
List<OrderinfoMode> orderinfoModes;
static string TitleStr = string.Empty;
public event Action<OrderinfoMode> CallBack;//回写事件
private static OrderSetWinForm orderWinForm;//单例对象
public OrderSetWinForm()
{
InitializeComponent();
}
private void OrderSetWinForm_Load(object sender, EventArgs e)
{
this.Text = TitleStr + "-" + this.Text;
XmlHelpers xmlHelpers = new XmlHelpers("config.xml");
if (xmlHelpers.ReadAllData())
{
orderinfoModes = new List<OrderinfoMode>(xmlHelpers.orderinfoModes);
}
foreach (OrderinfoMode orderinfo in orderinfoModes)
cmb_Orderinfo.Properties.Items.Add(orderinfo.OrderNumber);
if (cmb_Orderinfo.Properties.Items.Count > 0)
cmb_Orderinfo.Enabled = true;
}
/// <summary>
/// 单例 实体
/// </summary>
/// <returns></returns>
public static OrderSetWinForm CreateInstance(string Title)
{
if (orderWinForm == null || orderWinForm.IsDisposed)
{
orderWinForm = new OrderSetWinForm();//上一个窗口资源存在
TitleStr = Title;
}
return orderWinForm;
}
/// <summary>
/// 关闭窗体
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OrderSetWinForm_FormClosing(object sender, FormClosingEventArgs e)
{
CallBack.Invoke(new OrderinfoMode());//回写
}
/// <summary>
/// 选择订单信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cmb_Orderinfo_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (OrderinfoMode orderinfo in orderinfoModes)
{
if (orderinfo.OrderNumber == cmb_Orderinfo.Text)
{
txt_binName.Text = orderinfo.GetBinNa;
txt_cmd.Text = orderinfo.GetMacCmd;
txt_Macfx.Text = orderinfo.MacPrefix;
txt_Snfx.Text = orderinfo.SnPrefix;
break;
}
index++;
}
}
/// <summary>
/// 设置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void bt_Set_Click(object sender, EventArgs e)
{
CallBack.Invoke(orderinfoModes[index]);//回写
this.Close();
}
}
}
using DevExpress.XtraEditors;
namespace Tie_Yards__Program.UI
{
partial class OrderSetWinForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OrderSetWinForm));
this.groupControl1 = new DevExpress.XtraEditors.GroupControl();
this.bt_Set = new DevExpress.XtraEditors.SimpleButton();
this.txt_binName = new DevExpress.XtraEditors.TextEdit();
this.txt_cmd = new DevExpress.XtraEditors.TextEdit();
this.txt_Snfx = new DevExpress.XtraEditors.TextEdit();
this.txt_Macfx = new DevExpress.XtraEditors.TextEdit();
this.cmb_Orderinfo = new DevExpress.XtraEditors.ComboBoxEdit();
this.labelControl5 = new DevExpress.XtraEditors.LabelControl();
this.labelControl4 = new DevExpress.XtraEditors.LabelControl();
this.labelControl3 = new DevExpress.XtraEditors.LabelControl();
this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
this.labelControl1 = new DevExpress.XtraEditors.LabelControl();
((System.ComponentModel.ISupportInitialize)(this.groupControl1)).BeginInit();
this.groupControl1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.txt_binName.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txt_cmd.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txt_Snfx.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txt_Macfx.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cmb_Orderinfo.Properties)).BeginInit();
this.SuspendLayout();
//
// groupControl1
//
this.groupControl1.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupControl1.Appearance.Options.UseFont = true;
this.groupControl1.AppearanceCaption.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupControl1.AppearanceCaption.Options.UseFont = true;
this.groupControl1.Controls.Add(this.bt_Set);
this.groupControl1.Controls.Add(this.txt_binName);
this.groupControl1.Controls.Add(this.txt_cmd);
this.groupControl1.Controls.Add(this.txt_Snfx);
this.groupControl1.Controls.Add(this.txt_Macfx);
this.groupControl1.Controls.Add(this.cmb_Orderinfo);
this.groupControl1.Controls.Add(this.labelControl5);
this.groupControl1.Controls.Add(this.labelControl4);
this.groupControl1.Controls.Add(this.labelControl3);
this.groupControl1.Controls.Add(this.labelControl2);
this.groupControl1.Controls.Add(this.labelControl1);
this.groupControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupControl1.Location = new System.Drawing.Point(0, 0);
this.groupControl1.Name = "groupControl1";
this.groupControl1.Size = new System.Drawing.Size(609, 428);
this.groupControl1.TabIndex = 0;
this.groupControl1.Text = "配置界面";
//
// bt_Set
//
this.bt_Set.Appearance.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.bt_Set.Appearance.Image = global::Tie_Yards_Program.UI.Properties.Resources.gear1;
this.bt_Set.Appearance.Options.UseFont = true;
this.bt_Set.Appearance.Options.UseImage = true;
this.bt_Set.BackgroundImage = global::Tie_Yards_Program.UI.Properties.Resources.gear1;
this.bt_Set.Location = new System.Drawing.Point(460, 333);
this.bt_Set.Name = "bt_Set";
this.bt_Set.Size = new System.Drawing.Size(137, 56);
this.bt_Set.TabIndex = 3;
this.bt_Set.Text = "设置";
this.bt_Set.Click += new System.EventHandler(this.bt_Set_Click);
//
// txt_binName
//
this.txt_binName.Enabled = false;
this.txt_binName.Location = new System.Drawing.Point(127, 255);
this.txt_binName.Name = "txt_binName";
this.txt_binName.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_binName.Properties.Appearance.Options.UseFont = true;
this.txt_binName.Size = new System.Drawing.Size(478, 24);
this.txt_binName.TabIndex = 2;
//
// txt_cmd
//
this.txt_cmd.Enabled = false;
this.txt_cmd.Location = new System.Drawing.Point(127, 201);
this.txt_cmd.Name = "txt_cmd";
this.txt_cmd.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_cmd.Properties.Appearance.Options.UseFont = true;
this.txt_cmd.Size = new System.Drawing.Size(478, 24);
this.txt_cmd.TabIndex = 2;
//
// txt_Snfx
//
this.txt_Snfx.Enabled = false;
this.txt_Snfx.Location = new System.Drawing.Point(127, 149);
this.txt_Snfx.Name = "txt_Snfx";
this.txt_Snfx.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_Snfx.Properties.Appearance.Options.UseFont = true;
this.txt_Snfx.Size = new System.Drawing.Size(478, 24);
this.txt_Snfx.TabIndex = 2;
//
// txt_Macfx
//
this.txt_Macfx.Enabled = false;
this.txt_Macfx.Location = new System.Drawing.Point(127, 97);
this.txt_Macfx.Name = "txt_Macfx";
this.txt_Macfx.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_Macfx.Properties.Appearance.Options.UseFont = true;
this.txt_Macfx.Size = new System.Drawing.Size(478, 24);
this.txt_Macfx.TabIndex = 2;
//
// cmb_Orderinfo
//
this.cmb_Orderinfo.Enabled = false;
this.cmb_Orderinfo.Location = new System.Drawing.Point(127, 44);
this.cmb_Orderinfo.Name = "cmb_Orderinfo";
this.cmb_Orderinfo.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.cmb_Orderinfo.Properties.Appearance.Options.UseFont = true;
this.cmb_Orderinfo.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.cmb_Orderinfo.Size = new System.Drawing.Size(478, 24);
this.cmb_Orderinfo.TabIndex = 1;
this.cmb_Orderinfo.SelectedIndexChanged += new System.EventHandler(this.cmb_Orderinfo_SelectedIndexChanged);
//
// labelControl5
//
this.labelControl5.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.labelControl5.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl5.Appearance.Options.UseBackColor = true;
this.labelControl5.Appearance.Options.UseFont = true;
this.labelControl5.Location = new System.Drawing.Point(12, 258);
this.labelControl5.Name = "labelControl5";
this.labelControl5.Size = new System.Drawing.Size(113, 18);
this.labelControl5.TabIndex = 0;
this.labelControl5.Text = "生成*.Bin文件名";
//
// labelControl4
//
this.labelControl4.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.labelControl4.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl4.Appearance.Options.UseBackColor = true;
this.labelControl4.Appearance.Options.UseFont = true;
this.labelControl4.Location = new System.Drawing.Point(29, 204);
this.labelControl4.Name = "labelControl4";
this.labelControl4.Size = new System.Drawing.Size(96, 18);
this.labelControl4.TabIndex = 0;
this.labelControl4.Text = "执行命令指令";
//
// labelControl3
//
this.labelControl3.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.labelControl3.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl3.Appearance.Options.UseBackColor = true;
this.labelControl3.Appearance.Options.UseFont = true;
this.labelControl3.Location = new System.Drawing.Point(42, 152);
this.labelControl3.Name = "labelControl3";
this.labelControl3.Size = new System.Drawing.Size(83, 18);
this.labelControl3.TabIndex = 0;
this.labelControl3.Text = "SN前缀字段";
//
// labelControl2
//
this.labelControl2.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
this.labelControl2.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl2.Appearance.Options.UseBackColor = true;
this.labelControl2.Appearance.Options.UseFont = true;
this.labelControl2.Location = new System.Drawing.Point(35, 100);
this.labelControl2.Name = "labelControl2";
this.labelControl2.Size = new System.Drawing.Size(90, 18);
this.labelControl2.TabIndex = 0;
this.labelControl2.Text = "Mac前缀字段";
//
// labelControl1
//
this.labelControl1.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.labelControl1.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl1.Appearance.Options.UseBackColor = true;
this.labelControl1.Appearance.Options.UseFont = true;
this.labelControl1.Location = new System.Drawing.Point(61, 47);
this.labelControl1.Name = "labelControl1";
this.labelControl1.Size = new System.Drawing.Size(64, 18);
this.labelControl1.TabIndex = 0;
this.labelControl1.Text = "选择订单";
//
// OrderSetWinForm
//
this.Appearance.Options.UseFont = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(609, 428);
this.Controls.Add(this.groupControl1);
this.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MaximizeBox = false;
this.Name = "OrderSetWinForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "OrderInfoSet";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OrderSetWinForm_FormClosing);
this.Load += new System.EventHandler(this.OrderSetWinForm_Load);
((System.ComponentModel.ISupportInitialize)(this.groupControl1)).EndInit();
this.groupControl1.ResumeLayout(false);
this.groupControl1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.txt_binName.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txt_cmd.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txt_Snfx.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txt_Macfx.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cmb_Orderinfo.Properties)).EndInit();
this.ResumeLayout(false);
}
#endregion
private GroupControl groupControl1;
private DevExpress.XtraEditors.LabelControl labelControl1;
private DevExpress.XtraEditors.TextEdit txt_binName;
private DevExpress.XtraEditors.TextEdit txt_cmd;
private DevExpress.XtraEditors.TextEdit txt_Snfx;
private DevExpress.XtraEditors.TextEdit txt_Macfx;
private DevExpress.XtraEditors.ComboBoxEdit cmb_Orderinfo;
private DevExpress.XtraEditors.LabelControl labelControl5;
private DevExpress.XtraEditors.LabelControl labelControl4;
private DevExpress.XtraEditors.LabelControl labelControl3;
private DevExpress.XtraEditors.LabelControl labelControl2;
private SimpleButton bt_Set;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Tie_Yards__Program.Models;
using System.Reflection;
using Tie_Yards__Program.Common;
using Tie_Yards_Program.Common;
namespace Tie_Yards__Program.UI
{
public partial class OrderWinForm : DevExpress.XtraEditors.XtraForm
{
OrderinfoMode orderinfoMode;
static string TitleStr = string.Empty;
public event Action CallBack;//回写事件
private static OrderWinForm orderWinForm;//单例对象
List<TextEdit> InTxtConsole;//录入的文本框控件
public OrderWinForm()
{
InitializeComponent();
}
private void OrderWinForm_Load(object sender, EventArgs e)
{
this.Text = TitleStr + "-" + this.Text;
InTxtConsole = new List<TextEdit>();
InTxtConsole.Add(txt_OrderNum);//订单号
InTxtConsole.Add(txt_MacFx);//Mac前缀
InTxtConsole.Add(txt_SnFx);//Sn前缀
InTxtConsole.Add(txt_MacGetCmd);//读取Mac指令
InTxtConsole.Add(txt_MacBinNa);//读取Mac Bin文件
orderinfoMode = new OrderinfoMode();
orderinfoMode.GetBinNa = @"mac.bin";
}
/// <summary>
/// 单例 实体
/// </summary>
/// <returns></returns>
public static OrderWinForm CreateInstance(string Title)
{
if (orderWinForm == null || orderWinForm.IsDisposed)
{
orderWinForm = new OrderWinForm();//上一个窗口资源存在
TitleStr = Title;
}
return orderWinForm;
}
/// <summary>
/// 订单窗体退出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OrderWinForm_FormClosing(object sender, FormClosingEventArgs e)
{
CallBack.Invoke();
}
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void bt_save_Click(object sender, EventArgs e)
{
bool CollectOk = true;
for (int i = 0; i < InTxtConsole.Count; i++)
{
if (InTxtConsole[i].Text == string.Empty || InTxtConsole[i].Text.Length < 1)
{
CollectOk = false;
break;
}
}
if (CollectOk)
{
XmlHelpers xmlHelpers = new XmlHelpers("Config.xml");
if (xmlHelpers.ReadAllData())
{
if (xmlHelpers.orderinfoModes.Any(a => a.OrderNumber.Contains(orderinfoMode.OrderNumber)))
{
if (xmlHelpers.UpdateNode(orderinfoMode))
{
MessageBox.Show($@"{orderinfoMode.OrderNumber}订单信息更新成功!!", "系统提醒");
}
else
{
MessageBox.Show($@"{orderinfoMode.OrderNumber}订单信息更新失败!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
CollectOk = false;
}
}
else
{
if (xmlHelpers.AddNodeData(orderinfoMode))
{
MessageBox.Show($@"{orderinfoMode.OrderNumber}订单信息添加成功!!", "系统提醒");
}
else
{
MessageBox.Show($@"{orderinfoMode.OrderNumber}订单信息添加失败!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
CollectOk = false;
}
}
}
if (CollectOk)
{
CallBack.Invoke();
this.Close();
}
}
else
{
MessageBox.Show("关键配置内容不能为空!!", "系统提醒");
}
}
private bool WriteData()
{
return false;
}
/// <summary>
/// 焦点离开时产生
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txt_OrderNum_Leave(object sender, EventArgs e)
{
if (((TextEdit)sender).Name == "txt_OrderNum")//订单号
{
if (((TextEdit)sender).Text != null)
orderinfoMode.OrderNumber = ((TextEdit)sender).Text;
}
else if (((TextEdit)sender).Name == "txt_MacFx")//Mac前缀
{
if (((TextEdit)sender).Text != null)
orderinfoMode.MacPrefix = ((TextEdit)sender).Text;
}
else if (((TextEdit)sender).Name == "txt_SnFx")//Sn前缀
{
if (((TextEdit)sender).Text != null)
orderinfoMode.SnPrefix = ((TextEdit)sender).Text;
}
else if (((TextEdit)sender).Name == "txt_MacGetCmd")//获取MAC指令
{
if (((TextEdit)sender).Text != null)
orderinfoMode.GetMacCmd = ((TextEdit)sender).Text;
}
else if (((TextEdit)sender).Name == "txt_MacBinNa")//获取的bin文件名
{
if (((TextEdit)sender).Text != null)
orderinfoMode.GetBinNa = ((TextEdit)sender).Text;
}
}
/// <summary>
/// 重置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void bt_cancel_Click(object sender, EventArgs e)
{
for (int i = 0; i < InTxtConsole.Count; i++)
InTxtConsole[i].Text = "";
InTxtConsole[0].Focus();
orderinfoMode.GetBinNa = @"mac.bin";
txt_MacBinNa.Text = @"mac.bin";
}
}
}
namespace Tie_Yards__Program.UI
{
partial class OrderWinForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OrderWinForm));
this.labelControl1 = new DevExpress.XtraEditors.LabelControl();
this.txt_OrderNum = new DevExpress.XtraEditors.TextEdit();
this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
this.labelControl3 = new DevExpress.XtraEditors.LabelControl();
this.labelControl4 = new DevExpress.XtraEditors.LabelControl();
this.txt_MacGetCmd = new DevExpress.XtraEditors.TextEdit();
this.txt_MacFx = new DevExpress.XtraEditors.TextEdit();
this.txt_SnFx = new DevExpress.XtraEditors.TextEdit();
this.bt_save = new DevExpress.XtraEditors.SimpleButton();
this.bt_cancel = new DevExpress.XtraEditors.SimpleButton();
this.labelControl5 = new DevExpress.XtraEditors.LabelControl();
this.txt_MacBinNa = new DevExpress.XtraEditors.TextEdit();
this.groupControl1 = new DevExpress.XtraEditors.GroupControl();
((System.ComponentModel.ISupportInitialize)(this.txt_OrderNum.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txt_MacGetCmd.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txt_MacFx.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txt_SnFx.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txt_MacBinNa.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.groupControl1)).BeginInit();
this.groupControl1.SuspendLayout();
this.SuspendLayout();
//
// labelControl1
//
this.labelControl1.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
this.labelControl1.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl1.Appearance.Options.UseBackColor = true;
this.labelControl1.Appearance.Options.UseFont = true;
this.labelControl1.Location = new System.Drawing.Point(86, 47);
this.labelControl1.Name = "labelControl1";
this.labelControl1.Size = new System.Drawing.Size(52, 18);
this.labelControl1.TabIndex = 0;
this.labelControl1.Text = "订单号:";
//
// txt_OrderNum
//
this.txt_OrderNum.Location = new System.Drawing.Point(143, 44);
this.txt_OrderNum.Name = "txt_OrderNum";
this.txt_OrderNum.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_OrderNum.Properties.Appearance.Options.UseFont = true;
this.txt_OrderNum.Size = new System.Drawing.Size(454, 24);
this.txt_OrderNum.TabIndex = 0;
this.txt_OrderNum.Leave += new System.EventHandler(this.txt_OrderNum_Leave);
//
// labelControl2
//
this.labelControl2.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.labelControl2.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl2.Appearance.Options.UseBackColor = true;
this.labelControl2.Appearance.Options.UseFont = true;
this.labelControl2.Location = new System.Drawing.Point(14, 206);
this.labelControl2.Name = "labelControl2";
this.labelControl2.Size = new System.Drawing.Size(126, 18);
this.labelControl2.TabIndex = 0;
this.labelControl2.Text = "Mac读取执行指令:";
//
// labelControl3
//
this.labelControl3.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.labelControl3.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl3.Appearance.Options.UseBackColor = true;
this.labelControl3.Appearance.Options.UseFont = true;
this.labelControl3.Location = new System.Drawing.Point(80, 100);
this.labelControl3.Name = "labelControl3";
this.labelControl3.Size = new System.Drawing.Size(62, 18);
this.labelControl3.TabIndex = 0;
this.labelControl3.Text = "Mac前缀:";
//
// labelControl4
//
this.labelControl4.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.labelControl4.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl4.Appearance.Options.UseBackColor = true;
this.labelControl4.Appearance.Options.UseFont = true;
this.labelControl4.Location = new System.Drawing.Point(84, 153);
this.labelControl4.Name = "labelControl4";
this.labelControl4.Size = new System.Drawing.Size(55, 18);
this.labelControl4.TabIndex = 0;
this.labelControl4.Text = "SN条缀:";
//
// txt_MacGetCmd
//
this.txt_MacGetCmd.Location = new System.Drawing.Point(143, 203);
this.txt_MacGetCmd.Name = "txt_MacGetCmd";
this.txt_MacGetCmd.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_MacGetCmd.Properties.Appearance.Options.UseFont = true;
this.txt_MacGetCmd.Size = new System.Drawing.Size(454, 24);
this.txt_MacGetCmd.TabIndex = 3;
this.txt_MacGetCmd.Leave += new System.EventHandler(this.txt_OrderNum_Leave);
//
// txt_MacFx
//
this.txt_MacFx.Location = new System.Drawing.Point(143, 97);
this.txt_MacFx.Name = "txt_MacFx";
this.txt_MacFx.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_MacFx.Properties.Appearance.Options.UseFont = true;
this.txt_MacFx.Size = new System.Drawing.Size(454, 24);
this.txt_MacFx.TabIndex = 1;
this.txt_MacFx.Leave += new System.EventHandler(this.txt_OrderNum_Leave);
//
// txt_SnFx
//
this.txt_SnFx.Location = new System.Drawing.Point(142, 150);
this.txt_SnFx.Name = "txt_SnFx";
this.txt_SnFx.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_SnFx.Properties.Appearance.Options.UseFont = true;
this.txt_SnFx.Size = new System.Drawing.Size(454, 24);
this.txt_SnFx.TabIndex = 2;
this.txt_SnFx.Leave += new System.EventHandler(this.txt_OrderNum_Leave);
//
// bt_save
//
this.bt_save.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.bt_save.Appearance.Options.UseFont = true;
this.bt_save.Location = new System.Drawing.Point(297, 339);
this.bt_save.Name = "bt_save";
this.bt_save.Size = new System.Drawing.Size(137, 56);
this.bt_save.TabIndex = 5;
this.bt_save.Text = "保存";
this.bt_save.Click += new System.EventHandler(this.bt_save_Click);
//
// bt_cancel
//
this.bt_cancel.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.bt_cancel.Appearance.Options.UseFont = true;
this.bt_cancel.Location = new System.Drawing.Point(459, 339);
this.bt_cancel.Name = "bt_cancel";
this.bt_cancel.Size = new System.Drawing.Size(137, 56);
this.bt_cancel.TabIndex = 6;
this.bt_cancel.Text = "重置";
this.bt_cancel.Click += new System.EventHandler(this.bt_cancel_Click);
//
// labelControl5
//
this.labelControl5.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.labelControl5.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl5.Appearance.Options.UseBackColor = true;
this.labelControl5.Appearance.Options.UseFont = true;
this.labelControl5.Location = new System.Drawing.Point(6, 259);
this.labelControl5.Name = "labelControl5";
this.labelControl5.Size = new System.Drawing.Size(135, 18);
this.labelControl5.TabIndex = 0;
this.labelControl5.Text = "生成Mac Bin文件名:";
//
// txt_MacBinNa
//
this.txt_MacBinNa.EditValue = "mac.bin";
this.txt_MacBinNa.Location = new System.Drawing.Point(143, 256);
this.txt_MacBinNa.Name = "txt_MacBinNa";
this.txt_MacBinNa.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_MacBinNa.Properties.Appearance.Options.UseFont = true;
this.txt_MacBinNa.Size = new System.Drawing.Size(454, 24);
this.txt_MacBinNa.TabIndex = 4;
this.txt_MacBinNa.Leave += new System.EventHandler(this.txt_OrderNum_Leave);
//
// groupControl1
//
this.groupControl1.Appearance.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupControl1.Appearance.Options.UseFont = true;
this.groupControl1.AppearanceCaption.Font = new System.Drawing.Font("方正姚体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupControl1.AppearanceCaption.Options.UseFont = true;
this.groupControl1.Controls.Add(this.labelControl1);
this.groupControl1.Controls.Add(this.bt_cancel);
this.groupControl1.Controls.Add(this.labelControl2);
this.groupControl1.Controls.Add(this.bt_save);
this.groupControl1.Controls.Add(this.labelControl5);
this.groupControl1.Controls.Add(this.txt_MacBinNa);
this.groupControl1.Controls.Add(this.labelControl3);
this.groupControl1.Controls.Add(this.txt_MacGetCmd);
this.groupControl1.Controls.Add(this.labelControl4);
this.groupControl1.Controls.Add(this.txt_SnFx);
this.groupControl1.Controls.Add(this.txt_OrderNum);
this.groupControl1.Controls.Add(this.txt_MacFx);
this.groupControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupControl1.Location = new System.Drawing.Point(0, 0);
this.groupControl1.Name = "groupControl1";
this.groupControl1.Size = new System.Drawing.Size(609, 428);
this.groupControl1.TabIndex = 7;
this.groupControl1.Text = "订单添加";
//
// OrderWinForm
//
this.Appearance.Options.UseFont = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(609, 428);
this.Controls.Add(this.groupControl1);
this.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MaximizeBox = false;
this.Name = "OrderWinForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Add.OrderInfo";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OrderWinForm_FormClosing);
this.Load += new System.EventHandler(this.OrderWinForm_Load);
((System.ComponentModel.ISupportInitialize)(this.txt_OrderNum.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txt_MacGetCmd.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txt_MacFx.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txt_SnFx.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txt_MacBinNa.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.groupControl1)).EndInit();
this.groupControl1.ResumeLayout(false);
this.groupControl1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private DevExpress.XtraEditors.LabelControl labelControl1;
private DevExpress.XtraEditors.TextEdit txt_OrderNum;
private DevExpress.XtraEditors.LabelControl labelControl2;
private DevExpress.XtraEditors.LabelControl labelControl3;
private DevExpress.XtraEditors.LabelControl labelControl4;
private DevExpress.XtraEditors.TextEdit txt_MacGetCmd;
private DevExpress.XtraEditors.TextEdit txt_MacFx;
private DevExpress.XtraEditors.TextEdit txt_SnFx;
private DevExpress.XtraEditors.SimpleButton bt_save;
private DevExpress.XtraEditors.SimpleButton bt_cancel;
private DevExpress.XtraEditors.LabelControl labelControl5;
private DevExpress.XtraEditors.TextEdit txt_MacBinNa;
private DevExpress.XtraEditors.GroupControl groupControl1;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Tie_Yards__Program.Models;
using System.Configuration;
namespace Tie_Yards_Program.UI
{
public partial class Login : DevExpress.XtraEditors.XtraForm
{
public event Action<string> CallBack;//回写事件
private static Login orderWinForm;//单例对象
public Login()
{
InitializeComponent();
}
private void Login_Load(object sender, EventArgs e)
{
}
/// <summary>
/// 单例 实体
/// </summary>
/// <returns></returns>
public static Login CreateInstance()
{
if (orderWinForm == null || orderWinForm.IsDisposed)
{
orderWinForm = new Login();//上一个窗口资源存在
}
return orderWinForm;
}
private void simpleButton1_Click(object sender, EventArgs e)
{
LoginMode loginMode = new LoginMode()
{
User=ConfigurationManager.ConnectionStrings["User"].ConnectionString,
Pwd= ConfigurationManager.ConnectionStrings["Passwed"].ConnectionString
};
if (txt_User.Text.ToUpper() == loginMode.User.ToUpper() &&
txt_Pwd.Text.ToUpper() == loginMode.Pwd.ToUpper())
{
CallBack.Invoke("OK");
this.Close();
}
else
{
MessageBox.Show("输入的用户名或者密码错误","系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void Login_FormClosed(object sender, FormClosedEventArgs e)
{
CallBack.Invoke("NG");
}
}
}
namespace Tie_Yards_Program.UI
{
partial class Login
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Login));
this.groupControl1 = new DevExpress.XtraEditors.GroupControl();
this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton();
this.txt_Pwd = new DevExpress.XtraEditors.TextEdit();
this.txt_User = new DevExpress.XtraEditors.TextEdit();
this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
this.labelControl1 = new DevExpress.XtraEditors.LabelControl();
this.behaviorManager1 = new DevExpress.Utils.Behaviors.BehaviorManager(this.components);
((System.ComponentModel.ISupportInitialize)(this.groupControl1)).BeginInit();
this.groupControl1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.txt_Pwd.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txt_User.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.behaviorManager1)).BeginInit();
this.SuspendLayout();
//
// groupControl1
//
this.groupControl1.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupControl1.Appearance.Options.UseFont = true;
this.groupControl1.AppearanceCaption.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupControl1.AppearanceCaption.Options.UseFont = true;
this.groupControl1.Controls.Add(this.simpleButton1);
this.groupControl1.Controls.Add(this.txt_Pwd);
this.groupControl1.Controls.Add(this.txt_User);
this.groupControl1.Controls.Add(this.labelControl2);
this.groupControl1.Controls.Add(this.labelControl1);
this.groupControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupControl1.Location = new System.Drawing.Point(0, 0);
this.groupControl1.Name = "groupControl1";
this.groupControl1.Size = new System.Drawing.Size(378, 167);
this.groupControl1.TabIndex = 0;
this.groupControl1.Text = "帐户信息";
//
// simpleButton1
//
this.simpleButton1.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.simpleButton1.Appearance.Options.UseFont = true;
this.simpleButton1.Location = new System.Drawing.Point(268, 119);
this.simpleButton1.Name = "simpleButton1";
this.simpleButton1.Size = new System.Drawing.Size(98, 36);
this.simpleButton1.TabIndex = 2;
this.simpleButton1.Text = "登陆";
this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click);
//
// txt_Pwd
//
this.txt_Pwd.Location = new System.Drawing.Point(71, 73);
this.txt_Pwd.Name = "txt_Pwd";
this.txt_Pwd.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_Pwd.Properties.Appearance.Options.UseFont = true;
this.txt_Pwd.Properties.PasswordChar = '*';
this.txt_Pwd.Size = new System.Drawing.Size(295, 24);
this.txt_Pwd.TabIndex = 1;
//
// txt_User
//
this.txt_User.Location = new System.Drawing.Point(71, 40);
this.txt_User.Name = "txt_User";
this.txt_User.Properties.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_User.Properties.Appearance.Options.UseFont = true;
this.txt_User.Size = new System.Drawing.Size(295, 24);
this.txt_User.TabIndex = 0;
//
// labelControl2
//
this.labelControl2.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.labelControl2.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl2.Appearance.Options.UseBackColor = true;
this.labelControl2.Appearance.Options.UseFont = true;
this.labelControl2.Location = new System.Drawing.Point(28, 76);
this.labelControl2.Name = "labelControl2";
this.labelControl2.Size = new System.Drawing.Size(32, 18);
this.labelControl2.TabIndex = 0;
this.labelControl2.Text = "密码";
//
// labelControl1
//
this.labelControl1.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
this.labelControl1.Appearance.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelControl1.Appearance.Options.UseBackColor = true;
this.labelControl1.Appearance.Options.UseFont = true;
this.labelControl1.Location = new System.Drawing.Point(12, 43);
this.labelControl1.Name = "labelControl1";
this.labelControl1.Size = new System.Drawing.Size(48, 18);
this.labelControl1.TabIndex = 0;
this.labelControl1.Text = "用户名";
//
// Login
//
this.Appearance.Options.UseFont = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(378, 167);
this.Controls.Add(this.groupControl1);
this.Font = new System.Drawing.Font("方正姚体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Login";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Login";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Login_FormClosed);
this.Load += new System.EventHandler(this.Login_Load);
((System.ComponentModel.ISupportInitialize)(this.groupControl1)).EndInit();
this.groupControl1.ResumeLayout(false);
this.groupControl1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.txt_Pwd.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txt_User.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.behaviorManager1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DevExpress.XtraEditors.GroupControl groupControl1;
private DevExpress.XtraEditors.SimpleButton simpleButton1;
private DevExpress.XtraEditors.TextEdit txt_Pwd;
private DevExpress.XtraEditors.TextEdit txt_User;
private DevExpress.XtraEditors.LabelControl labelControl2;
private DevExpress.XtraEditors.LabelControl labelControl1;
private DevExpress.Utils.Behaviors.BehaviorManager behaviorManager1;
}
}
using CsvHelper;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tie_Yards__Program.Models;
namespace Tie_Yards__Program.Common
{
public class CvsHelper
{
private string filePathCsv;
/// <summary>
///
/// </summary>
/// <param name="filePathCsv">Csv文件名</param>
public CvsHelper(string filePathCsv)
{
this.filePathCsv = filePathCsv;
}
/// <summary>
/// 读取Csv文件所有内容
/// </summary>
/// <returns></returns>
public bool ReadCsvAllData()
{
using (var reader = new StreamReader(this.filePathCsv))
{
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
var records = csv.GetRecords<TieYards_BarcodeMode>();
}
}
return false;
}
/// <summary>
/// 读取行内容
/// </summary>
/// <returns></returns>
public bool LineRead(ref List<TieYards_BarcodeMode>tieYards)
{
try
{
using (var reader = new StreamReader(this.filePathCsv))
{
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
while (csv.Read())
{
var record = csv.GetRecord<TieYards_BarcodeMode>();
tieYards.Add(record);
}
}
}
return true;
}
catch (Exception ex)
{
LogHelper<CvsHelper>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
return false;
}
}
/// <summary>
/// 读取字段
/// </summary>
/// <param name="tieYards"></param>
/// <returns></returns>
public bool ReadFields(ref TieYards_BarcodeMode tieYards)
{
try
{
using (var reader = new StreamReader(this.filePathCsv))
{
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
csv.Read();
csv.ReadHeader();
while (csv.Read())
{
var id = csv.GetField<int>(0);
var name = csv.GetField<string>("Name");
}
}
}
return true;
}
catch (Exception ex)
{
LogHelper<CvsHelper>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
return false;
}
}
/// <summary>
/// 写所有数据
/// </summary>
/// <param name="tyb"></param>
/// <returns></returns>
public bool CsvWriteAllData(List<TieYards_BarcodeMode> tyb)
{
try
{
using (var writer = new StreamWriter(filePathCsv))
{
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.WriteRecords(tyb);
}
}
return true;
}
catch (Exception ex)
{
LogHelper<CvsHelper>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
return false;
}
}
/// <summary>
/// Csv文件行写入
/// </summary>
/// <param name="tyb"></param>
/// <returns></returns>
public bool CsvFieldByfieldWrite(TieYards_BarcodeMode tyb)
{
try
{
using (var writer = new StreamWriter(this.filePathCsv))
{
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.WriteHeader<TieYards_BarcodeMode>();
csv.NextRecord();
csv.WriteField(tyb.SN);
csv.WriteField(tyb.Mac);
}
}
return true;
}
catch (Exception ex)
{
LogHelper<CvsHelper>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
return false;
}
}
}
}
using log4net;
using log4net.Config;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
namespace Tie_Yards__Program.Common
{
public class LogHelper<T>
{
static ILog log;//不对外开放
//默认使用类自动调用,只会执行一次
static LogHelper()
{
XmlConfigurator.Configure();//加载配置文件
log = LogManager.GetLogger(typeof(T));
}
public static void Debug(string info)
{
log.Debug(info);
}
public static void Debug(string info, Exception ex)
{
log.Debug(info, ex);
}
public static void Error(string info, Exception ex)
{
log.Error(info, ex);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Tie_Yards__Program.Common
{
public class SystemHelper
{
/// <summary>
/// 获得当前绝对路径
/// </summary>
/// <param name="strPath">指定的路径</param>
/// <returns>绝对路径</returns>
public string GetMapPath(string strPath)
{
if (strPath.ToLower().StartsWith("http://"))
{
return strPath;
}
if (HttpContext.Current != null)
{
return HttpContext.Current.Server.MapPath(strPath);
}
else //非web程序引用
{
strPath = strPath.Replace("/", "\\");
if (strPath.StartsWith("\\"))
{
strPath = strPath.Substring(strPath.IndexOf('\\', 1)).TrimStart('\\');
}
return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Tie_Yards__Program.Models;
namespace Tie_Yards__Program.Common
{
public class XmlHelpers
{
string XmlFileName;
XmlDocument xmlDoc;
XmlReaderSettings settings;
string filepath;
public List<OrderinfoMode> orderinfoModes;
public XmlHelpers(string XmlFileName)
{
this.XmlFileName = XmlFileName;
this.xmlDoc = new XmlDocument();
this.settings = new XmlReaderSettings();
this.settings.IgnoreComments = true;//忽略文档里面的注释
this.filepath = Environment.CurrentDirectory;//获取当前路径
filepath += $@"\{XmlFileName}";
}
/// <summary>
/// 获取所有节点数据
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="XmlFileName">Xml文件名</param>
/// <param name="NodeName">节点名称</param>
/// <returns></returns>
public bool ReadAllData()
{
orderinfoModes = new List<OrderinfoMode>();
using (XmlReader reader = XmlReader.Create(filepath, settings))
{
try
{
xmlDoc.Load(reader);
//得到根节点的所有子节点
XmlNode xn = xmlDoc.SelectSingleNode("configargs");
//得到根节点的所有子节点
XmlNodeList xnl = xn.ChildNodes;
//得到根节点的所有子节点
foreach (XmlNode xn1 in xnl)
{
OrderinfoMode orderinfoMode = new OrderinfoMode();
//将节点转换为元素,便于得到节点的属值
XmlElement xe = (XmlElement)xn1;
//得到OrderNumber的属性值
orderinfoMode.OrderNumber = xe.GetAttribute("Type").ToString();
//得到Order节点的所有子节点
XmlNodeList xnl0 = xe.ChildNodes;
orderinfoMode.MacPrefix = xnl0.Item(0).InnerText;
orderinfoMode.SnPrefix = xnl0.Item(1).InnerText;
orderinfoMode.GetMacCmd = xnl0.Item(2).InnerText;
orderinfoMode.GetBinNa = xnl0.Item(3).InnerText;
orderinfoMode.QtCount = Convert.ToInt32(xnl0.Item(4).InnerText);
orderinfoModes.Add(orderinfoMode);
}
return true;
}
catch (Exception ex)
{
//return false;
LogHelper<XmlHelpers>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
return false;
}
}
}
/// <summary>
/// 更新数据
/// </summary>
/// <param name="orderinfoMode"></param>
/// <returns></returns>
public bool UpdateNode(OrderinfoMode orderinfoMode)
{
try
{
xmlDoc.Load(filepath);
XmlNodeList nodeList = xmlDoc.SelectSingleNode("configargs").ChildNodes;//获取bookstore节点的所有子节点
foreach (XmlNode xn in nodeList)//遍历所有子节点
{
XmlElement xe = (XmlElement)xn;//将子节点类型转换为XmlElement类型
if (xe.GetAttribute("Type") == orderinfoMode.OrderNumber)
{
//xe.SetAttribute("genre", "林芳");//则修改该属性为“update李赞红”
XmlNodeList nls = xe.ChildNodes;//继续获取xe子节点的所有子节点
foreach (XmlNode xn1 in nls)//遍历
{
XmlElement xe2 = (XmlElement)xn1;//转换类型
if (xe2.Name == "SnPrefix")
{
xe2.InnerText = orderinfoMode.SnPrefix;
}
else if (xe2.Name == "GetMacCmd")
{
xe2.InnerText = orderinfoMode.GetMacCmd;
}
else if (xe2.Name == "GetBinNa")
{
xe2.InnerText = orderinfoMode.GetBinNa;
}
else if (xe2.Name == "QtCount")
{
xe2.InnerText = orderinfoMode.QtCount.ToString();
}
else if (xe2.Name == "MacPrefix")
{
xe2.InnerText = orderinfoMode.MacPrefix;
}
}
break;
}
}
xmlDoc.Save(filepath);//保存
return true;
}
catch (Exception ex)
{
LogHelper<XmlHelpers>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
return false;
}
}
/// <summary>
/// 删除节点
/// </summary>
/// <param name="OrderName">数据集合类</param>
/// <returns></returns>
public bool DeleteNodeData(string OrderName)
{
try
{
xmlDoc.Load(filepath);
XmlNodeList xnl = xmlDoc.SelectSingleNode("configargs").ChildNodes;//获取bookstore节点的所有子节点
foreach (XmlNode xn in xnl)//遍历所有子节点
{
XmlElement xe = (XmlElement)xn;//将子节点类型转换为xmlelement类型
if (xe.GetAttribute("Type") == OrderName)
{
//xe.RemoveAttribute("Type");//删除genre属性
xe.RemoveAll();
break;
}
}
xmlDoc.Save(filepath);
return true;
}
catch (Exception ex)
{
LogHelper<XmlHelpers>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
return false;
}
}
/// <summary>
/// 添加节点数据
/// </summary>
/// <param name="orderinfoMode"></param>
/// <returns></returns>
public bool AddNodeData(OrderinfoMode orderinfoMode)
{
try
{
xmlDoc.Load(filepath);
XmlNode root = xmlDoc.SelectSingleNode("configargs");//查找<bookstore>
XmlElement xe1 = xmlDoc.CreateElement("config");//创建一个<book>节点
xe1.SetAttribute("Type", orderinfoMode.OrderNumber);//设置该节点genre属性
xe1.SetAttribute("subtype", orderinfoMode.OrderNumber);//设置该节点ISBN属性
XmlElement xesub = xmlDoc.CreateElement("MacPrefix");
xesub.InnerText = orderinfoMode.MacPrefix;//设置文本节点
xe1.AppendChild(xesub);//添加到节点中
XmlElement xesub1 = xmlDoc.CreateElement("SnPrefix");
xesub1.InnerText = orderinfoMode.SnPrefix;//设置文本节点
xe1.AppendChild(xesub1);//添加到节点中
XmlElement xesub2 = xmlDoc.CreateElement("GetMacCmd");
xesub2.InnerText = orderinfoMode.GetMacCmd;//设置文本节点
xe1.AppendChild(xesub2);//添加到节点中
XmlElement xesub3 = xmlDoc.CreateElement("GetBinNa");
xesub3.InnerText = orderinfoMode.GetBinNa;//设置文本节点
xe1.AppendChild(xesub3);//添加到节点中
XmlElement xesub4 = xmlDoc.CreateElement("QtCount");
xesub4.InnerText = orderinfoMode.QtCount.ToString();//设置文本节点
xe1.AppendChild(xesub4);//添加到节点中
root.AppendChild(xe1);//添加到节点中
xmlDoc.Save(this.filepath);
return true;
}
catch (Exception ex)
{
LogHelper<XmlHelpers>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
return false;
//throw new Exception(ex.Message);
}
}
/// <summary>
/// 创建XML
/// </summary>
/// <param name="XmlFileName">XML文件名</param>
/// <param name="orderinfoMode">订单文件信息</param>
/// <returns></returns>
public bool CreateXml(OrderinfoMode orderinfoMode)
{
try
{
this.xmlDoc.Load(filepath);//加载xml文件
this.xmlDoc.LoadXml("<configargs></configargs>");//覆盖保存
XmlNode root = this.xmlDoc.SelectSingleNode("configargs");//建立跟节点
XmlElement xeKey = this.xmlDoc.CreateElement("config");//创建子节点,并且
XmlAttribute xeType = this.xmlDoc.CreateAttribute("Type");
xeType.InnerText = orderinfoMode.OrderNumber;
xeKey.SetAttributeNode(xeType);
XmlAttribute xeType2 = this.xmlDoc.CreateAttribute("subtype");
xeType2.InnerText = orderinfoMode.OrderNumber;
xeKey.SetAttributeNode(xeType2);
XmlElement MacPrefix = this.xmlDoc.CreateElement("MacPrefix");//创建子节点
MacPrefix.InnerText = orderinfoMode.MacPrefix;
xeKey.AppendChild(MacPrefix);
XmlElement SnPrefix = this.xmlDoc.CreateElement("SnPrefix");//创建子节点
SnPrefix.InnerText = orderinfoMode.SnPrefix;
xeKey.AppendChild(SnPrefix);
XmlElement GetMacCmd = this.xmlDoc.CreateElement("GetMacCmd");//创建子节点
GetMacCmd.InnerText = orderinfoMode.GetMacCmd;
xeKey.AppendChild(GetMacCmd);
XmlElement GetBinNa = this.xmlDoc.CreateElement("GetBinNa");//创建子节点
GetBinNa.InnerText = orderinfoMode.GetBinNa;
xeKey.AppendChild(GetBinNa);
XmlElement QtCount = this.xmlDoc.CreateElement("QtCount");//创建子节点
QtCount.InnerText = orderinfoMode.QtCount.ToString();
xeKey.AppendChild(QtCount);
root.AppendChild(xeKey);//挂载父节点
this.xmlDoc.Save(filepath);//保存xml文件
return true;
}
catch (Exception ex)
{
LogHelper<XmlHelpers>.Debug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", ex);
return false;
//throw new Exception(ex.Message);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tie_Yards__Program.Models
{
public class LoginMode
{
/// <summary>
/// 用户名
/// </summary>
public string User { get; set; }
/// <summary>
/// 密码
/// </summary>
public string Pwd { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tie_Yards__Program.Models
{
public class OrderinfoMode
{
public OrderinfoMode() { }
public OrderinfoMode(OrderinfoMode orderinfoMode)
{
this.OrderNumber = orderinfoMode.OrderNumber;
this.QtCount = orderinfoMode.QtCount;
this.SnPrefix = orderinfoMode.SnPrefix;
this.MacPrefix = orderinfoMode.MacPrefix;
this.GetMacCmd = orderinfoMode.GetMacCmd;
this.GetBinNa = orderinfoMode.GetBinNa;
}
/// <summary>
/// 订单号
/// </summary>
public string OrderNumber { get; set; }
/// <summary>
/// Mac前缀
/// </summary>
public string MacPrefix { get; set; }
/// <summary>
/// SN前缀
/// </summary>
public string SnPrefix { get; set; }
/// <summary>
/// 读取Mac的指令
/// </summary>
public string GetMacCmd { get; set; }
/// <summary>
/// 获取的Bin文件名
/// </summary>
public string GetBinNa { get; set; }
/// <summary>
/// 完成的数量
/// </summary>
public int QtCount { get; set; } = 0;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tie_Yards__Program.Models
{
public class TieYards_BarcodeMode
{
/// <summary>
/// SN条码
/// </summary>
public string SN { get; set; }
/// <summary>
/// Mac地址
/// </summary>
public string Mac { get; set; }
}
}