You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
320 lines
12 KiB
C#
320 lines
12 KiB
C#
using CommonFunc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using XGL.Models;
|
|
|
|
namespace XGL.UControl
|
|
{
|
|
/// <summary>
|
|
/// UCStorageNew.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class UCStorageNew : UserControl
|
|
{
|
|
|
|
/// <summary>
|
|
/// 小车列表
|
|
/// </summary>
|
|
private List<CarInfo> CarList { get; set; }
|
|
|
|
|
|
public UCStorageNew()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public delegate string deletegateSetCarLocator(string carno);
|
|
public deletegateSetCarLocator SetCarLocatorEvent;
|
|
|
|
public delegate string deletegateSetLocatorMaterial(int locatorid);
|
|
public deletegateSetLocatorMaterial SetLocatorMaterialEvent;
|
|
public UCStorageNew(int locatornum, List<CarInfo> list)
|
|
{
|
|
InitializeComponent();
|
|
this.TotalNum = locatornum;
|
|
this.CarList = list;
|
|
}
|
|
#region 库存数量
|
|
public int LocatorId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 缓存区域缓存数量
|
|
/// </summary>
|
|
public int TotalNum
|
|
{
|
|
get
|
|
{
|
|
return (int)GetValue(TotalNumProperty);
|
|
}
|
|
set
|
|
{
|
|
SetValue(TotalNumProperty, value);
|
|
}
|
|
}
|
|
|
|
public static DependencyProperty TotalNumProperty =
|
|
DependencyProperty.Register("TotalNum", typeof(int), typeof(UCStorageNew), new PropertyMetadata(0, new PropertyChangedCallback(TotalNumPropertyChanged))); //属性默认值
|
|
|
|
private static void TotalNumPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
int totalnum = Convert.ToInt32(e.NewValue);
|
|
var uccontrol = d as UCStorageNew;
|
|
// var panel = uccontrol.FindName("StoreCars") as StackPanel;
|
|
for (int i = 0; i < totalnum; i++)
|
|
{
|
|
if (uccontrol.StoreCars.FindName("locator_" + i) == null)
|
|
{
|
|
TextBlock label = new TextBlock();
|
|
label.Width = 31;
|
|
label.Margin = new Thickness(3, 5, 3, 5);
|
|
label.FontSize = 10;
|
|
label.Foreground = new SolidColorBrush(Colors.White);
|
|
label.Background = new SolidColorBrush(Colors.Gray);
|
|
label.MouseDown += new MouseButtonEventHandler(uccontrol.CarClick);
|
|
uccontrol.RegisterName("locator_" + i, label);
|
|
uccontrol.StoreCars.Children.Add(label);
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 产品小车
|
|
/// <summary>
|
|
/// 产品型号
|
|
/// </summary>
|
|
public List<CarInfo> ProductCar
|
|
{
|
|
get
|
|
{
|
|
return (List<CarInfo>)GetValue(ProductCarProperty);
|
|
}
|
|
set
|
|
{
|
|
SetValue(ProductCarProperty, value);
|
|
}
|
|
}
|
|
|
|
public static DependencyProperty ProductCarProperty =
|
|
DependencyProperty.Register("ProductCar", typeof(List<CarInfo>), typeof(UCStorageNew), new PropertyMetadata(null, new PropertyChangedCallback(ProductCarPropertyChanged))); //属性默认值
|
|
|
|
private static void ProductCarPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
List<CarInfo> CarList = e.NewValue as List<CarInfo>;
|
|
var uccontrol = d as UCStorageNew;
|
|
int hadNum = 0;
|
|
for (int j = 0; j < uccontrol.TotalNum; j++)
|
|
{
|
|
TextBlock label = uccontrol.StoreCars.FindName("locator_" + j) as TextBlock;
|
|
label.TextWrapping = TextWrapping.Wrap;
|
|
label.TextAlignment = TextAlignment.Center;
|
|
if (j < CarList.Count)
|
|
{
|
|
label.Tag = CarList[j].CarNo;
|
|
if (CarList[j].IsOutLocator == 0)//入库中
|
|
{
|
|
label.Background = new SolidColorBrush(Colors.LawnGreen);
|
|
}
|
|
else if (CarList[j].IsOutLocator == 1)//在库里
|
|
{
|
|
label.Background = new SolidColorBrush(Colors.Blue);
|
|
}
|
|
else if (CarList[j].IsOutLocator == 2)//出库
|
|
{
|
|
label.Background = new SolidColorBrush(Colors.Red);
|
|
}
|
|
else if (CarList[j].IsOutLocator == 3)//倒库
|
|
{
|
|
label.Background = new SolidColorBrush(Colors.Purple);
|
|
}
|
|
else if (CarList[j].IsOutLocator == 4)//下件返回库里
|
|
{
|
|
label.Background = new SolidColorBrush(Colors.Pink);
|
|
}
|
|
string carnum = "";
|
|
if (CarList[j].CarNo.Length == 1)
|
|
{
|
|
carnum = "00" + CarList[j].CarNo;
|
|
}
|
|
else if (CarList[j].CarNo.Length == 2)
|
|
{
|
|
carnum = "0" + CarList[j].CarNo;
|
|
}
|
|
else
|
|
{
|
|
carnum= CarList[j].CarNo;
|
|
}
|
|
// label.Content = CarList[j].CarNo + "\r\n" + CarList[j].MaterialNo;
|
|
//label.Text = "车号: " + CarList[j].CarNo + "\r\n" + CarList[j].MaterialBarNo;
|
|
label.Text = carnum + ":"+CarList[j].MaterialNo;
|
|
hadNum++;
|
|
}
|
|
else
|
|
{
|
|
label.Tag = "";
|
|
label.Text = "";
|
|
label.Background = new SolidColorBrush(Colors.Gray);
|
|
}
|
|
}
|
|
|
|
int person = hadNum*100 / uccontrol.TotalNum;
|
|
uccontrol.txtStoreLoad.Text = hadNum +"/"+ uccontrol.TotalNum;
|
|
uccontrol.bBg.Background = new SolidColorBrush(CommonHelper.GetColor((double)person));
|
|
uccontrol.bBg.Height = hadNum * 70 / uccontrol.TotalNum;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 库区名称
|
|
/// <summary>
|
|
/// 库区名称
|
|
/// </summary>
|
|
public string StorageNm
|
|
{
|
|
get
|
|
{
|
|
return (string)GetValue(StorageNmProperty);
|
|
}
|
|
set
|
|
{
|
|
SetValue(StorageNmProperty, value);
|
|
}
|
|
}
|
|
|
|
public static DependencyProperty StorageNmProperty =
|
|
DependencyProperty.Register("StorageNm", typeof(string), typeof(UCStorageNew), new PropertyMetadata("", new PropertyChangedCallback(StorageNmValuePropertyChanged))); //属性默认值
|
|
|
|
private static void StorageNmValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var control = d as UCStorageNew;
|
|
control.txtStoreNm.Text = e.NewValue.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 类型名称
|
|
/// <summary>
|
|
/// 库区名称
|
|
/// </summary>
|
|
public string StorageTypeNm
|
|
{
|
|
get
|
|
{
|
|
return (string)GetValue(StorageTypeNmProperty);
|
|
}
|
|
set
|
|
{
|
|
SetValue(StorageTypeNmProperty, value);
|
|
}
|
|
}
|
|
|
|
public static DependencyProperty StorageTypeNmProperty =
|
|
DependencyProperty.Register("StorageTypeNm", typeof(string), typeof(UCStorageNew), new PropertyMetadata("", new PropertyChangedCallback(StorageTypeNmValuePropertyChanged))); //属性默认值
|
|
|
|
private static void StorageTypeNmValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var control = d as UCStorageNew;
|
|
control.txtStoreType.Text = e.NewValue.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 库位类型
|
|
/// <summary>
|
|
/// 库位类型
|
|
/// </summary>
|
|
public string AreaType
|
|
{
|
|
get
|
|
{
|
|
return (string)GetValue(StorageTypeProperty);
|
|
}
|
|
set
|
|
{
|
|
SetValue(StorageTypeProperty, value);
|
|
}
|
|
}
|
|
|
|
public static DependencyProperty StorageTypeProperty =
|
|
DependencyProperty.Register("AreaType", typeof(string), typeof(UCStorageNew), new PropertyMetadata("", new PropertyChangedCallback(StorageTypeValuePropertyChanged))); //属性默认值
|
|
|
|
private static void StorageTypeValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var control = d as UCStorageNew;
|
|
int type = string.IsNullOrEmpty(e.NewValue.ToString())?0: Convert.ToInt32(e.NewValue);
|
|
if (type == 1)
|
|
{
|
|
//如果库 0 是从右向左 ,1 是 从左向右
|
|
control.StoreCars.FlowDirection = FlowDirection.RightToLeft;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
private void CarClick(object obj, MouseButtonEventArgs e)
|
|
{
|
|
if (SetCarLocatorEvent != null)
|
|
{
|
|
TextBlock lblcar = obj as TextBlock;
|
|
if (obj != null && lblcar.Tag.ToString() != "")
|
|
{
|
|
SetCarLocatorEvent(lblcar.Tag.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
private void BBg_MouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if(SetLocatorMaterialEvent!=null)
|
|
{
|
|
|
|
SetLocatorMaterialEvent(this.LocatorId);
|
|
}
|
|
}
|
|
}
|
|
}
|