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.
976 lines
42 KiB
976 lines
42 KiB
2 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 grproLib;
|
||
|
using MESClassLibrary.BLL;
|
||
|
using MESClassLibrary.BLL.BasicInfo;
|
||
|
using MESClassLibrary.BLL.Injection;
|
||
|
using MESClassLibrary.BLL.Log;
|
||
|
using MESClassLibrary.BLL.TruckBox;
|
||
|
using MESClassLibrary.DAL;
|
||
|
using MESClassLibrary.EFModel;
|
||
|
using MESClassLibrary.Model;
|
||
|
using DataTable = System.Data.DataTable;
|
||
|
|
||
|
namespace InjectionSearch
|
||
|
{
|
||
|
public partial class FrmBarCodeSearch : Form
|
||
|
{
|
||
|
private UniqueBll _uniqueBll = new UniqueBll();
|
||
|
public FrmBarCodeSearch()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
private void initProduct()
|
||
|
{
|
||
|
comboBox1.Items.Clear();
|
||
|
|
||
|
ProductBLL bll = new ProductBLL();
|
||
|
|
||
|
DataTable dt = bll.SearchInfoAllByType("2000");
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
for (int i = 0; i < dt.Rows.Count; i++)
|
||
|
{
|
||
|
comboBox1.Items.Add(dt.Rows[i]["StockNo"].ToString() +"--"+dt.Rows[i]["ProductName"].ToString());
|
||
|
}
|
||
|
}
|
||
|
dt.Dispose();
|
||
|
}
|
||
|
|
||
|
private void initBarCode()
|
||
|
{
|
||
|
BarCodeBLL bll = new BarCodeBLL();
|
||
|
|
||
|
glacialList1.Items.Clear();
|
||
|
DataTable dt = bll.SearchBarCode();
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
for (int i = 0; i < dt.Rows.Count; i++)
|
||
|
{
|
||
|
glacialList1.Items.Add(i.ToString());
|
||
|
glacialList1.Items[i].SubItems[0].Text = dt.Rows[i]["BarCode"].ToString();
|
||
|
glacialList1.Items[i].SubItems[1].Text = dt.Rows[i]["ProductName"].ToString();
|
||
|
glacialList1.Items[i].SubItems[2].Text = dt.Rows[i]["PrintType"].ToString();
|
||
|
glacialList1.Items[i].SubItems[3].Text = dt.Rows[i]["CreateTime"].ToString() == "" ? "" : Convert.ToDateTime(dt.Rows[i]["CreateTime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||
|
//glacialList1.Items[i].SubItems[4].Text = dt.Rows[i]["MaterialName"].ToString();
|
||
|
//glacialList1.Items[i].SubItems[5].Text = dt.Rows[i]["BatchNo"].ToString();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
string stockNo = comboBox1.Text.Substring(0, 10);
|
||
|
|
||
|
ProductBLL bll=new ProductBLL();
|
||
|
BomBLL bombll=new BomBLL();
|
||
|
|
||
|
DataTable dt = bll.SearchInfoByStock(stockNo);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
textBox1.Text = dt.Rows[0]["PartNo"].ToString();
|
||
|
dt.Dispose();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
textBox1.Text = "";
|
||
|
}
|
||
|
|
||
|
DataTable dt1 = bombll.SearchBom(textBox1.Text);
|
||
|
if (dt1 != null && dt1.Rows.Count > 0)
|
||
|
{
|
||
|
textBox2.Text = dt1.Rows[0]["PartNo2"].ToString();
|
||
|
dt.Dispose();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
textBox2.Text = "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void FrmBarCodeSearch_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
initProduct();
|
||
|
initBarCode();
|
||
|
comboBox2.Items.Clear();
|
||
|
comboBox2.Items.Add("IM01");
|
||
|
comboBox2.Items.Add("IM02");
|
||
|
comboBox2.Items.Add("IM03");
|
||
|
comboBox2.Items.Add("IM04");
|
||
|
comboBox2.Items.Add("IM05");
|
||
|
comboBox2.Items.Add("IM06");
|
||
|
comboBox2.Items.Add("IM07");
|
||
|
comboBox2.Items.Add("IM08");
|
||
|
comboBox2.Items.Add("IM09");
|
||
|
comboBox2.Items.Add("IM10");
|
||
|
comboBox2.Items.Add("IM11");
|
||
|
comboBox2.Items.Add("IM12");
|
||
|
comboBox2.Items.Add("IM13");
|
||
|
comboBox2.Items.Add("IM14");
|
||
|
comboBox2.Items.Add("IM15");
|
||
|
comboBox2.Items.Add("IM16");
|
||
|
comboBox2.Items.Add("IM17");
|
||
|
comboBox2.Items.Add("IM18");
|
||
|
comboBox2.Items.Add("IM19");
|
||
|
comboBox2.Items.Add("IM20");
|
||
|
GetClass();
|
||
|
textBox3.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) +
|
||
|
Program.ProductDate.Substring(8, 2); //批次
|
||
|
}
|
||
|
|
||
|
private void GetClass()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
DateTime aa = GetDateTime();
|
||
|
|
||
|
if (GetDateTime().Hour >= 8 && GetDateTime().Hour < 20)
|
||
|
{
|
||
|
Program.Shift = "A班";
|
||
|
Program.ProductDate = aa.ToString("yyyy-MM-dd");
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Program.Shift = "B班";
|
||
|
if (GetDateTime().Hour >= 0 && GetDateTime().Hour < 8)
|
||
|
{
|
||
|
Program.ProductDate = aa.AddDays(-1).ToString("yyyy-MM-dd");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Program.ProductDate = aa.ToString("yyyy-MM-dd");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void label18_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
string code = "",name="";
|
||
|
BarCodeModel md = new BarCodeModel();
|
||
|
BarCodeBLL bll = new BarCodeBLL();
|
||
|
ProductBLL pbll=new ProductBLL();
|
||
|
string filename = "", partNo = "", OneCode="";
|
||
|
|
||
|
try
|
||
|
{
|
||
|
if (glacialList1.SelectedItems.Count == 0)
|
||
|
{
|
||
|
MessageBox.Show("请选择要补打的条码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
GlacialComponents.Controls.GLItem gv;
|
||
|
gv = glacialList1.SelectedItems[0] as GlacialComponents.Controls.GLItem;
|
||
|
code = gv.Text;
|
||
|
|
||
|
string[] aa = code.Split('.');
|
||
|
partNo = aa[0];
|
||
|
|
||
|
DataTable dt = bll.SearchInfoByBarCode(code);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
name = dt.Rows[0]["ProductName"].ToString();
|
||
|
md.ID = Guid.NewGuid().ToString();
|
||
|
md.BarCode = code;
|
||
|
md.StationID = Program.StationID;
|
||
|
md.StockNo = dt.Rows[0]["StockNo"].ToString();
|
||
|
md.OneBarCode = dt.Rows[0]["OneBarCode"].ToString();
|
||
|
md.StationID2 = dt.Rows[0]["StationID"].ToString();
|
||
|
md.PrintType = 2;
|
||
|
|
||
|
DataTable pdt = pbll.SearchIsImportByStockNo(md.StockNo);
|
||
|
if (pdt != null && pdt.Rows.Count > 0)
|
||
|
{
|
||
|
if (pdt.Rows[0]["isImport"].ToString() == "1")
|
||
|
{
|
||
|
md.Import = "国产料Kingfa";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
md.Import = "";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (bll.Add_Info_New(md, "tb_BarCode5") == false)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#region 打印条码
|
||
|
PlasticBLL plbll = new PlasticBLL();
|
||
|
|
||
|
filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码.grf";
|
||
|
DataTable headTable = new DataTable();
|
||
|
headTable.Columns.Add("PrintTime");
|
||
|
headTable.Columns.Add("PartNo");
|
||
|
headTable.Columns.Add("PartName");
|
||
|
headTable.Columns.Add("OneBarCode");
|
||
|
headTable.Columns.Add("BarCode");
|
||
|
DataRow row = headTable.NewRow();
|
||
|
row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||
|
row["PartNo"] = partNo;
|
||
|
row["PartName"] = name;
|
||
|
row["OneBarCode"] = md.OneBarCode;
|
||
|
row["BarCode"] = code;
|
||
|
|
||
|
|
||
|
string reportName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
||
|
headTable.Rows.Add(row);
|
||
|
|
||
|
ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName);
|
||
|
|
||
|
rp.Report.Print(false);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
initBarCode();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public DateTime GetDateTime()
|
||
|
{
|
||
|
string sql = "";
|
||
|
DateTime time;
|
||
|
DataTable dt;
|
||
|
try
|
||
|
{
|
||
|
sql = @"select getdate() as time";
|
||
|
|
||
|
dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
time = Convert.ToDateTime(dt.Rows[0]["time"].ToString());
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
time = DateTime.Now;
|
||
|
}
|
||
|
return time;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return DateTime.Now;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static bool IsNumeric(string str)
|
||
|
{
|
||
|
System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[0-9]\d*$");
|
||
|
return reg1.IsMatch(str);
|
||
|
}
|
||
|
|
||
|
private void label19_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
string code = "", stationID = "", OneCode = "",planID="";
|
||
|
string newcode = "", partNo = "", stockNo = "", NewOneCode = "";
|
||
|
string filename = "", printName = "", PartName = "", IsSupply="",QLevel="",ProductNature="",IsPrint="";
|
||
|
|
||
|
ProductBLL pbll = new ProductBLL();
|
||
|
BarCodeBLL bll = new BarCodeBLL();
|
||
|
BarCodeModel md = new BarCodeModel();
|
||
|
InjectionPlanBLL planbll = new InjectionPlanBLL();
|
||
|
|
||
|
try
|
||
|
{
|
||
|
#region 数据合法性判断
|
||
|
if (comboBox2.Text.Trim() == "")
|
||
|
{
|
||
|
MessageBox.Show("请选择机台!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (comboBox1.Text.Trim() == "")
|
||
|
{
|
||
|
MessageBox.Show("请选择产品!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (textBox3.Text.Trim() == "")
|
||
|
{
|
||
|
MessageBox.Show("请输入批次!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (textBox4.Text.Trim() == "")
|
||
|
{
|
||
|
MessageBox.Show("请输入数量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
if (!IsNumeric(textBox4.Text.Trim()))
|
||
|
{
|
||
|
MessageBox.Show("数量格式不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (Convert.ToInt32(textBox4.Text.Trim()) > 100)
|
||
|
{
|
||
|
MessageBox.Show("数量不能大于100!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 获取工位编号
|
||
|
|
||
|
StationBLL sbll = new StationBLL();
|
||
|
DataTable sdt = sbll.SearchInfoByNo(comboBox2.Text.Trim());
|
||
|
if (sdt != null && sdt.Rows.Count > 0)
|
||
|
{
|
||
|
stationID = sdt.Rows[0]["StationID"].ToString();
|
||
|
}
|
||
|
sdt.Dispose();
|
||
|
#endregion
|
||
|
|
||
|
#region 获取对应工位的当前计划信息
|
||
|
|
||
|
|
||
|
DataTable plandt = planbll.SearchInfoByName(comboBox2.Text);
|
||
|
if (plandt != null && plandt.Rows.Count > 0)
|
||
|
{
|
||
|
planID = plandt.Rows[0]["InjectionPlanID"].ToString();
|
||
|
ProductNature = plandt.Rows[0]["ProductNature"].ToString();
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
DialogResult result = MessageBox.Show("确定手工打印条码?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
|
||
|
if (result == DialogResult.OK)
|
||
|
{
|
||
|
//查询零件号
|
||
|
stockNo = comboBox1.Text.Substring(0, 10);
|
||
|
partNo = textBox1.Text.Trim();
|
||
|
|
||
|
#region 判断零件是否是直供件、是否打印标签
|
||
|
|
||
|
ProductBLL prbll = new ProductBLL();
|
||
|
DataTable prdt = prbll.SearchInfoByPartNo(partNo);
|
||
|
if (prdt != null && prdt.Rows.Count > 0)
|
||
|
{
|
||
|
IsSupply = prdt.Rows[0]["IsSupply"].ToString();
|
||
|
QLevel = prdt.Rows[0]["QLevel"].ToString();
|
||
|
IsPrint = prdt.Rows[0]["IsPrintOneTag"].ToString();
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 非直供件
|
||
|
|
||
|
if (IsSupply != "1")
|
||
|
{
|
||
|
for (int i = 1; i <= Convert.ToInt32(textBox4.Text.Trim()); i++)
|
||
|
{
|
||
|
|
||
|
GetSjBarCode(stockNo, partNo,false, ref NewOneCode, ref newcode);
|
||
|
string[] part = newcode.Split('.');
|
||
|
//存入tb_BarCode表
|
||
|
md.ID = Guid.NewGuid().ToString();
|
||
|
md.StationID = Program.StationID;
|
||
|
md.StationID2 = stationID;
|
||
|
md.StockNo = stockNo;
|
||
|
md.OneBarCode = NewOneCode;
|
||
|
md.BarCode = newcode;
|
||
|
md.PrintType = 1;
|
||
|
md.PartNo = partNo;
|
||
|
md.PlanID = planID;
|
||
|
md.ProductNature = ProductNature;
|
||
|
|
||
|
DataTable pdt = pbll.SearchIsImportByStockNo(stockNo);
|
||
|
if (pdt != null && pdt.Rows.Count > 0)
|
||
|
{
|
||
|
PartName = pdt.Rows[0]["ProductName"].ToString();
|
||
|
if (pdt.Rows[0]["isImport"].ToString() == "1")
|
||
|
{
|
||
|
md.Import = "国产料Kingfa";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
md.Import = "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (bll.Add_Info_New(md, "tb_BarCode5") == false)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#region 214TrunkBox存入质检表
|
||
|
|
||
|
if (partNo == "A2146106203kz")
|
||
|
{
|
||
|
tb_Inspection_tx imd = new tb_Inspection_tx();
|
||
|
InspectionBLL ibll = new InspectionBLL();
|
||
|
|
||
|
imd.BarCode = NewOneCode;
|
||
|
imd.IsOK = 1;
|
||
|
imd.Station = 1;
|
||
|
|
||
|
ibll.AddInfo(imd);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
if (IsPrint == "1")
|
||
|
{
|
||
|
#region 打印条码
|
||
|
|
||
|
filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码.grf";
|
||
|
DataTable headTable = new DataTable();
|
||
|
headTable.Columns.Add("PrintTime");
|
||
|
headTable.Columns.Add("PartNo");
|
||
|
headTable.Columns.Add("PartName");
|
||
|
headTable.Columns.Add("OneBarCode");
|
||
|
headTable.Columns.Add("BarCode");
|
||
|
DataRow row = headTable.NewRow();
|
||
|
row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||
|
row["PartNo"] = partNo;
|
||
|
row["PartName"] = PartName;
|
||
|
row["OneBarCode"] = NewOneCode;
|
||
|
row["BarCode"] = newcode;
|
||
|
string reportName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
||
|
headTable.Rows.Add(row);
|
||
|
|
||
|
ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName);
|
||
|
|
||
|
rp.Report.Print(false);
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#region 原有打印代码
|
||
|
//DataTable dt = bll.SearchSerialNoByBarCodeNew(partNo + "." + textBox3.Text.Trim(),"");
|
||
|
//if (dt != null && dt.Rows.Count > 0)
|
||
|
//{
|
||
|
// OneCode = dt.Rows[0]["OneBarCode"].ToString().Trim();
|
||
|
// code = dt.Rows[0]["BarCode"].ToString().TrimEnd();
|
||
|
// for (int i = 1; i <= Convert.ToInt32(textBox4.Text.Trim()); i++)
|
||
|
// {
|
||
|
// //newcode = code.Substring(0, code.Length - 4) +
|
||
|
// // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + i)
|
||
|
// // .ToString()
|
||
|
// // .PadLeft(4, '0');
|
||
|
// //NewOneCode = OneCode.Substring(0, OneCode.Length - 4) +
|
||
|
// // (Convert.ToInt32(OneCode.Substring(OneCode.Length - 4, 4)) + i).ToString()
|
||
|
// // .PadLeft(4, '0');
|
||
|
|
||
|
// GetSjBarCode(stockNo, partNo, ref NewOneCode, ref newcode);
|
||
|
// string[] part = newcode.Split('.');
|
||
|
// //存入tb_BarCode表
|
||
|
// md.ID = Guid.NewGuid().ToString();
|
||
|
// md.StationID = Program.StationID;
|
||
|
// md.StationID2 = stationID;
|
||
|
// md.StockNo = stockNo;
|
||
|
// md.OneBarCode = NewOneCode;
|
||
|
// md.BarCode = newcode;
|
||
|
// md.PrintType = 1;
|
||
|
// md.PartNo = partNo;
|
||
|
// md.PlanID = planID;
|
||
|
// md.ProductNature = ProductNature;
|
||
|
|
||
|
// DataTable pdt = pbll.SearchIsImportByStockNo(stockNo);
|
||
|
// if (pdt != null && pdt.Rows.Count > 0)
|
||
|
// {
|
||
|
// PartName = pdt.Rows[0]["ProductName"].ToString();
|
||
|
// if (pdt.Rows[0]["isImport"].ToString() == "1")
|
||
|
// {
|
||
|
// md.Import = "国产料Kingfa";
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// md.Import = "";
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// if (bll.Add_Info_New(md, "tb_BarCode5") == false)
|
||
|
// {
|
||
|
// return;
|
||
|
// }
|
||
|
|
||
|
// #region 214TrunkBox存入质检表
|
||
|
|
||
|
// if (partNo == "A2146106203kz")
|
||
|
// {
|
||
|
// tb_Inspection_tx imd = new tb_Inspection_tx();
|
||
|
// InspectionBLL ibll = new InspectionBLL();
|
||
|
|
||
|
// imd.BarCode = NewOneCode;
|
||
|
// imd.IsOK =1;
|
||
|
// imd.Station = 1;
|
||
|
|
||
|
// ibll.AddInfo(imd);
|
||
|
// }
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
// if (IsPrint == "1")
|
||
|
// {
|
||
|
// #region 打印条码
|
||
|
|
||
|
// filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码.grf";
|
||
|
// DataTable headTable = new DataTable();
|
||
|
// headTable.Columns.Add("PrintTime");
|
||
|
// headTable.Columns.Add("PartNo");
|
||
|
// headTable.Columns.Add("PartName");
|
||
|
// headTable.Columns.Add("OneBarCode");
|
||
|
// headTable.Columns.Add("BarCode");
|
||
|
// DataRow row = headTable.NewRow();
|
||
|
// row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||
|
// row["PartNo"] = partNo;
|
||
|
// row["PartName"] = PartName;
|
||
|
// row["OneBarCode"] = NewOneCode;
|
||
|
// row["BarCode"] = newcode;
|
||
|
// string reportName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
||
|
// headTable.Rows.Add(row);
|
||
|
|
||
|
// ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName);
|
||
|
|
||
|
// rp.Report.Print(false);
|
||
|
|
||
|
// #endregion
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// for (int i = 1; i <= Convert.ToInt32(textBox4.Text.Trim()); i++)
|
||
|
// {
|
||
|
// newcode = partNo + "." + textBox3.Text.Trim() + "." + i.ToString().PadLeft(4, '0');
|
||
|
// NewOneCode = stockNo + textBox3.Text.Trim() + i.ToString().PadLeft(4, '0');
|
||
|
// string[] part = newcode.Split('.');
|
||
|
// //存入tb_BarCode表
|
||
|
// md.ID = Guid.NewGuid().ToString();
|
||
|
// md.StationID = Program.StationID;
|
||
|
// md.StationID2 = stationID;
|
||
|
// md.StockNo = stockNo;
|
||
|
// md.OneBarCode = NewOneCode;
|
||
|
// md.BarCode = newcode;
|
||
|
// md.PrintType = 1;
|
||
|
// md.PartNo = partNo;
|
||
|
// md.PlanID = planID;
|
||
|
// md.ProductNature = ProductNature;
|
||
|
|
||
|
// DataTable pdt = pbll.SearchIsImportByStockNo(stockNo);
|
||
|
// if (pdt != null && pdt.Rows.Count > 0)
|
||
|
// {
|
||
|
// PartName = pdt.Rows[0]["ProductName"].ToString();
|
||
|
// if (pdt.Rows[0]["isImport"].ToString() == "1")
|
||
|
// {
|
||
|
// md.Import = "国产料Kingfa";
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// md.Import = "";
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// if (bll.Add_Info_New(md, "tb_BarCode5") == false)
|
||
|
// {
|
||
|
// return;
|
||
|
// }
|
||
|
|
||
|
// #region 214TrunkBox存入质检表
|
||
|
|
||
|
// if (partNo == "A2146106203kz")
|
||
|
// {
|
||
|
// tb_Inspection_tx imd = new tb_Inspection_tx();
|
||
|
// InspectionBLL ibll = new InspectionBLL();
|
||
|
|
||
|
// imd.BarCode = NewOneCode;
|
||
|
// imd.IsOK = 1;
|
||
|
// imd.Station = 1;
|
||
|
|
||
|
// ibll.AddInfo(imd);
|
||
|
// }
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
// if (IsPrint == "1")
|
||
|
// {
|
||
|
// #region 打印条码
|
||
|
|
||
|
// filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码.grf";
|
||
|
// DataTable headTable = new DataTable();
|
||
|
// headTable.Columns.Add("PrintTime");
|
||
|
// headTable.Columns.Add("PartNo");
|
||
|
// headTable.Columns.Add("PartName");
|
||
|
// headTable.Columns.Add("OneBarCode");
|
||
|
// headTable.Columns.Add("BarCode");
|
||
|
// DataRow row = headTable.NewRow();
|
||
|
// row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||
|
// row["PartNo"] = partNo;
|
||
|
// row["PartName"] = PartName;
|
||
|
// row["OneBarCode"] = NewOneCode;
|
||
|
// row["BarCode"] = newcode;
|
||
|
|
||
|
// string reportName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
||
|
// headTable.Rows.Add(row);
|
||
|
|
||
|
// ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName);
|
||
|
|
||
|
// rp.Report.Print(false);
|
||
|
|
||
|
// #endregion
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 直供件
|
||
|
|
||
|
if (IsSupply == "1")
|
||
|
{
|
||
|
|
||
|
for (int i = 1; i <= Convert.ToInt32(textBox4.Text.Trim()); i++)
|
||
|
{
|
||
|
//newcode = partNo + "#" + QLevel + "#" + textBox3.Text.Trim() + "#" +
|
||
|
// i.ToString().PadLeft(3, '0') + "#";
|
||
|
NewOneCode = "";
|
||
|
|
||
|
GetSupplyCode(partNo, QLevel,true, ref newcode);
|
||
|
|
||
|
string[] part = newcode.Split('.');
|
||
|
|
||
|
#region 存入tb_BarCode表
|
||
|
|
||
|
md.ID = Guid.NewGuid().ToString();
|
||
|
md.StationID = Program.StationID;
|
||
|
md.StationID2 = stationID;
|
||
|
md.StockNo = stockNo;
|
||
|
md.OneBarCode = NewOneCode;
|
||
|
md.BarCode = newcode;
|
||
|
md.PrintType = 1;
|
||
|
md.PartNo = partNo;
|
||
|
md.PlanID = planID;
|
||
|
md.ProductNature = ProductNature;
|
||
|
|
||
|
DataTable pdt = pbll.SearchIsImportByStockNo(stockNo);
|
||
|
if (pdt != null && pdt.Rows.Count > 0)
|
||
|
{
|
||
|
if (pdt.Rows[0]["isImport"].ToString() == "1")
|
||
|
{
|
||
|
md.Import = "国产料Kingfa";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
md.Import = "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (bll.Add_Info_New(md, "tb_BarCode5") == false)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
if (IsPrint == "1")
|
||
|
{
|
||
|
#region 打印条码
|
||
|
|
||
|
filename = System.AppDomain.CurrentDomain.BaseDirectory +
|
||
|
"单个条码1.grf";
|
||
|
|
||
|
DataTable headTable = new DataTable();
|
||
|
headTable.Columns.Add("PrintTime");
|
||
|
headTable.Columns.Add("PartNo");
|
||
|
headTable.Columns.Add("PartName");
|
||
|
headTable.Columns.Add("OneBarCode");
|
||
|
headTable.Columns.Add("BarCode");
|
||
|
DataRow row = headTable.NewRow();
|
||
|
row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||
|
row["PartNo"] = partNo;
|
||
|
row["PartName"] = PartName;
|
||
|
row["OneBarCode"] = NewOneCode;
|
||
|
row["BarCode"] = newcode;
|
||
|
string reportName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
||
|
headTable.Rows.Add(row);
|
||
|
|
||
|
ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName);
|
||
|
|
||
|
rp.Report.Print(false);
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#region 原来打印代码
|
||
|
//DataTable dt = bll.SearchSerialNoByBarCodeNew1(partNo + "#" + QLevel + "#" + textBox3.Text.Trim() + "#");
|
||
|
//if (dt != null && dt.Rows.Count > 0)
|
||
|
//{
|
||
|
// code = dt.Rows[0]["BarCode"].ToString().Trim();
|
||
|
// for (int i = 1; i <= Convert.ToInt32(textBox2.Text.Trim()); i++)
|
||
|
// {
|
||
|
// newcode = code.Substring(0, code.Length - 4) +
|
||
|
// (Convert.ToInt32(code.Substring(23, 3)) +
|
||
|
// i).ToString()
|
||
|
// .PadLeft(3, '0') + "#";
|
||
|
|
||
|
// #region 插入数据tb_barCode
|
||
|
|
||
|
// md.ID = Guid.NewGuid().ToString();
|
||
|
// md.StationID = Program.StationID;
|
||
|
// md.StationID2 = stationID;
|
||
|
// md.StockNo = stockNo;
|
||
|
// md.OneBarCode = "";
|
||
|
// md.BarCode = newcode;
|
||
|
// md.PrintType = 1;
|
||
|
// md.PartNo = partNo;
|
||
|
|
||
|
// md.PlanID = planID;
|
||
|
// md.ProductNature = ProductNature;
|
||
|
|
||
|
// DataTable dt2 = pbll.SearchIsImportByPartNo(partNo);
|
||
|
// if (dt2 != null && dt2.Rows.Count > 0)
|
||
|
// {
|
||
|
// if (dt2.Rows[0]["isImport"].ToString() == "1")
|
||
|
// {
|
||
|
// md.Import = "国产料Kingfa";
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// md.Import = "";
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// if (bll.Add_Info_New(md, "tb_BarCode5") == false)
|
||
|
// {
|
||
|
// return;
|
||
|
// }
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
// if (IsPrint == "1")
|
||
|
// {
|
||
|
// #region 打印条码
|
||
|
|
||
|
// filename = System.AppDomain.CurrentDomain.BaseDirectory +
|
||
|
// "单个条码1.grf";
|
||
|
|
||
|
// DataTable headTable = new DataTable();
|
||
|
// headTable.Columns.Add("PrintTime");
|
||
|
// headTable.Columns.Add("PartNo");
|
||
|
// headTable.Columns.Add("PartName");
|
||
|
// headTable.Columns.Add("OneBarCode");
|
||
|
// headTable.Columns.Add("BarCode");
|
||
|
// DataRow row = headTable.NewRow();
|
||
|
// row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||
|
// row["PartNo"] = partNo;
|
||
|
// row["PartName"] = PartName;
|
||
|
// row["OneBarCode"] = NewOneCode;
|
||
|
// row["BarCode"] = newcode;
|
||
|
// string reportName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
||
|
// headTable.Rows.Add(row);
|
||
|
|
||
|
// ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName);
|
||
|
|
||
|
// rp.Report.Print(false);
|
||
|
|
||
|
// #endregion
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// for (int i = 1; i <= Convert.ToInt32(textBox4.Text.Trim()); i++)
|
||
|
// {
|
||
|
// newcode = partNo + "#" + QLevel + "#" + textBox3.Text.Trim() + "#" +
|
||
|
// i.ToString().PadLeft(3, '0') + "#";
|
||
|
// NewOneCode = "";
|
||
|
// string[] part = newcode.Split('.');
|
||
|
|
||
|
// #region 存入tb_BarCode表
|
||
|
|
||
|
// md.ID = Guid.NewGuid().ToString();
|
||
|
// md.StationID = Program.StationID;
|
||
|
// md.StationID2 = stationID;
|
||
|
// md.StockNo = stockNo;
|
||
|
// md.OneBarCode = NewOneCode;
|
||
|
// md.BarCode = newcode;
|
||
|
// md.PrintType = 1;
|
||
|
// md.PartNo = partNo;
|
||
|
// md.PlanID = planID;
|
||
|
// md.ProductNature = ProductNature;
|
||
|
|
||
|
// DataTable pdt = pbll.SearchIsImportByStockNo(stockNo);
|
||
|
// if (pdt != null && pdt.Rows.Count > 0)
|
||
|
// {
|
||
|
// if (pdt.Rows[0]["isImport"].ToString() == "1")
|
||
|
// {
|
||
|
// md.Import = "国产料Kingfa";
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// md.Import = "";
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// if (bll.Add_Info_New(md, "tb_BarCode5") == false)
|
||
|
// {
|
||
|
// return;
|
||
|
// }
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
|
||
|
// if (IsPrint == "1")
|
||
|
// {
|
||
|
// #region 打印条码
|
||
|
|
||
|
// filename = System.AppDomain.CurrentDomain.BaseDirectory +
|
||
|
// "单个条码1.grf";
|
||
|
|
||
|
// DataTable headTable = new DataTable();
|
||
|
// headTable.Columns.Add("PrintTime");
|
||
|
// headTable.Columns.Add("PartNo");
|
||
|
// headTable.Columns.Add("PartName");
|
||
|
// headTable.Columns.Add("OneBarCode");
|
||
|
// headTable.Columns.Add("BarCode");
|
||
|
// DataRow row = headTable.NewRow();
|
||
|
// row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||
|
// row["PartNo"] = partNo;
|
||
|
// row["PartName"] = PartName;
|
||
|
// row["OneBarCode"] = NewOneCode;
|
||
|
// row["BarCode"] = newcode;
|
||
|
// string reportName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
||
|
// headTable.Rows.Add(row);
|
||
|
|
||
|
// ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName);
|
||
|
|
||
|
// rp.Report.Print(false);
|
||
|
|
||
|
// #endregion
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
initBarCode();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void button1_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
BarCodeBLL bll = new BarCodeBLL();
|
||
|
DataTable dt = null;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
glacialList1.Items.Clear();
|
||
|
if (textBox5.Text.Trim() == "")
|
||
|
{
|
||
|
dt = bll.SearchBarCode();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (textBox5.Text.Trim().Length == 20)
|
||
|
{
|
||
|
dt = bll.SearchBarCodeByOne(textBox5.Text.Trim());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
dt = bll.SearchBarCodeByTwo(textBox5.Text.Trim());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
for (int i = 0; i < dt.Rows.Count; i++)
|
||
|
{
|
||
|
glacialList1.Items.Add(i.ToString());
|
||
|
glacialList1.Items[i].SubItems[0].Text = dt.Rows[i]["BarCode"].ToString();
|
||
|
glacialList1.Items[i].SubItems[1].Text = dt.Rows[i]["ProductName"].ToString();
|
||
|
glacialList1.Items[i].SubItems[2].Text = dt.Rows[i]["PrintType"].ToString();
|
||
|
glacialList1.Items[i].SubItems[3].Text = dt.Rows[i]["PrintTime"].ToString() == "" ? "" : Convert.ToDateTime(dt.Rows[i]["PrintTime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||
|
glacialList1.Items[i].SubItems[4].Text = dt.Rows[i]["MaterialName"].ToString();
|
||
|
glacialList1.Items[i].SubItems[5].Text = dt.Rows[i]["BatchNo"].ToString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void FrmBarCodeSearch_FormClosing(object sender, FormClosingEventArgs e)
|
||
|
{
|
||
|
Application.Exit();
|
||
|
}
|
||
|
|
||
|
void GetSjBarCode(string stockNo, string partNo,bool autoPrint, ref string newOneCode, ref string newCode)
|
||
|
{
|
||
|
string batch = string.Empty;
|
||
|
if (autoPrint)
|
||
|
{
|
||
|
batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
batch = textBox3.Text.Trim();
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
newOneCode = _uniqueBll.GetSjBarCodeSerialNo(stockNo, batch);
|
||
|
newCode = partNo + "." + batch + "." + newOneCode.Substring(newOneCode.Length - 4, 4);
|
||
|
}
|
||
|
void GetSupplyCode(string partNo, string qLevel, bool autoPrint, ref string newCode)
|
||
|
{
|
||
|
string batch = string.Empty;
|
||
|
if (autoPrint)
|
||
|
{
|
||
|
batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
batch = textBox3.Text.Trim();
|
||
|
}
|
||
|
newCode = _uniqueBll.GetSupplySerialNo(partNo, qLevel, batch);
|
||
|
}
|
||
|
}
|
||
|
}
|