@ -25,6 +25,8 @@ namespace CowOutputClient
private List < ProCataGoods > catalogsDetails = new List < ProCataGoods > ( ) ;
private List < ProCataGoods > catalogsDetails = new List < ProCataGoods > ( ) ;
List < long > detailIds = new List < long > ( ) ;
List < long > detailIds = new List < long > ( ) ;
bool? useSequenceWindow = null ;
bool? useSequenceWindow = null ;
//====新增:记录当前选中的分类ID,用于搜索过滤====
private long? _currentSelectCatalogId ;
public SelectedProductWindow ( )
public SelectedProductWindow ( )
{
{
InitializeComponent ( ) ;
InitializeComponent ( ) ;
@ -40,8 +42,8 @@ namespace CowOutputClient
BindProductCatalogs ( ) ;
BindProductCatalogs ( ) ;
}
}
private void BindProductCatalogs ( )
{
private void BindProductCatalogs ( )
{
ProductCatalogPanel . Children . Clear ( ) ;
ProductCatalogPanel . Children . Clear ( ) ;
var catalogs = ProductCatalogBL . GetProductCatalogs ( ) ;
var catalogs = ProductCatalogBL . GetProductCatalogs ( ) ;
catalogsDetails = ProductCatalogBL . GetProductCatalogDetails ( ) ;
catalogsDetails = ProductCatalogBL . GetProductCatalogDetails ( ) ;
@ -65,7 +67,7 @@ namespace CowOutputClient
txtCatalog . Background = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#3598fe" ) ) ;
txtCatalog . Background = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#3598fe" ) ) ;
txtCatalog . Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#fff" ) ) ;
txtCatalog . Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#fff" ) ) ;
var result = ( ProductCatalog ) txtCatalog . Tag ;
var result = ( ProductCatalog ) txtCatalog . Tag ;
BindProductCatalogsDetails ( result . ProductCatalog_ID ) ;
BindProductCatalogsDetails ( result . ProductCatalog_ID , txtSearchCode . Text ) ;
} ;
} ;
var border = new Border ( ) ;
var border = new Border ( ) ;
border . BorderThickness = new Thickness ( 1 , 1 , 1 , 1 ) ;
border . BorderThickness = new Thickness ( 1 , 1 , 1 , 1 ) ;
@ -75,43 +77,65 @@ namespace CowOutputClient
ProductCatalogPanel . Children . Add ( border ) ;
ProductCatalogPanel . Children . Add ( border ) ;
}
}
}
}
}
private void BindProductCatalogsDetails ( long productCatalog_ID )
}
/// <summary>
/// 绑定商品列表,增加searchCode关键词:按商品编码模糊过滤
/// </summary>
/// <param name="productCatalog_ID">分类ID</param>
/// <param name="searchCode">编码搜索关键词</param>
private void BindProductCatalogsDetails ( long productCatalog_ID , string searchCode = "" )
{
{
//记录当前分类Id
_currentSelectCatalogId = productCatalog_ID ;
CatalogDetails . Children . Clear ( ) ;
CatalogDetails . Children . Clear ( ) ;
if ( catalogsDetails . Count ( ) > 0 ) {
var details = catalogsDetails . Where ( x = > x . ProductCatalog_ID = = productCatalog_ID ) ;
foreach ( var catalog in details ) {
var txtCatalog = new TextBlock ( ) { Text = catalog . Goods_Name , FontSize = 1 5 , TextWrapping = TextWrapping . Wrap , TextAlignment = TextAlignment . Center } ;
txtCatalog . Tag = catalog ;
if ( catalog . IsSelected ) {
txtCatalog . Background = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#3598fe" ) ) ;
txtCatalog . Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#fff" ) ) ;
}
txtCatalog . MouseDown + = ( object sende , MouseButtonEventArgs args ) = > {
var cata = txtCatalog . Tag as ProCataGoods ;
if ( ! cata . IsSelected ) {
txtCatalog . Background = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#3598fe" ) ) ;
txtCatalog . Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#fff" ) ) ;
cata . IsSelected = true ;
} else {
cata . IsSelected = false ;
txtCatalog . Background = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#fff" ) ) ;
txtCatalog . Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#000" ) ) ;
}
} ;
var border = new Border ( ) ;
border . BorderThickness = new Thickness ( 1 , 1 , 1 , 1 ) ;
border . BorderBrush = Brushes . Black ;
border . Child = txtCatalog ;
border . Margin = new Thickness ( 8 , 8 , 0 , 0 ) ;
CatalogDetails . Children . Add ( border ) ;
if ( catalogsDetails . Count ( ) > 0 )
{
//先按分类筛选
IEnumerable < ProCataGoods > details = catalogsDetails . Where ( x = > x . ProductCatalog_ID = = productCatalog_ID ) ;
//====编码模糊过滤,不区分大小写;注意:ProCataGoods编码字段名如果不是Goods_Code,请修改此处属性名====
if ( ! string . IsNullOrWhiteSpace ( searchCode ) )
{
details = details . Where ( c = > c . Goods_Code ! = null
& & c . Goods_Code . IndexOf ( searchCode , StringComparison . OrdinalIgnoreCase ) > = 0 ) ;
}
foreach ( var catalog in details )
{
var txtCatalog = new TextBlock ( ) { Text = catalog . Goods_Name , FontSize = 1 5 , TextWrapping = TextWrapping . Wrap , TextAlignment = TextAlignment . Center } ;
txtCatalog . Tag = catalog ;
if ( catalog . IsSelected )
{
txtCatalog . Background = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#3598fe" ) ) ;
txtCatalog . Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#fff" ) ) ;
}
txtCatalog . MouseDown + = ( object sende , MouseButtonEventArgs args ) = > {
var cata = txtCatalog . Tag as ProCataGoods ;
if ( ! cata . IsSelected )
{
txtCatalog . Background = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#3598fe" ) ) ;
txtCatalog . Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#fff" ) ) ;
cata . IsSelected = true ;
}
else
{
cata . IsSelected = false ;
txtCatalog . Background = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#fff" ) ) ;
txtCatalog . Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#000" ) ) ;
}
} ;
var border = new Border ( ) ;
border . BorderThickness = new Thickness ( 1 , 1 , 1 , 1 ) ;
border . BorderBrush = Brushes . Black ;
border . Child = txtCatalog ;
border . Margin = new Thickness ( 8 , 8 , 0 , 0 ) ;
CatalogDetails . Children . Add ( border ) ;
}
}
}
}
}
}
private void btnClose_Click_1 ( object sender , RoutedEventArgs e )
private void btnClose_Click_1 ( object sender , RoutedEventArgs e )
{
{
this . DialogResult = useSequenceWindow = = true ? true : false ;
this . DialogResult = useSequenceWindow = = true ? true : false ;
@ -160,5 +184,19 @@ namespace CowOutputClient
DialogResult = true ;
DialogResult = true ;
}
}
}
}
//====新增:搜索框文本变化,执行编码模糊过滤====
private void TxtSearchCode_TextChanged ( object sender , TextChangedEventArgs e )
{
if ( _currentSelectCatalogId . HasValue )
{
BindProductCatalogsDetails ( _currentSelectCatalogId . Value , txtSearchCode . Text ) ;
}
}
private void btnClear_Click ( object sender , RoutedEventArgs e )
{
txtSearchCode . Text = string . Empty ;
}
}
}
}
}