Browse Source

需求单No.4309

master
Robin_PC\robin 1 month ago
parent
commit
53bda14e66
5 changed files with 107 additions and 50 deletions
  1. +26
    -13
      CowOutputClient/SelectedProductWindow.xaml
  2. +72
    -34
      CowOutputClient/SelectedProductWindow.xaml.cs
  3. +6
    -3
      WeighBusiness/BL/ProductCatalogBL.cs
  4. +1
    -0
      WeighBusiness/BO/CreateTables/CreateProductCatalog_Detail.cs
  5. +2
    -0
      WeighBusiness/BO/ProductCatalog_Detail.cs

+ 26
- 13
CowOutputClient/SelectedProductWindow.xaml View File

@ -6,17 +6,28 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" mc:Ignorable="d"
x:Class="CowOutputClient.SelectedProductWindow" x:Class="CowOutputClient.SelectedProductWindow"
Title="SelectedProductWindow" Height="500" Width="705" Loaded="Window_Loaded" WindowStyle="None" AllowsTransparency="True" Background="#0fff" WindowStartupLocation="CenterScreen" >
Title="SelectedProductWindow" Height="550" Width="702.6" Loaded="Window_Loaded" WindowStyle="None" AllowsTransparency="True" Background="#0fff" WindowStartupLocation="CenterScreen" >
<Grid MouseLeftButtonDown="Grid_MouseLeftButtonDown"> <Grid MouseLeftButtonDown="Grid_MouseLeftButtonDown">
<Border CornerRadius="20" Background="#ccc">
<Border CornerRadius="20" Background="#ccc" >
<Border Margin="20" Background="White"> <Border Margin="20" Background="White">
</Border> </Border>
</Border> </Border>
<Grid Name="Grid2" Margin="30,20,0,0" Width="470" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top">
<ScrollViewer x:Name="scrList2" Margin="0" VerticalScrollBarVisibility="Auto">
<TextBox x:Name="txtSearchCode" TextWrapping="Wrap" Width="270" Height="32"
Margin="30,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="20"
TextChanged="TxtSearchCode_TextChanged"/>
<Button Focusable="False" Content="清空" x:Name="btnClear" Click="btnClear_Click" FontSize="15" Margin="0,20,337.4,0" Width="50" Height="32" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<Grid Name="Grid2" Margin="30,20,0,0" Width="470" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="27*"/>
<ColumnDefinition Width="67*"/>
</Grid.ColumnDefinitions>
<ScrollViewer x:Name="scrList2" Margin="0,38,0.4,-30" VerticalScrollBarVisibility="Auto" Grid.ColumnSpan="2">
<WrapPanel Name="ProductCatalogPanel" ItemHeight="45" ItemWidth="110" Width="{Binding ElementName=scrList, Path=Width, Mode=OneWay}" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"> <WrapPanel Name="ProductCatalogPanel" ItemHeight="45" ItemWidth="110" Width="{Binding ElementName=scrList, Path=Width, Mode=OneWay}" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top">
<!--<Button Focusable="False" Content="鲜品" Name="btn4" FontSize="20" Margin="10,10,0,0" />
<!--
<Button Focusable="False" Content="鲜品" Name="btn4" FontSize="20" Margin="10,10,0,0" />
<Button Focusable="False" Content="鲜品" Name="btn3" FontSize="20" Margin="10,10,0,0" /> <Button Focusable="False" Content="鲜品" Name="btn3" FontSize="20" Margin="10,10,0,0" />
<Button Focusable="False" Content="鲜品" Name="btn2" FontSize="20" Margin="10,10,0,0" /> <Button Focusable="False" Content="鲜品" Name="btn2" FontSize="20" Margin="10,10,0,0" />
<Button Focusable="False" Content="鲜品" Name="btn5" FontSize="20" Margin="10,10,0,0" /> <Button Focusable="False" Content="鲜品" Name="btn5" FontSize="20" Margin="10,10,0,0" />
@ -31,15 +42,17 @@
</WrapPanel> </WrapPanel>
</ScrollViewer> </ScrollViewer>
</Grid> </Grid>
<Button Focusable="False" Content="设置顺序" Name="btnSequence" Click="btnSequence_Click_1" FontSize="15" Margin="0,19,74.8,0" Width="70" Height="45" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<Button Focusable="False" Content="保存" Name="btnSave" Click="btnSave_Click_1" FontSize="15" Margin="0,20,149.8,0" Width="50" Height="45" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<Button Focusable="False" Content="关闭" Name="btnClose" Click="btnClose_Click_1" FontSize="15" Margin="0,20,22.8,0" Width="50" Height="45" HorizontalAlignment="Right" VerticalAlignment="Top" />
<Button Focusable="False" Content="备份" x:Name="btnBackup" Click="btnBackup_Click_1" FontSize="15" Margin="0,69,149.8,0" Width="50" Height="45" HorizontalAlignment="Right" VerticalAlignment="Top" RenderTransformOrigin="-0.664,0.434" />
<Button Focusable="False" Content="恢复" Name="btnRestore" Click="btnRestore_Click_1" FontSize="15" Margin="0,69,22.8,0" Width="50" Height="45" HorizontalAlignment="Right" VerticalAlignment="Top" RenderTransformOrigin="0.902,0.411" />
<Grid Name="Grid1" Margin="30,115,0,0" Width="650" Height="360" HorizontalAlignment="Left" VerticalAlignment="Top">
<Border BorderThickness="1" BorderBrush="Black">
<Button Focusable="False" Content="设置顺序" Name="btnSequence" Click="btnSequence_Click_1" FontSize="15" Margin="0,58,74.4,0" Width="70" Height="45" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<Button Focusable="False" Content="保存" Name="btnSave" Click="btnSave_Click_1" FontSize="15" Margin="0,58,149.4,0" Width="50" Height="45" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<Button Focusable="False" Content="关闭" Name="btnClose" Click="btnClose_Click_1" FontSize="15" Margin="0,58,22.4,0" Width="50" Height="45" HorizontalAlignment="Right" VerticalAlignment="Top" />
<Button Focusable="False" Content="备份" x:Name="btnBackup" Click="btnBackup_Click_1" FontSize="15" Margin="0,107,149.4,0" Width="50" Height="45" HorizontalAlignment="Right" VerticalAlignment="Top" RenderTransformOrigin="-0.664,0.434" />
<Button Focusable="False" Content="恢复" Name="btnRestore" Click="btnRestore_Click_1" FontSize="15" Margin="0,107,22.4,0" Width="50" Height="45" HorizontalAlignment="Right" VerticalAlignment="Top" RenderTransformOrigin="0.902,0.411" />
<Grid Name="Grid1" Margin="30,176,0,0" Width="650" Height="360" HorizontalAlignment="Left" VerticalAlignment="Top">
<Border BorderThickness="1" BorderBrush="Black" Margin="-9,-22,0,10">
</Border> </Border>
<ScrollViewer x:Name="scrList" Margin="0" VerticalScrollBarVisibility="Auto">
<ScrollViewer x:Name="scrList" Margin="0,-22,0,10" VerticalScrollBarVisibility="Auto">
<!--<WrapPanel Name="CatalogDetails" ItemHeight="45" ItemWidth="110" Width="350" Height="540" >--> <!--<WrapPanel Name="CatalogDetails" ItemHeight="45" ItemWidth="110" Width="350" Height="540" >-->
<WrapPanel Name="CatalogDetails" ItemHeight="50" ItemWidth="160" Margin="0" Width="{Binding ElementName=scrList, Path=Width, Mode=OneWay}"> <WrapPanel Name="CatalogDetails" ItemHeight="50" ItemWidth="160" Margin="0" Width="{Binding ElementName=scrList, Path=Width, Mode=OneWay}">
</WrapPanel> </WrapPanel>


