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.
1110 lines
47 KiB
1110 lines
47 KiB
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.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms.VisualStyles;
|
|
using gregn6Lib;
|
|
using MESClassLibrary.BLL.Log;
|
|
using MESClassLibrary.BLL.Mistake247;
|
|
using MESClassLibrary.Model;
|
|
|
|
namespace PurchingMistakeNew
|
|
{
|
|
public partial class Form3 : Form
|
|
{
|
|
public Form3()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Form3_Load(object sender, EventArgs e)
|
|
{
|
|
textBox1.Enabled = false;
|
|
textBox2.Enabled = true;
|
|
textBox2.Focus();
|
|
textBox1.Text = "";
|
|
textBox2.Text = "";
|
|
panel1.Visible = false;
|
|
panel2.Visible = false;
|
|
panel3.Visible = false;
|
|
InitUC();
|
|
}
|
|
|
|
private void InitUC()
|
|
{
|
|
MistakeBLL mbll = new MistakeBLL();
|
|
RecordBLL rbll = new RecordBLL();
|
|
|
|
int[] maxCount = new int[12];
|
|
int[] currentCount = new int[12];
|
|
//string[] part =
|
|
//{
|
|
// "A2477203007", "A2477203207", "A2477205006", "A2477305303", "A2477305503", "A2477305703", "A2477203107",
|
|
// "A2477203307", "A2477205106", "A2477305403", "A2477305603", "A2477305803"
|
|
//};
|
|
|
|
string[] part =
|
|
{
|
|
"A2477203007", "A2477203207", "A2477205006", "A2477305303", "A2477305503", "A2477305703", "A2477203107",
|
|
"A2477203307", "A2477205106", "A2477305403", "A2477305603", "A2477305803"
|
|
};
|
|
string[] box = new string [12];
|
|
|
|
|
|
#region 查找产品的最大包装量、装箱单号
|
|
|
|
DataTable dt1 = null;
|
|
for (int i = 0; i < 12; i++)
|
|
{
|
|
dt1 = mbll.SearchPartName(part[i]);
|
|
if (dt1 != null && dt1.Rows.Count > 0)
|
|
{
|
|
maxCount[i] = Convert.ToInt32(dt1.Rows[0]["PackCount"].ToString());
|
|
}
|
|
else
|
|
{
|
|
maxCount[i] = 0;
|
|
}
|
|
|
|
DataTable boxdt = rbll.SearchBoxByPart(part[i]);
|
|
if (boxdt != null && boxdt.Rows.Count > 0)
|
|
{
|
|
box[i] = boxdt.Rows[0]["BoxNo"].ToString();
|
|
}
|
|
else
|
|
{
|
|
box[i] = "";
|
|
}
|
|
|
|
if (box[i] != "")
|
|
{
|
|
#region 判断装箱单是否已满
|
|
|
|
DataTable indt = rbll.SearchCountByBox(box[i]);
|
|
if (indt != null && indt.Rows.Count > 0)
|
|
{
|
|
currentCount[i] = Convert.ToInt32(indt.Rows[0]["sum"].ToString());
|
|
}
|
|
else
|
|
{
|
|
currentCount[i] = 0;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 左前
|
|
|
|
userControl11.Part = "A2477203007 左侧前门板装饰件总成VAR7—高光电镀";
|
|
userControl12.Part = "A2477203207 左侧前门板装饰件总成VAR7 VAR9—喷涂";
|
|
userControl13.Part = "A2477205006 左侧前门板装饰件总成VAR5—珍珠镍电镀";
|
|
userControl11.Box = box[0];
|
|
userControl12.Box = box[1];
|
|
userControl13.Box = box[2];
|
|
if (currentCount[0] == maxCount[0])
|
|
{
|
|
userControl11.strIn = "0" + "/" + maxCount[0].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl11.strIn = currentCount[0].ToString() + "/" + maxCount[0].ToString();
|
|
}
|
|
|
|
if (currentCount[1] == maxCount[1])
|
|
{
|
|
userControl12.strIn = "0" + "/" + maxCount[1].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl12.strIn = currentCount[1].ToString() + "/" + maxCount[1].ToString();
|
|
}
|
|
|
|
if (currentCount[2] == maxCount[2])
|
|
{
|
|
userControl13.strIn = "0" + "/" + maxCount[2].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl13.strIn = currentCount[2].ToString() + "/" + maxCount[2].ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 左后
|
|
|
|
userControl14.Part = "A2477305303 左侧后门板装饰件总成VAR7—高光电镀";
|
|
userControl15.Part = "A2477305503 左侧后门板装饰件总成VAR7 VAR9—喷涂";
|
|
userControl16.Part = "A2477305703 左侧后门板装饰件总成VAR5—珍珠镍电镀";
|
|
userControl14.Box = box[3];
|
|
userControl15.Box = box[4];
|
|
userControl16.Box = box[5];
|
|
if (currentCount[3] == maxCount[3])
|
|
{
|
|
userControl14.strIn = "0" + "/" + maxCount[3].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl14.strIn = currentCount[3].ToString() + "/" + maxCount[3].ToString();
|
|
}
|
|
|
|
if (currentCount[4] == maxCount[4])
|
|
{
|
|
userControl15.strIn = "0" + "/" + maxCount[4].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl15.strIn = currentCount[4].ToString() + "/" + maxCount[4].ToString();
|
|
}
|
|
|
|
if (currentCount[5] == maxCount[5])
|
|
{
|
|
userControl16.strIn = "0" + "/" + maxCount[5].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl16.strIn = currentCount[5].ToString() + "/" + maxCount[5].ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 右前
|
|
|
|
userControl17.Part = "A2477203107 右侧前门板装饰件总成VAR7—高光电镀";
|
|
userControl18.Part = "A2477203307 右侧前门板装饰件总成VAR7 VAR9—喷涂";
|
|
userControl19.Part = "A2477205106 右侧前门板装饰件总成VAR5—珍珠镍电镀";
|
|
userControl17.Box = box[6];
|
|
userControl18.Box = box[7];
|
|
userControl19.Box = box[8];
|
|
if (currentCount[6] == maxCount[6])
|
|
{
|
|
userControl17.strIn = "0" + "/" + maxCount[6].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl17.strIn = currentCount[6].ToString() + "/" + maxCount[6].ToString();
|
|
}
|
|
|
|
if (currentCount[7] == maxCount[7])
|
|
{
|
|
userControl18.strIn = "0" + "/" + maxCount[7].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl18.strIn = currentCount[7].ToString() + "/" + maxCount[7].ToString();
|
|
}
|
|
|
|
if (currentCount[8] == maxCount[8])
|
|
{
|
|
userControl19.strIn = "0" + "/" + maxCount[8].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl19.strIn = currentCount[8].ToString() + "/" + maxCount[8].ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 右后
|
|
|
|
userControl110.Part = "A2477305403 右侧后门板装饰件总成VAR7—高光电镀";
|
|
userControl111.Part = "A2477305603 右侧后门板装饰件总成VAR7 VAR9—喷涂";
|
|
userControl112.Part = "A2477305803 右后门板装饰件总成—珍珠镍电镀";
|
|
userControl110.Box = box[9];
|
|
userControl111.Box = box[10];
|
|
userControl112.Box = box[11];
|
|
if (currentCount[9] == maxCount[9])
|
|
{
|
|
userControl110.strIn = "0" + "/" + maxCount[9].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl110.strIn = currentCount[9].ToString() + "/" + maxCount[9].ToString();
|
|
}
|
|
|
|
if (currentCount[10] == maxCount[10])
|
|
{
|
|
userControl111.strIn = "0" + "/" + maxCount[10].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl111.strIn = currentCount[10].ToString() + "/" + maxCount[10].ToString();
|
|
}
|
|
|
|
if (currentCount[11] == maxCount[11])
|
|
{
|
|
userControl112.strIn = "0" + "/" + maxCount[11].ToString();
|
|
}
|
|
else
|
|
{
|
|
userControl112.strIn = currentCount[11].ToString() + "/" + maxCount[11].ToString();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
private void textBox2_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
MistakeBLL mbll = new MistakeBLL();
|
|
RecordBLL rbll=new RecordBLL();
|
|
BoxBLL boxBll=new BoxBLL();
|
|
BoxModel md=new BoxModel();
|
|
BoxBLL bll=new BoxBLL();
|
|
AssemblyBLL abll=new AssemblyBLL();
|
|
|
|
DataTable dt1 = null;
|
|
GridppReport report = new GridppReport();
|
|
|
|
string part = "",box="",batch="",newBox="",newBatch="",partName="";
|
|
int maxCount = 0, currentCount = 0;
|
|
try
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
if (textBox2.Text.Trim() == "")
|
|
{
|
|
MessageBox.Show("请扫描总成码!","提示",MessageBoxButtons.OK);
|
|
textBox2.Focus();
|
|
return;
|
|
}
|
|
|
|
DataTable recorddt = rbll.SearchByPartNo2(textBox2.Text.Trim());
|
|
if (recorddt != null && recorddt.Rows.Count > 0)
|
|
{
|
|
if (recorddt.Rows[0]["BoxNo"].ToString()!="")
|
|
{
|
|
MessageBox.Show("此总成已入箱!", "提示", MessageBoxButtons.OK);
|
|
textBox2.Focus();
|
|
return;
|
|
}
|
|
|
|
if (Convert.ToInt32(recorddt.Rows[0]["Flag"].ToString()) == 2)
|
|
{
|
|
|
|
MessageBox.Show("此总成已报废!", "提示", MessageBoxButtons.OK);
|
|
textBox2.Focus();
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("此总成不存在!", "提示", MessageBoxButtons.OK);
|
|
textBox2.Focus();
|
|
return;
|
|
}
|
|
|
|
#region 2022-01-04wff增加,扫描总成标签时校验是否进行视觉检测,ToVisual=1未检测,=0已检测
|
|
|
|
//DataTable dt3 = abll.IsVisual(textBox2.Text.Trim());
|
|
//if (dt3 != null && dt3.Rows.Count > 0)
|
|
//{
|
|
// if (dt3.Rows[0]["ToVisual"].ToString() == "1")
|
|
// {
|
|
// MessageBox.Show("此总成未进行视觉检测,不允许装箱!", "提示", MessageBoxButtons.OK);
|
|
// textBox2.Focus();
|
|
// return;
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
|
|
|
|
#region 颜色
|
|
//if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203007")
|
|
//{
|
|
// userControl11.BackColor = System.Drawing.Color.Cyan;
|
|
//}
|
|
//if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203207")
|
|
//{
|
|
// userControl12.BackColor = System.Drawing.Color.Cyan;
|
|
//}
|
|
//变更零件号后
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203007")
|
|
{
|
|
userControl11.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203207")
|
|
{
|
|
userControl12.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477205006")
|
|
{
|
|
userControl13.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477305303")
|
|
{
|
|
userControl14.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477305503")
|
|
{
|
|
userControl15.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477305703")
|
|
{
|
|
userControl16.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
//if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203107")
|
|
//{
|
|
// userControl17.BackColor = System.Drawing.Color.Cyan;
|
|
//}
|
|
//if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203307")
|
|
//{
|
|
// userControl18.BackColor = System.Drawing.Color.Cyan;
|
|
//}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203107")
|
|
{
|
|
userControl17.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203307")
|
|
{
|
|
userControl18.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477205106")
|
|
{
|
|
userControl19.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477305403")
|
|
{
|
|
userControl110.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203307")
|
|
{
|
|
userControl111.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477205106")
|
|
{
|
|
userControl112.BackColor = System.Drawing.Color.Cyan;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 判断是否需要打印箱单
|
|
|
|
part = textBox2.Text.Substring(0,textBox2.Text.IndexOf("."));
|
|
dt1 = mbll.SearchPartName(part);
|
|
if (dt1 != null && dt1.Rows.Count > 0)
|
|
{
|
|
maxCount= Convert.ToInt32(dt1.Rows[0]["PackCount"].ToString());
|
|
partName = dt1.Rows[0]["PartName2"].ToString();
|
|
}
|
|
else
|
|
{
|
|
maxCount = 0;
|
|
}
|
|
|
|
DataTable boxdt = rbll.SearchBoxByPart(part);
|
|
if (boxdt != null && boxdt.Rows.Count > 0)
|
|
{
|
|
box= boxdt.Rows[0]["BoxNo"].ToString();
|
|
}
|
|
else
|
|
{
|
|
box = "";
|
|
}
|
|
|
|
batch = DateTime.Now.ToString("yyyy-MM-dd").Substring(2, 2) + DateTime.Now.ToString("yyyy-MM-dd").Substring(5, 2) + DateTime.Now.ToString("yyyy-MM-dd").Substring(8, 2);
|
|
if (box != "")
|
|
{
|
|
#region 判断装箱单是否已满
|
|
|
|
DataTable indt = rbll.SearchCountByBox(box);
|
|
if (indt != null && indt.Rows.Count > 0)
|
|
{
|
|
currentCount = Convert.ToInt32(indt.Rows[0]["sum"].ToString());
|
|
}
|
|
else
|
|
{
|
|
currentCount = 0;
|
|
}
|
|
|
|
if (currentCount == 0 || currentCount >= maxCount)
|
|
{
|
|
#region 生成装箱单
|
|
|
|
if (box.Substring(12, 6) == batch)
|
|
{
|
|
newBox = box.Substring(0,box.Length-6) + (Convert.ToInt32(box.Substring(box.Length - 6, 6)) + 1).ToString().PadLeft(6, '0');
|
|
newBatch = batch;
|
|
}
|
|
else
|
|
{
|
|
newBox = textBox2.Text.Substring(0,11) + "." + batch + "." + "000001";
|
|
newBatch = box.Substring(12, 6);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 保存装箱单并打印
|
|
|
|
md.ID = Guid.NewGuid().ToString();
|
|
md.BoxNo = newBox;
|
|
md.PartNo = part;
|
|
md.PartName = partName;
|
|
md.BatchNo = newBatch;
|
|
md.Flag = 0;
|
|
md.Validity = "3个月";
|
|
md.ValidityDate = "从" + DateTime.Now.ToString("yyyy-MM-dd") + "到" +
|
|
DateTime.Now.AddMonths(3).ToString("yyyy-MM-dd");
|
|
|
|
if (part == "A2477203007"||part=="A2477305303" ||part=="A2477203107" ||part=="A247730540")
|
|
{
|
|
md.Des = "装饰条-高光电镀";
|
|
}
|
|
|
|
if (part == "A2477203207" || part == "A2477305503" || part == "A2477203307" || part == "A2477305603")
|
|
{
|
|
md.Des = "装饰条-喷涂";
|
|
}
|
|
|
|
if (part == "A2477205006" || part == "A2477305703" || part == "A2477205106" || part == "A2477305803")
|
|
{
|
|
md.Des = "装饰条-珍珠镍电镀";
|
|
}
|
|
|
|
bll.AddInfo(md);
|
|
#region 打印装箱单
|
|
|
|
if (part == "A2477209103" || part == "A2477209203" || part == "A2477209305" || part == "A2477203007" || part == "A2477203207" || part == "A2477205006")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 左侧前门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
|
|
if (part == "A2477309401" || part == "A2477309501" || part == "A2477300203" || part == "A2477305303" || part == "A2477305503" || part == "A2477305703")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 左侧后门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (part == "A2477209303" || part == "A2477209403" || part == "A2477207505" || part == "A2477203107" || part == "A2477203307" || part == "A2477205106")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 右侧前门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477309601" || part == "A2477309701" || part == "A2477300303" || part == "A2477305403" || part == "A2477305603" || part == "A2477305803")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 右侧后门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850022")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 前部左侧轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850222")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 后部左侧轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850122")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 前部右侧轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850322")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 后部右侧后轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477309400")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 后部左侧前轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477309600")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 后部右侧前轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477900788" || part == "A2477901300")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 后部左侧扰流板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477900888" || part == "A2477901400")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 后部右侧扰流板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
report.Register("");
|
|
report.ConnectionString = ConfigurationManager.ConnectionStrings["report"].ToString();
|
|
report.Print(false);
|
|
|
|
bll.UpdateInfo(md);
|
|
|
|
#endregion
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = boxBll.searchBox(part);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
newBox = textBox2.Text.Substring(0, 11) + "." + batch + "." + "000001";
|
|
newBatch = batch;
|
|
#region 保存装箱单并打印
|
|
|
|
md.ID = Guid.NewGuid().ToString();
|
|
md.BoxNo = newBox;
|
|
md.PartNo = part;
|
|
md.PartName = partName;
|
|
md.BatchNo = newBatch;
|
|
md.Flag = 0;
|
|
|
|
bll.AddInfo(md);
|
|
#region 打印装箱单
|
|
|
|
//if (part == "A2477209103" || part == "A2477209203" || part == "A2477209305" || part == "A2477203007" || part == "A2477203207" || part == "A2477205006")
|
|
//{
|
|
// report.LoadFromFile(@"D:\X247 左侧前门板装箱单.grf");
|
|
// report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
//}
|
|
|
|
if (part == "A2477209103" || part == "A2477209203" || part == "A2477209305" || part == "A2477203007" || part == "A2477203207" || part == "A2477205006")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 左侧前门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (part == "A2477309401" || part == "A2477309501" || part == "A2477300203" || part == "A2477305303" || part == "A2477305503" || part == "A2477305703")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 左侧后门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
//if (part == "A2477209303" || part == "A2477209403" || part == "A2477207505" || part == "A2477203107" || part == "A2477203307" || part == "A2477205106")
|
|
//{
|
|
// report.LoadFromFile(@"D:\New\X247 右侧前门板装箱单.grf");
|
|
// report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
//}
|
|
|
|
if (part == "A2477209303" || part == "A2477209403" || part == "A2477207505" || part == "A2477203107" || part == "A2477203307" || part == "A2477205106")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 右侧前门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477309601" || part == "A2477309701" || part == "A2477300303" || part == "A2477305403" || part == "A2477305603" || part == "A2477305803")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 右侧后门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850022")
|
|
{
|
|
report.LoadFromFile(@"D:\X247 前部左侧轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850222")
|
|
{
|
|
report.LoadFromFile(@"D:\X247 后部左侧轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850122")
|
|
{
|
|
report.LoadFromFile(@"D:\X247 前部右侧轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850322")
|
|
{
|
|
report.LoadFromFile(@"D:\X247 后部右侧后轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477309400")
|
|
{
|
|
report.LoadFromFile(@"D:\X247 后部左侧前轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477309600")
|
|
{
|
|
report.LoadFromFile(@"D:\X247 后部右侧前轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477900788" || part == "A2477901300")
|
|
{
|
|
report.LoadFromFile(@"D:\X247 后部左侧扰流板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477900888" || part == "A2477901400")
|
|
{
|
|
report.LoadFromFile(@"D:\X247 后部右侧扰流板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
report.Register("");
|
|
report.ConnectionString = ConfigurationManager.ConnectionStrings["report"].ToString();
|
|
report.Print(false);
|
|
|
|
bll.UpdateInfo(md);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
textBox1.Enabled = true;
|
|
textBox1.Focus();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
}
|
|
|
|
private void textBox1_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
MistakeBLL mbll=new MistakeBLL();
|
|
RecordBLL rbll=new RecordBLL();
|
|
RecordModel md=new RecordModel();
|
|
BoxBLL boxBll=new BoxBLL();
|
|
|
|
int maxCount = 0,currentCount=0;
|
|
bool flag;
|
|
|
|
try
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
if (textBox1.Text.Trim() == "")
|
|
{
|
|
MessageBox.Show("请扫描箱单!", "提示", MessageBoxButtons.OK);
|
|
textBox1.Focus();
|
|
return;
|
|
}
|
|
|
|
#region 判断箱单是否存在
|
|
|
|
DataTable IsBoxdt = boxBll.SearchBoxIsExsit(textBox1.Text.Trim());
|
|
if (IsBoxdt != null && IsBoxdt.Rows.Count > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("此箱单不存在!", "提示", MessageBoxButtons.OK);
|
|
textBox1.Focus();
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region 判断装箱单是否已满
|
|
|
|
DataTable dt1 = mbll.SearchPartName(textBox1.Text.Substring(0, textBox1.Text.IndexOf(".")));
|
|
if (dt1 != null && dt1.Rows.Count > 0)
|
|
{
|
|
maxCount = Convert.ToInt32(dt1.Rows[0]["PackCount"].ToString());
|
|
}
|
|
else
|
|
{
|
|
maxCount = 0;
|
|
}
|
|
|
|
|
|
DataTable dt2 = rbll.SearchCountByBox(textBox1.Text.Trim());
|
|
if (dt2 != null && dt2.Rows.Count > 0)
|
|
{
|
|
currentCount = Convert.ToInt32(dt2.Rows[0]["sum"].ToString());
|
|
}
|
|
else
|
|
{
|
|
currentCount = 0;
|
|
}
|
|
|
|
if (currentCount == maxCount)
|
|
{
|
|
MessageBox.Show("此装箱单已满!", "提示", MessageBoxButtons.OK);
|
|
textBox1.Focus();
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) !=
|
|
textBox1.Text.Substring(0, textBox1.Text.IndexOf(".")))
|
|
{
|
|
MessageBox.Show("总成和箱子不匹配!", "提示", MessageBoxButtons.OK);
|
|
textBox1.Focus();
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
#region 入箱
|
|
|
|
md.PartNo2 = textBox2.Text.Trim();
|
|
md.BoxNo = textBox1.Text.Trim();
|
|
md.Flag = 1;
|
|
flag = rbll.updateBoxInfo(md);
|
|
|
|
#endregion
|
|
|
|
if (flag == true)
|
|
{
|
|
#region 颜色
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203007")
|
|
{
|
|
userControl11.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203207")
|
|
{
|
|
userControl12.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477205006")
|
|
{
|
|
userControl13.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477305303")
|
|
{
|
|
userControl14.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477305503")
|
|
{
|
|
userControl15.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477305703")
|
|
{
|
|
userControl16.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203107")
|
|
{
|
|
userControl17.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203307")
|
|
{
|
|
userControl18.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477205106")
|
|
{
|
|
userControl19.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203107")
|
|
{
|
|
userControl110.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477203307")
|
|
{
|
|
userControl111.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
if (textBox2.Text.Substring(0, textBox2.Text.IndexOf(".")) == "A2477205106")
|
|
{
|
|
userControl112.BackColor = System.Drawing.Color.Chartreuse;
|
|
}
|
|
#endregion
|
|
|
|
textBox1.Enabled = false;
|
|
textBox2.Focus();
|
|
textBox2.Text = "";
|
|
textBox1.Text = "";
|
|
InitUC();
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
RecordBLL bll = new RecordBLL();
|
|
RecordModel md = new RecordModel();
|
|
|
|
bool flag;
|
|
try
|
|
{
|
|
DialogResult result = MessageBox.Show("确认报废?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
|
|
if (result == DialogResult.OK)
|
|
{
|
|
|
|
md.Flag = 2;
|
|
md.PartNo2 = textBox2.Text.Trim();
|
|
|
|
flag = bll.DelInfo(md);
|
|
if (flag == false)
|
|
{
|
|
MessageBox.Show("报废失败!", "提示", MessageBoxButtons.OK);
|
|
textBox2.Focus();
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("报废成功!", "提示", MessageBoxButtons.OK);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
}
|
|
|
|
private void button4_Click(object sender, EventArgs e)
|
|
{
|
|
panel1.Visible = true;
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
BoxBLL bll=new BoxBLL();
|
|
BoxModel md=new BoxModel();
|
|
string part = "";
|
|
GridppReport report = new GridppReport();
|
|
|
|
try
|
|
{
|
|
if (textBox3.Text.Trim() == "")
|
|
{
|
|
MessageBox.Show("请输入箱单!", "提示", MessageBoxButtons.OK);
|
|
textBox3.Focus();
|
|
return;
|
|
}
|
|
|
|
DataTable dt = bll.SearchBoxIsExsit(textBox3.Text.Trim());
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
#region 补打
|
|
|
|
md.ID = Guid.NewGuid().ToString();
|
|
md.BoxNo = dt.Rows[0]["BoxNo"].ToString();
|
|
md.PartNo = dt.Rows[0]["PartNo"].ToString();
|
|
part = md.PartNo;
|
|
md.PartName = dt.Rows[0]["PartName"].ToString();
|
|
md.BatchNo = dt.Rows[0]["BatchNo"].ToString();
|
|
md.Des = dt.Rows[0]["Des"].ToString();
|
|
md.Flag = 1;
|
|
md.Validity = dt.Rows[0]["Validity"].ToString();
|
|
md.ValidityDate = dt.Rows[0]["ValidityDate"].ToString();
|
|
|
|
bll.AddInfo(md);
|
|
|
|
#endregion
|
|
|
|
#region 打印装箱单
|
|
|
|
if (part == "A2477209103" || part == "A2477209203" || part == "A2477209305" || part == "A2477203007" || part == "A2477203207" || part == "A2477205006")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 左侧前门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
|
|
if (part == "A2477309401" || part == "A2477309501" || part == "A2477300203" || part == "A2477305303" || part == "A2477305503" || part == "A2477305703")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 左侧后门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (part == "A2477209303" || part == "A2477209403" || part == "A2477207505" || part == "A2477203107" || part == "A2477203307" || part == "A2477205106")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 右侧前门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477309601" || part == "A2477309701" || part == "A2477300303" || part == "A2477305403" || part == "A2477305603" || part == "A2477305803")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 右侧后门板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850022")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 前部左侧轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850222")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 后部左侧轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850122")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 前部右侧轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850322")
|
|
{
|
|
report.LoadFromFile(@"D:\X247 后部右侧后轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477309400")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 后部左侧前轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477309600")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 后部右侧前轮眉装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477900788" || part == "A2477901300")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 后部左侧扰流板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2477900888" || part == "A2477901400")
|
|
{
|
|
report.LoadFromFile(@"D:\New\X247 后部右侧扰流板装箱单.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
report.Register("");
|
|
report.ConnectionString = ConfigurationManager.ConnectionStrings["report"].ToString();
|
|
report.Print(false);
|
|
|
|
bll.UpdateInfo(md);
|
|
}
|
|
|
|
else
|
|
{
|
|
MessageBox.Show("箱单不存在!", "提示", MessageBoxButtons.OK);
|
|
textBox3.Focus();
|
|
return;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
}
|
|
|
|
private void button3_Click(object sender, EventArgs e)
|
|
{
|
|
panel1.Visible = false;
|
|
}
|
|
|
|
private void button5_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
panel2.Visible = true;
|
|
this.listView1.Columns.Clear();
|
|
this.listView1.Clear();
|
|
this.listView1.Columns.Add("总成零件号", 300, HorizontalAlignment.Center);
|
|
this.listView1.Columns.Add("总成打印时间", 300, HorizontalAlignment.Center);
|
|
|
|
RecordBLL bll=new RecordBLL();
|
|
|
|
DataTable dt = bll.SearchState(1, 2, 0);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
ListViewItem lvi = new ListViewItem(dt.Rows[i]["PartNo2"].ToString());
|
|
lvi.SubItems.Add(dt.Rows[i]["CreateTime1"].ToString()); //后面添加的Item都为SubItems ,即为子项
|
|
listView1.Items.Add(lvi);
|
|
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
}
|
|
|
|
private void button6_Click(object sender, EventArgs e)
|
|
{
|
|
panel2.Visible = false;
|
|
}
|
|
|
|
private void button7_Click(object sender, EventArgs e)
|
|
{
|
|
panel3.Visible = true;
|
|
textBox4.Focus();
|
|
}
|
|
|
|
private void button9_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
panel3.Visible = true;
|
|
this.listView2.Columns.Clear();
|
|
this.listView2.Clear();
|
|
this.listView2.Columns.Add("总成零件号", 300, HorizontalAlignment.Center);
|
|
this.listView2.Columns.Add("总成打印时间", 300, HorizontalAlignment.Center);
|
|
|
|
string boxNo = textBox4.Text.Trim();
|
|
RecordBLL bll = new RecordBLL();
|
|
DataTable dt = bll.GetRecord(boxNo);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
ListViewItem lvi = new ListViewItem(dt.Rows[i]["PartNo2"].ToString());
|
|
lvi.SubItems.Add(dt.Rows[i]["CreateTime1"].ToString()); //后面添加的Item都为SubItems ,即为子项
|
|
listView2.Items.Add(lvi);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
}
|
|
|
|
private void button8_Click(object sender, EventArgs e)
|
|
{
|
|
panel3.Visible = false;
|
|
textBox2.Focus();
|
|
}
|
|
|
|
}
|
|
}
|
|
|