ruoxing.wang 7 days ago
parent
commit
3ff3e3225b
  1. 27
      InjectionPC/FrmLogin.Designer.cs
  2. 140
      InjectionPC/FrmLogin.cs
  3. 1086
      InjectionPC/FrmLogin.resx
  4. 2
      InjectionPC/FrmMain2408.Designer.cs
  5. 222
      InjectionPC/FrmMain2408.cs
  6. 396
      InjectionPC/FrmMain2411.Designer.cs
  7. 127
      InjectionPC/FrmMain2411.cs
  8. 2
      InjectionPC/Program.cs
  9. 61
      InjectionSearch/Form1.Designer.cs
  10. 71
      InjectionSearch/Form1.cs
  11. 1086
      InjectionSearch/Form1.resx
  12. 8
      InjectionSearch/FrmBarCodeSearch2408.Designer.cs
  13. 67
      InjectionSearch/FrmBarCodeSearch2408.cs
  14. 3
      InjectionSearch/FrmBarCodeSearch2408.resx
  15. 4
      InjectionSearch/Program.cs
  16. 2
      MESClassLibrary/BLL/BasicInfo/BarCodeBLL.cs
  17. 16
      MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs
  18. 1
      MESClassLibrary/Model/BarCodeModel.cs

27
InjectionPC/FrmLogin.Designer.cs

@ -36,6 +36,7 @@
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.lbtip = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -66,7 +67,7 @@
// //
this.textBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.textBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox1.Location = new System.Drawing.Point(592, 370); this.textBox1.Location = new System.Drawing.Point(592, 370);
this.textBox1.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.textBox1.Margin = new System.Windows.Forms.Padding(6);
this.textBox1.Name = "textBox1"; this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(314, 51); this.textBox1.Size = new System.Drawing.Size(314, 51);
this.textBox1.TabIndex = 2; this.textBox1.TabIndex = 2;
@ -76,7 +77,7 @@
// //
this.textBox2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.textBox2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox2.Location = new System.Drawing.Point(592, 494); this.textBox2.Location = new System.Drawing.Point(592, 494);
this.textBox2.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.textBox2.Margin = new System.Windows.Forms.Padding(6);
this.textBox2.Name = "textBox2"; this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*'; this.textBox2.PasswordChar = '*';
this.textBox2.Size = new System.Drawing.Size(314, 51); this.textBox2.Size = new System.Drawing.Size(314, 51);
@ -88,7 +89,7 @@
this.button1.BackColor = System.Drawing.Color.LightSkyBlue; this.button1.BackColor = System.Drawing.Color.LightSkyBlue;
this.button1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.button1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.Location = new System.Drawing.Point(462, 612); this.button1.Location = new System.Drawing.Point(462, 612);
this.button1.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.button1.Margin = new System.Windows.Forms.Padding(6);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(168, 76); this.button1.Size = new System.Drawing.Size(168, 76);
this.button1.TabIndex = 4; this.button1.TabIndex = 4;
@ -101,7 +102,7 @@
this.button2.BackColor = System.Drawing.Color.LightSkyBlue; this.button2.BackColor = System.Drawing.Color.LightSkyBlue;
this.button2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.button2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button2.Location = new System.Drawing.Point(774, 612); this.button2.Location = new System.Drawing.Point(774, 612);
this.button2.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.button2.Margin = new System.Windows.Forms.Padding(6);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(166, 76); this.button2.Size = new System.Drawing.Size(166, 76);
this.button2.TabIndex = 5; this.button2.TabIndex = 5;
@ -114,18 +115,31 @@
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(0, 0); this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.pictureBox1.Margin = new System.Windows.Forms.Padding(6);
this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(1406, 906); this.pictureBox1.Size = new System.Drawing.Size(1406, 906);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 6; this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
// //
// lbtip
//
this.lbtip.AutoSize = true;
this.lbtip.BackColor = System.Drawing.Color.White;
this.lbtip.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbtip.ForeColor = System.Drawing.Color.Red;
this.lbtip.Location = new System.Drawing.Point(435, 563);
this.lbtip.Name = "lbtip";
this.lbtip.Size = new System.Drawing.Size(62, 24);
this.lbtip.TabIndex = 8;
this.lbtip.Text = " ";
//
// FrmLogin // FrmLogin
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F); this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1406, 906); this.ClientSize = new System.Drawing.Size(1406, 906);
this.Controls.Add(this.lbtip);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1); this.Controls.Add(this.textBox1);
this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox2);
@ -133,7 +147,7 @@
this.Controls.Add(this.button2); this.Controls.Add(this.button2);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1); this.Controls.Add(this.pictureBox1);
this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.Margin = new System.Windows.Forms.Padding(6);
this.Name = "FrmLogin"; this.Name = "FrmLogin";
this.Text = "登录"; this.Text = "登录";
this.Load += new System.EventHandler(this.FrmLogin_Load); this.Load += new System.EventHandler(this.FrmLogin_Load);
@ -152,5 +166,6 @@
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label lbtip;
} }
} }

140
InjectionPC/FrmLogin.cs

