@ -57,6 +57,8 @@ namespace InjectionPC
private bool _ isPrintPackage = true ;
private BarCodeBLL _ barCodeBLL = new BarCodeBLL ( ) ;
private InjectionBoxBLL _ injectionBoxBLL = new InjectionBoxBLL ( ) ;
private PLCMouldBLL _ PLCbll = new PLCMouldBLL ( ) ;
private PLCBreakBLL _ bbll = new PLCBreakBLL ( ) ;
private DataTable tb_Plastic = new DataTable ( ) ;
private string _ currentStationID = string . Empty ;
private const string _l eftType = "0" ; //模具1
@ -109,8 +111,9 @@ namespace InjectionPC
comboBox1 . Text = "A班" ; //班次
Program . cc = comboBox1 . Text ;
initProduct ( ) ;
textBox1 . Text = Program . ProductDate . Substring ( 2 , 2 ) + Program . ProductDate . Substring ( 5 , 2 ) +
Program . ProductDate . Substring ( 8 , 2 ) ; //批次
//textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) +
// Program.ProductDate.Substring(8, 2); //批次
textBox1 . Text = GetBatch ( true ) ;
initBarCode ( ) ;
label23 . Enabled = false ;
label23 . BackColor = System . Drawing . Color . Gray ;
@ -194,10 +197,10 @@ namespace InjectionPC
opcItems1 = opcGroup1 . OPCItems ;
opcItems1 . DefaultIsActive = true ;
PLCMouldBLL PLCbll = new PLCMouldBLL ( ) ;
PLCBreakBLL bbll = new PLCBreakBLL ( ) ;
//PLCMouldBLL PLCbll = new PLCMouldBLL();
//PLCBreakBLL bbll = new PLCBreakBLL();
DataTable PLCdt = PLCbll . SearchMould ( Program . station ) ;
DataTable PLCdt = _ PLCbll . SearchMould ( Program . station ) ;
if ( PLCdt ! = null & & PLCdt . Rows . Count > 0 )
{
opcItemm1 = new OPCItem [ PLCdt . Rows . Count ] ;
@ -348,6 +351,7 @@ namespace InjectionPC
string filename = "" , printName = "" , printBoxName = "" ;
int MaxCount = 0 , CurrentCount = 0 ;
if ( status = = false )
{
@ -371,12 +375,13 @@ namespace InjectionPC
{
return ;
}
_ bbll . SavePlcReceive ( Program . station , TransactionID , NumItems , aa , planID , "2411" ) ;
#endregion
//comboBox1.Text = "A班"; //班次
textBox1 . Text = Program . ProductDate . Substring ( 2 , 2 ) + Program . ProductDate . Substring ( 5 , 2 ) +
Program . ProductDate . Substring ( 8 , 2 ) ; //批次
//textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) +
// Program.ProductDate.Substring(8, 2); //批次
textBox1 . Text = GetBatch ( true ) ;
}
catch ( Exception ex )
{
@ -2157,8 +2162,8 @@ namespace InjectionPC
MessageBox . Show ( $"补打失败,条码[{code}]在表[{ Program.tableName}]中不存在!" ) ;
return ;
}
string msg = bll . ReprintSave ( md , Program . tableName , dt . Rows [ 0 ] [ "OneBarCode" ] . ToString ( ) , dt . Rows [ 0 ] [ "BarCode" ] . ToString ( ) , Program . station ) ;
//补打条码
string msg = bll . ReprintSave ( md , Program . tableName , dt . Rows [ 0 ] [ "OneBarCode" ] . ToString ( ) , dt . Rows [ 0 ] [ "BarCode" ] . ToString ( ) , Program . station , "3" ) ;
if ( ! string . IsNullOrEmpty ( msg ) )
{
MessageBox . Show ( $"补打失败,原因:" + msg ) ;
@ -2683,10 +2688,10 @@ namespace InjectionPC
opcItems1 = opcGroup1 . OPCItems ;
opcItems1 . DefaultIsActive = true ;
PLCMouldBLL PLCbll = new PLCMouldBLL ( ) ;
PLCBreakBLL bbll = new PLCBreakBLL ( ) ;
//PLCMouldBLL PLCbll = new PLCMouldBLL();
//PLCBreakBLL bbll = new PLCBreakBLL();
DataTable PLCdt = PLCbll . SearchMould ( Program . station ) ;
DataTable PLCdt = _ PLCbll . SearchMould ( Program . station ) ;
if ( PLCdt ! = null & & PLCdt . Rows . Count > 0 )
{
opcItemm1 = new OPCItem [ PLCdt . Rows . Count ] ;
@ -2802,286 +2807,289 @@ namespace InjectionPC
fr . Show ( ) ;
}
private void serialPort1_DataReceived ( object sender , SerialDataReceivedEventArgs e )
{
try
{
base . Invoke ( new EventHandler ( this . Scan ) ) ;
}
catch ( Exception ex )
{
LogErrBLL . AddInfo ( ex . ToString ( ) , MethodBase . GetCurrentMethod ( ) ) ;
}
}
private void Scan ( object sender , EventArgs e )
{
string _ code_meca = "" , printBoxName = "" ;
try
{
Thread . Sleep ( 1 5 0 0 ) ;
char [ ] buffer = new char [ serialPort1 . BytesToRead ] ;
serialPort1 . Read ( buffer , 0 , serialPort1 . BytesToRead ) ;
for ( int i = 0 ; i < buffer . Length ; i + + )
{
_ code_meca = _ code_meca + buffer [ i ] ;
}
GetClass ( ) ;
string aa = _ code_meca ;
var result1 = System . Text . RegularExpressions . Regex . Replace ( aa , @"\s*\n\s*" , "," ) ;
result1 = System . Text . RegularExpressions . Regex . Replace ( aa , @"\s*\f\s*" , "," ) ;
result1 = System . Text . RegularExpressions . Regex . Replace ( aa , @"\s*\r\s*" , "," ) ;
result1 = result1 . Remove ( result1 . LastIndexOf ( "," ) , 1 ) ;
result1 = result1 . Remove ( result1 . LastIndexOf ( "g" ) , 1 ) ;
int idxStart = result1 . LastIndexOf ( " " ) ;
string value = result1 . Substring ( idxStart , result1 . Length - idxStart ) . Trim ( ) ;
string [ ] b = value . Split ( '.' ) ;
string c = b [ 0 ] ;
string d = b [ 1 ] ;
int chengzhong = Convert . ToInt32 ( c ) ;
int chengzhong1 = Convert . ToInt32 ( d ) ;
if ( chengzhong1 > = 5 )
{
chengzhong = chengzhong + 1 ; //重量
}
InjectionPlanBLL bll = new InjectionPlanBLL ( ) ;
BarCodeBLL brbll = new BarCodeBLL ( ) ;
BarCodeModel md = new BarCodeModel ( ) ;
ProductBLL productBll = new ProductBLL ( ) ;
PlasticBLL pbll = _ plasticBLL ;
InjectionBoxBLL boxbll = new InjectionBoxBLL ( ) ;
InjectionBoxModel boxmd = new InjectionBoxModel ( ) ;
DataTable dt2 = null ;
string code = "" , OneCode = "" ;
string newcode = "" , newcode1 = "" , NewOneCode = "" , NewOneCode1 = "" ;
string IsPack = "" , IsOne = "" , QLevel = "" , IsPaint = "" , PartName = "" , IsSupply = "" ;
string filename = "" , printName = "" ;
int MaxCount = 0 , CurrentCount = 0 ;
#region 查找当前计划
//private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
//{
// try
// {
// base.Invoke(new EventHandler(this.Scan));
// }
// catch (Exception ex)
// {
// LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
// }
DataTable dt = bll . SearchInfoByName ( Program . station ) ;
if ( dt ! = null & & dt . Rows . Count > 0 )
{
planID = dt . Rows [ 0 ] [ "InjectionPlanID" ] . ToString ( ) ;
string [ ] partNo = dt . Rows [ 0 ] [ "PartNo" ] . ToString ( ) . Split ( ',' ) ;
string [ ] stockNo = new string [ partNo . Length ] ;
//string[] stockNo = dt.Rows[0]["StockNo"].ToString().Split(',');
string ProductNature = dt . Rows [ 0 ] [ "ProductNature" ] . ToString ( ) ;
int IsSame = 0 ;
//}
#region 判断有几个零件号
string mould = "0" ;
for ( int j = 0 ; j < partNo . Length ; j + + )
{
#region 根据零件号查找存货代码
//private void Scan(object sender, EventArgs e)
//{
// string _code_meca = "",printBoxName="";
// try
// {
// Thread.Sleep(1500);
// char[] buffer = new char[serialPort1.BytesToRead];
// serialPort1.Read(buffer, 0, serialPort1.BytesToRead);
// for (int i = 0; i < buffer.Length; i++)
// {
// _code_meca = _code_meca + buffer[i];
// }
DataTable sdt = productBll . SearchInfoByPartNo ( partNo [ j ] . ToString ( ) . Trim ( ) ) ;
if ( sdt ! = null & & sdt . Rows . Count > 0 )
{
stockNo [ j ] = sdt . Rows [ 0 ] [ "StockNo" ] . ToString ( ) ;
IsSame = Convert . ToInt32 ( sdt . Rows [ 0 ] [ "IsSame" ] . ToString ( ) ) ;
}
else
{
stockNo [ j ] = "" ;
IsSame = 0 ;
}
// GetClass();
// string aa = _code_meca;
// var result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\n\s*", ",");
// result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\f\s*", ",");
// result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\r\s*", ",");
// result1 = result1.Remove(result1.LastIndexOf(","), 1);
// result1 = result1.Remove(result1.LastIndexOf("g"), 1);
// int idxStart = result1.LastIndexOf(" ");
// string value = result1.Substring(idxStart, result1.Length - idxStart).Trim();
// string[] b = value.Split('.');
// string c = b[0];
// string d = b[1];
// int chengzhong = Convert.ToInt32(c);
// int chengzhong1 = Convert.ToInt32(d);
// if (chengzhong1 >= 5)
// {
// chengzhong = chengzhong + 1; //重量
// }
#endregion
// InjectionPlanBLL bll = new InjectionPlanBLL();
// BarCodeBLL brbll = new BarCodeBLL();
// BarCodeModel md = new BarCodeModel();
// ProductBLL productBll = new ProductBLL();
// PlasticBLL pbll = _plasticBLL;
// InjectionBoxBLL boxbll = new InjectionBoxBLL();
// InjectionBoxModel boxmd = new InjectionBoxModel();
// DataTable dt2 = null;
// string code = "", OneCode = "";
// string newcode = "", newcode1 = "", NewOneCode = "", NewOneCode1 = "";
// string IsPack = "", IsOne = "", QLevel = "", IsPaint = "", PartName = "",IsSupply="";
// string filename = "", printName = "";
// int MaxCount = 0, CurrentCount = 0;
// #region 查找当前计划
// DataTable dt = bll.SearchInfoByName(Program.station);
// if (dt != null && dt.Rows.Count > 0)
// {
// planID = dt.Rows[0]["InjectionPlanID"].ToString();
// string[] partNo = dt.Rows[0]["PartNo"].ToString().Split(',');
// string[] stockNo = new string [partNo.Length];
// //string[] stockNo = dt.Rows[0]["StockNo"].ToString().Split(',');
// string ProductNature = dt.Rows[0]["ProductNature"].ToString();
// int IsSame = 0;
// #region 判断有几个零件号
// string mould = "0";
// for (int j = 0; j < partNo.Length; j++)
// {
// #region 根据零件号查找存货代码
DataTable dt3 = productBll . SearchInfoByPartNo ( partNo [ j ] . ToString ( ) . Trim ( ) ) ;
if ( dt3 ! = null & & dt3 . Rows . Count > 0 )
{
QLevel = dt3 . Rows [ 0 ] [ "QLevel" ] . ToString ( ) ;
IsOne = dt3 . Rows [ 0 ] [ "IsPrintOneTag" ] . ToString ( ) ;
IsPack = dt3 . Rows [ 0 ] [ "IsPrintPackList" ] . ToString ( ) ;
IsPaint = dt3 . Rows [ 0 ] [ "IsPlating" ] . ToString ( ) ;
PartName = dt3 . Rows [ 0 ] [ "ProductName" ] . ToString ( ) ;
MaxCount = Convert . ToInt32 ( dt3 . Rows [ 0 ] [ "PackCount" ] . ToString ( ) ) ;
IsSupply = dt3 . Rows [ 0 ] [ "IsSupply" ] . ToString ( ) ;
}
// DataTable s dt = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim());
// if (s dt != null && s dt.Rows.Count > 0)
// {
// stockNo[j] = sdt.Rows[0]["StockNo"].ToString();
// IsSame=Convert.ToInt32(sdt.Rows[0]["IsSame"].ToString());
// }
// else
// {
// stockNo[j] = "";
// IsSame = 0;
// }
if ( IsSame = = 1 )
{
for ( int k = 0 ; k < 2 ; k + + )
{
// #endregion
GetSjBarCode ( stockNo [ j ] . ToString ( ) . Trim ( ) , partNo [ j ] . ToString ( ) . Trim ( ) , true , mould , PartName , ref NewOneCode , ref newcode ) ;
// DataTable dt3 = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim());
// if (dt3 != null && dt3.Rows.Count > 0)
// {
// QLevel = dt3.Rows[0]["QLevel"].ToString();
// IsOne = dt3.Rows[0]["IsPrintOneTag"].ToString();
// IsPack = dt3.Rows[0]["IsPrintPackList"].ToString();
// IsPaint = dt3.Rows[0]["IsPlating"].ToString();
// PartName = dt3.Rows[0]["ProductName"].ToString();
// MaxCount = Convert.ToInt32(dt3.Rows[0]["PackCount"].ToString());
// IsSupply = dt3.Rows[0]["IsSupply"].ToString();
// }
#region 插入数据tb_barCode
// if (IsSame == 1)
// {
// for (int k = 0; k < 2; k++)
// {
md . ID = Guid . NewGuid ( ) . ToString ( ) ;
md . StationID = dt . Rows [ 0 ] [ "StationID" ] . ToString ( ) ;
md . OneBarCode = NewOneCode ;
md . BarCode = newcode ;
md . StockNo = stockNo [ j ] . ToString ( ) . Trim ( ) ;
md . PartNo = partNo [ j ] . ToString ( ) . Trim ( ) ;
md . PrintType = 0 ;
md . PlanID = planID ;
md . ProductNature = ProductNature ;
md . Des1 = PartName ;
DataTable pdt = productBll . SearchIsImportByPartNo ( partNo [ j ] . ToString ( ) ) ;
if ( pdt ! = null & & pdt . Rows . Count > 0 )
{
if ( pdt . Rows [ 0 ] [ "isImport" ] . ToString ( ) = = "1" )
{
md . Import = "国产料Kingfa" ;
}
else
{
md . Import = "" ;
}
}
// GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, ref NewOneCode, ref newcode);
// #region 插入数据tb_barCode
// md.ID = Guid.NewGuid().ToString();
// md.StationID = dt.Rows[0]["StationID"].ToString();
// md.OneBarCode = NewOneCode;
// md.BarCode = newcode;
// md.StockNo = stockNo[j].ToString().Trim();
// md.PartNo = partNo[j].ToString().Trim();
// md.PrintType = 0;
// md.PlanID = planID;
// md.ProductNature = ProductNature;
// md.Des1 = PartName;
// DataTable pdt = productBll.SearchIsImportByPartNo(partNo[j].ToString());
// if (pdt != null && pdt.Rows.Count > 0)
// {
// if (pdt.Rows[0]["isImport"].ToString() == "1")
// {
// md.Import = "国产料Kingfa";
// }
// else
// {
// md.Import = "";
// }
// }
////if (brbll.Add_Info_New(md, Program.tableName)==false)
//if (SaveBarCode(md, Program.tableName, true, mould) == false)
//{
// return;
//}
// ////if (brbll.Add_Info_New(md, Program.tableName)==false)
// //if (SaveBarCode(md, Program.tableName, true, mould) == false)
// //{
// // return;
// //}
string errMsg = string . Empty ;
bool saveRst = SaveInfo ( md , true , mould , false , ref errMsg ) ;
if ( saveRst = = false )
{
//MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg);
//return;
}
// string errMsg = string.Empty;
// bool saveRst = SaveInfo(md, true, mould, false, ref errMsg);
// if (saveRst = = false)
// {
// //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg);
// //return;
// }
#endregion
// #endregion
#region 打印条码,判断是否打印单个条码
// #region 打印条码,判断是否打印单个条码
DataTable dt4 = pbll . SearchInfo ( partNo [ j ] . ToString ( ) . Trim ( ) ,
dt . Rows [ 0 ] [ "StationID" ] . ToString ( ) ) ;
if ( dt4 ! = null & & dt4 . Rows . Count > 0 )
{
printName = "Printer" + dt4 . Rows [ 0 ] [ "PrinterNo" ] . ToString ( ) ;
}
// DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(),
// dt.Rows[0]["StationID"].ToString());
// if (dt4 != null && dt4.Rows.Count > 0)
// {
// printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString();
// }
#region 打印单个标签
// #region 打印单个标签
if ( IsOne = = "1" )
{
if ( IsSupply = = "1" )
{
filename = System . AppDomain . CurrentDomain . BaseDirectory + PrintMoudleName ( IsSupply ) ;
// if (IsOne = = "1")
// {
// if (IsSupply = = "1")
// {
// filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply);
string reportName = ConfigurationManager . AppSettings [ printName ] . ToString ( ) ;
DataTable headTable = GetPrintHeadTable ( partNo [ j ] . ToString ( ) . Trim ( ) , PartName , NewOneCode , newcode ) ;
// string reportName = ConfigurationManager.AppSettings[printName].ToString();
// DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode);
ReportHelper rp = new ReportHelper ( filename , headTable , null ,
( int ) GRPaperOrientation . grpoDefault , 1 , reportName ) ;
// ReportHelper rp = new ReportHelper(filename, headTable, null,
// (int) GRPaperOrientation.grpoDefault, 1, reportName);
rp . Report . Print ( false ) ;
}
}
// rp.Report.Print(false);
// }
// }
#endregion
// #endregion
#endregion
}
}
else
{
GetSjBarCode ( stockNo [ j ] . ToString ( ) . Trim ( ) , partNo [ j ] . ToString ( ) . Trim ( ) , true , mould , PartName , ref NewOneCode , ref newcode ) ;
// #endregion
// }
// }
// else
// {
// GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, ref NewOneCode, ref newcode);
// #region 插入数据tb_barCode
// md.ID = Guid.NewGuid().ToString();
// md.StationID = dt.Rows[0]["StationID"].ToString();
// md.OneBarCode = NewOneCode;
// md.BarCode = newcode;
// md.StockNo = stockNo[j].ToString().Trim();
// md.PartNo = partNo[j].ToString().Trim();
// md.PrintType = 0;
// md.PlanID = planID;
// md.ProductNature = ProductNature;
// md.Des1 = PartName;
// DataTable pdt = productBll.SearchIsImportByPartNo(partNo[j].ToString());
// if (pdt != null && pdt.Rows.Count > 0)
// {
// if (pdt.Rows[0]["isImport"].ToString() == "1")
// {
// md.Import = "国产料Kingfa";
// }
// else
// {
// md.Import = "";
// }
// }
#region 插入数据tb_barCode
// ////if (brbll.Add_Info_New(md, Program.tableName)==false)
// //if (SaveBarCode(md, Program.tableName, true, mould) == false)
// //{
// // return;
// //}
md . ID = Guid . NewGuid ( ) . ToString ( ) ;
md . StationID = dt . Rows [ 0 ] [ "StationID" ] . ToString ( ) ;
md . OneBarCode = NewOneCode ;
md . BarCode = newcode ;
md . StockNo = stockNo [ j ] . ToString ( ) . Trim ( ) ;
md . PartNo = partNo [ j ] . ToString ( ) . Trim ( ) ;
md . PrintType = 0 ;
md . PlanID = planID ;
md . ProductNature = ProductNature ;
md . Des1 = PartName ;
DataTable pdt = productBll . SearchIsImportByPartNo ( partNo [ j ] . ToString ( ) ) ;
if ( pdt ! = null & & pdt . Rows . Count > 0 )
{
if ( pdt . Rows [ 0 ] [ "isImport" ] . ToString ( ) = = "1" )
{
md . Import = "国产料Kingfa" ;
}
else
{
md . Import = "" ;
}
}
// string errMsg = string.Empty;
// bool saveRst = SaveInfo(md, true, mould, false, ref errMsg);
// if (saveRst == false)
// {
// //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg);
// //return;
// }
// #endregion
////if (brbll.Add_Info_New(md, Program.tableName)==false)
//if (SaveBarCode(md, Program.tableName, true, mould) == false)
//{
// return;
//}
// #region 打印条码,判断是否打印单个条码
string errMsg = string . Empty ;
bool saveRst = SaveInfo ( md , true , mould , false , ref errMsg ) ;
if ( saveRst = = false )
{
//MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg);
//return;
}
#endregion
// DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(),
// dt.Rows[0]["StationID"].ToString());
// if (dt4 != null && dt4.Rows.Count > 0)
// {
// printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString();
// }
#region 打印条码,判断是否打印单个条码
// #region 打印单个标签
DataTable dt4 = pbll . SearchInfo ( partNo [ j ] . ToString ( ) . Trim ( ) ,
dt . Rows [ 0 ] [ "StationID" ] . ToString ( ) ) ;
if ( dt4 ! = null & & dt4 . Rows . Count > 0 )
{
printName = "Printer" + dt4 . Rows [ 0 ] [ "PrinterNo" ] . ToString ( ) ;
}
// if (IsOne == "1")
// {
// if (IsSupply == "1")
// {
// filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply); //new
#region 打印单个标签
// string reportName = ConfigurationManager.AppSettings[printName].ToString();
// DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode);
if ( IsOne = = "1" )
{
if ( IsSupply = = "1" )
{
filename = System . AppDomain . CurrentDomain . BaseDirectory + PrintMoudleName ( IsSupply ) ; //new
// LogHelper.WriteLog(printName + ";" + reportName + ";" + filename);
// ReportHelper rp = new ReportHelper(filename, headTable, null,
// (int) GRPaperOrientation.grpoDefault, 1, reportName);
string reportName = ConfigurationManager . AppSettings [ printName ] . ToString ( ) ;
DataTable headTable = GetPrintHeadTable ( partNo [ j ] . ToString ( ) . Trim ( ) , PartName , NewOneCode , newcode ) ;
// rp.Report.Print(false);
// }
// }
LogHelper . WriteLog ( printName + ";" + reportName + ";" + filename ) ;
ReportHelper rp = new ReportHelper ( filename , headTable , null ,
( int ) GRPaperOrientation . grpoDefault , 1 , reportName ) ;
// #endregion
rp . Report . Print ( false ) ;
}
}
#endregion
// #endregion
// }
// initBarCode();
// }
// #endregion
// }
#endregion
}
initBarCode ( ) ;
}
// #endregion
// }
// catch (Exception ex)
// {
// LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
// }
//}
#endregion
}
#endregion
}
catch ( Exception ex )
{
LogErrBLL . AddInfo ( ex . ToString ( ) , MethodBase . GetCurrentMethod ( ) ) ;
}
}
private void timer2_Tick ( object sender , EventArgs e )
{
initPlan ( ) ;
Program . ProductDate = _ barCodeBLL . GetServiceTime ( ) . ToString ( ) ;
//initPlan();
}
private void comboBox2_TextChanged ( object sender , EventArgs e )
@ -3132,8 +3140,11 @@ namespace InjectionPC
label2 . BackColor = Color . Red ;
}
GetClass ( ) ;
textBox1 . Text = Program . ProductDate . Substring ( 2 , 2 ) + Program . ProductDate . Substring ( 5 , 2 ) +
Program . ProductDate . Substring ( 8 , 2 ) ; //批次
//textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) +
// Program.ProductDate.Substring(8, 2); //批次
textBox1 . Text = GetBatch ( true ) ;
@ -3157,130 +3168,127 @@ namespace InjectionPC
private DateTime GetPrintTime ( string station )
{
try
{
DateTime time = DateTime . Now ;
StationBLL bll = new StationBLL ( ) ;
//private DateTime GetPrintTime(string station)
//{
// try
// {
// DateTime time = DateTime.Now;
// StationBLL bll = new StationBLL();
DataTable dt = bll . SearchInfoByNo ( station ) ;
if ( dt ! = null & & dt . Rows . Count > 0 )
{
if ( string . IsNullOrEmpty ( dt . Rows [ 0 ] [ "PrintTime" ] . ToString ( ) ) )
{
time = DateTime . Now ;
}
else
{
time = Convert . ToDateTime ( dt . Rows [ 0 ] [ "PrintTime" ] . ToString ( ) ) ;
}
}
// DataTable dt = bll.SearchInfoByNo(station);
// if (dt != null && dt.Rows.Count > 0)
// {
// if (string.IsNullOrEmpty(dt.Rows[0]["PrintTime"].ToString()))
// {
// time = DateTime.Now;
// }
// else
// {
// time = Convert.ToDateTime(dt.Rows[0]["PrintTime"].ToString());
// }
// }
return time ;
}
catch ( Exception ex )
{
LogErrBLL . AddInfo ( ex . ToString ( ) , MethodBase . GetCurrentMethod ( ) ) ;
return DateTime . Now ;
}
}
// return time;
// }
// catch (Exception ex)
// {
// LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
// return DateTime.Now;
// }
//}
private bool UpdatePrintTime ( DateTime time , string station )
{
try
{
StationBLL bll = new StationBLL ( ) ;
return bll . UpdateTime ( time , station ) ;
}
catch ( Exception ex )
{
LogErrBLL . AddInfo ( ex . ToString ( ) , MethodBase . GetCurrentMethod ( ) ) ;
return false ;
}
}
private int GetSeconds ( string station )
{
try
{
int seconds = 0 ;
StationBLL bll = new StationBLL ( ) ;
//private bool UpdatePrintTime(DateTime time, string station)
//{
// try
// {
// StationBLL bll = new StationBLL();
// return bll.UpdateTime(time, station);
// }
// catch (Exception ex)
// {
// LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
// return false;
// }
//}
DataTable dt = bll . SearchInfoByNo ( station ) ;
if ( dt ! = null & & dt . Rows . Count > 0 )
{
if ( string . IsNullOrEmpty ( dt . Rows [ 0 ] [ "Seconds" ] . ToString ( ) ) )
{
seconds = 0 ;
}
else
{
seconds = Convert . ToInt32 ( dt . Rows [ 0 ] [ "Seconds" ] . ToString ( ) ) ;
}
}
//private int GetSeconds(string station)
//{
// try
// {
// int seconds = 0;
// StationBLL bll = new StationBLL();
return seconds ;
}
catch ( Exception ex )
{
LogErrBLL . AddInfo ( ex . ToString ( ) , MethodBase . GetCurrentMethod ( ) ) ;
return 0 ;
}
}
// DataTable dt = bll.SearchInfoByNo(station);
// if (dt != null && dt.Rows.Count > 0)
// {
// if (string.IsNullOrEmpty(dt.Rows[0]["Seconds"].ToString()))
// {
// seconds = 0;
// }
// else
// {
// seconds = Convert.ToInt32(dt.Rows[0]["Seconds"].ToString());
// }
// }
/// <summary>
/// 计算时间差
/// </summary>
/// <param name="t">时间1</param>
/// <param name="t2">时间2</param>
/// <returns>返回值:时间差(毫秒为单位)</returns>
private long TimeDiff ( DateTime t , DateTime t2 )
{
long lReturn = - 1 ;
System . TimeSpan NowValue = new TimeSpan ( t . Ticks ) ;
System . TimeSpan TimeValue = new TimeSpan ( t2 . Ticks ) ;
System . TimeSpan DateDiff = TimeSpan . Zero ;
try
{
//计算时间差
//DateDiff = TimeValue.Subtract(NowValue).Duration();
DateDiff = TimeValue . Subtract ( NowValue ) ;
int hours = DateDiff . Hours ;
int minutes = DateDiff . Minutes ;
int seconds = DateDiff . Seconds ;
int milliseconds = DateDiff . Milliseconds ;
string TimeDiff = hours . ToString ( ) + ":"
+ minutes . ToString ( ) + ":"
+ seconds . ToString ( ) + "."
+ milliseconds . ToString ( ) ;
//是否比现在的时间小,如果小就设置成第二天再启动,否则当天启动
if ( hours < = 0 & & minutes < = 0 & & seconds < = 0 & & milliseconds < = 0 )
hours + = 2 4 ;
lReturn = hours * 3 6 0 0
+ minutes * 6 0
+ seconds ;
}
catch ( Exception ex )
{
LogErrBLL . AddInfo ( ex . ToString ( ) , MethodBase . GetCurrentMethod ( ) ) ;
}
return lReturn ;
}
// return seconds;
// }
// catch (Exception ex)
// {
// LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
// return 0;
// }
//}
//bool SaveBarCode(BarCodeModel bcm, string tableName, bool isAutoPrint, string mould, bool handPrint = false)
///// <summary>
///// 计算时间差
///// </summary>
///// <param name="t">时间1</param>
///// <param name="t2">时间2</param>
///// <returns>返回值:时间差(毫秒为单位)</returns>
//private long TimeDiff(DateTime t, DateTime t2)
//{
// return true;
// long lReturn = -1;
// System.TimeSpan NowValue = new TimeSpan(t.Ticks);
// System.TimeSpan TimeValue = new TimeSpan(t2.Ticks);
// System.TimeSpan DateDiff = TimeSpan.Zero;
// try
// {
// //计算时间差
// //DateDiff = TimeValue.Subtract(NowValue).Duration();
// DateDiff = TimeValue.Subtract(NowValue);
// int hours = DateDiff.Hours;
// int minutes = DateDiff.Minutes;
// int seconds = DateDiff.Seconds;
// int milliseconds = DateDiff.Milliseconds;
// string TimeDiff = hours.ToString() + ":"
// + minutes.ToString() + ":"
// + seconds.ToString() + "."
// + milliseconds.ToString();
// //是否比现在的时间小,如果小就设置成第二天再启动,否则当天启动
// if (hours <= 0 && minutes <= 0 && seconds <= 0 && milliseconds <= 0)
// hours += 24;
// lReturn = hours * 3600
// + minutes * 60
// + seconds;
// }
// catch (Exception ex)
// {
// LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
// }
// return lReturn;
//}
bool SaveBarCode ( BarCodeModel bcm , string tableName , bool isAutoPrint , string mould , ref string errorMsg , bool handPrint = false )
{
string rst = _ wmsBll . SaveRecordAndInterface ( bcm , Program . tableName , "" , Program . station ) ;
string rst = _ wmsBll . SaveRecordAndInterface ( bcm , Program . tableName , "" , Program . station , "4" ) ;
if ( string . IsNullOrEmpty ( rst ) )
{
return true ;
@ -3368,13 +3376,31 @@ namespace InjectionPC
string batch = string . Empty ;
if ( isAutoPrint )
{
batch = Program . ProductDate . Substring ( 2 , 2 ) + Program . ProductDate . Substring ( 5 , 2 ) + Program . ProductDate . Substring ( 8 , 2 ) ;
DateTime dt = DateTime . Now ;
if ( DateTime . TryParse ( Program . ProductDate , out dt ) = = false )
{
dt = DateTime . Now ;
}
batch = dt . ToString ( "yyMMdd" ) ;
// batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2);
}
else
{
batch = textBox1 . Text . Trim ( ) ;
}
return batch ;
//string batch = string.Empty;
//if (isAutoPrint)
//{
// batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2);
//}
//else
//{
// batch = textBox1.Text.Trim();
//}
//return batch;
}
//private object _selectItemL = null;
//bool _isShowHintL = true;
@ -3394,7 +3420,8 @@ namespace InjectionPC
string batch = string . Empty ;
if ( autoPrint )
{
batch = Program . ProductDate . Substring ( 2 , 2 ) + Program . ProductDate . Substring ( 5 , 2 ) + Program . ProductDate . Substring ( 8 , 2 ) ;
//batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2);
batch = GetBatch ( true ) ;
}
else
{
@ -3429,8 +3456,9 @@ namespace InjectionPC
IsTest = true ;
bool bbb = true ;
//label23_Click(null, null);
textBox1 . Text = Program . ProductDate . Substring ( 2 , 2 ) + Program . ProductDate . Substring ( 5 , 2 ) +
Program . ProductDate . Substring ( 8 , 2 ) ;
//textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) +
// Program.ProductDate.Substring(8, 2);
textBox1 . Text = GetBatch ( true ) ;
if ( bbb = = true )
{ //自动
opcGroup1_DataChange ( 1 , 1 , ref a , ref b , ref c , ref d ) ;
@ -3520,10 +3548,10 @@ namespace InjectionPC
opcItems1 = opcGroup1 . OPCItems ;
opcItems1 . DefaultIsActive = true ;
PLCMouldBLL PLCbll = new PLCMouldBLL ( ) ;
PLCBreakBLL bbll = new PLCBreakBLL ( ) ;
//PLCMouldBLL PLCbll = new PLCMouldBLL();
//PLCBreakBLL bbll = new PLCBreakBLL();
DataTable PLCdt = PLCbll . SearchMould ( Program . station ) ;
DataTable PLCdt = _ PLCbll . SearchMould ( Program . station ) ;
if ( PLCdt ! = null & & PLCdt . Rows . Count > 0 )
{
opcItemm1 = new OPCItem [ PLCdt . Rows . Count ] ;
@ -3575,35 +3603,36 @@ namespace InjectionPC
string PrintMoudleName ( string isSupply = "0" )
{
if ( "IM05,IM08,IM10" . Contains ( Program . station ) ) //二维小条码
{
return "单个条码2.grf" ;
}
else if ( "IM06,IM07,IM09,IM11,IM12," . Contains ( Program . station ) ) //一维条码
{
return "单个条码.grf" ;
}
return BussinessHelper . PrintMoudleName ( Program . station , isSupply ) ;
//if ("IM05,IM08,IM10".Contains(Program.station)) //二维小条码
//{
// return "单个条码2.grf";
//}
//else if ("IM06,IM07,IM09,IM11,IM12,".Contains(Program.station)) //一维条码
//{
// return "单个条码.grf";
//}
else if ( "IM01,IM02,IM03,IM04,IM15,IM18,IM20" . Contains ( Program . station ) ) //小米大条码
{
return "Sill.grf" ;
}
else if ( "IM13,IM14" . Contains ( Program . station ) ) //直供条码
{
//return "单个条码1.grf";
if ( isSupply = = "0" ) //13,14机台,直供件打二维码 非直供件打一维码
{
return "单个条码.grf" ;
}
else
{
return "单个条码2.grf" ;
}
}
else
{
return "单个条码2.grf" ;
}
//else if ("IM01,IM02,IM03,IM04,IM15,IM18,IM20".Contains(Program.station)) //小米大条码
//{
// return "Sill.grf";
//}
//else if ("IM13,IM14".Contains(Program.station)) //直供条码
//{
// //return "单个条码1.grf";
// if (isSupply == "0") //13,14机台,直供件打二维码 非直供件打一维码
// {
// return "单个条码.grf";
// }
// else
// {
// return "单个条码2.grf";
// }
//}
//else
//{
// return "单个条码2.grf";
//}
}