@ -39,7 +39,7 @@ namespace XGLFinishPro.Views
private static double MainLineWidth = 80 ;
private static double MainLineWidth = 80 ;
private static double MainLineHeight = 50 ;
private static double MainLineHeight = 50 ;
string deviceCode = Utils . GetAppSetting ( "DeviceCode" ) ;
string deviceCode = Utils . GetAppSetting ( "DeviceCode" ) ;
private string LProductName = string . Empty ;
private string product_code = string . Empty ;
private string product_code = string . Empty ;
private bool isUpdate = false ;
private bool isUpdate = false ;
private List < string > DefaultTypeDic = new List < string > ( ) { string . Empty , "√" , "x" } ;
private List < string > DefaultTypeDic = new List < string > ( ) { string . Empty , "√" , "x" } ;
@ -49,27 +49,32 @@ namespace XGLFinishPro.Views
private List < ConveterData > list = new List < ConveterData > ( ) ;
private List < ConveterData > list = new List < ConveterData > ( ) ;
private readonly List < string > _minutes = new List < string > { "00" , "05" , "10" , "15" , "20" , "25" , "30" , "35" , "40" , "45" , "50" , "55" } ;
private readonly List < string > _minutes = new List < string > { "00" , "05" , "10" , "15" , "20" , "25" , "30" , "35" , "40" , "45" , "50" , "55" } ;
private readonly string workId = string . Empty ;
private string workId = string . Empty ;
private readonly string date = string . Empty ;
private string date = string . Empty ;
public LanJu_First_Inspection_Reprot ( string workId , string date )
public LanJu_First_Inspection_Reprot ( )
{
{
InitializeComponent ( ) ;
InitializeComponent ( ) ;
this . workId = workId ;
this . date = date ;
}
}
private void Window_Loaded ( object sender , RoutedEventArgs e )
private void Window_Loaded ( object sender , RoutedEventArgs e )
{
{
try
try
{
{
this . RightNickName . Text = LoginUser . UserName ;
//this.RightNickName.Text = LoginUser.UserName ;
this . LeftNickName . Text = LoginUser . UserName ;
this . LeftNickName . Text = LoginUser . UserName ;
this . LeftCheckDate . Text = date ;
try
this . RightCheckDate . Text = DateTime . Parse ( this . LeftCheckDate . Text ) . AddDays ( 1 ) . ToString ( "yyyy/MM/dd" ) ;
{
this . LeftCheckDate . SelectedDate = DateTime . Parse ( LoginUser . WorkDate ) ;
}
catch
{
}
//this.RightCheckDate.Text = DateTime.Parse(this.LeftCheckDate.Text).AddDays(1).ToString("yyyy/MM/dd");
this . LeftLine . Text = dbService . GetBaseEquipment ( Utils . GetAppSetting ( "DeviceCode" ) ) ;
this . LeftLine . Text = dbService . GetBaseEquipment ( Utils . GetAppSetting ( "DeviceCode" ) ) ;
this . RightLine . Text = this . LeftLine . Text ;
//this.RightLine.Text = this.LeftLine.Text ;
product_code = string . Empty ;
product_code = string . Empty ;
}
}
@ -87,17 +92,16 @@ namespace XGLFinishPro.Views
DataTable dataTable = dbService . GetProOrderWorkorder ( workId ) ;
DataTable dataTable = dbService . GetProOrderWorkorder ( workId ) ;
if ( dataTable ! = null & & dataTable . Rows . Count > 0 )
if ( dataTable ! = null & & dataTable . Rows . Count > 0 )
{
{
this . LeftProductName . Text = dataTable . Rows [ 0 ] [ "product_name" ] . ToString ( ) ;
//LProductName = dataTable.Rows[0]["product_name"].ToString() ;
this . RightProductName . Text = dataTable . Rows [ 0 ] [ "product_name" ] . ToString ( ) ;
//this.RightProductName.Text = dataTable.Rows[0]["product_name"].ToString() ;
product_code = dataTable . Rows [ 0 ] [ "product_code" ] . ToString ( ) ;
product_code = dataTable . Rows [ 0 ] [ "product_code" ] . ToString ( ) ;
}
}
var leftHearList = dbService . GetSelfCheckInfo ( "first_inspection_left" ) . OrderBy ( t = > t . dict_sort ) . ToList ( ) ;
var leftHearList = dbService . GetSelfCheckInfo ( "first_inspection_left" ) . OrderBy ( t = > t . dict_sort ) . ToList ( ) ;
var leftMainList = dbService . GetSelfCheckInfo ( "first_inspection_left_info" ) . OrderBy ( t = > t . dict_sort ) . ToList ( ) ;
var leftMainList = dbService . GetSelfCheckInfo ( "first_inspection_left_info" ) . OrderBy ( t = > t . dict_sort ) . ToList ( ) ;
var rightHearList = dbService . GetSelfCheckInfo ( "first_inspection_right" ) . OrderBy ( t = > t . dict_sort ) . ToList ( ) ;
var rightHearList = dbService . GetSelfCheckInfo ( "first_inspection_right" ) . OrderBy ( t = > t . dict_sort ) . ToList ( ) ;
var rightMainList = dbService . GetSelfCheckInfo ( "first_inspection_right_info" ) . OrderBy ( t = > t . dict_sort ) . ToList ( ) ;
var rightMainList = dbService . GetSelfCheckInfo ( "first_inspection_right_info" ) . OrderBy ( t = > t . dict_sort ) . ToList ( ) ;
GetMesTableSeft ( ) ;
GetMesTableSeft ( ) ;
leftData = dbService . GetMesTableSelfDetial ( leftbelong_to , 6 ) ;
leftData = dbService . GetMesTableSelfDetial ( leftbelong_to , 6 ) ;
rightData = dbService . GetMesTableSelfDetial ( rightbelong_to , 6 ) ;
rightData = dbService . GetMesTableSelfDetial ( rightbelong_to , 6 ) ;
if ( addLine )
if ( addLine )
@ -214,9 +218,10 @@ namespace XGLFinishPro.Views
var dictionary = mesTableSelfDetialModels . ToDictionary ( t = > t . index ) ;
var dictionary = mesTableSelfDetialModels . ToDictionary ( t = > t . index ) ;
rightDic . Add ( item . info_name , dictionary ) ;
rightDic . Add ( item . info_name , dictionary ) ;
}
}
list . ForEach ( t = > t . value . Remove ( 9 , 11 ) ) ;
list . ForEach ( t = > t . value = t . value . Insert ( 0 , "A" ) ) ;
list . ForEach ( t = > t . value = t . value . Insert ( 0 , "A" ) ) ;
MakeHeaderData ( this . Left Grid ) ;
MakeHeaderData ( this . Left ) ;
MakeHeaderData ( this . RightGrid ) ;
//MakeHeaderData(this.Right) ;
var leftTypeDic = new Dictionary < string , List < string > > ( ) ;
var leftTypeDic = new Dictionary < string , List < string > > ( ) ;
foreach ( var item in leftHearList )
foreach ( var item in leftHearList )
@ -242,55 +247,59 @@ namespace XGLFinishPro.Views
}
}
}
}
MainValueData ( this . Left Grid , leftHearList , leftDic , leftTypeDic ) ;
MainValueData ( this . Left , leftHearList , leftDic , leftTypeDic ) ;
MainValueData ( this . RightGrid , rightHearList , rightDic , rightTypeDic ) ;
//MainValueData(this.Right, rightHearList, rightDic, rightTypeDic) ;
UpdateUi ( this . Left Grid ) ;
UpdateUi ( this . Left ) ;
UpdateUi ( this . RightGrid ) ;
//UpdateUi(this.Right) ;
isUpdate = false ;
isUpdate = false ;
}
}
private void GetMesTableSeft ( )
private void GetMesTableSeft ( )
{
{
MesTableSelf leftmesTableSelf = dbService . GetMesTableSelf ( deviceCode , this . L eft ProductName. Text , this . LeftCheckDate . Text , "ConversionReportLeft" ) ;
MesTableSelf leftmesTableSelf = dbService . GetMesTableSelf ( deviceCode , L ProductName, this . LeftCheckDate . Text , "ConversionReportLeft" ) ;
if ( leftmesTableSelf = = null )
if ( leftmesTableSelf = = null )
{
{
leftmesTableSelf = new MesTableSelf ( )
if ( ! string . IsNullOrEmpty ( LProductName ) )
{
{
id = Guid . NewGuid ( ) . ToString ( ) ,
leftmesTableSelf = new MesTableSelf ( )
line_code = deviceCode ,
{
product_name = this . LeftProductName . Text ,
id = Guid . NewGuid ( ) . ToString ( ) ,
check_date = this . LeftCheckDate . Text ,
line_code = deviceCode ,
product_code = product_code ,
product_name = LProductName ,
factory_code = Utils . GetAppSetting ( "SiteCode" ) ,
check_date = this . LeftCheckDate . Text ,
del_flag = "0" ,
product_code = product_code ,
product_date = this . LeftCheckDate . Text ,
factory_code = Utils . GetAppSetting ( "SiteCode" ) ,
bz = string . Empty ,
del_flag = "0" ,
report_name = "ConversionReportLeft"
product_date = this . LeftCheckDate . Text ,
} ;
bz = string . Empty ,
report_name = "ConversionReportLeft"
} ;
}
dbService . InsertMesTableSelf ( leftmesTableSelf ) ;
dbService . InsertMesTableSelf ( leftmesTableSelf ) ;
}
}
//7c9070ea-75f9-42ad-bf6b-3638f4745141
leftbelong_to = leftmesTableSelf . id ;
leftbelong_to = leftmesTableSelf . id ;
MesTableSelf rightmesTableSelf = dbService . GetMesTableSelf ( deviceCode , this . LeftProductName . Text , this . RightCheckDate . Text , "ConversionReportRight" ) ;
//MesTableSelf rightmesTableSelf = dbService.GetMesTableSelf(deviceCode, LProductName, this.RightCheckDate.Text, "ConversionReportRight") ;
if ( rightmesTableSelf = = null )
//if (rightmesTableSelf == null )
{
// {
rightmesTableSelf = new MesTableSelf ( )
// rightmesTableSelf = new MesTableSelf()
{
// {
id = Guid . NewGuid ( ) . ToString ( ) ,
// id = Guid.NewGuid().ToString(),
line_code = deviceCode ,
// line_code = deviceCode,
product_name = this . Left ProductName. Text ,
// product_name = LProductName,
check_date = this . RightCheckDate . Text ,
// //check_date = this.RightCheckDate.Text ,
product_code = product_code ,
// product_code = product_code,
factory_code = Utils . GetAppSetting ( "SiteCode" ) ,
// factory_code = Utils.GetAppSetting("SiteCode"),
del_flag = "0" ,
// del_flag = "0",
product_date = this . RightCheckDate . Text ,
// //product_date = this.RightCheckDate.Text ,
bz = string . Empty ,
// bz = string.Empty,
report_name = "ConversionReportRight"
// report_name = "ConversionReportRight"
} ;
// };
dbService . InsertMesTableSelf ( rightmesTableSelf ) ;
// dbService.InsertMesTableSelf(rightmesTableSelf);
}
// }
rightbelong_to = rightmesTableSelf . id ;
//rightbelong_to = rightmesTableSelf.id ;
}
}
private void MainValueData ( Grid grid , List < BaseDictData > HearListDic , Dictionary < string , Dictionary < int , MesTableSelfDetialModel > > data , Dictionary < string , List < string > > typeList )
private void MainValueData ( Grid grid , List < BaseDictData > HearListDic , Dictionary < string , Dictionary < int , MesTableSelfDetialModel > > data , Dictionary < string , List < string > > typeList )
@ -392,39 +401,64 @@ namespace XGLFinishPro.Views
{
{
SelectedItem = model . check_result ;
SelectedItem = model . check_result ;
}
}
ComboBox comboBox = new ComboBox ( )
if ( key . Contains ( "灌装量" ) )
{
{
Name = $"{grid.Name}{list.First(t => t.label == key).value}{j}" ,
TextBox textBox = new TextBox ( )
ItemsSource = hasType ? type : DefaultTypeDic ,
{
SelectedItem = SelectedItem ,
Name = $"{grid.Name}{list.First(t => t.label == key).value}{j}" ,
Width = MainLineWidth ,
Text = SelectedItem ,
Height = MainLineHeight
Width = MainLineWidth ,
} ;
Height = MainLineHeight ,
comboBox . SelectionChanged + = SelectionChanged ;
VerticalAlignment = VerticalAlignment . Center ,
Grid . SetRow ( comboBox , i ) ;
HorizontalAlignment = HorizontalAlignment . Center ,
Grid . SetColumn ( comboBox , j ) ;
FontSize = 20 ,
grid . Children . Add ( comboBox ) ;
TextWrapping = TextWrapping . Wrap ,
AcceptsReturn = true ,
} ;
textBox . LostFocus + = TextBox_LostFocus ;
Grid . SetRow ( textBox , i ) ;
Grid . SetColumn ( textBox , j ) ;
grid . Children . Add ( textBox ) ;
}
else
{
ComboBox comboBox = new ComboBox ( )
{
Name = $"{grid.Name}{list.First(t => t.label == key).value}{j}" ,
ItemsSource = hasType ? type : DefaultTypeDic ,
SelectedItem = SelectedItem ,
Width = MainLineWidth ,
Height = MainLineHeight
} ;
comboBox . SelectionChanged + = SelectionChanged ;
Grid . SetRow ( comboBox , i ) ;
Grid . SetColumn ( comboBox , j ) ;
grid . Children . Add ( comboBox ) ;
}
}
}
}
}
}
}
List < string > batchCodes = dbService . GetBatchCode ( workId ) ;
List < string > batchCodes = dbService . GetBatchCode ( workId ) ;
foreach ( var item in this . LeftGrid . Children )
foreach ( var item in this . Left . Children )
{
{
if ( item is ComboBox box )
if ( item is ComboBox box )
{
{
if ( box . Name . Contains ( "日期码" ) | | box . Name . Contains ( "生产批号" ) )
string label = list . Where ( t = > t . value = = box . Name . Substring ( 0 , box . Name . Length - 1 ) . Replace ( "Left" , "" ) . Replace ( "Right" , "" ) ) . First ( ) . label ;
if ( label . Contains ( "日期码" ) | | label . Contains ( "生产批号" ) )
{
{
box . ItemsSource = batchCodes ;
box . ItemsSource = batchCodes ;
}
}
}
}
}
}
foreach ( var item in this . RightGrid . Children )
foreach ( var item in this . Right . Children )
{
{
if ( item is ComboBox box )
if ( item is ComboBox box )
{
{
if ( box . Name . Contains ( "日期码" ) | | box . Name . Contains ( "生产批号" ) )
string v = box . Name . Substring ( 0 , box . Name . Length - 1 ) ;
string label = list . Where ( t = > t . value = = box . Name . Substring ( 0 , box . Name . Length - 1 ) . Replace ( "Left" , "" ) . Replace ( "Right" , "" ) ) . First ( ) . label ;
if ( label . Contains ( "日期码" ) | | label . Contains ( "生产批号" ) )
{
{
box . ItemsSource = batchCodes ;
box . ItemsSource = batchCodes ;
}
}
@ -432,6 +466,37 @@ namespace XGLFinishPro.Views
}
}
}
}
private void TextBox_LostFocus ( object sender , RoutedEventArgs e )
{
try
{
if ( isUpdate )
{
return ;
}
if ( sender is TextBox textBox )
{
string name = textBox . Name . Replace ( "Left" , "" ) . Replace ( "Right" , "" ) ;
string index = name . Substring ( name . Length - 1 , 1 ) ;
string key = list . First ( t = > t . value = = name . Substring ( 0 , name . Length - 1 ) ) . label ;
var mesTableSelfDetialModel = leftData . Where ( t = > t . info_name = = key & & t . index = = int . Parse ( index ) - 1 ) . FirstOrDefault ( ) ;
if ( mesTableSelfDetialModel ! = null )
{
if ( string . IsNullOrEmpty ( mesTableSelfDetialModel . id ) )
{
mesTableSelfDetialModel . id = Guid . NewGuid ( ) . ToString ( ) ;
mesTableSelfDetialModel . belong_to = leftbelong_to ;
}
mesTableSelfDetialModel . check_result = textBox . Text ;
}
}
}
catch
{
}
}
private void UpdateUi ( Grid grid )
private void UpdateUi ( Grid grid )
{
{
Dispatcher . Invoke ( ( ) = >
Dispatcher . Invoke ( ( ) = >
@ -448,7 +513,21 @@ namespace XGLFinishPro.Views
{
{
comboBox . Width = lineWidth - 10 ;
comboBox . Width = lineWidth - 10 ;
comboBox . Height = lineHeight - 10 ;
comboBox . Height = lineHeight - 10 ;
if ( string . IsNullOrEmpty ( LProductName ) )
{
comboBox . IsEnabled = false ;
}
}
}
if ( item is TextBox textBox )
{
textBox . Width = lineWidth - 10 ;
textBox . Height = lineHeight - 10 ;
if ( string . IsNullOrEmpty ( LProductName ) )
{
textBox . IsReadOnly = false ;
}
}
}
}
} ) ;
} ) ;
}
}
@ -611,17 +690,15 @@ namespace XGLFinishPro.Views
}
}
if ( sender is ComboBox comboBox )
if ( sender is ComboBox comboBox )
{
{
string name = comboBox . Name . Replace ( this . LeftGrid . Name , "" ) . Replace ( this . RightGrid . Name , "" ) ;
string name = comboBox . Name . Replace ( "Left" , "" ) . Replace ( "Right" , "" ) ;
string index = name . Substring ( name . Length - 1 , 1 ) ;
string index = name . Substring ( name . Length - 1 , 1 ) ;
string key = list . First ( t = > t . value = = name . Substring ( 0 , name . Length - 1 ) ) . label ;
string Hour = "00" ;
string Hour = "00" ;
string Minute = "00" ;
string Minute = "00" ;
if ( comboBox . Name . Contains ( "Hour" ) | | comboBox . Name . Contains ( "Minute" ) )
if ( comboBox . Name . Contains ( "Hour" ) | | comboBox . Name . Contains ( "Minute" ) )
{
{
if ( comboBox . Name . Contains ( "Left" ) )
if ( comboBox . Name . Contains ( this . LeftGrid . Name ) )
{
{
foreach ( var item in Left Grid . Children )
foreach ( var item in Left . Children )
{
{
if ( item is StackPanel stackPanel )
if ( item is StackPanel stackPanel )
{
{
@ -646,9 +723,9 @@ namespace XGLFinishPro.Views
t . check_time_s = Hour + ":" + Minute ;
t . check_time_s = Hour + ":" + Minute ;
} ) ;
} ) ;
}
}
else if ( comboBox . Name . Contains ( this . RightGrid . Name ) )
else if ( comboBox . Name . Contains ( "Left" ) )
{
{
foreach ( var item in Right Grid . Children )
foreach ( var item in Right . Children )
{
{
if ( item is StackPanel stackPanel )
if ( item is StackPanel stackPanel )
{
{
@ -676,7 +753,8 @@ namespace XGLFinishPro.Views
}
}
else
else
{
{
if ( comboBox . Name . Contains ( this . LeftGrid . Name ) )
string key = list . First ( t = > t . value = = name . Substring ( 0 , name . Length - 1 ) ) . label ;
if ( comboBox . Name . Contains ( "Left" ) )
{
{
var mesTableSelfDetialModel = leftData . Where ( t = > t . info_name = = key & & t . index = = int . Parse ( index ) - 1 ) . FirstOrDefault ( ) ;
var mesTableSelfDetialModel = leftData . Where ( t = > t . info_name = = key & & t . index = = int . Parse ( index ) - 1 ) . FirstOrDefault ( ) ;
if ( mesTableSelfDetialModel ! = null )
if ( mesTableSelfDetialModel ! = null )
@ -690,7 +768,7 @@ namespace XGLFinishPro.Views
}
}
string hour = string . Empty ;
string hour = string . Empty ;
string minute = string . Empty ;
string minute = string . Empty ;
foreach ( var item in Left Grid . Children )
foreach ( var item in Left . Children )
{
{
if ( item is StackPanel stackPanel )
if ( item is StackPanel stackPanel )
{
{
@ -715,7 +793,7 @@ namespace XGLFinishPro.Views
t . check_time_s = hour + ":" + minute ;
t . check_time_s = hour + ":" + minute ;
} ) ;
} ) ;
}
}
else if ( comboBox . Name . Contains ( this . RightGrid . Name ) )
else if ( comboBox . Name . Contains ( "Left" ) )
{
{
var mesTableSelfDetialModel = rightData . Where ( t = > t . info_name = = key & & t . index = = int . Parse ( index ) ) . FirstOrDefault ( ) ;
var mesTableSelfDetialModel = rightData . Where ( t = > t . info_name = = key & & t . index = = int . Parse ( index ) ) . FirstOrDefault ( ) ;
if ( mesTableSelfDetialModel ! = null )
if ( mesTableSelfDetialModel ! = null )
@ -729,7 +807,7 @@ namespace XGLFinishPro.Views
}
}
string hour = string . Empty ;
string hour = string . Empty ;
string minute = string . Empty ;
string minute = string . Empty ;
foreach ( var item in Left Grid . Children )
foreach ( var item in Left . Children )
{
{
if ( item is StackPanel stackPanel )
if ( item is StackPanel stackPanel )
{
{
@ -838,14 +916,54 @@ namespace XGLFinishPro.Views
this . Close ( ) ;
this . Close ( ) ;
}
}
private void LeftCheckDate_SelectedDateChanged ( object sender , SelectionChangedEventArgs e )
//private void LeftCheckDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
//{
// if (sender is DatePicker date)
// {
// this.LeftCheckDate.Text = date.SelectedDate.Value.ToString("yyyy/MM/dd");
// //this.RightCheckDate.Text = DateTime.Parse(this.LeftCheckDate.Text).AddDays(1).ToString("yyyy/MM/dd");
// LoadData();
// }
//}
private void LeftCheckDate_SelectedDateChanged_1 ( object sender , SelectionChangedEventArgs e )
{
{
if ( sender is DatePicker date )
this . date = this . LeftCheckDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) ;
DataTable dataTable = dbService . GetProOrderWorkorder ( deviceCode , date ) ;
List < OrderWork > orderWorks = new List < OrderWork > ( ) ;
if ( dataTable = = null | | dataTable . Rows . Count = = 0 )
{
{
this . LeftCheckDate . Text = date . SelectedDate . Value . ToString ( "yyyy/MM/dd" ) ;
MessageBox . Show ( "没有查询到工单信息!" ) ;
this . RightCheckDate . Text = DateTime . Parse ( this . LeftCheckDate . Text ) . AddDays ( 1 ) . ToString ( "yyyy/MM/dd" ) ;
LoadData ( ) ;
}
}
else
{
foreach ( DataRow row in dataTable . Rows )
{
orderWorks . Add ( new OrderWork ( )
{
WorkId = row [ "workorder_id" ] . ToString ( ) ,
WorkName = row [ "product_name" ] . ToString ( ) ,
} ) ;
}
}
this . LeftProductName . ItemsSource = orderWorks ;
this . LeftProductName . Items . Refresh ( ) ;
this . workId = string . Empty ;
this . LProductName = string . Empty ;
LoadData ( ) ;
}
private void LeftProductName_SelectionChanged ( object sender , SelectionChangedEventArgs e )
{
if ( sender is ComboBox comboBox )
{
if ( comboBox . SelectedItem is OrderWork orderWork )
{
this . workId = orderWork . WorkId ;
this . LProductName = orderWork . WorkName ;
}
}
LoadData ( ) ;
}
}
}
}
}
}