@ -20,27 +20,29 @@ namespace InjectionPC
public partial class FrmLogin : Form public partial class FrmLogin : Form
{ {
private string _defualtPage = string.Empty; private string _defualtPage = string.Empty;
public Action<string, string> LoginAction = null;
public FrmLogin() public FrmLogin()
{ {
InitializeComponent(); InitializeComponent();
this.StartPosition = FormStartPosition.CenterScreen; this.StartPosition = FormStartPosition.CenterScreen;
Program.station = ConfigurationManager.AppSettings["Station"].ToString();
LoginAction = Login;
}
public void RegisterLoginMethod(Action<string, string> outLogin)
{
LoginAction = outLogin;
} }
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
try try
{ {
Program.station = ConfigurationManager.AppSettings["Station"].ToString(); Program.station = ConfigurationManager.AppSettings["Station"].ToString();
//Program.IP = ConfigurationManager.AppSettings["IP"].ToString();
Program.RemoteIP = ConfigurationManager.AppSettings["RemoteIP"].ToString(); Program.RemoteIP = ConfigurationManager.AppSettings["RemoteIP"].ToString();
Program.PicturePath = ConfigurationManager.AppSettings["PicturePath"].ToString(); Program.PicturePath = ConfigurationManager.AppSettings["PicturePath"].ToString();
//Program.WeightFolder = ConfigurationManager.AppSettings["WeightFolder"].ToString();
//Program.WeightFile = ConfigurationManager.AppSettings["WeightFile"].ToString();
//Program.WeightUser = ConfigurationManager.AppSettings["WeightUser"].ToString();
//Program.WeightPsw = ConfigurationManager.AppSettings["WeightPsw"].ToString();
Program.tableName = ConfigurationManager.AppSettings["tableName"].ToString(); Program.tableName = ConfigurationManager.AppSettings["tableName"].ToString();
_defualtPage = ConfigurationManager.AppSettings["DefualtPage"]?.ToString(); _defualtPage = ConfigurationManager.AppSettings["DefualtPage"]?.ToString();
Program.interVal = Convert.ToInt32(ConfigurationManager.AppSettings["InterVal"].ToString()); Program.interVal = Convert.ToInt32(ConfigurationManager.AppSettings["InterVal"].ToString());
@ -60,7 +62,7 @@ namespace InjectionPC
} }
OpenDb(); OpenDb();
string stationID = "";
#region 判断输入合法性 #region 判断输入合法性
if (textBox1.Text.Trim() == "") if (textBox1.Text.Trim() == "")
{ {
@ -77,72 +79,80 @@ namespace InjectionPC
} }
#endregion #endregion
StationBLL sbll = new StationBLL();
DataTable sdt = sbll.SearchInfoByNo(Program.station);
if (sdt != null && sdt.Rows.Count > 0)
{
stationID = sdt.Rows[0]["StationID"].ToString();
}
sdt.Dispose();
Program.OperatorName = textBox1.Text.Trim();
OperatorBLL bll = new OperatorBLL(); LoginAction(textBox1.Text.Trim(), textBox2.Text.Trim());
DataTable dt = bll.SearchInfoByNameAndPsw(textBox1.Text.Trim(), stationID, textBox2.Text.Trim());
if (dt != null && dt.Rows.Count > 0)
{
this.Visible = false;
//Form fr = new FrmMain();
if(_defualtPage?.ToLower() == "frmmain2411")
{
Form fr = new FrmMain2411();
fr.Show();
}
else
{
Form fr = new FrmMain2408();
fr.Show();
}
//Form fr = new FrmMain2411();
//if (ConfigurationManager.AppSettings["Mode"] == "0")
//{
// Form fr = new FrmMain();
// fr.Show();
//}
//else if (ConfigurationManager.AppSettings["Mode"] == "1")
//{
// Form fr = new FrmMain_Injection();
// fr.Show();
//}
//else if (ConfigurationManager.AppSettings["Mode"] == "2")
//{
// Form fr = new FrmTighten();
// fr.Show();
//}
//else if (ConfigurationManager.AppSettings["Mode"] == "3") //注塑质检
//{
// Form fr = new FrmQuality();
// fr.Show();
//}
//else if (ConfigurationManager.AppSettings["Mode"] == "4") //总成
//{
// Form fr = new FrmQuality_new();
// fr.Show();
//}
}
} }
catch (Exception ex) catch (Exception ex)
{ {
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
} }
} }
void Login(string name, string pass)
{
Program.UserName = textBox1.Text.Trim();
string stationID = "";
StationBLL sbll = new StationBLL();
DataTable sdt = sbll.SearchInfoByNo(Program.station);
if (sdt != null && sdt.Rows.Count > 0)
{
stationID = sdt.Rows[0]["StationID"].ToString();
}
sdt.Dispose();
Program.OperatorName = textBox1.Text.Trim();
OperatorBLL bll = new OperatorBLL();
DataTable dt = bll.SearchInfoByNameAndPsw(textBox1.Text.Trim(), stationID, textBox2.Text.Trim());
if (dt != null && dt.Rows.Count > 0)
{
this.Visible = false;
//Form fr = new FrmMain();
if (_defualtPage?.ToLower() == "frmmain2411")
{
Form fr = new FrmMain2411();
fr.Show();
}
else
{
Form fr = new FrmMain2408();
fr.Show();
}
//Form fr = new FrmMain2411();
//if (ConfigurationManager.AppSettings["Mode"] == "0")
//{
// Form fr = new FrmMain();
// fr.Show();
//}
//else if (ConfigurationManager.AppSettings["Mode"] == "1")
//{
// Form fr = new FrmMain_Injection();
// fr.Show();
//}
//else if (ConfigurationManager.AppSettings["Mode"] == "2")
//{
// Form fr = new FrmTighten();
// fr.Show();
//}
//else if (ConfigurationManager.AppSettings["Mode"] == "3") //注塑质检
//{
// Form fr = new FrmQuality();
// fr.Show();
//}
//else if (ConfigurationManager.AppSettings["Mode"] == "4") //总成
//{
// Form fr = new FrmQuality_new();
// fr.Show();
//}
}
}
private bool OpenDb() private bool OpenDb()
{ {
bool OpenDb = false; bool OpenDb = false;

1086
InjectionPC/FrmLogin.resx

File diff suppressed because it is too large

2
InjectionPC/FrmMain2408.Designer.cs

@ -837,7 +837,7 @@
this.glacialList1.HoverEvents = false; this.glacialList1.HoverEvents = false;
this.glacialList1.HoverTime = 1; this.glacialList1.HoverTime = 1;
this.glacialList1.ImageList = null; this.glacialList1.ImageList = null;
this.glacialList1.ItemHeight = 50; this.glacialList1.ItemHeight = 57;
this.glacialList1.ItemWordWrap = false; this.glacialList1.ItemWordWrap = false;
this.glacialList1.Location = new System.Drawing.Point(0, 0); this.glacialList1.Location = new System.Drawing.Point(0, 0);
this.glacialList1.Margin = new System.Windows.Forms.Padding(6, 3, 6, 3); this.glacialList1.Margin = new System.Windows.Forms.Padding(6, 3, 6, 3);

222
InjectionPC/FrmMain2408.cs

@ -76,6 +76,8 @@ namespace InjectionPC
private ProductBLL productBll = new ProductBLL(); private ProductBLL productBll = new ProductBLL();
//允许修改箱码标包的已打码最小数量 //允许修改箱码标包的已打码最小数量
private int _allowChangeBoxSizeMaxPrint = 8; private int _allowChangeBoxSizeMaxPrint = 8;
private string _currentUserName = string.Empty;
private FrmLogin _login = new FrmLogin();
#endregion #endregion
public FrmMain2408() public FrmMain2408()
@ -137,7 +139,7 @@ namespace InjectionPC
} }
} }
} }
_currentUserName = Program.UserName;
initBarCode(); initBarCode();
label23.Enabled = false; label23.Enabled = false;
@ -989,7 +991,7 @@ namespace InjectionPC
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new Exception("p988" + ex.Message); throw new Exception("p989" + ex.Message);
} }
} }
@ -1868,7 +1870,14 @@ namespace InjectionPC
string IsPack = "", IsOne = "", QLevel = "", IsPaint = "", PartName = "", printBoxName="",IsSupply="",ManufacturerName=""; string IsPack = "", IsOne = "", QLevel = "", IsPaint = "", PartName = "", printBoxName="",IsSupply="",ManufacturerName="";
string filename = "", printName = ""; string filename = "", printName = "";
int MaxCount = 0, CurrentCount = 0; int MaxCount = 0, CurrentCount = 0;
if(comBoxSizeL.SelectedValue == null)
{
MessageBox.Show("请选择规格型号.");
return;
}
CheckPackageSelect(); CheckPackageSelect();
ProductBLL pbll = new ProductBLL(); ProductBLL pbll = new ProductBLL();
BarCodeBLL bll = new BarCodeBLL(); BarCodeBLL bll = new BarCodeBLL();
BarCodeModel md = new BarCodeModel(); BarCodeModel md = new BarCodeModel();
@ -2336,6 +2345,7 @@ namespace InjectionPC
ManufacturerName = pdt.Rows[0]["ManufacturerName"].ToString().Trim(); ManufacturerName = pdt.Rows[0]["ManufacturerName"].ToString().Trim();
IsSupply = pdt.Rows[0]["IsSupply"].ToString(); IsSupply = pdt.Rows[0]["IsSupply"].ToString();
} }
md.AddMan = _currentUserName;
//向箱码手动添加条码 //向箱码手动添加条码
string msg = bll.ReprintSave(md, Program.tableName, "", "", Program.station, "2"); string msg = bll.ReprintSave(md, Program.tableName, "", "", Program.station, "2");
if (!string.IsNullOrEmpty(msg)) if (!string.IsNullOrEmpty(msg))
@ -2468,7 +2478,7 @@ namespace InjectionPC
IsSupply = pdt.Rows[0]["IsSupply"].ToString(); IsSupply = pdt.Rows[0]["IsSupply"].ToString();
} }
md.AddMan = _currentUserName;
//补打条码 //补打条码
string msg = bll.ReprintSave(md, Program.tableName, dt.Rows[0]["OneBarCode"].ToString(), dt.Rows[0]["BarCode"].ToString(), Program.station,"3"); string msg = bll.ReprintSave(md, Program.tableName, dt.Rows[0]["OneBarCode"].ToString(), dt.Rows[0]["BarCode"].ToString(), Program.station,"3");
if (!string.IsNullOrEmpty(msg)) if (!string.IsNullOrEmpty(msg))
@ -2891,7 +2901,7 @@ namespace InjectionPC
panel45.Visible = false; panel45.Visible = false;
textBox4.Text = ""; textBox4.Text = "";
} }
/// <summary> /// <summary>
/// 暂停打印 /// 暂停打印
/// </summary> /// </summary>
@ -2901,38 +2911,40 @@ namespace InjectionPC
{ {
try try
{ {
if (label13.Text == "暂停打印") if (label13.Text == "暂停打印")
{ {
_login = new FrmLogin();
DialogResult result = MessageBox.Show("确认暂停打印?", "提示", MessageBoxButtons.OKCancel, _login.RegisterLoginMethod(Login);
MessageBoxIcon.Information); _login.ShowDialog();
if (result == DialogResult.OK)
{ //DialogResult result = MessageBox.Show("确认暂停打印?", "提示", MessageBoxButtons.OKCancel,
if (UnCompletePrintBox("切换手动打印","all") == false) return; // MessageBoxIcon.Information);
opcGroup1.DataChange -= new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange); //if (result == DialogResult.OK)
cboxHandBox.Enabled = true; //{
opcServer.OPCGroups.RemoveAll(); // if (UnCompletePrintBox("切换手动打印","all") == false) return;
opcServer.Disconnect(); // opcGroup1.DataChange -= new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange);
//serialPort1.Close(); // cboxHandBox.Enabled = true;
comboBox2.Enabled = true; // opcServer.OPCGroups.RemoveAll();
label23.Enabled = true; // opcServer.Disconnect();
label23.BackColor = System.Drawing.Color.DeepSkyBlue; // //serialPort1.Close();
//if (ConfigurationManager.AppSettings["StationMode"].ToString() == "1") // comboBox2.Enabled = true;
//{ // label23.Enabled = true;
// timer1.Enabled = false; // label23.BackColor = System.Drawing.Color.DeepSkyBlue;
//} // //if (ConfigurationManager.AppSettings["StationMode"].ToString() == "1")
//if (ConfigurationManager.AppSettings["StationMode"].ToString() == "2") // //{
//{ // // timer1.Enabled = false;
// serialPort1.Close(); // //}
//} // //if (ConfigurationManager.AppSettings["StationMode"].ToString() == "2")
label13.Text = "开始打印"; // //{
label13.BackColor = System.Drawing.Color.Gray; // // serialPort1.Close();
} // //}
else // label13.Text = "开始打印";
{ // label13.BackColor = System.Drawing.Color.Gray;
return; //}
} //else
//{
// return;
//}
} }
else else
@ -2945,6 +2957,7 @@ namespace InjectionPC
cboxHandBox.Enabled = false; cboxHandBox.Enabled = false;
comboBox2.Enabled = false; comboBox2.Enabled = false;
_currentUserName = Program.UserName;
#region 连接PLC #region 连接PLC
try try
{ {
@ -3036,6 +3049,70 @@ namespace InjectionPC
} }
} }
private void Login(string name, string pass)
{
string stationID = "";
StationBLL sbll = new StationBLL();
DataTable sdt = sbll.SearchInfoByNo(Program.station);
if (sdt != null && sdt.Rows.Count > 0)
{
stationID = sdt.Rows[0]["StationID"].ToString();
}
sdt.Dispose();
if (string.IsNullOrEmpty(stationID))
{
MessageBox.Show("配置工位" + Program.station + "在系统中不存在.");
return;
}
OperatorBLL bll = new OperatorBLL();
DataTable dt = bll.SearchInfoByNameAndPsw(name, stationID, pass);
if (dt != null && dt.Rows.Count > 0)
{
string lmt = dt.Rows[0]["Limit"].ToString();
if (lmt == "allowhandprint")
{
DialogResult result = MessageBox.Show("确认暂停打印?", "提示", MessageBoxButtons.OKCancel,
MessageBoxIcon.Information);
if (result == DialogResult.OK)
{
if (UnCompletePrintBox("切换手动打印", "all") == false) return;
opcGroup1.DataChange -= new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange);
cboxHandBox.Enabled = true;
opcServer.OPCGroups.RemoveAll();
opcServer.Disconnect();
//serialPort1.Close();
comboBox2.Enabled = true;
label23.Enabled = true;
label23.BackColor = System.Drawing.Color.DeepSkyBlue;
label13.Text = "开始打印";
label13.BackColor = System.Drawing.Color.Gray;
_currentUserName = name;
}
else
{
return;
}
_login.Close();
}
else
{
MessageBox.Show("登录用户手动打码权限");
}
}
else
{
//f7ce2efa-13ac-4daa-8c7e-8f6287889411
//lbtip.Text = "用户名或者密码错误"
MessageBox.Show("用户名或者密码错误");
}
}
/// <summary> /// <summary>
/// 质量录入 /// 质量录入
/// </summary> /// </summary>
@ -3297,6 +3374,7 @@ namespace InjectionPC
} }
bool saveRst = true; bool saveRst = true;
bcm.AddMan = _currentUserName;
//自动模式 或者手动模式选中绑定箱码 //自动模式 或者手动模式选中绑定箱码
if (isAutoPrint == true || (isAutoPrint==false && cboxHandBox.Checked ==true)) if (isAutoPrint == true || (isAutoPrint==false && cboxHandBox.Checked ==true))
{ {
@ -3612,6 +3690,10 @@ namespace InjectionPC
{ {
lbPackageCode.Text = packageCode; lbPackageCode.Text = packageCode;
} }
else
{
}
} }
else else
{ {
@ -3712,11 +3794,6 @@ namespace InjectionPC
} }
//会死循环
//CheckPackageCode(partCode, autoPrint, mould, partName, isHandPrint);
} }
} }
@ -3750,10 +3827,10 @@ namespace InjectionPC
string batch = GetBatch(autoPrint); string batch = GetBatch(autoPrint);
GetBarCode(stockNo, batch, partNo, ref newOneCode, ref newCode); GetBarCode(stockNo, batch, partNo, ref newOneCode, ref newCode);
if (!string.IsNullOrEmpty(printTest)) //if (!string.IsNullOrEmpty(printTest))
{ //{
SaveLog3("BarCodePrint:"+ Program.station + ":" + printTest + "_" + newOneCode); // SaveLog3("BarCodePrint:"+ Program.station + ":" + printTest + "_" + newOneCode);
} //}
// newOneCode = _uniqueBll.GetSjBarCodeSerialNo(stockNo, batch); // newOneCode = _uniqueBll.GetSjBarCodeSerialNo(stockNo, batch);
//newCode = partNo + "." + batch + "." + newOneCode.Substring(newOneCode.Length - 4, 4); //newCode = partNo + "." + batch + "." + newOneCode.Substring(newOneCode.Length - 4, 4);
} }
@ -3765,38 +3842,45 @@ namespace InjectionPC
string GetPackageCode(string partNo,bool autoPrint, string mould) string GetPackageCode(string partNo,bool autoPrint, string mould)
{ {
string batch = GetBatch(autoPrint); try
Label lbNeedQty = lbNeedQtyL;
if(mould == "1")
{
lbNeedQty = lbNeedQtyR;
//packageSize = lbNeedQtyR.Text.Trim();
}
string packageSize = lbNeedQty.Text.Trim();
int p = 0;
int.TryParse(packageSize, out p);
if (string.IsNullOrEmpty(packageSize) || p == 0)
{ {
//packageSize = "1"; string batch = GetBatch(autoPrint);
DataTable dt3 = productBll.SearchInfoByPartNo(partNo); Label lbNeedQty = lbNeedQtyL;
if(dt3.Rows.Count>0)
if (mould == "1")
{
lbNeedQty = lbNeedQtyR;
//packageSize = lbNeedQtyR.Text.Trim();
}
string packageSize = lbNeedQty.Text.Trim();
int p = 0;
int.TryParse(packageSize, out p);
if (string.IsNullOrEmpty(packageSize) || p == 0)
{
//packageSize = "1";
DataTable dt3 = productBll.SearchInfoByPartNo(partNo);
if (dt3.Rows.Count > 0)
{
packageSize = dt3.Rows[0]["PackCount"].ToString();
lbNeedQty.Text = packageSize;
}
}
int.TryParse(packageSize, out p);
if (string.IsNullOrEmpty(packageSize) || p == 0)
{ {
packageSize = dt3.Rows[0]["PackCount"].ToString(); packageSize = (_allowChangeBoxSizeMaxPrint + 2).ToString();
lbNeedQty.Text = packageSize; lbNeedQty.Text = packageSize;
} }
string packageCode = _uniqueBll.GetPackageCodeSerialNo(partNo, batch, packageSize);
return packageCode;
} }
int.TryParse(packageSize, out p); catch (Exception ex)
if (string.IsNullOrEmpty(packageSize) || p == 0)
{ {
packageSize = (_allowChangeBoxSizeMaxPrint + 2).ToString() ; throw new Exception("获取箱码发生异常.-GetPackageCode:partNo:autoPrint:mould" + ex.Message);
lbNeedQty.Text = packageSize;
} }
string packageCode = _uniqueBll.GetPackageCodeSerialNo(partNo, batch, packageSize);
return packageCode;
} }
string GetBatch(bool isAutoPrint) string GetBatch(bool isAutoPrint)
{ {
@ -3993,6 +4077,10 @@ namespace InjectionPC
if(i == 0) if(i == 0)
{ {
List<string> list = comBoxSizeL.DataSource as List<string>; List<string> list = comBoxSizeL.DataSource as List<string>;
if(list == null)
{
throw new Exception("左侧规格标包列表数据源为空(CheckPackageSelect).");
}
if (list.Count > 0) if (list.Count > 0)
{ {
lbNeedQtyL.Text = list[0]; lbNeedQtyL.Text = list[0];

396
InjectionPC/FrmMain2411.Designer.cs

File diff suppressed because it is too large

127
InjectionPC/FrmMain2411.cs

@ -70,6 +70,9 @@ namespace InjectionPC
private Dictionary<string, string> _printNameDict = new Dictionary<string, string>(); private Dictionary<string, string> _printNameDict = new Dictionary<string, string>();
private PlasticBLL _plasticBLL = new PlasticBLL(); private PlasticBLL _plasticBLL = new PlasticBLL();
private int _plcRate = 100; //500 private int _plcRate = 100; //500
private string _currentUserName = string.Empty;
private FrmLogin _login = new FrmLogin();
#endregion #endregion
public FrmMain2411() public FrmMain2411()
@ -120,6 +123,8 @@ namespace InjectionPC
label23.Enabled = false; label23.Enabled = false;
label23.BackColor = System.Drawing.Color.Gray; label23.BackColor = System.Drawing.Color.Gray;
_currentUserName = Program.UserName;
DataTable plasticTable = GetPlastic(); DataTable plasticTable = GetPlastic();
foreach(DataRow dr in plasticTable.Rows) foreach(DataRow dr in plasticTable.Rows)
{ {
@ -2186,6 +2191,7 @@ namespace InjectionPC
MessageBox.Show($"补打失败,条码[{code}]在表[{ Program.tableName}]中不存在!"); MessageBox.Show($"补打失败,条码[{code}]在表[{ Program.tableName}]中不存在!");
return; return;
} }
md.AddMan = _currentUserName;
//补打条码 //补打条码
string msg = bll.ReprintSave(md, Program.tableName, dt.Rows[0]["OneBarCode"].ToString(), dt.Rows[0]["BarCode"].ToString(),Program.station,"3"); string msg = bll.ReprintSave(md, Program.tableName, dt.Rows[0]["OneBarCode"].ToString(), dt.Rows[0]["BarCode"].ToString(),Program.station,"3");
if (!string.IsNullOrEmpty(msg)) if (!string.IsNullOrEmpty(msg))
@ -2654,33 +2660,38 @@ namespace InjectionPC
if (label13.Text == "暂停打印") if (label13.Text == "暂停打印")
{ {
DialogResult result = MessageBox.Show("确认暂停打印?", "提示", MessageBoxButtons.OKCancel, _login = new FrmLogin();
MessageBoxIcon.Information); _login.RegisterLoginMethod(Login);
if (result == DialogResult.OK) _login.ShowDialog();
{
opcGroup1.DataChange -= new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange);
opcServer.OPCGroups.RemoveAll(); //DialogResult result = MessageBox.Show("确认暂停打印?", "提示", MessageBoxButtons.OKCancel,
opcServer.Disconnect(); // MessageBoxIcon.Information);
serialPort1.Close(); //if (result == DialogResult.OK)
//{
// opcGroup1.DataChange -= new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange);
// opcServer.OPCGroups.RemoveAll();
// opcServer.Disconnect();
// serialPort1.Close();
label23.Enabled = true; // label23.Enabled = true;
label23.BackColor = System.Drawing.Color.DeepSkyBlue; // label23.BackColor = System.Drawing.Color.DeepSkyBlue;
//if (ConfigurationManager.AppSettings["StationMode"].ToString() == "1") // //if (ConfigurationManager.AppSettings["StationMode"].ToString() == "1")
//{ // //{
// timer1.Enabled = false; // // timer1.Enabled = false;
//} // //}
//if (ConfigurationManager.AppSettings["StationMode"].ToString() == "2") // //if (ConfigurationManager.AppSettings["StationMode"].ToString() == "2")
//{ // //{
// serialPort1.Close(); // // serialPort1.Close();
//} // //}
label13.Text = "开始打印"; // label13.Text = "开始打印";
label13.BackColor = System.Drawing.Color.Gray; // label13.BackColor = System.Drawing.Color.Gray;
} //}
else //else
{ //{
return; // return;
} //}
} }
else else
@ -2689,7 +2700,7 @@ namespace InjectionPC
DialogResult result = MessageBox.Show("确认开始打印?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); DialogResult result = MessageBox.Show("确认开始打印?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
_currentUserName = Program.UserName;
#region 连接PLC #region 连接PLC
try try
{ {
@ -2797,7 +2808,67 @@ namespace InjectionPC
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
} }
} }
private void Login(string name, string pass)
{
string stationID = "";
StationBLL sbll = new StationBLL();
DataTable sdt = sbll.SearchInfoByNo(Program.station);
if (sdt != null && sdt.Rows.Count > 0)
{
stationID = sdt.Rows[0]["StationID"].ToString();
}
sdt.Dispose();
if (string.IsNullOrEmpty(stationID))
{
MessageBox.Show("配置工位" + Program.station + "在系统中不存在.");
return;
}
OperatorBLL bll = new OperatorBLL();
DataTable dt = bll.SearchInfoByNameAndPsw(name, stationID, pass);
if (dt != null && dt.Rows.Count > 0)
{
string lmt = dt.Rows[0]["Limit"].ToString();
if (lmt == "allowhandprint")
{
DialogResult result = MessageBox.Show("确认暂停打印?", "提示", MessageBoxButtons.OKCancel,
MessageBoxIcon.Information);
if (result == DialogResult.OK)
{
opcGroup1.DataChange -= new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange);
opcServer.OPCGroups.RemoveAll();
opcServer.Disconnect();
serialPort1.Close();
label23.Enabled = true;
label23.BackColor = System.Drawing.Color.DeepSkyBlue;
label13.Text = "开始打印";
label13.BackColor = System.Drawing.Color.Gray;
_currentUserName = name;
}
else
{
return;
}
_login.Close();
}
else
{
MessageBox.Show("登录用户手动打码权限");
}
}
else
{
//f7ce2efa-13ac-4daa-8c7e-8f6287889411
//lbtip.Text = "用户名或者密码错误"
MessageBox.Show("用户名或者密码错误");
}
}
/// <summary> /// <summary>
/// 质量录入 /// 质量录入
/// </summary> /// </summary>
@ -3311,7 +3382,7 @@ namespace InjectionPC
bool SaveBarCode(BarCodeModel bcm,string tableName, bool isAutoPrint,string mould, ref string errorMsg ,bool handPrint = false ) bool SaveBarCode(BarCodeModel bcm,string tableName, bool isAutoPrint,string mould, ref string errorMsg ,bool handPrint = false )
{ {
bcm.AddMan = _currentUserName;
string rst = _wmsBll.SaveRecordAndInterface(bcm, Program.tableName,"",Program.station,"4"); string rst = _wmsBll.SaveRecordAndInterface(bcm, Program.tableName,"",Program.station,"4");
if (string.IsNullOrEmpty(rst)) if (string.IsNullOrEmpty(rst))
{ {

2
InjectionPC/Program.cs

@ -32,7 +32,7 @@ namespace InjectionPC
public static string tableName; public static string tableName;
public static string strBarCode; public static string strBarCode;
public static string strBoxCode; public static string strBoxCode;
public static string UserName;
public static int interVal; public static int interVal;
[STAThread] [STAThread]

61
InjectionSearch/Form1.Designer.cs

@ -36,6 +36,7 @@
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.lbtip = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -43,9 +44,9 @@
// //
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(2, 0); this.pictureBox1.Location = new System.Drawing.Point(2, 0);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.pictureBox1.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6);
this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(1291, 798); this.pictureBox1.Size = new System.Drawing.Size(1408, 912);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0; this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
@ -55,30 +56,30 @@
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(411, 410); this.label2.Location = new System.Drawing.Point(448, 469);
this.label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); this.label2.Margin = new System.Windows.Forms.Padding(7, 0, 7, 0);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(83, 34); this.label2.Size = new System.Drawing.Size(93, 38);
this.label2.TabIndex = 7; this.label2.TabIndex = 7;
this.label2.Text = "密码"; this.label2.Text = "密码";
// //
// textBox1 // textBox1
// //
this.textBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.textBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox1.Location = new System.Drawing.Point(557, 301); this.textBox1.Location = new System.Drawing.Point(608, 344);
this.textBox1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.textBox1.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6);
this.textBox1.Name = "textBox1"; this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(288, 45); this.textBox1.Size = new System.Drawing.Size(314, 51);
this.textBox1.TabIndex = 8; this.textBox1.TabIndex = 8;
// //
// textBox2 // textBox2
// //
this.textBox2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.textBox2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox2.Location = new System.Drawing.Point(557, 410); this.textBox2.Location = new System.Drawing.Point(608, 469);
this.textBox2.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.textBox2.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6);
this.textBox2.Name = "textBox2"; this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*'; this.textBox2.PasswordChar = '*';
this.textBox2.Size = new System.Drawing.Size(288, 45); this.textBox2.Size = new System.Drawing.Size(314, 51);
this.textBox2.TabIndex = 9; this.textBox2.TabIndex = 9;
this.textBox2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox2_KeyDown); this.textBox2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox2_KeyDown);
// //
@ -86,10 +87,10 @@
// //
this.button1.BackColor = System.Drawing.Color.LightSkyBlue; this.button1.BackColor = System.Drawing.Color.LightSkyBlue;
this.button1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.button1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.Location = new System.Drawing.Point(438, 513); this.button1.Location = new System.Drawing.Point(478, 586);
this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.button1.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(154, 66); this.button1.Size = new System.Drawing.Size(168, 75);
this.button1.TabIndex = 10; this.button1.TabIndex = 10;
this.button1.Text = "登录"; this.button1.Text = "登录";
this.button1.UseVisualStyleBackColor = false; this.button1.UseVisualStyleBackColor = false;
@ -99,10 +100,10 @@
// //
this.button2.BackColor = System.Drawing.Color.LightSkyBlue; this.button2.BackColor = System.Drawing.Color.LightSkyBlue;
this.button2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.button2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button2.Location = new System.Drawing.Point(724, 513); this.button2.Location = new System.Drawing.Point(790, 586);
this.button2.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.button2.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(152, 66); this.button2.Size = new System.Drawing.Size(166, 75);
this.button2.TabIndex = 11; this.button2.TabIndex = 11;
this.button2.Text = "取消"; this.button2.Text = "取消";
this.button2.UseVisualStyleBackColor = false; this.button2.UseVisualStyleBackColor = false;
@ -111,18 +112,31 @@
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(411, 317); this.label1.Location = new System.Drawing.Point(448, 362);
this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); this.label1.Margin = new System.Windows.Forms.Padding(7, 0, 7, 0);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(117, 34); this.label1.Size = new System.Drawing.Size(131, 38);
this.label1.TabIndex = 6; this.label1.TabIndex = 6;
this.label1.Text = "用户名"; this.label1.Text = "用户名";
// //
// lbtip
//
this.lbtip.AutoSize = true;
this.lbtip.BackColor = System.Drawing.Color.White;
this.lbtip.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbtip.ForeColor = System.Drawing.Color.Red;
this.lbtip.Location = new System.Drawing.Point(451, 543);
this.lbtip.Name = "lbtip";
this.lbtip.Size = new System.Drawing.Size(62, 24);
this.lbtip.TabIndex = 12;
this.lbtip.Text = " ";
//
// FrmLogin // FrmLogin
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 21F); this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1289, 793); this.ClientSize = new System.Drawing.Size(1406, 906);
this.Controls.Add(this.lbtip);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1); this.Controls.Add(this.textBox1);
this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox2);
@ -130,7 +144,7 @@
this.Controls.Add(this.button2); this.Controls.Add(this.button2);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1); this.Controls.Add(this.pictureBox1);
this.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5); this.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6);
this.Name = "FrmLogin"; this.Name = "FrmLogin";
this.Text = "登录"; this.Text = "登录";
this.Load += new System.EventHandler(this.FrmLogin_Load); this.Load += new System.EventHandler(this.FrmLogin_Load);
@ -149,6 +163,7 @@
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lbtip;
} }
} }

