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.
247 lines
8.9 KiB
247 lines
8.9 KiB
5 days 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;
|
||
|
using MESClassLibrary.BLL;
|
||
|
using MESClassLibrary.BLL.BasicInfo;
|
||
|
using MESClassLibrary.BLL.Injection;
|
||
|
using MESClassLibrary.BLL.Inspection;
|
||
|
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 FrmBarCodeSearch2502 : Form
|
||
|
{
|
||
|
private BarCodeBLL _barCodeBLL = new BarCodeBLL();
|
||
|
public FrmBarCodeSearch2502()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
this.Size = new Size(1280, 1024);
|
||
|
}
|
||
|
|
||
|
|
||
|
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]["StationNo"].ToString();
|
||
|
//glacialList1.Items[i].SubItems[5].Text = dt.Rows[i]["isSupply"].ToString();
|
||
|
//glacialList1.Items[i].SubItems[5].Text = dt.Rows[i]["BatchNo"].ToString();
|
||
|
glacialList1.Items[i].SubItems[0].Tag = dt.Rows[i];
|
||
|
glacialList1.Items[i].SubItems[1].Tag = dt.Rows[i]["TableName"].ToString();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
private void FrmBarCodeSearch_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
initBarCode();
|
||
|
|
||
|
GetClass();
|
||
|
}
|
||
|
|
||
|
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());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
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 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();
|
||
|
//glacialList1.Items[i].SubItems[6].Text = dt.Rows[i]["StationNo"].ToString();
|
||
|
|
||
|
glacialList1.Items[i].SubItems[0].Tag = dt.Rows[i];
|
||
|
glacialList1.Items[i].SubItems[1].Tag = dt.Rows[i]["TableName"].ToString();
|
||
|
}
|
||
|
}
|
||
|
textBox5.Text = "";
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void FrmBarCodeSearch_FormClosing(object sender, FormClosingEventArgs e)
|
||
|
{
|
||
|
Application.Exit();
|
||
|
}
|
||
|
|
||
|
private void timer1_Tick(object sender, EventArgs e)
|
||
|
{
|
||
|
Program.ProductDate = _barCodeBLL.GetServiceTime().ToString();
|
||
|
}
|
||
|
|
||
|
private void btnRePrint_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (glacialList1.SelectedItems.Count > 0)
|
||
|
{
|
||
|
GlacialComponents.Controls.GLItem gv;
|
||
|
gv = glacialList1.SelectedItems[0] as GlacialComponents.Controls.GLItem;
|
||
|
|
||
|
DataRow recordRow = gv.SubItems[0].Tag as DataRow;
|
||
|
string printName = PrintMoudleName(recordRow);
|
||
|
|
||
|
DataTable headTable = new DataTable();
|
||
|
headTable.Columns.Add("PrintTime");
|
||
|
headTable.Columns.Add("PartNo");
|
||
|
headTable.Columns.Add("PartName");
|
||
|
headTable.Columns.Add("OneBarCode");
|
||
|
headTable.Columns.Add("BarCode");
|
||
|
headTable.Columns.Add("Station");
|
||
|
DataRow row = headTable.NewRow();
|
||
|
row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||
|
row["PartNo"] = recordRow["PartNo"].ToString();
|
||
|
row["PartName"] = recordRow["ProductName"].ToString();
|
||
|
row["OneBarCode"] = recordRow["OneBarCode"].ToString();
|
||
|
row["BarCode"] = recordRow["BarCode"].ToString();
|
||
|
row["Station"] = recordRow["StationNo"].ToString();
|
||
|
string reportName = ConfigurationManager.AppSettings["Printer1"].ToString();
|
||
|
headTable.Rows.Add(row);
|
||
|
|
||
|
ReportHelper rp = new ReportHelper(printName, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName);
|
||
|
|
||
|
rp.Report.Print(false);
|
||
|
|
||
|
AddRePrintRecords(row);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void AddRePrintRecords(DataRow row)
|
||
|
{
|
||
|
_barCodeBLL.Add_ReprintRecord(row, Program.OperatorName, Program.OperatorName);
|
||
|
}
|
||
|
|
||
|
string PrintMoudleName(DataRow row)
|
||
|
{
|
||
|
string stationName = row["StationNo"].ToString();
|
||
|
string isSupply = row["isSupply"].ToString();
|
||
|
return BussinessHelper.PrintMoudleName(stationName, isSupply);
|
||
|
}
|
||
|
}
|
||
|
}
|