@ -76,6 +76,8 @@ namespace InjectionPC
private ProductBLL productBll = new ProductBLL ( ) ;
//允许修改箱码标包的已打码最小数量
private int _ allowChangeBoxSizeMaxPrint = 8 ;
private string _ currentUserName = string . Empty ;
private FrmLogin _l ogin = new FrmLogin ( ) ;
#endregion
public FrmMain2408 ( )
@ -137,7 +139,7 @@ namespace InjectionPC
}
}
}
_ currentUserName = Program . UserName ;
initBarCode ( ) ;
label23 . Enabled = false ;
@ -989,7 +991,7 @@ namespace InjectionPC
}
catch ( Exception ex )
{
throw new Exception ( "p988 " + ex . Message ) ;
throw new Exception ( "p989 " + ex . Message ) ;
}
}
@ -1868,7 +1870,14 @@ namespace InjectionPC
string IsPack = "" , IsOne = "" , QLevel = "" , IsPaint = "" , PartName = "" , printBoxName = "" , IsSupply = "" , ManufacturerName = "" ;
string filename = "" , printName = "" ;
int MaxCount = 0 , CurrentCount = 0 ;
if ( comBoxSizeL . SelectedValue = = null )
{
MessageBox . Show ( "请选择规格型号." ) ;
return ;
}
CheckPackageSelect ( ) ;
ProductBLL pbll = new ProductBLL ( ) ;
BarCodeBLL bll = new BarCodeBLL ( ) ;
BarCodeModel md = new BarCodeModel ( ) ;
@ -2336,6 +2345,7 @@ namespace InjectionPC
ManufacturerName = pdt . Rows [ 0 ] [ "ManufacturerName" ] . ToString ( ) . Trim ( ) ;
IsSupply = pdt . Rows [ 0 ] [ "IsSupply" ] . ToString ( ) ;
}
md . AddMan = _ currentUserName ;
//向箱码手动添加条码
string msg = bll . ReprintSave ( md , Program . tableName , "" , "" , Program . station , "2" ) ;
if ( ! string . IsNullOrEmpty ( msg ) )
@ -2468,7 +2478,7 @@ namespace InjectionPC
IsSupply = pdt . Rows [ 0 ] [ "IsSupply" ] . ToString ( ) ;
}
md . AddMan = _ currentUserName ;
//补打条码
string msg = bll . ReprintSave ( md , Program . tableName , dt . Rows [ 0 ] [ "OneBarCode" ] . ToString ( ) , dt . Rows [ 0 ] [ "BarCode" ] . ToString ( ) , Program . station , "3" ) ;
if ( ! string . IsNullOrEmpty ( msg ) )
@ -2891,7 +2901,7 @@ namespace InjectionPC
panel45 . Visible = false ;
textBox4 . Text = "" ;
}
/// <summary>
/// 暂停打印
/// </summary>
@ -2901,38 +2911,40 @@ namespace InjectionPC
{
try
{
if ( label13 . Text = = "暂停打印" )
{
DialogResult result = MessageBox . Show ( "确认暂停打印?" , "提示" , MessageBoxButtons . OKCancel ,
MessageBoxIcon . Information ) ;
if ( result = = DialogResult . OK )
{
if ( UnCompletePrintBox ( "切换手动打印" , "all" ) = = false ) return ;
opcGroup1 . DataChange - = new DIOPCGroupEvent_DataChangeEventHandler ( opcGroup1_DataChange ) ;
cboxHandBox . Enabled = true ;
opcServer . OPCGroups . RemoveAll ( ) ;
opcServer . Disconnect ( ) ;
//serialPort1.Close();
comboBox2 . Enabled = true ;
label23 . Enabled = true ;
label23 . BackColor = System . Drawing . Color . DeepSkyBlue ;
//if (ConfigurationManager.AppSettings["StationMode"].ToString() == "1")
//{
// timer1.Enabled = false;
//}
//if (ConfigurationManager.AppSettings["StationMode"].ToString() == "2")
//{
// serialPort1.Close();
//}
label13 . Text = "开始打印" ;
label13 . BackColor = System . Drawing . Color . Gray ;
}
else
{
return ;
}
_l ogin = new FrmLogin ( ) ;
_l ogin . RegisterLoginMethod ( Login ) ;
_l ogin . ShowDialog ( ) ;
//DialogResult result = MessageBox.Show("确认暂停打印?", "提示", MessageBoxButtons.OKCancel,
// MessageBoxIcon.Information);
//if (result == DialogResult.OK)
//{
// if (UnCompletePrintBox("切换手动打印","all") == false) return;
// opcGroup1.DataChange -= new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange);
// cboxHandBox.Enabled = true;
// opcServer.OPCGroups.RemoveAll();
// opcServer.Disconnect();
// //serialPort1.Close();
// comboBox2.Enabled = true;
// label23.Enabled = true;
// label23.BackColor = System.Drawing.Color.DeepSkyBlue;
// //if (ConfigurationManager.AppSettings["StationMode"].ToString() == "1")
// //{
// // timer1.Enabled = false;
// //}
// //if (ConfigurationManager.AppSettings["StationMode"].ToString() == "2")
// //{
// // serialPort1.Close();
// //}
// label13.Text = "开始打印";
// label13.BackColor = System.Drawing.Color.Gray;
//}
//else
//{
// return;
//}
}
else
@ -2945,6 +2957,7 @@ namespace InjectionPC
cboxHandBox . Enabled = false ;
comboBox2 . Enabled = false ;
_ currentUserName = Program . UserName ;
#region 连接PLC
try
{
@ -3036,6 +3049,70 @@ namespace InjectionPC
}
}
private void Login ( string name , string pass )
{
string stationID = "" ;
StationBLL sbll = new StationBLL ( ) ;
DataTable sdt = sbll . SearchInfoByNo ( Program . station ) ;
if ( sdt ! = null & & sdt . Rows . Count > 0 )
{
stationID = sdt . Rows [ 0 ] [ "StationID" ] . ToString ( ) ;
}
sdt . Dispose ( ) ;
if ( string . IsNullOrEmpty ( stationID ) )
{
MessageBox . Show ( "配置工位" + Program . station + "在系统中不存在." ) ;
return ;
}
OperatorBLL bll = new OperatorBLL ( ) ;
DataTable dt = bll . SearchInfoByNameAndPsw ( name , stationID , pass ) ;
if ( dt ! = null & & dt . Rows . Count > 0 )
{
string lmt = dt . Rows [ 0 ] [ "Limit" ] . ToString ( ) ;
if ( lmt = = "allowhandprint" )
{
DialogResult result = MessageBox . Show ( "确认暂停打印?" , "提示" , MessageBoxButtons . OKCancel ,
MessageBoxIcon . Information ) ;
if ( result = = DialogResult . OK )
{
if ( UnCompletePrintBox ( "切换手动打印" , "all" ) = = false ) return ;
opcGroup1 . DataChange - = new DIOPCGroupEvent_DataChangeEventHandler ( opcGroup1_DataChange ) ;
cboxHandBox . Enabled = true ;
opcServer . OPCGroups . RemoveAll ( ) ;
opcServer . Disconnect ( ) ;
//serialPort1.Close();
comboBox2 . Enabled = true ;
label23 . Enabled = true ;
label23 . BackColor = System . Drawing . Color . DeepSkyBlue ;
label13 . Text = "开始打印" ;
label13 . BackColor = System . Drawing . Color . Gray ;
_ currentUserName = name ;
}
else
{
return ;
}
_l ogin . Close ( ) ;
}
else
{
MessageBox . Show ( "登录用户手动打码权限" ) ;
}
}
else
{
//f7ce2efa-13ac-4daa-8c7e-8f6287889411
//lbtip.Text = "用户名或者密码错误"
MessageBox . Show ( "用户名或者密码错误" ) ;
}
}
/// <summary>
/// 质量录入
/// </summary>
@ -3297,6 +3374,7 @@ namespace InjectionPC
}
bool saveRst = true ;
bcm . AddMan = _ currentUserName ;
//自动模式 或者手动模式选中绑定箱码
if ( isAutoPrint = = true | | ( isAutoPrint = = false & & cboxHandBox . Checked = = true ) )
{
@ -3612,6 +3690,10 @@ namespace InjectionPC
{
lbPackageCode . Text = packageCode ;
}
else
{
}
}
else
{
@ -3712,11 +3794,6 @@ namespace InjectionPC
}
//会死循环
//CheckPackageCode(partCode, autoPrint, mould, partName, isHandPrint);
}
}
@ -3750,10 +3827,10 @@ namespace InjectionPC
string batch = GetBatch ( autoPrint ) ;
GetBarCode ( stockNo , batch , partNo , ref newOneCode , ref newCode ) ;
if ( ! string . IsNullOrEmpty ( printTest ) )
{
SaveLog3 ( "BarCodePrint:" + Program . station + ":" + printTest + "_" + newOneCode ) ;
}
//if (!string.IsNullOrEmpty(printTest))
//{
// SaveLog3("BarCodePrint:"+ Program.station + ":" + printTest + "_" + newOneCode);
//}
// newOneCode = _uniqueBll.GetSjBarCodeSerialNo(stockNo, batch);
//newCode = partNo + "." + batch + "." + newOneCode.Substring(newOneCode.Length - 4, 4);
}
@ -3765,38 +3842,45 @@ namespace InjectionPC
string GetPackageCode ( string partNo , bool autoPrint , string mould )
{
string batch = GetBatch ( autoPrint ) ;
Label lbNeedQty = lbNeedQtyL ;
if ( mould = = "1" )
{
lbNeedQty = lbNeedQtyR ;
//packageSize = lbNeedQtyR.Text.Trim();
}
string packageSize = lbNeedQty . Text . Trim ( ) ;
int p = 0 ;
int . TryParse ( packageSize , out p ) ;
if ( string . IsNullOrEmpty ( packageSize ) | | p = = 0 )
try
{
//packageSize = "1";
DataTable dt3 = productBll . SearchInfoByPartNo ( partNo ) ;
if ( dt3 . Rows . Count > 0 )
string batch = GetBatch ( autoPrint ) ;
Label lbNeedQty = lbNeedQtyL ;
if ( mould = = "1" )
{
lbNeedQty = lbNeedQtyR ;
//packageSize = lbNeedQtyR.Text.Trim();
}
string packageSize = lbNeedQty . Text . Trim ( ) ;
int p = 0 ;
int . TryParse ( packageSize , out p ) ;
if ( string . IsNullOrEmpty ( packageSize ) | | p = = 0 )
{
//packageSize = "1";
DataTable dt3 = productBll . SearchInfoByPartNo ( partNo ) ;
if ( dt3 . Rows . Count > 0 )
{
packageSize = dt3 . Rows [ 0 ] [ "PackCount" ] . ToString ( ) ;
lbNeedQty . Text = packageSize ;
}
}
int . TryParse ( packageSize , out p ) ;
if ( string . IsNullOrEmpty ( packageSize ) | | p = = 0 )
{
packageSize = dt3 . Rows [ 0 ] [ "PackCount" ] . ToString ( ) ;
packageSize = ( _ allowChangeBoxSizeMaxPrint + 2 ) . ToString ( ) ;
lbNeedQty . Text = packageSize ;
}
string packageCode = _ uniqueBll . GetPackageCodeSerialNo ( partNo , batch , packageSize ) ;
return packageCode ;
}
int . TryParse ( packageSize , out p ) ;
if ( string . IsNullOrEmpty ( packageSize ) | | p = = 0 )
catch ( Exception ex )
{
packageSize = ( _ allowChangeBoxSizeMaxPrint + 2 ) . ToString ( ) ;
lbNeedQty . Text = packageSize ;
throw new Exception ( "获取箱码发生异常.-GetPackageCode:partNo:autoPrint:mould" + ex . Message ) ;
}
string packageCode = _ uniqueBll . GetPackageCodeSerialNo ( partNo , batch , packageSize ) ;
return packageCode ;
}
string GetBatch ( bool isAutoPrint )
{
@ -3993,6 +4077,10 @@ namespace InjectionPC
if ( i = = 0 )
{
List < string > list = comBoxSizeL . DataSource as List < string > ;
if ( list = = null )
{
throw new Exception ( "左侧规格标包列表数据源为空(CheckPackageSelect)." ) ;
}
if ( list . Count > 0 )
{
lbNeedQtyL . Text = list [ 0 ] ;