71
InjectionSearch/Form1.cs

@ -15,10 +15,13 @@ namespace InjectionSearch
{ {
public partial class FrmLogin : Form public partial class FrmLogin : Form
{ {
public Action<string, string> LoginAction = null;
public FrmLogin() public FrmLogin()
{ {
InitializeComponent(); InitializeComponent();
StartPosition = FormStartPosition.CenterScreen; StartPosition = FormStartPosition.CenterScreen;
Program.station = ConfigurationManager.AppSettings["Station"].ToString();
LoginAction = Login;
} }
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
@ -31,6 +34,7 @@ namespace InjectionSearch
string stationID = ""; string stationID = "";
Program.station = ConfigurationManager.AppSettings["Station"].ToString(); Program.station = ConfigurationManager.AppSettings["Station"].ToString();
Program.StationID = ConfigurationManager.AppSettings["StationID"].ToString(); Program.StationID = ConfigurationManager.AppSettings["StationID"].ToString();
Program.tableName = ConfigurationManager.AppSettings["tableName"].ToString();
OpenDb(); OpenDb();
#region 判断输入合法性 #region 判断输入合法性
@ -50,7 +54,42 @@ namespace InjectionSearch
} }
#endregion #endregion
LoginAction(textBox1.Text.Trim(), textBox2.Text.Trim());
//StationBLL sbll = new StationBLL();
//DataTable sdt = sbll.SearchInfoByNo(Program.station);
//if (sdt != null && sdt.Rows.Count > 0)
//{
// stationID = sdt.Rows[0]["StationID"].ToString();
//}
//sdt.Dispose();
//Program.OperatorName = textBox1.Text.Trim();
//OperatorBLL bll = new OperatorBLL();
//DataTable dt = bll.SearchInfoByNameAndPsw(textBox1.Text.Trim(), stationID, textBox2.Text.Trim());
//if (dt != null && dt.Rows.Count > 0)
//{
// if (ConfigurationManager.AppSettings["PageType"]?.ToString() == "RePrintBarCode")
// {
// Form fr = new FrmBarCodeSearch2502();
// fr.Show();
// }
// else
// {
// Form fr = new FrmBarCodeSearch2408();
// fr.Show();
// }
// this.Hide();
//}
}
void Login(string name, string pass)
{
string stationID = "";
StationBLL sbll = new StationBLL(); StationBLL sbll = new StationBLL();
DataTable sdt = sbll.SearchInfoByNo(Program.station); DataTable sdt = sbll.SearchInfoByNo(Program.station);
if (sdt != null && sdt.Rows.Count > 0) if (sdt != null && sdt.Rows.Count > 0)
@ -67,6 +106,7 @@ namespace InjectionSearch
DataTable dt = bll.SearchInfoByNameAndPsw(textBox1.Text.Trim(), stationID, textBox2.Text.Trim()); DataTable dt = bll.SearchInfoByNameAndPsw(textBox1.Text.Trim(), stationID, textBox2.Text.Trim());
if (dt != null && dt.Rows.Count > 0) if (dt != null && dt.Rows.Count > 0)
{ {
Program.UserName = textBox1.Text.Trim();
if (ConfigurationManager.AppSettings["PageType"]?.ToString() == "RePrintBarCode") if (ConfigurationManager.AppSettings["PageType"]?.ToString() == "RePrintBarCode")
{ {
Form fr = new FrmBarCodeSearch2502(); Form fr = new FrmBarCodeSearch2502();
@ -74,16 +114,31 @@ namespace InjectionSearch
} }
else else
{ {
Form fr = new FrmBarCodeSearch2408(); Form fr = new FrmBarCodeSearch2408();
//fr.FormClosed += (arg1, ar2) => {
// Action act = ReOpen;
// act.BeginInvoke(null, null);
//};
fr.Show(); fr.Show();
} }
this.Hide(); this.Hide();
} }
else else
{ {
//f7ce2efa-13ac-4daa-8c7e-8f6287889411
lbtip.Text = "用户名或者密码错误";
} }
}
}
void ReOpen()
{
FrmLogin frm = new FrmLogin();
frm.Show();
//System.Diagnostics.Process.Start("InjectionSearch.exe");
}
private bool OpenDb() private bool OpenDb()
{ {
bool OpenDb = false; bool OpenDb = false;
@ -118,13 +173,13 @@ namespace InjectionSearch
private void FrmLogin_Load(object sender, EventArgs e) private void FrmLogin_Load(object sender, EventArgs e)
{ {
var serverUrl = "http://10.60.101.59:8013/"; //var serverUrl = "http://10.60.101.59:8013/";
var updateXmlFileName = "InjectionSearchUpdate.xml"; //var updateXmlFileName = "InjectionSearchUpdate.xml";
var updater = new AutoUpdater(); //var updater = new AutoUpdater();
if (updater.CheckUpdateLoad(serverUrl, updateXmlFileName)) //if (updater.CheckUpdateLoad(serverUrl, updateXmlFileName))
{ //{
Environment.Exit(0); // Environment.Exit(0);
} //}
} }
} }
} }

