大连融科 WMS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

354 lines
13 KiB

using System;
using System.Collections.Generic;
using System.Linq;
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.Shapes;
using System.Data;
namespace SiaSun.LMS.WPFClient.TASK
{
/// <summary>
///
/// </summary>
public partial class ManageOut : AvalonDock.DocumentContent
{
Model.MANAGE_TYPE mMANAGE_TYPE = null;
List<Model.MANAGE_LIST> listMANAGE_LIST = null;
DataRowView[] listDataRowView = null;
#region 构造函数
public ManageOut(string MANAGE_TYPE_CODE)
{
InitializeComponent();
//友谊胶带按钮更新状态
// MainApp._I_BaseService.GetList("update io_control_route where start_device='12247' and end_device in('18001,18002')");
// MainApp._I_BaseService.GetList("update io_control_route where start_device='12347' and end_device in('18001,18002')");
this.mMANAGE_TYPE = (Model.MANAGE_TYPE)MainApp._I_BaseService.GetModel("MANAGE_TYPE_SELECT_BY_MANAGE_TYPE_CODE", MANAGE_TYPE_CODE).RequestObject;
this.ucQuery.U_Query += new UC.ucQuickQuery.U_QueryEventHandler
( (QueryWhere)=>
{
QueryWhere = string.Format("{0} AND {1}",
string.IsNullOrEmpty(QueryWhere) ? "1=1" : QueryWhere,
string.Format(" AREA_TYPE = 'XuNiKu' "));
this.StorageListBind(QueryWhere);
}
);
}
#endregion
#region 系统方法
private void DocumentContent_Loaded(object sender, RoutedEventArgs e)
{
//查询控件
this.InitQueryControl();
Plan_Type_Bind();
}
#endregion
#region 自定义方法
/// <summary>
/// 初始化查询控件
/// </summary>
private void InitQueryControl()
{
this.ucQuery.U_WindowName = this.GetType().Name;
this.ucQuery.U_XmlTableName = "V_STORAGE_LIST";
this.ucQuery.U_InitControl();
}
/// <summary>
/// 初始化属性面板
/// </summary>
private void Plan_Type_Bind()
{
this.cbbPLAN_TYPE.DisplayMemberPath = "PLAN_TYPE_NAME";
this.cbbPLAN_TYPE.SelectedValuePath = "PLAN_TYPE_CODE";
try
{
string strSQL = string.Format(@"SELECT PLAN_TYPE_CODE,
PLAN_TYPE_NAME
FROM PLAN_TYPE
WHERE PLAN_TYPE_INOUT = '2'
AND PLAN_TYPE_FLAG= '1'
ORDER BY PLAN_TYPE_ORDER");
this.cbbPLAN_TYPE.ItemsSource = MainApp._I_BaseService.GetList(strSQL).DefaultView;
if (this.cbbPLAN_TYPE.Items.Count > 0)
{
this.cbbPLAN_TYPE.SelectedIndex = this.cbbPLAN_TYPE.SelectedIndex < 0 ? 0 : this.cbbPLAN_TYPE.SelectedIndex;
}
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
}
private void Register_DataTable_Event()
{
//当输入列值改变后验证数据是否合法
foreach (TabItem tabItem in this.ucStorageGroup.tabSplitProperty.Items)
{
if (tabItem.HasContent)
{
DataTable tableSource = (tabItem.Content as UC.ucCommonDataGrid).U_DataSource.Table;
tableSource.ColumnChanged -= new DataColumnChangeEventHandler(table_ColumnChanged);
tableSource.ColumnChanged += new DataColumnChangeEventHandler(table_ColumnChanged);
}
}
}
/// <summary>
/// 表单数据校验
/// </summary>
private void table_ColumnChanged(object sender, DataColumnChangeEventArgs e)
{
bool bResult = true;
string sResult = string.Empty;
//判断列
switch (e.Column.ColumnName)
{
case "MANAGE_LIST_QUANTITY":
bResult = (string.Empty != e.ProposedValue.ToString()) && Convert.ToDecimal(e.ProposedValue) > 0;
sResult = "请输入大于0的数量";
bResult = (Convert.ToDecimal(e.ProposedValue) <= Convert.ToDecimal(e.Row["STORAGE_LIST_QUANTITY"]));
sResult = string.Format("出库数量不能大于库存数量!");
break;
}
if (bResult)
{
e.Row.RowError = null;
e.Row.SetColumnError(e.Column, null);
}
else
{
e.Row.RowError = "数据校验失败";
e.Row.SetColumnError(e.Column, sResult);
}
}
private void StorageListBind(string QueryWhere)
{
this.ucStorageGroup.U_WindowName = this.GetType().Name;
this.ucStorageGroup.U_TableName = "V_STORAGE_LIST";
this.ucStorageGroup.U_XmlTableName = "V_STORAGE_LIST";
//this.ucStorageGroup.U_AppendFieldStyles = this.GetColumnDescriptionList();
this.ucStorageGroup.U_TotalColumnName = "STORAGE_LIST_QUANTITY";
this.ucStorageGroup.U_OrderField = "STORAGE_LIST_ID";
this.ucStorageGroup.U_Where = string.Format(" cell_status <> 'Pallet' and STORAGE_LIST_ID not in ( select STORAGE_LIST_ID from manage_list) and {0} ",
QueryWhere);
this.ucStorageGroup.U_AllowOperatData = false;
this.ucStorageGroup.U_AllowChecked = true;
this.ucStorageGroup.U_AllowShowPage = true;
//拆分列属性
this.ucStorageGroup.U_SplitPropertyType = "GOODS_TYPE";
this.ucStorageGroup.U_SplitGroupColumn = "GOODS_TYPE_ID";
this.ucStorageGroup.U_SplitGroupHeader = "GOODS_TYPE.GOODS_TYPE_NAME";
this.ucStorageGroup.U_SplitPropertyColumn = "GOODS_PROPERTY";
this.ucStorageGroup.U_InitControl();
Register_DataTable_Event();
}
#endregion
#region 按钮事件
private void WrapPanel_Click(object sender, RoutedEventArgs e)
{
Button btn = e.OriginalSource as Button;
if (btn != null)
{
switch (btn.Name)
{
case "btnConfirm":
this.CreateTaskOut();
break;
case "btnRefresh":
this.Refresh();
break;
}
}
}
/// <summary>
/// 创建出库任务
/// </summary>
private void CreateTaskOut()
{
bool boolResult = true;
bool boolSingleResult = true;
string strResult = string.Empty;
string sSingleReslut = string.Empty;
try
{
//获得选中记录
listDataRowView = this.ucStorageGroup.U_GetCheckedDataRows();
this.ucStorageGroup.U_EndCurrentEdit();
#region 校验表单数据
if (this.ucStorageGroup.U_DataSource.HasErrors)
{
MainApp._MessageDialog.Show(false, "表单存在不合法的数据");
return;
}
if (listDataRowView.Length == 0)
{
MainApp._MessageDialog.Show(false,"请选中要出库的记录");
return;
}
var list = from v in listDataRowView
where Convert.ToInt32(v["MANAGE_LIST_QUANTITY"]) > 0
select v;
if (list.Count() != listDataRowView.Length)
{
MainApp._MessageDialog.Show(false, "出库数量要大于0");
return;
}
#endregion
#region 校验出库类型
if (this.cbbPLAN_TYPE.SelectedValue == null)
{
MainApp._MessageDialog.Show(false, "请选择出库类型");
return;
}
#endregion
var storage_id_group = from v in listDataRowView
group v by v["STORAGE_ID"].ToString() into a
select a;
if (MainApp._MessageDialog.ShowDialog("确认下达出库任务") == Sid.Windows.Controls.TaskDialogResult.Ok)
{
//获得所有的选定的条码
foreach (var storage_id in storage_id_group)
{
var value_storage_id = from v in listDataRowView
where v["STORAGE_ID"].ToString() == storage_id.Key
select v;
listMANAGE_LIST = new SiaSun.LMS.Common.CloneObjectValues().GetListFromDataTable<Model.MANAGE_LIST>(value_storage_id.Cast<DataRowView>().ToArray(), null);
//无计划出库,清空计划
foreach (Model.MANAGE_LIST mMANAGE_LIST in listMANAGE_LIST)
{
mMANAGE_LIST.PLAN_LIST_ID = 0;
}
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = new Model.MANAGE_MAIN();
SiaSun.LMS.Model.STORAGE_MAIN mSTORAGE_MAIN = (Model.STORAGE_MAIN)MainApp._I_BaseService.GetModel("STORAGE_MAIN_SELECT_BY_ID", Convert.ToInt32(storage_id.Key)).RequestObject;
mMANAGE_MAIN.MANAGE_TYPE_CODE = mMANAGE_TYPE.MANAGE_TYPE_CODE.TrimEnd();
mMANAGE_MAIN.PLAN_ID = 0;
mMANAGE_MAIN.PLAN_TYPE_CODE = string.Empty;
mMANAGE_MAIN.STOCK_BARCODE = mSTORAGE_MAIN.STOCK_BARCODE;
mMANAGE_MAIN.CELL_MODEL = mSTORAGE_MAIN.CELL_MODEL;
mMANAGE_MAIN.START_CELL_ID = mSTORAGE_MAIN.CELL_ID;
mMANAGE_MAIN.END_CELL_ID = mSTORAGE_MAIN.CELL_ID;
mMANAGE_MAIN.MANAGE_OPERATOR = MainApp._USER.USER_NAME;
mMANAGE_MAIN.MANAGE_BEGIN_TIME = SiaSun.LMS.Common.StringUtil.GetDateTime();
mMANAGE_MAIN.MANAGE_STATUS = SiaSun.LMS.Enum.MANAGE_STATUS.Waiting.ToString();
mMANAGE_MAIN.MANAGE_LEVEL = string.Empty;
mMANAGE_MAIN.MANAGE_REMARK = string.Empty;
boolSingleResult = MainApp._I_BaseService.Invoke(mMANAGE_TYPE.MANAGE_TYPE_CLASS.TrimEnd(),
"ManageCreate",
new object[] { mMANAGE_MAIN,
listMANAGE_LIST
},
out sSingleReslut);
if (!boolSingleResult)
{
strResult += value_storage_id.Cast<DataRowView>().ToArray()[0]["CELL_CODE"].ToString() + " 任务下达失败 " + sSingleReslut + "\n";
break;
}
else
{
strResult += value_storage_id.Cast<DataRowView>().ToArray()[0]["CELL_CODE"].ToString() + " 任务下达成功 " + "\n";
boolResult = true;
}
}
//刷新
this.Refresh();
MainApp._MessageDialog.Show(boolResult, strResult);
}
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
}
/// <summary>
/// 刷新
/// </summary>
private void Refresh()
{
this.ucStorageGroup.U_Update();
}
#endregion
}
}