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.
517 lines
20 KiB
517 lines
20 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using gregn6Lib;
|
|
using MESClassLibrary.BLL.Log;
|
|
using MESClassLibrary.BLL.Mistake243;
|
|
using MESClassLibrary.BLL.Mistake247;
|
|
using MESClassLibrary.Model;
|
|
using RecordBLL = MESClassLibrary.BLL.Mistake243.RecordBLL;
|
|
|
|
namespace PurchingMistakeNew
|
|
{
|
|
public partial class FrmProduct_243 : Form
|
|
{
|
|
public FrmProduct_243()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void textBox4_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
|
|
|
|
if (textBox4.Text.Trim().Length != 12)
|
|
{
|
|
MessageBox.Show("订单号有误,请重新扫描!", "提示", MessageBoxButtons.OK);
|
|
textBox4.Focus();
|
|
return;
|
|
}
|
|
|
|
|
|
#region 判断订单号是否存在
|
|
|
|
if (initList()) return;
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
}
|
|
|
|
private bool initList()
|
|
{
|
|
Plan243BLL bll = new Plan243BLL();
|
|
int a = 0;
|
|
this.listView1.Items.Clear();
|
|
|
|
DataTable dt = bll.SearhByOrderNo(textBox4.Text.Trim());
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
#region 判断订单是否生产完成
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
if (Convert.ToInt32(dt.Rows[i]["IsFinish"].ToString()) == 1)
|
|
{
|
|
a += 1;
|
|
if (a == dt.Rows.Count)
|
|
{
|
|
MessageBox.Show("订单已完成,请扫描其他订单!", "提示", MessageBoxButtons.OK);
|
|
textBox4.Focus();
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ListViewItem lvi = new ListViewItem(dt.Rows[i]["OrderNo"].ToString());
|
|
lvi.SubItems.Add(dt.Rows[i]["PartNo"].ToString()); //后面添加的Item都为SubItems ,即为子项
|
|
lvi.SubItems.Add(dt.Rows[i]["PartName2"].ToString());
|
|
lvi.SubItems.Add(dt.Rows[i]["OrderCount"].ToString());
|
|
lvi.SubItems.Add(dt.Rows[i]["CompleteCount"].ToString());
|
|
listView1.Items.Add(lvi);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("订单号不存在,请重新扫描!", "提示", MessageBoxButtons.OK);
|
|
textBox4.Focus();
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
private void textBox1_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
if (textBox1.Text.Trim() != "")
|
|
{
|
|
textBox2.Enabled = true;
|
|
textBox2.Focus();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("请扫描设备配置码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
textBox1.Focus();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
}
|
|
|
|
private void textBox2_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string partNo = "", deviceNo = "", partsub = "", order = "";
|
|
int BoxCount = 0, type = 0, orderCount = 0, ActualCount = 0;
|
|
RecordBLL rbll = new RecordBLL();
|
|
Mistake243BLL bll = new Mistake243BLL();
|
|
Assembly243BLL abll = new Assembly243BLL();
|
|
Plan243BLL pbll = new Plan243BLL();
|
|
|
|
Assembly243Model md = new Assembly243Model();
|
|
RecordModel rmd = new RecordModel();
|
|
|
|
GridppReport report = new GridppReport();
|
|
|
|
string batchNo = "", newbatchNo = "";
|
|
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
#region 是否扫描单号
|
|
|
|
if (textBox4.Text.Trim() == "")
|
|
{
|
|
MessageBox.Show("请扫描计划单!", "提示", MessageBoxButtons.OK);
|
|
textBox4.Focus();
|
|
return;
|
|
}
|
|
|
|
if (VerifyHelper.ScanSjBarCodeFormat(textBox2.Text.Trim()) == false)
|
|
{
|
|
MessageBox.Show($"扫描条码[{textBox2.Text.Trim()}]格式错误!", "提示", MessageBoxButtons.OK);
|
|
textBox2.Text = "";
|
|
textBox2.Focus();
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
if (textBox2.Text.Trim().Length < 10)
|
|
{
|
|
MessageBox.Show("半成品条码有误,请重新扫描!", "提示", MessageBoxButtons.OK);
|
|
textBox2.Focus();
|
|
return;
|
|
}
|
|
|
|
#region 判断计划单里是否有此产品的生产计划并且是未完成
|
|
|
|
DataTable hdt = pbll.IsHavePlan(textBox2.Text.Trim().Substring(0, 10), textBox4.Text.Trim());
|
|
if (hdt != null && hdt.Rows.Count > 0)
|
|
{
|
|
order = hdt.Rows[0]["OrderNo"].ToString();
|
|
orderCount = Convert.ToInt32(hdt.Rows[0]["OrderCount"].ToString());
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("该零件已生产完成!", "提示", MessageBoxButtons.OK);
|
|
textBox2.Focus();
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
DataTable recorddt = rbll.SearchByPartNo1(textBox2.Text.Trim());
|
|
if (recorddt != null && recorddt.Rows.Count > 0)
|
|
{
|
|
MessageBox.Show("此半成品已装配过!", "提示", MessageBoxButtons.OK);
|
|
textBox2.Focus();
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
deviceNo = textBox1.Text.Trim();
|
|
partNo = textBox2.Text.Substring(0, 10);
|
|
|
|
#region 判断半成品和设备码是否匹配
|
|
|
|
DataTable dt = bll.IsMath(deviceNo, partNo);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
#region 根据半成品查找总成零件号
|
|
|
|
DataTable dt2 = bll.SearchByNo(partNo, deviceNo);
|
|
if (dt2 != null && dt2.Rows.Count > 0)
|
|
{
|
|
partsub = dt2.Rows[0]["PartNo2"].ToString();
|
|
|
|
#region 判断总成零件当前批次是否存在
|
|
|
|
newbatchNo = 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);
|
|
|
|
DataTable partdt =
|
|
abll.searchPartNo(dt2.Rows[0]["PartNo2"].ToString() + "." + newbatchNo);
|
|
if (partdt != null && partdt.Rows.Count > 0)
|
|
{
|
|
md.PartNo = partdt.Rows[0]["PartNo"].ToString()
|
|
.Substring(0, partdt.Rows[0]["PartNo"].ToString().Length - 6) +
|
|
(Convert.ToInt32(partdt.Rows[0]["PartNo"].ToString()
|
|
.Substring(partdt.Rows[0]["PartNo"].ToString().Length - 6, 6)) + 1)
|
|
.ToString()
|
|
.PadLeft(6, '0');
|
|
}
|
|
else
|
|
{
|
|
md.PartNo = dt2.Rows[0]["PartNo2"].ToString() + "." + newbatchNo + "." + "000001";
|
|
}
|
|
|
|
#endregion
|
|
|
|
md.PartName = dt2.Rows[0]["PartName2"].ToString();
|
|
|
|
#region 保存总成条码
|
|
|
|
md.ID = Guid.NewGuid().ToString();
|
|
|
|
md.BatchNo = 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);
|
|
|
|
#region 根据半成品零件号判断总成类型、总成条码模板、打印机
|
|
|
|
#region 轮眉
|
|
|
|
if (partNo == "1230005988")
|
|
{
|
|
md.PartType = "X243 前部左侧轮眉";
|
|
type = 3;
|
|
report.LoadFromFile(@"D:\X243 前部左侧轮眉.grf");
|
|
|
|
report.Printer.PrinterName =
|
|
ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (partNo == "1230002615")
|
|
{
|
|
md.PartType = "X243 后部左侧轮眉";
|
|
type = 3;
|
|
report.LoadFromFile(@"D:\X243 后部左侧轮眉.grf");
|
|
|
|
report.Printer.PrinterName =
|
|
ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (partNo == "1230005989")
|
|
{
|
|
md.PartType = "X243 前部右侧轮眉";
|
|
type = 4;
|
|
report.LoadFromFile(@"D:\X243 前部右侧轮眉.grf");
|
|
|
|
report.Printer.PrinterName =
|
|
ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (partNo == "1230002617")
|
|
{
|
|
md.PartType = "X243 右侧后部后轮眉";
|
|
type = 4;
|
|
|
|
report.LoadFromFile(@"D:\X243 右侧后部后轮眉.grf");
|
|
|
|
report.Printer.PrinterName =
|
|
ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
md.Color = "通用";
|
|
md.ColorNo = "";
|
|
md.TapeBatchNo = md.BatchNo;
|
|
md.Validity = "3个月";
|
|
md.ValidityDate = "从" + DateTime.Now.ToString("yyyy-MM-dd") + "到" +
|
|
DateTime.Now.AddMonths(3).ToString("yyyy-MM-dd");
|
|
md.Flag = 0;
|
|
abll.AddInfo(md);
|
|
#endregion
|
|
|
|
#region 打印总成条码
|
|
|
|
report.Register("");
|
|
report.ConnectionString = ConfigurationManager.ConnectionStrings["report"].ToString();
|
|
report.Print(false);
|
|
abll.UpdateInfo(md);
|
|
|
|
#endregion
|
|
|
|
#region 更新订单完成数
|
|
|
|
pbll.UpdateCount(partsub, order);
|
|
|
|
#endregion
|
|
|
|
#region 保存记录
|
|
|
|
rmd.ID = Guid.NewGuid().ToString();
|
|
rmd.PartNo1 = textBox2.Text.Trim();
|
|
rmd.PartNo2 = md.PartNo;
|
|
rmd.Type = type;
|
|
rbll.AddInfo(rmd);
|
|
|
|
#endregion
|
|
|
|
textBox1.Focus();
|
|
textBox2.Enabled = false;
|
|
textBox1.Text = "";
|
|
textBox2.Text = "";
|
|
initData();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("匹配失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
}
|
|
|
|
public void initData()
|
|
{
|
|
string[] part =
|
|
{
|
|
"A2438808501", "A2478850222", "A2438808601", "A2478850322"
|
|
};
|
|
|
|
string[] sum = new string[4];
|
|
DataTable dt = null;
|
|
RecordBLL bll = new RecordBLL();
|
|
string 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);
|
|
|
|
try
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
dt = bll.GetCount(part[i], batch);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
sum[i] = dt.Rows[0]["sum"].ToString();
|
|
}
|
|
else
|
|
{
|
|
sum[i] = "";
|
|
}
|
|
}
|
|
|
|
#region
|
|
|
|
uc1.PartInfo = "A2438808501 X243 前部左侧轮眉总成";
|
|
uc2.PartInfo = "A2478850222 X243&X247 后部左侧后轮眉总成";
|
|
uc3.PartInfo = "A2438808601 X243 前部右侧轮眉总成";
|
|
uc4.PartInfo = "A2478850322 X243&X247 后部右侧后轮眉总成";
|
|
|
|
uc1.Sum = sum[0];
|
|
uc2.Sum = sum[1];
|
|
uc3.Sum = sum[2];
|
|
uc4.Sum = sum[3];
|
|
|
|
#endregion
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
}
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Assembly243BLL bll = new Assembly243BLL();
|
|
Assembly243Model md = new Assembly243Model();
|
|
string part = "";
|
|
GridppReport report = new GridppReport();
|
|
|
|
if (textBox3.Text.Trim() == "")
|
|
{
|
|
MessageBox.Show("总成条码不能为空!", "提示", MessageBoxButtons.OK);
|
|
textBox3.Focus();
|
|
return;
|
|
}
|
|
|
|
DataTable dt = bll.searchPartNo(textBox3.Text.Trim());
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
#region 补打
|
|
|
|
md.ID = Guid.NewGuid().ToString();
|
|
md.PartNo = textBox3.Text.Trim();
|
|
md.PartName = dt.Rows[0]["PartName"].ToString();
|
|
md.BatchNo = dt.Rows[0]["BatchNo"].ToString();
|
|
md.Color = dt.Rows[0]["Color"].ToString();
|
|
md.ColorNo = dt.Rows[0]["ColorNo"].ToString();
|
|
md.PartType = dt.Rows[0]["PartType"].ToString();
|
|
md.TapeBatchNo = dt.Rows[0]["TapeBatchNo"].ToString();
|
|
md.Validity = dt.Rows[0]["Validity"].ToString();
|
|
md.ValidityDate = dt.Rows[0]["ValidityDate"].ToString();
|
|
md.Des = dt.Rows[0]["Des"].ToString();
|
|
md.Flag = 1;
|
|
|
|
bll.AddInfo(md);
|
|
|
|
part = textBox3.Text.Trim().Substring(0, textBox3.Text.Trim().IndexOf("."));
|
|
|
|
#region 轮眉
|
|
|
|
if (part == "A2438808501")
|
|
{
|
|
md.PartType = "X243 前部左侧轮眉";
|
|
report.LoadFromFile(@"D:\X247 前部左侧轮眉.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850222")
|
|
{
|
|
md.PartType = "X243 后部左侧后轮眉";
|
|
report.LoadFromFile(@"D:\X243 后部左侧后轮眉.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
|
}
|
|
|
|
if (part == "A2438808601")
|
|
{
|
|
md.PartType = "X243 前部右侧轮眉";
|
|
report.LoadFromFile(@"D:\X243 前部右侧轮眉.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
if (part == "A2478850322")
|
|
{
|
|
md.PartType = "X243 右侧后部后轮眉";
|
|
report.LoadFromFile(@"D:\X243 右侧后部后轮眉.grf");
|
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#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)
|
|
{
|
|
textBox3.Text = "";
|
|
panel1.Visible = false;
|
|
}
|
|
|
|
private void FrmProduct_243_Load(object sender, EventArgs e)
|
|
{
|
|
Control.CheckForIllegalCrossThreadCalls = false;
|
|
textBox1.Enabled = true;
|
|
textBox2.Enabled = false;
|
|
panel1.Visible = false;
|
|
initData();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
panel1.Visible = true;
|
|
}
|
|
}
|
|
}
|
|
|