1086
InjectionSearch/Form1.resx

File diff suppressed because it is too large

8
InjectionSearch/FrmBarCodeSearch2408.Designer.cs

@ -72,6 +72,7 @@
this.txtRePrintBoxCode = new System.Windows.Forms.TextBox(); this.txtRePrintBoxCode = new System.Windows.Forms.TextBox();
this.label24 = new System.Windows.Forms.Label(); this.label24 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.panel3.SuspendLayout(); this.panel3.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
@ -621,6 +622,12 @@
this.timer1.Interval = 5000; this.timer1.Interval = 5000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick); this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
// //
// timer2
//
this.timer2.Enabled = true;
this.timer2.Interval = 1000;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// FrmBarCodeSearch2408 // FrmBarCodeSearch2408
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F); this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
@ -694,5 +701,6 @@
private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button btnChangeSizeR; private System.Windows.Forms.Button btnChangeSizeR;
private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Timer timer2;
} }
} }

67
InjectionSearch/FrmBarCodeSearch2408.cs

@ -34,12 +34,20 @@ namespace InjectionSearch
private string _lastBoxNo = string.Empty; private string _lastBoxNo = string.Empty;
private BarCodeBLL _barCodeBLL = new BarCodeBLL(); private BarCodeBLL _barCodeBLL = new BarCodeBLL();
private BarCodeModel _lastFailedModel = null; private BarCodeModel _lastFailedModel = null;
private int _outPageSeconds = 1800;
private bool _isAutoClosed = false;
public FrmBarCodeSearch2408() public FrmBarCodeSearch2408()
{ {
InitializeComponent(); InitializeComponent();
this.Size = new Size(1280, 1024); this.Size = new Size(1280, 1024);
string s = ConfigurationManager.AppSettings["OutPageLen"]?.ToString();
if(int.TryParse(s,out _outPageSeconds) == false)
{
_outPageSeconds = 1800;
}
} }
private void initProduct() private void initProduct()
@ -149,6 +157,25 @@ namespace InjectionSearch
//comBoxSizeL.DataSource = _basicBLL1.GetPackageSize(); //comBoxSizeL.DataSource = _basicBLL1.GetPackageSize();
//comBoxSizeL.DisplayMember = "describe"; //comBoxSizeL.DisplayMember = "describe";
//comBoxSizeL.ValueMember = "Count"; //comBoxSizeL.ValueMember = "Count";
this.FormClosed += FrmBarCodeSearch2408_FormClosed;
}
private void FrmBarCodeSearch2408_FormClosed(object sender, FormClosedEventArgs e)
{
//if (_isAutoClosed)
//{
// FrmLogin frm = new FrmLogin();
// frm.Show();
// //_isAutoClosed = false;
// //this.FormClosed -= FrmBarCodeSearch2408_FormClosed;
// //FrmLogin frm = new FrmLogin();
// //DialogResult dr = frm.ShowDialog();
//}
} }
private void GetClass() private void GetClass()
@ -231,7 +258,7 @@ namespace InjectionSearch
try try
{ {
timer2.Enabled = false;
#region 数据合法性判断 #region 数据合法性判断
if (comboBox2.Text.Trim() == "") if (comboBox2.Text.Trim() == "")
@ -415,7 +442,7 @@ namespace InjectionSearch
//{ //{
// return; // return;
//} //}
if(SaveBarCode(md, "tb_BarCode5", i== Convert.ToInt32(textBox4.Text.Trim())) == false) if(SaveBarCode(md, Program.tableName, i== Convert.ToInt32(textBox4.Text.Trim())) == false)
{ {
LogErrBLL.AddInfo("手动批量打印条码" + md.OneBarCode + "报错", MethodBase.GetCurrentMethod()); LogErrBLL.AddInfo("手动批量打印条码" + md.OneBarCode + "报错", MethodBase.GetCurrentMethod());
//return; //return;
@ -555,7 +582,7 @@ namespace InjectionSearch
//{ //{
// return; // return;
//} //}
if (SaveBarCode(md, "tb_BarCode5", i == Convert.ToInt32(textBox4.Text.Trim())) == false) if (SaveBarCode(md, Program.tableName, i == Convert.ToInt32(textBox4.Text.Trim())) == false)
{ {
LogErrBLL.AddInfo("手动批量打印条码" + md.OneBarCode + "报错", MethodBase.GetCurrentMethod()); LogErrBLL.AddInfo("手动批量打印条码" + md.OneBarCode + "报错", MethodBase.GetCurrentMethod());
//return; //return;
@ -611,6 +638,11 @@ namespace InjectionSearch
MessageBox.Show(ex.Message); MessageBox.Show(ex.Message);
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
} }
finally
{
_stopSeconds = 0;
timer2.Enabled = true;
}
} }
string SaveBoxInfo(DataTable pdt, string partNo, string batch,string packageSize) string SaveBoxInfo(DataTable pdt, string partNo, string batch,string packageSize)
@ -658,7 +690,8 @@ namespace InjectionSearch
{ {
try try
{ {
saveRst = _bll.Add_Info_New(bcm, "tb_BarCode5", "5"); bcm.AddMan = Program.UserName;
saveRst = _bll.Add_Info_New(bcm, tableName, "5");
if (saveRst == false) if (saveRst == false)
{ {
_lastFailedModel = bcm; _lastFailedModel = bcm;
@ -685,7 +718,8 @@ namespace InjectionSearch
try try
{ {
local.BeginTrans(); local.BeginTrans();
_bll.Add_Info_New(local, bcm, "tb_BarCode5", "5"); bcm.AddMan = Program.UserName;
_bll.Add_Info_New(local, bcm, tableName, "5");
if (_injectionBoxBLL.UpdateBoxCount(local, bcm.BoxNo, 1)) if (_injectionBoxBLL.UpdateBoxCount(local, bcm.BoxNo, 1))
{ {
@ -737,7 +771,8 @@ namespace InjectionSearch
{ {
try try
{ {
bool rst = _bll.Add_Info_New(bcm, "tb_BarCode5", "5"); bcm.AddMan = Program.UserName;
bool rst = _bll.Add_Info_New(bcm, Program.tableName, "5");
if (rst == false) if (rst == false)
{ {
_lastFailedModel = bcm; _lastFailedModel = bcm;
@ -1090,5 +1125,23 @@ namespace InjectionSearch
{ {
Program.ProductDate = _barCodeBLL.GetServiceTime().ToString(); Program.ProductDate = _barCodeBLL.GetServiceTime().ToString();
} }
int _stopSeconds = 0;
private void timer2_Tick(object sender, EventArgs e)
{
_stopSeconds++;
if (_stopSeconds >= _outPageSeconds)
{
_isAutoClosed = true;
timer2.Enabled = false;
this.Hide();
FrmLogin frm = new FrmLogin();
frm.Show();
}
}
} }
} }

3
InjectionSearch/FrmBarCodeSearch2408.resx

@ -120,4 +120,7 @@
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="timer2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>165, 17</value>
</metadata>
</root> </root>

4
InjectionSearch/Program.cs

@ -22,7 +22,9 @@ namespace InjectionSearch
public static string IP; public static string IP;
public static string Shift; //班次 public static string Shift; //班次
public static string ProductDate; public static string ProductDate;
public static string UserName;
public static string tableName;
[STAThread] [STAThread]
static void Main() static void Main()
{ {

2
MESClassLibrary/BLL/BasicInfo/BarCodeBLL.cs

@ -173,7 +173,7 @@ namespace MESClassLibrary.BLL.BasicInfo
{ {
db.DelBarCode(local, oldOneBarCode, tableName, $",Des5='条码补打,新条码[{md.OneBarCode}]'"); db.DelBarCode(local, oldOneBarCode, tableName, $",Des5='条码补打,新条码[{md.OneBarCode}]'");
} }
//tb_barCode 插入 printType=2 补打 //tb_barCode 插入 printType=2 补打
db.AddInfoNew(local, md, tableName, isNew); db.AddInfoNew(local, md, tableName, isNew);

16
MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs

@ -273,7 +273,7 @@ namespace MESClassLibrary.DAL.BasicInfo
#region 添加数据 #region 添加数据
string sql = ""; string sql = "";
SqlParameter[] param = null; SqlParameter[] param = null;
sql = "INSERT INTO " + tableName + " (ID,StationID,OneBarCode,[BarCode],[StockNo],[PartNo],[PrintType],[CreateTime],[IsImport],StationID2,PlanID,ProductNature,Des1,Des2,Des3,Des4,Des5,BoxNo,IsNew,Weight"; sql = "INSERT INTO " + tableName + " (ID,StationID,OneBarCode,[BarCode],[StockNo],[PartNo],[PrintType],[CreateTime],[IsImport],StationID2,PlanID,ProductNature,Des1,Des2,Des3,Des4,Des5,BoxNo,IsNew,AddMan,Weight";
sql += ") VALUES ("; sql += ") VALUES (";
sql += "@ID,"; sql += "@ID,";
sql += "@StationID,"; sql += "@StationID,";
@ -295,10 +295,11 @@ namespace MESClassLibrary.DAL.BasicInfo
sql += "@Des5,"; sql += "@Des5,";
sql += "@BoxNo,"; sql += "@BoxNo,";
sql += "@IsNew,"; sql += "@IsNew,";
sql += "@AddMan,";
sql += "@Weight)"; sql += "@Weight)";
#region 添加参数 #region 添加参数
param = new SqlParameter[19]; param = new SqlParameter[20];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar); param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID; param[0].Value = md.ID;
@ -353,8 +354,11 @@ namespace MESClassLibrary.DAL.BasicInfo
param[17] = new SqlParameter("@IsNew", SqlDbType.VarChar); param[17] = new SqlParameter("@IsNew", SqlDbType.VarChar);
param[17].Value = isNew; param[17].Value = isNew;
param[18] = new SqlParameter("@Weight", SqlDbType.Decimal); param[18] = new SqlParameter("@AddMan", SqlDbType.VarChar);
param[18].Value = md.Weight; param[18].Value = md.AddMan;
param[19] = new SqlParameter("@Weight", SqlDbType.Decimal);
param[19].Value = md.Weight;
#endregion #endregion
@ -373,9 +377,9 @@ namespace MESClassLibrary.DAL.BasicInfo
string sql = ""; string sql = "";
sql = "INSERT INTO " + tableName + " (ID,StationID,OneBarCode,[BarCode],[StockNo],[PartNo],[PrintType],[CreateTime],[IsImport],StationID2,PlanID,ProductNature,Des1,Des2,Des3,Des4,Des5,BoxNo,Weight,BatchNo,IsNew"; sql = "INSERT INTO " + tableName + " (ID,StationID,OneBarCode,[BarCode],[StockNo],[PartNo],[PrintType],[CreateTime],[IsImport],StationID2,PlanID,ProductNature,Des1,Des2,Des3,Des4,Des5,BoxNo,Weight,BatchNo,IsNew,AddMan";
sql += $") VALUES ('{md.ID}','{md.StationID}','{md.OneBarCode}','{md.BarCode}','{md.StockNo}','{md.PartNo}','{md.PrintType}',getdate(),'{md.Import}'," + sql += $") VALUES ('{md.ID}','{md.StationID}','{md.OneBarCode}','{md.BarCode}','{md.StockNo}','{md.PartNo}','{md.PrintType}',getdate(),'{md.Import}'," +
$"'{md.StationID2}','{md.PlanID}','{md.ProductNature}','{md.Des1}','{md.Des2}','{md.Des3}','{md.Des4}','{md.Des5}','{md.BoxNo}','{ md.Weight}','{ md.BatchNo}','{isNew}')"; $"'{md.StationID2}','{md.PlanID}','{md.ProductNature}','{md.Des1}','{md.Des2}','{md.Des3}','{md.Des4}','{md.Des5}','{md.BoxNo}','{ md.Weight}','{ md.BatchNo}','{isNew}','{md.AddMan}')";
local.Exec_NonQuery(sql); local.Exec_NonQuery(sql);

1
MESClassLibrary/Model/BarCodeModel.cs

@ -48,5 +48,6 @@ namespace MESClassLibrary.Model
public decimal Weight { get; set; } public decimal Weight { get; set; }
public string BatchNo { get; set; } public string BatchNo { get; set; }
public string Remark { get; set; } public string Remark { get; set; }
public string AddMan { get; set; }
} }
} }

Loading…
Cancel
Save