一厂MES,含注塑,喷涂,冲孔
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.
 
 
 
 
 

323 lines
10 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//using grproLib;
using gregn6Lib;
using MESClassLibrary.BLL.BasicInfo;
using MESClassLibrary.BLL.Mistake247;
using MESClassLibrary.DAL.BasicInfo;
using MESClassLibrary.Model;
using System.Configuration;
using System.Reflection;
using System.Runtime.CompilerServices;
using MESClassLibrary.BLL.Log;
namespace PunchingMistake
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label3_Click(object sender, EventArgs e)
{
label14.Text = label3.Text;
}
private void label4_Click(object sender, EventArgs e)
{
label14.Text = label4.Text;
}
private void label5_Click(object sender, EventArgs e)
{
label14.Text = label5.Text;
}
private void label6_Click(object sender, EventArgs e)
{
label14.Text = label6.Text;
}
private void label9_Click(object sender, EventArgs e)
{
label14.Text = label9.Text;
}
private void label8_Click(object sender, EventArgs e)
{
label14.Text = label8.Text;
}
private void label12_Click(object sender, EventArgs e)
{
label14.Text = label12.Text;
}
private void label11_Click(object sender, EventArgs e)
{
label14.Text = label11.Text;
}
private void label10_Click(object sender, EventArgs e)
{
label14.Text = label10.Text;
}
private void Form1_Load(object sender, EventArgs e)
{
label14.Text = "";
panel1.Visible = false;
}
/// <summary>
/// 打印总成条码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
#region 合法性校验
if (label14.Text == "")
{
MessageBox.Show("请选择颜色!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (textBox1.Text.Trim() == "")
{
MessageBox.Show("请输入当前装配此产品的胶带批次号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
textBox1.Focus();
return;
}
#endregion
GridppReport report = new GridppReport();
ColorBLL cbll = new ColorBLL();
AssemblyBLL bll = new AssemblyBLL();
MistakeBLL mbll=new MistakeBLL();
BoxBLL boxbll=new BoxBLL();
BoxModel boxmd=new BoxModel();
AssemblyModel md = new AssemblyModel();
int BoxCount = 0;
try
{
#region 根据颜色查找四位数字代号
DataTable dt1 = cbll.SearchByName(label14.Text);
if (dt1 != null && dt1.Rows.Count > 0)
{
md.ColorNo = dt1.Rows[0]["ColorNo"].ToString();
}
md.Color = label14.Text;
#endregion
#region 根据半成品查找总成零件号
DataTable dt2 = mbll.SearchByNo("1230002580","A8");
if (dt2 != null && dt2.Rows.Count > 0)
{
md.PartNo = dt2.Rows[0]["PartNo2"].ToString();
md.PartName = dt2.Rows[0]["PartName2"].ToString();
BoxCount = Convert.ToInt32(dt2.Rows[0]["PackCount"].ToString());
}
#endregion
#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);
md.PartType = "X247 扰流板";
md.TapeBatchNo = textBox1.Text.Trim();
md.Validity = "3个月";
md.ValidityDate = "从" + DateTime.Now.ToString("yyyy-MM-dd") + "到" +
DateTime.Now.AddMonths(3).ToString("yyyy-MM-dd");
bll.AddInfo(md);
#endregion
#region 打印总成条码
report.Register("");
report.LoadFromFile(@"D:\X247后部中间扰流板.grf");
report.ConnectionString = ConfigurationManager.ConnectionStrings["report"].ToString();
report.Print(false);
bll.UpdateInfo(md);
#endregion
#region 判断是否打印箱单
DataTable pdt = bll.SearchCount(md.PartNo);
if (pdt != null && pdt.Rows.Count >= 0)
{
if (Convert.ToInt32(pdt.Rows[0]["sum"].ToString()) == BoxCount)
{
#region 保存并打印箱单
string BoxNo = "", oldBoxNo = "";
DataTable dt3 = boxbll.SearchByNo(md.PartNo, md.BatchNo);
if (dt3 != null && dt3.Rows.Count > 0)
{
oldBoxNo = dt3.Rows[0]["BoxNo"].ToString();
BoxNo = oldBoxNo.Substring(0, oldBoxNo.Length - 6) +
(Convert.ToInt32(oldBoxNo.Substring(oldBoxNo.Length - 6, 6)) + 1).ToString()
.PadLeft(6, '0');
}
else
{
BoxNo = md.PartNo + "-" + md.ColorNo + "." + md.BatchNo + "." + "000001";
}
boxmd.ID = Guid.NewGuid().ToString();
boxmd.BoxNo = BoxNo;
boxmd.PartNo = md.PartNo + "-" + md.ColorNo;
boxmd.PartName = md.PartName + label14.Text;
boxmd.BatchNo = md.BatchNo;
boxmd.BoxCount = BoxCount;
boxbll.AddInfo(boxmd);
report.Register("");
report.LoadFromFile(@"D:\X247后部扰流板装箱单.grf");
report.ConnectionString = ConfigurationManager.ConnectionStrings["report"].ToString();
report.Print(false);
boxbll.UpdateInfo(boxmd);
#endregion
}
}
#endregion
#region 关闭页面
this.Dispose();
#endregion
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked == false)
{
panel1.Visible = true;
}
}
private void button2_Click(object sender, EventArgs e)
{
#region 判断数据合法性
if (textBox2.Text.Trim() == "")
{
MessageBox.Show("请输入数量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (!IsNumeric(textBox2.Text.Trim()))
{
MessageBox.Show("数量格式不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
#endregion
try
{
GridppReport report = new GridppReport();
ColorBLL cbll = new ColorBLL();
AssemblyBLL bll = new AssemblyBLL();
MistakeBLL mbll = new MistakeBLL();
BoxBLL boxbll = new BoxBLL();
BoxModel boxmd = new BoxModel();
AssemblyModel md = new AssemblyModel();
#region 根据颜色查找四位数字代号
DataTable dt1 = cbll.SearchByName(label14.Text);
if (dt1 != null && dt1.Rows.Count > 0)
{
md.ColorNo = dt1.Rows[0]["ColorNo"].ToString();
}
md.Color = label14.Text;
#endregion
#region 根据半成品查找总成零件号
DataTable dt2 = mbll.SearchByNo("1230002580", "A8");
if (dt2 != null && dt2.Rows.Count > 0)
{
md.PartNo = dt2.Rows[0]["PartNo2"].ToString();
md.PartName = dt2.Rows[0]["PartName2"].ToString();
}
string BoxNo = "", oldBoxNo = "";
DataTable dt3 = boxbll.SearchByNo(md.PartNo,md.BatchNo);
if (dt3 != null && dt3.Rows.Count > 0)
{
oldBoxNo = dt3.Rows[0]["BoxNo"].ToString();
BoxNo = oldBoxNo.Substring(0, oldBoxNo.Length - 6) +
(Convert.ToInt32(oldBoxNo.Substring(oldBoxNo.Length - 6, 6)) + 1).ToString().PadLeft(6, '0');
}
else
{
BoxNo = md.PartNo + "-" + md.ColorNo + "." + md.BatchNo + "." + "000001";
}
boxmd.ID = Guid.NewGuid().ToString();
boxmd.BoxNo = BoxNo;
boxmd.PartNo = md.PartNo + "-" + md.ColorNo;
boxmd.PartName = md.PartName + label14.Text;
boxmd.BatchNo = md.BatchNo;
boxmd.BoxCount = Convert.ToInt32(textBox2.Text.Trim());
boxbll.AddInfo(boxmd);
report.Register("");
report.LoadFromFile(@"D:\X247后部扰流板装箱单.grf");
report.ConnectionString = ConfigurationManager.ConnectionStrings["report"].ToString();
report.Print(false);
boxbll.UpdateInfo(boxmd);
#endregion
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
}
}
private static bool IsNumeric(string str)
{
System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[0-9]\d*$");
return reg1.IsMatch(str);
}
}
}