+ 72
- 34
CowOutputClient/SelectedProductWindow.xaml.cs View File

@ -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 = 15, 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 = 15, 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;
}
} }
} }

+ 6
- 3
WeighBusiness/BL/ProductCatalogBL.cs View File

@ -67,8 +67,8 @@ namespace WeighBusiness.BL
if (catalogDetails.Count() > 0) { if (catalogDetails.Count() > 0) {
foreach (var detail in catalogDetails) { foreach (var detail in catalogDetails) {
string insertSql = InsertUtil.GetInsertSql(TableNames.客户端产品分类明细, string insertSql = InsertUtil.GetInsertSql(TableNames.客户端产品分类明细,
new string[] { "ProductCatalog_ID", "CatalogDetail_ID", "Goods_Name", "Goods_ID", "UnitConvertDirection", "MainUnitRatio", "SecondUnitRatio","Goods_Spec" },
new string[] { detail.ProductCatalog_ID.ToString(), detail.CatalogDetail_ID.ToString(), detail.Goods_Name, detail.Goods_ID.ToString(), detail.UnitConvertDirection == null ? "null" : detail.UnitConvertDirection.ToString(), detail.MainUnitRatio == null ? "null" : detail.MainUnitRatio.ToString(), detail.SecondUnitRatio == null ? "null" : detail.SecondUnitRatio.ToString(),detail.Goods_Spec });
new string[] { "ProductCatalog_ID", "CatalogDetail_ID", "Goods_Name", "Goods_ID", "UnitConvertDirection", "MainUnitRatio", "SecondUnitRatio","Goods_Spec", "Goods_Code" },
new string[] { detail.ProductCatalog_ID.ToString(), detail.CatalogDetail_ID.ToString(), detail.Goods_Name, detail.Goods_ID.ToString(), detail.UnitConvertDirection == null ? "null" : detail.UnitConvertDirection.ToString(), detail.MainUnitRatio == null ? "null" : detail.MainUnitRatio.ToString(), detail.SecondUnitRatio == null ? "null" : detail.SecondUnitRatio.ToString(),detail.Goods_Spec,detail.Goods_Code });
she.ExecuteNonQuery(insertSql, out success, out errorMessage); she.ExecuteNonQuery(insertSql, out success, out errorMessage);
if (!success && !string.IsNullOrEmpty(errorMessage)) { if (!success && !string.IsNullOrEmpty(errorMessage)) {
she.Rollback(); she.Rollback();
@ -179,6 +179,7 @@ namespace WeighBusiness.BL
catalogDetail.MainUnitRatio = detail.Get<decimal?>("MainUnitRatio"); catalogDetail.MainUnitRatio = detail.Get<decimal?>("MainUnitRatio");
catalogDetail.SecondUnitRatio = detail.Get<decimal?>("SecondUnitRatio"); catalogDetail.SecondUnitRatio = detail.Get<decimal?>("SecondUnitRatio");
catalogDetail.Goods_Spec = detail.Get<string>("Goods_Spec"); catalogDetail.Goods_Spec = detail.Get<string>("Goods_Spec");
catalogDetail.Goods_Code = detail.Get<string>("Goods_Code");
detailList.Add(catalogDetail); detailList.Add(catalogDetail);
} }
} }
@ -229,7 +230,7 @@ namespace WeighBusiness.BL
public static List<ProCataGoods> GetProductCatalogDetails(bool? isSelected = null) public static List<ProCataGoods> GetProductCatalogDetails(bool? isSelected = null)
{ {
var table = SqlHelperEx.DoQuery("select a.ProductCatalog_ID,a.CatalogDetail_ID,a.Goods_Name,a.Goods_ID,b.Goods_ID,a.UnitConvertDirection,a.MainUnitRatio,a.SecondUnitRatio,a.Goods_Spec from {0} a left outer join {1} b on a.ProductCatalog_ID = b.ProductCatalog_ID and a.Goods_ID = b.Goods_ID where 1=1 {2}".FormatWith(TableNames.客户端产品分类明细, TableNames.客户端产品分类配制存货, isSelected == true ? "and b.Goods_ID is not null" : string.Empty));
var table = SqlHelperEx.DoQuery("select a.ProductCatalog_ID,a.CatalogDetail_ID,a.Goods_Name,a.Goods_ID,b.Goods_ID,a.UnitConvertDirection,a.MainUnitRatio,a.SecondUnitRatio,a.Goods_Spec,a.Goods_Code from {0} a left outer join {1} b on a.ProductCatalog_ID = b.ProductCatalog_ID and a.Goods_ID = b.Goods_ID where 1=1 {2}".FormatWith(TableNames.客户端产品分类明细, TableNames.客户端产品分类配制存货, isSelected == true ? "and b.Goods_ID is not null" : string.Empty));
if (table.Rows.Count == 0) if (table.Rows.Count == 0)
return new List<ProCataGoods>(); return new List<ProCataGoods>();
var list = new List<ProCataGoods>(); var list = new List<ProCataGoods>();
@ -244,6 +245,7 @@ namespace WeighBusiness.BL
catalog.MainUnitRatio = DataTypeUtil.GetDecimalNullNum(row[6]); catalog.MainUnitRatio = DataTypeUtil.GetDecimalNullNum(row[6]);
catalog.SecondUnitRatio = DataTypeUtil.GetDecimalNullNum(row[7]); catalog.SecondUnitRatio = DataTypeUtil.GetDecimalNullNum(row[7]);
catalog.Goods_Spec = DataTypeUtil.ToStringEmptyIfNull(row[8]); catalog.Goods_Spec = DataTypeUtil.ToStringEmptyIfNull(row[8]);
catalog.Goods_Code = DataTypeUtil.ToStringEmptyIfNull(row[9]);
list.Add(catalog); list.Add(catalog);
} }
return list; return list;
@ -428,6 +430,7 @@ namespace WeighBusiness.BL
public long ProductCatalog_ID { get; set; } public long ProductCatalog_ID { get; set; }
public long CatalogDetail_ID { get; set; } public long CatalogDetail_ID { get; set; }
public string Goods_Name { get; set; } public string Goods_Name { get; set; }
public string Goods_Code { get; set; }
public string Goods_Spec { get; set; } public string Goods_Spec { get; set; }
public long Goods_ID { get; set; } public long Goods_ID { get; set; }
public string UnitConvertDirection { get; set; } public string UnitConvertDirection { get; set; }


+ 1
- 0
WeighBusiness/BO/CreateTables/CreateProductCatalog_Detail.cs View File

@ -31,6 +31,7 @@ namespace WeighBusiness.BO.CreateTables
IsNotNull = false IsNotNull = false
}); });
cth.AddField(new FieldInfo() { FieldName = "Goods_Spec", FieldType = FBType.Varchar, FieldTypeParams = "(100)", IsNotNull = false }); cth.AddField(new FieldInfo() { FieldName = "Goods_Spec", FieldType = FBType.Varchar, FieldTypeParams = "(100)", IsNotNull = false });
cth.AddField(new FieldInfo() { FieldName = "Goods_Code", FieldType = FBType.Varchar, FieldTypeParams = "(100)", IsNotNull = false });
base.AddFields(cth); base.AddFields(cth);
} }


+ 2
- 0
WeighBusiness/BO/ProductCatalog_Detail.cs View File

@ -18,6 +18,8 @@ namespace WeighBusiness.BO
public long ProductCatalog_ID { get; set; } public long ProductCatalog_ID { get; set; }
public long CatalogDetail_ID { get; set; } public long CatalogDetail_ID { get; set; }
public string Goods_Name { get; set; } public string Goods_Name { get; set; }
public string Goods_Code { get; set; }
public string Goods_Spec { get; set; } public string Goods_Spec { get; set; }
public long Goods_ID { get; set; } public long Goods_ID { get; set; }
public string UnitConvertDirection { get; set; } public string UnitConvertDirection { get; set; }


Loading…
Cancel
Save