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
6 months ago
|
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.Mistake247;
|
||
|
using MESClassLibrary.Model;
|
||
|
|
||
|
namespace PurchingMistakeNew
|
||
|
{
|
||
|
public partial class Form6 : Form
|
||
|
{
|
||
|
public Form6()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
private void Form6_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
Control.CheckForIllegalCrossThreadCalls = false;
|
||
|
textBox1.Enabled = true;
|
||
|
textBox2.Enabled = false;
|
||
|
panel1.Visible = false;
|
||
|
textBox1.Text = "";
|
||
|
textBox2.Text = "";
|
||
|
initData();
|
||
|
}
|
||
|
|
||
|
public void initData()
|
||
|
{
|
||
|
string[] part =
|
||
|
{
|
||
|
"A2477309400", "A2477309600"
|
||
|
};
|
||
|
|
||
|
string[] sum = new string[2];
|
||
|
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);
|
||
|
//string batch = "191111";
|
||
|
|
||
|
try
|
||
|
{
|
||
|
for (int i = 0; i < 2; i++)
|
||
|
{
|
||
|
dt = bll.GetCount(part[i], batch);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
sum[i] = dt.Rows[0]["sum"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sum[i] = "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
uc1.PartInfo = "A2477309400 后部左侧前轮眉总成";
|
||
|
uc2.PartInfo = "A2477309600 后部右侧前轮眉总成";
|
||
|
|
||
|
uc1.Sum = sum[0];
|
||
|
uc2.Sum = sum[1];
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void textBox1_KeyDown(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
MistakeBLL bll = new MistakeBLL();
|
||
|
BoxBLL bbll = new BoxBLL();
|
||
|
RecordBLL rbll = new RecordBLL();
|
||
|
|
||
|
BoxModel bmd = new BoxModel();
|
||
|
|
||
|
string partno = "", PartName = "", BoxNo = "", newBoxNo = "", banBatchNo = "", newBatchNo = "";
|
||
|
int packCount = 0;
|
||
|
|
||
|
|
||
|
GridppReport report = new GridppReport();
|
||
|
|
||
|
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();
|
||
|
MistakeBLL bll = new MistakeBLL();
|
||
|
AssemblyBLL abll = new AssemblyBLL();
|
||
|
Plan247BLL pbll = new Plan247BLL();
|
||
|
|
||
|
AssemblyModel md = new AssemblyModel();
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
if (textBox2.Text.Trim().Length < 10)
|
||
|
{
|
||
|
MessageBox.Show("半成品条码有误,请重新扫描!", "提示", MessageBoxButtons.OK);
|
||
|
textBox2.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
5 months ago
|
if (VerifyHelper.ScanSjBarCodeFormat(textBox2.Text.Trim()) == false)
|
||
|
{
|
||
|
MessageBox.Show($"扫描条码[{textBox2.Text.Trim()}]格式错误!", "提示", MessageBoxButtons.OK);
|
||
|
textBox2.Text = "";
|
||
|
textBox2.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
6 months ago
|
#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
|
||
|
|
||
|
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();
|
||
|
LogHelper.WriteLog("PartSub:" + partsub);
|
||
|
|
||
|
#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);
|
||
|
LogHelper.WriteLog("NewBatch:" + newbatchNo);
|
||
|
|
||
|
try
|
||
|
{
|
||
|
DataTable partdt =
|
||
|
abll.searchPartNo(partsub + "." + newbatchNo);
|
||
|
if (partdt != null && partdt.Rows.Count > 0)
|
||
|
{
|
||
|
string tmpPartNo = partdt.Rows[0]["PartNo"].ToString();
|
||
|
//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');
|
||
|
md.PartNo = tmpPartNo.Substring(0, tmpPartNo.Length - 6) +
|
||
|
(Convert.ToInt32(tmpPartNo.Substring(partdt.Rows[0]["PartNo"].ToString().Length - 6, 6)) + 1)
|
||
|
.ToString()
|
||
|
.PadLeft(6, '0');
|
||
|
LogHelper.WriteLog("有记录:" + md.PartNo);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
md.PartNo = partsub + "." + newbatchNo + "." + "000001";
|
||
|
LogHelper.WriteLog("无记录:" + md.PartNo);
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLog("报catch");
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
//LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
||
|
MessageBox.Show("连接数据库失败!");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 根据总成零件号获取总成描述
|
||
|
if (partsub == "A2477204706" || partsub == "A2477305403" || partsub == "A2477204606" ||
|
||
|
partsub == "A2477305303")
|
||
|
{
|
||
|
md.Des = "装饰条-高光电镀";
|
||
|
}
|
||
|
|
||
|
if (partsub == "A2477204906" || partsub == "A2477305603" || partsub == "A2477204806" ||
|
||
|
partsub == "A2477305503")
|
||
|
{
|
||
|
md.Des = "装饰条-喷涂";
|
||
|
}
|
||
|
|
||
|
if (partsub == "A2477205106" || partsub == "A2477305803" || partsub == "A2477205006" ||
|
||
|
partsub == "A2477305703")
|
||
|
{
|
||
|
md.Des = "装饰条-珍珠镍电镀";
|
||
|
}
|
||
|
#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 根据半成品零件号判断总成类型、总成条码模板、打印机
|
||
|
|
||
|
if (partNo == "1230002619")
|
||
|
{
|
||
|
md.PartType = "X247 后部左侧前轮眉";
|
||
|
|
||
|
type = 5;
|
||
|
report.LoadFromFile(@"D:\X247 后部左侧前轮眉.grf");
|
||
|
|
||
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
||
|
}
|
||
|
|
||
|
if (partNo == "1230002621")
|
||
|
{
|
||
|
md.PartType = "X247 后部右侧前轮眉";
|
||
|
|
||
|
type = 5;
|
||
|
|
||
|
report.LoadFromFile(@"D:\X247 后部右侧前轮眉.grf");
|
||
|
|
||
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer2"].ToString();
|
||
|
}
|
||
|
|
||
|
|
||
|
#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
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("匹配失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
textBox1.Text = "";
|
||
|
textBox2.Text = "";
|
||
|
textBox2.Enabled = false;
|
||
|
textBox1.Focus();
|
||
|
//bindData();
|
||
|
initData();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void button1_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
panel1.Visible = true;
|
||
|
}
|
||
|
|
||
|
private void button2_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
AssemblyBLL bll = new AssemblyBLL();
|
||
|
AssemblyModel md = new AssemblyModel();
|
||
|
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("."));
|
||
|
|
||
|
if (part == "A2477309400")
|
||
|
{
|
||
|
md.PartType = "X247 后部左侧前轮眉";
|
||
|
//report.LoadFromFile(@"D:\X247 后部左侧轮眉.grf");
|
||
|
report.LoadFromFile(@"D:\X247 后部左侧前轮眉.grf");
|
||
|
report.Printer.PrinterName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
||
|
}
|
||
|
|
||
|
if (part == "A2477309600")
|
||
|
{
|
||
|
md.PartType = "X247 后部右侧前轮眉";
|
||
|
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);
|
||
|
|
||
|
|
||
|
}
|
||
|
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 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()
|
||
|
{
|
||
|
Plan247BLL bll = new Plan247BLL();
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|