You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1062 lines
40 KiB
1062 lines
40 KiB
2 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Configuration;
|
||
|
using System.Data;
|
||
|
using System.Diagnostics.Eventing.Reader;
|
||
|
using System.Drawing;
|
||
|
using System.IO;
|
||
|
using System.Linq;
|
||
|
using System.Net;
|
||
|
using System.Net.NetworkInformation;
|
||
|
using System.Reflection;
|
||
|
using System.Text;
|
||
|
using System.Threading;
|
||
|
using System.Threading.Tasks;
|
||
|
using System.Windows.Forms;
|
||
|
using MESClassLibrary.BLL.BasicInfo;
|
||
|
using MESClassLibrary.BLL.Inspection;
|
||
|
using MESClassLibrary.BLL.Log;
|
||
|
using MESClassLibrary.BLL.TruckBox;
|
||
|
using MESClassLibrary.DAL;
|
||
|
using MESClassLibrary.EFModel;
|
||
|
using MESClassLibrary.Model;
|
||
|
|
||
|
namespace InjectionPC
|
||
|
{
|
||
|
public partial class FrmQuality : Form
|
||
|
{
|
||
|
private static string position = "", reason = "";
|
||
|
int count = 0; //缺陷图选择个数
|
||
|
|
||
|
private string stationId = "";
|
||
|
public FrmQuality()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
private void label9_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
this.Close();
|
||
|
//OnVisibleChanged()
|
||
|
}
|
||
|
|
||
|
protected override void OnVisibleChanged(EventArgs e)
|
||
|
{
|
||
|
base.OnVisibleChanged(e);
|
||
|
if (!IsHandleCreated)
|
||
|
{
|
||
|
this.Close();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void FrmQuality_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
Control.CheckForIllegalCrossThreadCalls = false;
|
||
|
string LineID = "";
|
||
|
label6.Text = Program.station;
|
||
|
label8.Text = Program.OperatorName;
|
||
|
comboBox1.Text = Program.Shift;
|
||
|
textBox3.TabIndex = 0;
|
||
|
textBox3.Focus();
|
||
|
|
||
|
GetClass();
|
||
|
comboBox1.Enabled = false;
|
||
|
|
||
|
textBox1.Text = "";
|
||
|
textBox2.Text = "";
|
||
|
Thread t = new Thread(new ThreadStart(TimeGo));
|
||
|
t.Start();
|
||
|
|
||
|
timer2.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["InterVal2"]);
|
||
|
timer2.Enabled = false;
|
||
|
|
||
|
StationBLL bll=new StationBLL();
|
||
|
|
||
|
DataTable dt = bll.SearchInfoByNo(Program.station);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
stationId = dt.Rows[0]["StationID"].ToString();
|
||
|
}
|
||
|
|
||
|
#region 测试
|
||
|
|
||
|
//获取服务器上图片
|
||
|
//Ping p1 = new Ping();
|
||
|
//bool status = false;
|
||
|
|
||
|
//PingReply reply = p1.Send(Program.IP); //发送主机名或Ip地址
|
||
|
//StringBuilder sbuilder;
|
||
|
//if (reply.Status == IPStatus.Success)
|
||
|
//{
|
||
|
// status = Upload.DoConnComputer(Program.IP, "aa", "Administrator", "Wff775168+");
|
||
|
// if (status == true)
|
||
|
// {
|
||
|
// //共享文件夹的目录
|
||
|
// DirectoryInfo theFolder = new DirectoryInfo(@"\\" + Program.IP + "\\aa\\");
|
||
|
// string filename = theFolder.ToString();
|
||
|
// //执行方法
|
||
|
// TransportRemoteToLocal(@"D:\车间.png", filename, "车间.png"); //实现将远程服务器文件写入到本地
|
||
|
// }
|
||
|
//}
|
||
|
//FileStream fs = new FileStream("D:\\2.jpg", FileMode.Open,
|
||
|
// FileAccess.Read);//获取图片文件流
|
||
|
//Image img = Image.FromStream(fs); // 文件流转换成Image格式
|
||
|
//pictureBox2.Image = img; //给 图片框设置要显示的图片
|
||
|
//fs.Close(); // 关闭流,释放图片资源
|
||
|
|
||
|
//Label[] lb = new Label[5];
|
||
|
//string[] str = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O" };
|
||
|
|
||
|
//for (int i = 0; i < 5; i++)
|
||
|
//{
|
||
|
// for (int j = 0; j < 3; j++)
|
||
|
// {
|
||
|
// lb[i] = new Label();
|
||
|
// lb[i].Text = str[i].ToString();
|
||
|
// lb[i].Font = new Font(lb[i].Font.FontFamily, 32, FontStyle.Bold);
|
||
|
|
||
|
// lb[i].Size = new Size(pictureBox2.Width / 5, pictureBox2.Height / 3);
|
||
|
// lb[i].Location = new Point(0 + i * lb[i].Size.Width, 0 + j * lb[i].Size.Height);
|
||
|
// lb[i].BorderStyle = BorderStyle.FixedSingle;
|
||
|
// lb[i].BackColor = Color.Transparent;
|
||
|
// lb[i].TextAlign = ContentAlignment.MiddleCenter;
|
||
|
// pictureBox2.Controls.Add(lb[i]);
|
||
|
|
||
|
// lb[i].Click += new EventHandler(lblRoom_Click);
|
||
|
// }
|
||
|
//}
|
||
|
//StationBLL sbll = new StationBLL();
|
||
|
//DataTable sdt = sbll.SearchInfoByNo(Program.station);
|
||
|
//if (sdt != null && sdt.Rows.Count > 0)
|
||
|
//{
|
||
|
// LineID = sdt.Rows[0]["LineID"].ToString();
|
||
|
//}
|
||
|
//sdt.Dispose();
|
||
|
|
||
|
//int row = 0, col = 6;
|
||
|
|
||
|
//DefectBLL dbll = new DefectBLL();
|
||
|
//DataTable dt3 = dbll.SearchInfo(LineID);
|
||
|
//if (dt3 != null && dt3.Rows.Count > 0)
|
||
|
//{
|
||
|
// row = Convert.ToInt32(Math.Ceiling((double)dt3.Rows.Count / 6));
|
||
|
// Label[] dLb = new Label[7];
|
||
|
// string[] dstr = new string[dt3.Rows.Count];
|
||
|
|
||
|
|
||
|
// for (int i = 0; i < dt3.Rows.Count; i++)
|
||
|
// {
|
||
|
// dstr[i] = dt3.Rows[i]["DefectName"].ToString();
|
||
|
// }
|
||
|
|
||
|
// for (int i = 0; i < 6; i++) //列
|
||
|
// {
|
||
|
// for (int j = 0; j < row;j++) //行
|
||
|
// {
|
||
|
// dLb[i] = new Label();
|
||
|
// if ((i + 6 * j) < dstr.Length)
|
||
|
// {
|
||
|
// dLb[i].Text = dstr[i + 6 * j].ToString();
|
||
|
// dLb[i].Font = new Font(dLb[i].Font.FontFamily, 24, FontStyle.Bold);
|
||
|
|
||
|
// dLb[i].Size = new Size(150, 50);
|
||
|
// dLb[i].Location = new Point(20 + i * (dLb[i].Size.Width+25), 5 + j * (dLb[i].Size.Height+20));
|
||
|
// dLb[i].BorderStyle = BorderStyle.FixedSingle;
|
||
|
// dLb[i].BackColor = Color.Transparent;
|
||
|
// dLb[i].TextAlign = ContentAlignment.MiddleCenter;
|
||
|
// panel2.Controls.Add(dLb[i]);
|
||
|
// }
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
textBox3.Text = Program.strBarCode;
|
||
|
textBox3.SelectAll();
|
||
|
|
||
|
if (ConfigurationManager.AppSettings["IsLast"] == "1")
|
||
|
{
|
||
|
label9.Visible = false;
|
||
|
}
|
||
|
else if (ConfigurationManager.AppSettings["IsLast"] == "0")
|
||
|
{
|
||
|
label9.Visible = false;
|
||
|
}
|
||
|
|
||
|
GetBadCount();
|
||
|
}
|
||
|
|
||
|
|
||
|
private void TimeGo()
|
||
|
{
|
||
|
System.Timers.Timer timer = new System.Timers.Timer();
|
||
|
timer.Interval = 1000;
|
||
|
timer.Enabled = true;
|
||
|
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Tick);
|
||
|
}
|
||
|
|
||
|
private void timer_Tick(object sender, EventArgs e)
|
||
|
{
|
||
|
label2.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||
|
Thread.Sleep(500);
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 从远程服务器下载文件到本地
|
||
|
/// </summary>
|
||
|
/// <param name="src">下载到本地后的文件路径,包含文件的扩展名</param>
|
||
|
/// <param name="dst">远程服务器路径(共享文件夹路径)</param>
|
||
|
/// <param name="fileName">远程服务器(共享文件夹)中的文件名称,包含扩展名</param>
|
||
|
public static void TransportRemoteToLocal(string src, string dst, string fileName) //src:下载到本地后的文件路径 dst:远程服务器路径 fileName:远程服务器dst路径下的文件名
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
FileStream inFileStream = new FileStream(src, FileMode.Open); //远程服务器文件 此处假定远程服务器共享文件夹下确实包含本文件,否则程序报错
|
||
|
|
||
|
if (!Directory.Exists(dst))
|
||
|
{
|
||
|
Directory.CreateDirectory(dst);
|
||
|
}
|
||
|
dst = dst + fileName;
|
||
|
FileStream outFileStream = new FileStream(dst, FileMode.OpenOrCreate); //从远程服务器下载到本地的文件
|
||
|
byte[] buf = new byte[inFileStream.Length];
|
||
|
int byteCount;
|
||
|
while ((byteCount = inFileStream.Read(buf, 0, buf.Length)) > 0)
|
||
|
{
|
||
|
outFileStream.Write(buf, 0, byteCount);
|
||
|
}
|
||
|
inFileStream.Flush();
|
||
|
inFileStream.Close();
|
||
|
outFileStream.Flush();
|
||
|
outFileStream.Close();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void lblRoom_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
Label a = (Label) sender;
|
||
|
//foreach (Control c in pictureBox2.Controls)
|
||
|
//{
|
||
|
// c.BackColor = Color.Transparent;
|
||
|
//}
|
||
|
if (a.BackColor == Color.Transparent)
|
||
|
{
|
||
|
a.BackColor = Color.FromArgb(150, System.Drawing.Color.Chartreuse);
|
||
|
count++;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
a.BackColor = Color.Transparent;
|
||
|
count--;
|
||
|
}
|
||
|
|
||
|
//position +=a.Text+",";
|
||
|
}
|
||
|
|
||
|
|
||
|
void dLbRoom_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
Label a = (Label)sender;
|
||
|
|
||
|
string aa = a.Text;
|
||
|
if (a.BackColor == Color.Transparent)
|
||
|
{
|
||
|
a.BackColor = Color.FromArgb(150, Color.Chartreuse);
|
||
|
reason += a.Text+";";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
reason = reason.Replace(a.Text+";","");
|
||
|
a.BackColor = Color.Transparent;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 保存缺陷
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void button1_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
string stockNo = "",batchNo="",partNo="",isbox="";
|
||
|
|
||
|
foreach (Control c in pictureBox2.Controls)
|
||
|
{
|
||
|
Label lab = c as Label;
|
||
|
if (lab.BackColor != Color.Transparent)
|
||
|
{
|
||
|
position += lab.Text + ";";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (position == "")
|
||
|
{
|
||
|
MessageBox.Show("请选择缺陷位置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (reason == "")
|
||
|
{
|
||
|
MessageBox.Show("请选择缺陷原因!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
BadInjectionBLL badBLL = new BadInjectionBLL();
|
||
|
BadInjectionModel badmd = new BadInjectionModel();
|
||
|
InjectionBoxBLL ibll=new InjectionBoxBLL();
|
||
|
BarCodeBLL barbll=new BarCodeBLL();
|
||
|
InspectionBLL bll = new InspectionBLL();
|
||
|
tb_Inspection_tx md = new tb_Inspection_tx();
|
||
|
|
||
|
if (textBox1.Text != "" && textBox3.Text != "")
|
||
|
{
|
||
|
MessageBox.Show("箱单和条码只能输入一个!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#region 大件报废
|
||
|
|
||
|
if (textBox1.Text == "" && textBox3.Text != "")
|
||
|
{
|
||
|
#region 判断是否已做过报废
|
||
|
|
||
|
DataTable baddt = badBLL.SearchByCode(textBox3.Text.Trim());
|
||
|
if (baddt != null && baddt.Rows.Count > 0)
|
||
|
{
|
||
|
MessageBox.Show("请产品已做过报废处理!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
reason = "";
|
||
|
textBox3.Text = "";
|
||
|
textBox3.TabIndex = 0;
|
||
|
textBox3.Focus();
|
||
|
|
||
|
textBox4.Text = "";
|
||
|
pictureBox2.Image = null;
|
||
|
|
||
|
pictureBox2.Controls.Clear();
|
||
|
|
||
|
panel2.Controls.Clear();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 保存报废详细信息和是否装过箱,装过箱子的不允许报废
|
||
|
|
||
|
badmd.ID = Guid.NewGuid().ToString();
|
||
|
if (textBox3.Text.Trim().Contains("#"))
|
||
|
{
|
||
|
badmd.BarCode = textBox3.Text.Trim();
|
||
|
DataTable dt1 = barbll.SeachInfoByOne(textBox3.Text.Trim(), Program.tableName, 2);
|
||
|
if (dt1 != null && dt1.Rows.Count > 0)
|
||
|
{
|
||
|
badmd.OneBarCode = dt1.Rows[0]["OneBarCode"].ToString();
|
||
|
isbox = dt1.Rows[0]["BoxNo"].ToString();
|
||
|
if (!string.IsNullOrEmpty(isbox))
|
||
|
{
|
||
|
MessageBox.Show("请产品已做装箱,不能做报废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
reason = "";
|
||
|
textBox3.Text = "";
|
||
|
textBox3.TabIndex = 0;
|
||
|
textBox3.Focus();
|
||
|
|
||
|
textBox4.Text = "";
|
||
|
pictureBox2.Image = null;
|
||
|
|
||
|
pictureBox2.Controls.Clear();
|
||
|
|
||
|
panel2.Controls.Clear();
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (textBox3.Text.Trim().Contains('.'))
|
||
|
{
|
||
|
badmd.BarCode = textBox3.Text.Trim();
|
||
|
DataTable dt = barbll.SeachInfoByOne(textBox3.Text.Trim(), Program.tableName, 2);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
badmd.OneBarCode = dt.Rows[0]["OneBarCode"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("条码不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
badmd.OneBarCode = textBox3.Text.Trim();
|
||
|
|
||
|
DataTable dt1 = barbll.SeachInfoByOne(textBox3.Text.Trim(), Program.tableName, 1);
|
||
|
if (dt1 != null && dt1.Rows.Count > 0)
|
||
|
{
|
||
|
badmd.BarCode = dt1.Rows[0]["BarCode"].ToString();
|
||
|
isbox = dt1.Rows[0]["BoxNo"].ToString();
|
||
|
if (!string.IsNullOrEmpty(isbox))
|
||
|
{
|
||
|
MessageBox.Show("请产品已做装箱,不能做报废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
reason = "";
|
||
|
textBox3.Text = "";
|
||
|
textBox3.TabIndex = 0;
|
||
|
textBox3.Focus();
|
||
|
|
||
|
textBox4.Text = "";
|
||
|
pictureBox2.Image = null;
|
||
|
pictureBox2.Controls.Clear();
|
||
|
panel2.Controls.Clear();
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
badmd.StationID = stationId;
|
||
|
badmd.BadPosition = position;
|
||
|
badmd.BadReason = reason.Trim();
|
||
|
badBLL.Add_Info(badmd);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 更新BarCode表标志位
|
||
|
|
||
|
barbll.UpdateIsBad(Program.tableName, badmd.OneBarCode, badmd.BarCode);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
GetBadCount();
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 小件报废,直接修改产量,如果是开机报废减产量,否则产量不变增加报废数
|
||
|
|
||
|
if (textBox1.Text != "" && textBox3.Text == "")
|
||
|
{
|
||
|
#region 验证数据有效性
|
||
|
|
||
|
if (textBox2.Text.Trim() == "")
|
||
|
{
|
||
|
MessageBox.Show("请输入报废数量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
textBox2.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!IsNumeric(textBox2.Text.Trim()))
|
||
|
{
|
||
|
MessageBox.Show("报废数量必须为整数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
textBox2.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 判断报废数量是否大于该箱子里的数量
|
||
|
|
||
|
DataTable dt1 = ibll.SearchBox(textBox1.Text);
|
||
|
if (dt1 != null && dt1.Rows.Count > 0)
|
||
|
{
|
||
|
if (Convert.ToInt32(textBox2.Text.Trim()) > dt1.Rows.Count)
|
||
|
{
|
||
|
MessageBox.Show("报废数不能大于装箱数量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
textBox2.Focus();
|
||
|
return;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
for (int i = 0; i < Convert.ToInt32(textBox2.Text.Trim()); i++)
|
||
|
{
|
||
|
#region 按时间倒序排并且已入箱的对应的个数将零件改为报废,
|
||
|
|
||
|
DataTable dt2 = barbll.SearchBarCode(textBox1.Text.Trim(), Program.tableName,
|
||
|
textBox2.Text.Trim());
|
||
|
if (dt2 != null && dt2.Rows.Count > 0)
|
||
|
{
|
||
|
for (int j = 0; j < dt2.Rows.Count; j++)
|
||
|
{
|
||
|
barbll.UpdateIsBad(Program.tableName, "", dt2.Rows[j]["BarCode"].ToString());
|
||
|
|
||
|
#region 添加报废记录
|
||
|
|
||
|
badmd.ID = Guid.NewGuid().ToString();
|
||
|
badmd.OneBarCode = dt2.Rows[j]["OneBarCode"].ToString();
|
||
|
badmd.BarCode = dt2.Rows[j]["BarCode"].ToString();
|
||
|
badmd.BadPosition = position;
|
||
|
badmd.BadReason = reason.Trim();
|
||
|
badBLL.Add_Info(badmd);
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("该箱单不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
textBox1.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 插入质检总表
|
||
|
|
||
|
md.BarCode = badmd.OneBarCode;
|
||
|
md.IsOK = 0;
|
||
|
md.Station = 2;
|
||
|
|
||
|
bll.AddInfo(md);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
reason = "";
|
||
|
textBox3.Text = "";
|
||
|
textBox3.TabIndex = 0;
|
||
|
textBox3.SelectAll();
|
||
|
textBox3.Focus();
|
||
|
|
||
|
textBox4.Text = "";
|
||
|
pictureBox2.Image = null;
|
||
|
textBox1.Text = "";
|
||
|
|
||
|
pictureBox2.Controls.Clear();
|
||
|
|
||
|
panel2.Controls.Clear();
|
||
|
position = "";
|
||
|
reason = "";
|
||
|
}
|
||
|
|
||
|
private static bool IsNumeric(string str)
|
||
|
{
|
||
|
System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[0-9]\d*$");
|
||
|
return reg1.IsMatch(str);
|
||
|
}
|
||
|
|
||
|
private void button2_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
#region 售后件,注销,改为合格
|
||
|
|
||
|
//string partNo = "", manufacturer = "", barCode = "";
|
||
|
|
||
|
//ProductBLL pbll = new ProductBLL();
|
||
|
//BarCodeBLL barbll = new BarCodeBLL();
|
||
|
|
||
|
//#region 验证数据有效性
|
||
|
|
||
|
//if (textBox1.Text.Trim() == "" && textBox3.Text.Trim() == "")
|
||
|
//{
|
||
|
// MessageBox.Show("请输入箱单或条码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
// return;
|
||
|
//}
|
||
|
|
||
|
//if (textBox1.Text.Trim() != "" && textBox3.Text.Trim() != "")
|
||
|
//{
|
||
|
// MessageBox.Show("箱单和条码只能输入一个!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
// return;
|
||
|
//}
|
||
|
|
||
|
//#endregion
|
||
|
|
||
|
//#region 小件
|
||
|
|
||
|
//if (textBox1.Text.Trim() != "")
|
||
|
//{
|
||
|
// string[] aa = textBox1.Text.Split('.');
|
||
|
|
||
|
// partNo = aa[0].Trim();
|
||
|
|
||
|
// DataTable dt1 = pbll.SearchInfoByPartNo(partNo);
|
||
|
// if (dt1 != null && dt1.Rows.Count > 0)
|
||
|
// {
|
||
|
// if (dt1.Rows[0]["ManufacturerName"].ToString().Contains("奔驰"))
|
||
|
// {
|
||
|
// MessageBox.Show("奔驰产品不能转售后件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
// return;
|
||
|
// }
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// for (int i = 0; i < Convert.ToInt32(textBox2.Text.Trim()); i++)
|
||
|
// {
|
||
|
// #region 按时间倒序排并且已入箱的对应的个数将零件改为报废,
|
||
|
|
||
|
// DataTable dt2 = barbll.SearchBarCode(textBox1.Text.Trim(), Program.tableName,
|
||
|
// textBox2.Text.Trim());
|
||
|
// if (dt2 != null && dt2.Rows.Count > 0)
|
||
|
// {
|
||
|
// for (int j = 0; j < dt2.Rows.Count; j++)
|
||
|
// {
|
||
|
// barbll.updateProductNature(Program.tableName, dt2.Rows[j]["BarCode"].ToString());
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// #endregion
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
//#endregion
|
||
|
|
||
|
//#region 大件
|
||
|
|
||
|
//if (textBox3.Text.Trim() != "")
|
||
|
//{
|
||
|
// if (textBox3.Text.Trim().Contains('.'))
|
||
|
// {
|
||
|
// barCode = textBox3.Text.Trim();
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// DataTable dt4 = barbll.SeachInfoByOne(textBox3.Text.Trim(), Program.tableName, 1);
|
||
|
// if (dt4 != null && dt4.Rows.Count > 0)
|
||
|
// {
|
||
|
// barCode = dt4.Rows[0]["BarCode"].ToString();
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// MessageBox.Show("条码不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
// return;
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// string[] aa = barCode.Split('.');
|
||
|
// partNo = aa[0].Trim();
|
||
|
|
||
|
// DataTable dt3 = pbll.SearchInfoByPartNo(partNo);
|
||
|
// if (dt3 != null && dt3.Rows.Count > 0)
|
||
|
// {
|
||
|
// if (dt3.Rows[0]["ManufacturerName"].ToString().Contains("奔驰"))
|
||
|
// {
|
||
|
// MessageBox.Show("奔驰产品不能转售后件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
// return;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// barbll.updateProductNature(Program.tableName, barCode);
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
//#endregion
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 合格打印条码
|
||
|
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void textBox3_KeyDown(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
if (e.KeyCode == Keys.Enter)
|
||
|
{
|
||
|
string code = "";
|
||
|
string[] barcode=new string[3];
|
||
|
int row = 0, col = 0;
|
||
|
string picture = "";
|
||
|
string LineID = "";
|
||
|
ProductBLL bll = new ProductBLL();
|
||
|
BarCodeBLL barbll=new BarCodeBLL();
|
||
|
|
||
|
string aa = textBox3.Text.Trim();
|
||
|
if (textBox3.Text.Contains('.') == false && textBox3.Text.Contains('#') == false)
|
||
|
{
|
||
|
DataTable xdt=barbll.SeachInfoByOne(textBox3.Text.Trim(), Program.tableName, 1);
|
||
|
if (xdt != null && xdt.Rows.Count > 0)
|
||
|
{
|
||
|
code = xdt.Rows[0]["BarCode"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("条码有误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
barcode = code.Split('.');
|
||
|
DataTable dt = bll.SearchInfoByPartNo(barcode[0]);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
textBox4.Text = dt.Rows[0]["ProductName"].ToString();
|
||
|
row = Convert.ToInt32(dt.Rows[0]["Rows"].ToString());
|
||
|
col = Convert.ToInt32(dt.Rows[0]["Cols"].ToString());
|
||
|
picture = dt.Rows[0]["PicturePath"].ToString();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DataTable xdt = barbll.SeachInfoByOne(textBox3.Text.Trim(), Program.tableName, 2);
|
||
|
if (xdt != null && xdt.Rows.Count > 0)
|
||
|
{
|
||
|
code = xdt.Rows[0]["BarCode"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("条码有误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (textBox3.Text.Contains('#') == false)
|
||
|
{
|
||
|
barcode = textBox3.Text.Trim().Split('.');
|
||
|
DataTable dt = bll.SearchInfoByPartNo(barcode[0]);
|
||
|
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
textBox4.Text = dt.Rows[0]["ProductName"].ToString();
|
||
|
row = Convert.ToInt32(dt.Rows[0]["Rows"].ToString());
|
||
|
col = Convert.ToInt32(dt.Rows[0]["Cols"].ToString());
|
||
|
picture = dt.Rows[0]["PicturePath"].ToString();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
barcode = textBox3.Text.Trim().Split('#');
|
||
|
DataTable dt = bll.SearchInfoByPartNo(barcode[0]);
|
||
|
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
textBox4.Text = dt.Rows[0]["ProductName"].ToString();
|
||
|
row = Convert.ToInt32(dt.Rows[0]["Rows"].ToString());
|
||
|
col = Convert.ToInt32(dt.Rows[0]["Cols"].ToString());
|
||
|
picture = dt.Rows[0]["PicturePath"].ToString();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
try
|
||
|
{
|
||
|
#region Load PictureBox
|
||
|
|
||
|
if (!string.IsNullOrEmpty(picture))
|
||
|
{
|
||
|
if (!File.Exists(System.IO.Directory.GetCurrentDirectory() + @"\" + picture))
|
||
|
{
|
||
|
//string strImageURL = ConfigurationManager.AppSettings["PicturePath"] + picture;
|
||
|
string strImageURL = "http://10.60.101.59:8001/PDF/" + picture;
|
||
|
|
||
|
System.Net.WebClient webClient = new System.Net.WebClient();
|
||
|
webClient.DownloadFile(strImageURL, Directory.GetCurrentDirectory() + @"\" + picture);
|
||
|
|
||
|
//Ping p1 = new Ping();
|
||
|
//bool status = false;
|
||
|
|
||
|
//PingReply reply = p1.Send(Program.RemoteIP); //发送主机名或Ip地址
|
||
|
//StringBuilder sbuilder;
|
||
|
//if (reply.Status == IPStatus.Success)
|
||
|
//{
|
||
|
// string PictureFolder = ConfigurationManager.AppSettings["PictureFolder"].ToString();
|
||
|
// string User = ConfigurationManager.AppSettings["PictureUser"].ToString();
|
||
|
// string UserPwd = ConfigurationManager.AppSettings["PicturePsw"].ToString();
|
||
|
// status = Upload.DoConnComputer(Program.RemoteIP, PictureFolder, User, UserPwd);
|
||
|
// if (status == true)
|
||
|
// {
|
||
|
// //共享文件夹的目录
|
||
|
// string path = ConfigurationManager.AppSettings["PicturePath"].ToString() + picture;
|
||
|
// DirectoryInfo theFolder = new DirectoryInfo(path);
|
||
|
// string filename = theFolder.ToString();
|
||
|
|
||
|
// //执行方法
|
||
|
// TransportRemoteToLocal(filename, System.Environment.CurrentDirectory + "\\", picture); //实现将远程服务器文件写入到本地
|
||
|
// }
|
||
|
//}
|
||
|
}
|
||
|
|
||
|
FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "\\" + picture, FileMode.Open,
|
||
|
FileAccess.Read); //获取图片文件流
|
||
|
Image img = Image.FromStream(fs); // 文件流转换成Image格式
|
||
|
pictureBox2.Image = img; //给 图片框设置要显示的图片
|
||
|
fs.Close(); // 关闭流,释放图片资源
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
|
||
|
#region 缺陷图划分区域
|
||
|
|
||
|
Label[] lb = new Label[5];
|
||
|
string[] str =
|
||
|
{
|
||
|
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
|
||
|
"U", "V", "W", "X", "Y", "Z"
|
||
|
};
|
||
|
|
||
|
for (int i = 0; i < col; i++)
|
||
|
{
|
||
|
for (int j = 0; j < row; j++)
|
||
|
{
|
||
|
lb[i] = new Label();
|
||
|
lb[i].Text = str[i + col * j].ToString();
|
||
|
lb[i].Font = new Font(lb[i].Font.FontFamily, 32, FontStyle.Bold);
|
||
|
|
||
|
lb[i].Size = new Size(pictureBox2.Width / col, pictureBox2.Height / row);
|
||
|
lb[i].Location = new Point(0 + i * lb[i].Size.Width, 0 + j * lb[i].Size.Height);
|
||
|
lb[i].BorderStyle = BorderStyle.FixedSingle;
|
||
|
lb[i].BackColor = Color.Transparent;
|
||
|
lb[i].TextAlign = ContentAlignment.MiddleCenter;
|
||
|
pictureBox2.Controls.Add(lb[i]);
|
||
|
|
||
|
lb[i].Click += new EventHandler(lblRoom_Click);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 缺陷原因
|
||
|
|
||
|
StationBLL sbll = new StationBLL();
|
||
|
DataTable sdt = sbll.SearchInfoByNo(Program.station);
|
||
|
if (sdt != null && sdt.Rows.Count > 0)
|
||
|
{
|
||
|
LineID = sdt.Rows[0]["LineID"].ToString();
|
||
|
}
|
||
|
|
||
|
sdt.Dispose();
|
||
|
|
||
|
int drow = 0, dcol = 6;
|
||
|
|
||
|
DefectBLL dbll = new DefectBLL();
|
||
|
DataTable dt3 = dbll.SearchInfo(LineID);
|
||
|
if (dt3 != null && dt3.Rows.Count > 0)
|
||
|
{
|
||
|
drow = Convert.ToInt32(Math.Ceiling((double) dt3.Rows.Count / dcol));
|
||
|
Label[] dLb = new Label[7];
|
||
|
string[] dstr = new string[dt3.Rows.Count];
|
||
|
|
||
|
|
||
|
for (int i = 0; i < dt3.Rows.Count; i++)
|
||
|
{
|
||
|
dstr[i] = dt3.Rows[i]["DefectName"].ToString();
|
||
|
}
|
||
|
|
||
|
for (int i = 0; i < dcol; i++) //列
|
||
|
{
|
||
|
for (int j = 0; j < drow; j++) //行
|
||
|
{
|
||
|
dLb[i] = new Label();
|
||
|
if ((i + dcol * j) < dstr.Length)
|
||
|
{
|
||
|
dLb[i].Text = dstr[i + dcol * j].ToString();
|
||
|
dLb[i].Font = new Font(dLb[i].Font.FontFamily, 20, FontStyle.Bold);
|
||
|
|
||
|
dLb[i].Size = new Size(130, 50);
|
||
|
dLb[i].Location = new Point(50 + i * (dLb[i].Size.Width + 25),
|
||
|
50 + j * (dLb[i].Size.Height + 20));
|
||
|
dLb[i].BorderStyle = BorderStyle.FixedSingle;
|
||
|
dLb[i].BackColor = Color.Transparent;
|
||
|
dLb[i].TextAlign = ContentAlignment.MiddleCenter;
|
||
|
panel2.Controls.Add(dLb[i]);
|
||
|
dLb[i].Click += new EventHandler(dLbRoom_Click);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
if (ConfigurationManager.AppSettings["IsLast"] == "1")
|
||
|
{
|
||
|
timer2.Enabled = true;
|
||
|
}
|
||
|
else if (ConfigurationManager.AppSettings["IsLast"] == "0")
|
||
|
{
|
||
|
timer2.Enabled = false;
|
||
|
label9.Visible = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void label2_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
Environment.Exit(0);
|
||
|
}
|
||
|
|
||
|
private void textBox1_KeyDown(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
InjectionBoxBLL bll=new InjectionBoxBLL();
|
||
|
ProductBLL pbll=new ProductBLL();
|
||
|
|
||
|
if (e.KeyCode == Keys.Enter)
|
||
|
{
|
||
|
if (textBox1.Text.Trim() == "")
|
||
|
{
|
||
|
MessageBox.Show("请扫描或输入箱单!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
textBox1.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (textBox1.Text.Contains('.')==false)
|
||
|
{
|
||
|
MessageBox.Show("箱单格式有误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
textBox1.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#region 判断箱单是否为小件,即看零件号是否需要打印单个条码
|
||
|
|
||
|
string[] aa = textBox1.Text.Split('.');
|
||
|
string partNo = aa[0].ToString().Trim();
|
||
|
|
||
|
DataTable dt = pbll.SearchInfoByPartNo(partNo);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
if (dt.Rows[0]["IsPrintOneTag"].ToString() == "1")
|
||
|
{
|
||
|
MessageBox.Show("该零件有单个条码,不能扫描箱单!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
textBox1.Focus();
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("该箱单有误,请重新扫描或输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
textBox1.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
DataTable dt1 = bll.SearchBox(textBox1.Text);
|
||
|
if (dt1 != null && dt1.Rows.Count > 0)
|
||
|
{
|
||
|
textBox2.Text = dt1.Rows[0]["BoxCount"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("该箱单不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
textBox1.Focus();
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void timer2_Tick(object sender, EventArgs e)
|
||
|
{
|
||
|
GetClass();
|
||
|
}
|
||
|
|
||
|
private DateTime GetDateTime()
|
||
|
{
|
||
|
string sql = "";
|
||
|
DateTime time;
|
||
|
DataTable dt;
|
||
|
try
|
||
|
{
|
||
|
sql = @"select convert(char(23),getdate(),121) as time";
|
||
|
|
||
|
dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
time = DateTime.ParseExact(dt.Rows[0]["time"].ToString(), "yyyy-MM-dd HH:mm:ss.fff",
|
||
|
System.Globalization.CultureInfo.CurrentCulture);
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
time = DateTime.Now;
|
||
|
}
|
||
|
return time;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return DateTime.Now;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void GetClass()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
DateTime aa = GetDateTime();
|
||
|
|
||
|
if (GetDateTime().Hour >= 8 && GetDateTime().Hour < 20)
|
||
|
{
|
||
|
Program.Shift = "白班";
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Program.Shift = "夜班";
|
||
|
}
|
||
|
|
||
|
comboBox1.Text = Program.Shift;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void GetBadCount()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
BadInjectionBLL bll = new BadInjectionBLL();
|
||
|
string startTime = "", endTime = "";
|
||
|
if (comboBox1.Text == "白班")
|
||
|
{
|
||
|
startTime = DateTime.Now.ToString("yyyy-MM-dd") + " 08:00:00";
|
||
|
endTime = DateTime.Now.ToString("yyyy-MM-dd") + " 20:00:00";
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (DateTime.Now.Hour <= 7)
|
||
|
{
|
||
|
startTime = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + " 20:00:00";
|
||
|
endTime = DateTime.Now.ToString("yyyy-MM-dd") + " 08:00:00";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
startTime = DateTime.Now.ToString("yyyy-MM-dd") + " 20:00:00";
|
||
|
endTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 08:00:00";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
textBox2.Text = bll.BadCount(startTime, endTime, stationId);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|