注塑喷涂
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.
 
 
 
 
 

475 lines
18 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.Windows.Forms;
using gregn6Lib;
using MESClassLibrary.BLL.Log;
using PunchAndWeld.DataSouce;
namespace PunchAndWeld
{
public partial class FrmProScreen_WheelBrow_New : Form
{
public FrmProScreen_WheelBrow_New()
{
InitializeComponent();
}
string[] partNo1 = new string[10];
private string planID = "";
private string zcPartNo = "",zcPartName="";
string stationNo = "", stationId = "";
private void txtScanPlan_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.KeyCode == Keys.Enter)
{
if (string.IsNullOrWhiteSpace(txtScanPlan.Text.Trim()))
{
MessageBox.Show("订单号不能为空!", "提示", MessageBoxButtons.OK);
txtScanPlan.SelectAll();
txtScanPlan.Focus();
return;
}
#region 判断订单号是否存在
if (InitList()) return;
#endregion
InitData();
textBox1.Focus();
}
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
}
}
private bool InitList()
{
int a = 0;
this.listView1.Items.Clear();
DataTable dt = ProScreenFunc.GetPlanInfoByOrderNo(txtScanPlan.Text.Trim());
if (dt != null && dt.Rows.Count > 0)
{
#region 判断订单是否生产完成
partNo1 = new string[dt.Rows.Count];
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);
txtScanPlan.Focus();
return true;
}
}
else
{
partNo1[i] = dt.Rows[i]["PartNo"].ToString();
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]["ProductName"].ToString());
lvi.SubItems.Add(dt.Rows[i]["OrderCount"].ToString());
listView1.Items.Add(lvi);
}
}
#endregion
}
else
{
MessageBox.Show("订单号不存在,请重新扫描!", "提示", MessageBoxButtons.OK);
textBox2.SelectAll();
textBox2.Focus();
return true;
}
return false;
}
public void InitData()
{
string[] part =
{
"A2548850000", "A2548850400", "A2548850200", "A2548850600"
};
string[] sum = new string[4];
try
{
for (int i = 0; i < 4; i++)
{
sum[i] = ProScreenFunc.SumByPartNo(txtScanPlan.Text.Trim(), part[i]);
}
#region
uc1.PartInfo = "A2548850000 前部左侧轮眉";
uc2.PartInfo = "A2548850400 后部左侧轮眉";
uc3.PartInfo = "A2548850200 前部右侧轮眉";
uc4.PartInfo = "A2548850600 后部右侧轮眉";
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 textBox1_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.KeyCode == Keys.Enter)
{
if (txtScanPlan.Text.Trim() == "")
{
MessageBox.Show("请扫描计划单!", "提示", MessageBoxButtons.OK);
txtScanPlan.Focus();
return;
}
if (string.IsNullOrWhiteSpace(textBox1.Text.Trim()))
{
MessageBox.Show("配置码不能为空,请重新输入!", "提示", MessageBoxButtons.OK);
textBox1.SelectAll();
textBox1.Focus();
return;
}
if (!ProScreenFunc.CheckDeviceNo(textBox1.Text.Trim(),stationId))
{
MessageBox.Show("配置码有误,请重新输入!", "提示", MessageBoxButtons.OK);
textBox1.SelectAll();
textBox1.Focus();
return;
}
textBox2.Enabled = true;
textBox2.Focus();
}
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
}
}
private void FrmProScreen_WheelBrow_New_Load(object sender, EventArgs e)
{
txtScanPlan.Focus();
textBox2.Enabled = false;
panel1.Visible = false;
stationNo = ConfigurationManager.AppSettings["StationNo"].ToString();
stationId = ProScreenFunc.GetStationId(stationNo);
}
private void textBox2_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.KeyCode == Keys.Enter)
{
if (txtScanPlan.Text.Trim() == "")
{
MessageBox.Show("请扫描计划单!", "提示", MessageBoxButtons.OK);
txtScanPlan.Focus();
return;
}
if (string.IsNullOrWhiteSpace(textBox2.Text.Trim()))
{
MessageBox.Show("半成品条码不能为空,请重新输入!", "提示", MessageBoxButtons.OK);
textBox2.SelectAll();
textBox2.Focus();
return;
}
if (textBox2.Text.Trim().Length != 20)
{
MessageBox.Show("半成品条码位数有误,请重新扫描!");
textBox1.SelectAll();
return;
}
if (ProScreenFunc.IsPunch(textBox2.Text.Trim(), stationNo))
{
MessageBox.Show("半成品条码已经装配过,请重新扫描!");
textBox2.SelectAll();
textBox2.Focus();
return;
}
#region 根据半成品查询总成零件号
DataTable dt= ProScreenFunc.ZcPartNo(textBox2.Text.Substring(0,10));
if (dt != null && dt.Rows.Count > 0)
{
zcPartNo = dt.Rows[0]["PartNo"].ToString();
zcPartName = dt.Rows[0]["ProductName"].ToString();
}
#endregion
#region 查询完成数==计划数,如果相等,就不允许扫描
string sum = ProScreenFunc.SumByPartNo(txtScanPlan.Text.Trim(), zcPartNo);
string planCount = ProScreenFunc.PlanCountByPartNo(txtScanPlan.Text.Trim(), zcPartNo);
if (int.Parse(planCount) <= int.Parse(sum))
{
MessageBox.Show("该零件已生产完成!");
textBox2.SelectAll();
return;
}
else
{
#region 校验配置码和半成品码是否匹配
if (!ProScreenFunc.IsCheck(textBox1.Text.Trim(), textBox2.Text.Substring(0,10)))
{
MessageBox.Show("配置码和半成品条码不匹配,请重新扫描!");
textBox2.SelectAll();
return;
}
else
{
#region 保存条码
string newbatch = 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 oldPartNo = ProScreenFunc.LastNo(zcPartNo + "." + newbatch);
string newPartNo =oldPartNo==""?zcPartNo + "." + newbatch+".000001": oldPartNo
.Substring(0, oldPartNo.Length - 6) +
(Convert.ToInt32(oldPartNo
.Substring(oldPartNo.Length - 6, 6)) + 1)
.ToString()
.PadLeft(6, '0');
string validityDate = "从" + DateTime.Now.ToString("yyyy-MM-dd") + "到" +
DateTime.Now.AddMonths(3).ToString("yyyy-MM-dd");
Assembly1 md = new Assembly1();
md.ID = Guid.NewGuid().ToString();
md.PartNo = newPartNo;
md.PartName = zcPartName;
md.Color = "通用";
md.BatchNo = newbatch;
md.BarCode = textBox2.Text.Trim();
md.TapeBatchNo = md.BatchNo;
md.Validity = "3个月";
md.ValidityDate = validityDate;
md.Flag = 0;
md.PartType = "";
md.Des = "";
ProScreenFunc.AddAssembly(md);
#endregion
#region 打印
string filename = AppDomain.CurrentDomain.BaseDirectory + "aa.grf";
DataTable headTable = new DataTable();
headTable.Columns.Add("PartNo");
headTable.Columns.Add("PartName");
headTable.Columns.Add("BatchNo");
headTable.Columns.Add("ValidityDate");
DataRow row = headTable.NewRow();
row["PartNo"] = newPartNo;
row["PartName"] = zcPartName;
row["BatchNo"] = newbatch;
row["ValidityDate"] = validityDate;
string reportName = "";
if (newPartNo.Substring(0, 11) == "A2548850000" ||
newPartNo.Substring(0, 11) == "A2548850600")
{
reportName = ConfigurationManager.AppSettings["PrinterName"];
}
else
{
reportName = ConfigurationManager.AppSettings["PrinterName1"];
}
headTable.Rows.Add(row);
ReportHelper rp = new ReportHelper(filename, headTable, null,
(int)GRPaperOrientation.grpoDefault, 1, reportName);
rp.Report.Print(false);
#endregion
md.PrintTime=DateTime.Now;
ProScreenFunc.UpdateAssembly(md);
#region 保存总成信息
planID = ProScreenFunc.GetPlanIDByOrderNo(txtScanPlan.Text.Trim(), zcPartNo);
ProScreenFunc.SavePartAndProduct1(textBox2.Text.Trim(), ProScreenFunc.GetProductIDByPartNo(textBox2.Text.Trim().Substring(0, 10)), ProScreenFunc.GetProductIDByPartNo(zcPartNo), txtScanPlan.Text.Trim(), txtScanPlan.Text.Trim().Substring(0, 1) + "班", planID, newPartNo,stationId, ConfigurationManager.AppSettings["StationDescription"]);
ProScreenFunc.SaveZcCode(textBox2.Text.Trim(), zcPartNo);
ProScreenFunc.AddCompleteCount(planID);
#endregion
InitData();
}
#endregion
}
#endregion
textBox1.SelectAll();
textBox1.Focus();
textBox2.Text = "";
textBox2.Enabled = false;
}
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
}
}
private void button1_Click(object sender, EventArgs e)
{
panel1.Visible = true;
textBox3.Focus();
}
private void button3_Click(object sender, EventArgs e)
{
panel1.Visible = false;
textBox3.Text = "";
}
private void button2_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBox3.Text))
{
MessageBox.Show("半成品不能为空,请重新扫描!");
textBox3.Text = "";
textBox3.SelectAll();
return;
}
if (!ProScreenFunc.HaveScan(textBox3.Text.Trim()))
{
MessageBox.Show("半成品未进行装配,请重新扫描!");
textBox3.SelectAll();
textBox3.Focus();
return;
}
#region 补打
string partNo = "", partName = "", batchNo = "", validityDate = "";
DataTable dt = ProScreenFunc.AssemblyInfo(textBox3.Text.Trim());
if (dt != null && dt.Rows.Count > 0)
{
partNo = dt.Rows[0]["PartNo"].ToString();
partName = dt.Rows[0]["PartName"].ToString();
batchNo = dt.Rows[0]["BatchNo"].ToString();
validityDate = dt.Rows[0]["ValidityDate"].ToString();
}
Assembly1 md=new Assembly1();
md.ID = Guid.NewGuid().ToString();
md.PartNo = partNo;
md.PartName = partName;
md.Color = "通用";
md.BatchNo = batchNo;
md.BarCode = textBox3.Text.Trim();
md.TapeBatchNo = md.BatchNo;
md.Validity = "3个月";
md.ValidityDate = validityDate;
md.Flag = 1;
md.PartType = "";
md.Des = "";
ProScreenFunc.AddAssembly(md);
string filename = AppDomain.CurrentDomain.BaseDirectory + "aa.grf";
DataTable headTable = new DataTable();
headTable.Columns.Add("PartNo");
headTable.Columns.Add("PartName");
headTable.Columns.Add("BatchNo");
headTable.Columns.Add("ValidityDate");
DataRow row = headTable.NewRow();
row["PartNo"] = partNo;
row["PartName"] = partName;
row["BatchNo"] = batchNo;
row["ValidityDate"] = validityDate;
//string reportName = partName.Contains('左') ? ConfigurationManager.AppSettings["PrinterName"] : ConfigurationManager.AppSettings["PrinterName1"];
string reportName = "";
if (partNo.Substring(0, 11) == "A2548850000" ||
partNo.Substring(0, 11) == "A2548850600")
{
reportName = ConfigurationManager.AppSettings["PrinterName"];
}
else
{
reportName = ConfigurationManager.AppSettings["PrinterName1"];
}
headTable.Rows.Add(row);
ReportHelper rp = new ReportHelper(filename, headTable, null,
(int)GRPaperOrientation.grpoDefault, 1, reportName);
rp.Report.Print(false);
md.PrintTime = DateTime.Now;
ProScreenFunc.UpdateAssembly(md);
#endregion
panel1.Visible = false;
textBox3.Text = "";
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
}
}
}
}