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.
620 lines
20 KiB
620 lines
20 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;
|
|
using SiaSun.LMS.Model;
|
|
using SiaSun.LMS.Common;
|
|
|
|
namespace SiaSun.LMS.WPFClient.TASK
|
|
{
|
|
/// <summary>
|
|
/// MANAGE_IN.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class ManageBindIn_Plan : AvalonDock.DocumentContent
|
|
{
|
|
int intPlanID = 0;
|
|
|
|
Model.PLAN_MAIN mPLAN_MAIN = null;
|
|
|
|
Model.MANAGE_TYPE mMANAGE_TYPE = null;
|
|
|
|
#region 系统方法
|
|
|
|
//构造函数
|
|
public ManageBindIn_Plan(int PLAN_ID, string MANAGE_TYPE_CODE)
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.intPlanID = PLAN_ID;
|
|
|
|
this.mMANAGE_TYPE =(MANAGE_TYPE) MainApp._I_BaseService.GetModel("MANAGE_TYPE_SELECT_BY_MANAGE_TYPE_CODE", MANAGE_TYPE_CODE).RequestObject;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 窗体加载
|
|
/// </summary>
|
|
private void DocumentContent_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (intPlanID > 0)
|
|
{
|
|
mPLAN_MAIN = MainApp._I_PlanService.PlanGetModel(intPlanID);
|
|
|
|
if (mPLAN_MAIN == null)
|
|
{
|
|
MainApp._MessageDialog.Show(false,string.Format("计划索引[{0}]不存在", intPlanID));
|
|
}
|
|
}
|
|
|
|
this.InitManagePosotion();
|
|
|
|
this.ucManagePosition.U_StockBarcodeKeyDown += new UC.ucManagePosition.U_StockBarcodeKeyDownHandler(ucManagePosition_U_StockBarcodeKeyDown);
|
|
|
|
this.PLAN_LIST_Bind(intPlanID);
|
|
Area_Bind();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MainApp._MessageDialog.ShowException(ex);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void tbSTOCK_BARCODE_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Key != Key.Enter)
|
|
{
|
|
return;
|
|
}
|
|
|
|
BindListBind();
|
|
}
|
|
|
|
private void cbbAREA_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
if (e.Source == null)
|
|
return;
|
|
|
|
this.cbbCELL.DisplayMemberPath = "CELL_NAME";
|
|
this.cbbCELL.SelectedValuePath = "CELL_ID";
|
|
try
|
|
{
|
|
string strSQL = string.Format(@"SELECT CELL_ID,
|
|
CELL_NAME
|
|
FROM WH_CELL
|
|
WHERE CELL_TYPE = 'Cell'
|
|
AND CELL_INOUT != 'Out'
|
|
AND AREA_ID = {0}
|
|
ORDER BY CELL_ID", this.cbbAREA.SelectedValue);
|
|
|
|
this.cbbCELL.ItemsSource = MainApp._I_BaseService.GetList(strSQL).DefaultView;
|
|
|
|
if (this.cbbCELL.Items.Count > 0)
|
|
{
|
|
this.cbbCELL.SelectedIndex = this.cbbCELL.SelectedIndex < 0 ? 0 : this.cbbCELL.SelectedIndex;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MainApp._MessageDialog.ShowException(ex);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 自定义方法
|
|
|
|
/// <summary>
|
|
/// 初始化输送位置控件
|
|
/// </summary>
|
|
private void InitManagePosotion()
|
|
{
|
|
//设置输送任务控件参数
|
|
this.ucManagePosition.U_AllowAutoEndPostion = false;
|
|
|
|
this.ucManagePosition.U_AllowAutoStartPostion = true;
|
|
//初始化
|
|
this.ucManagePosition.U_InitControl(mMANAGE_TYPE.MANAGE_TYPE_ID);
|
|
}
|
|
|
|
void ucManagePosition_U_StockBarcodeKeyDown()
|
|
{
|
|
//显示托盘库存
|
|
BindListBind();
|
|
}
|
|
|
|
private void PLAN_LIST_Bind(int PLAN_ID)
|
|
{
|
|
//数据源属性
|
|
this.gridPlanList.U_Clear();
|
|
this.gridPlanList.U_WindowName = this.GetType().Name;
|
|
this.gridPlanList.U_TableName = "V_PLAN_LIST";
|
|
this.gridPlanList.U_XmlTableName = "V_PLAN_LIST";
|
|
this.gridPlanList.U_Fields = "*";
|
|
this.gridPlanList.U_Where = string.Format("PLAN_STATUS ='{0}' AND (PLAN_LIST_QUANTITY>PLAN_LIST_ORDERED_QUANTITY) AND PLAN_ID={1}", Enum.PLAN_STATUS.Executing.ToString(), PLAN_ID);
|
|
this.gridPlanList.U_OrderField = "PLAN_LIST_ID";
|
|
|
|
this.gridPlanList.U_AllowChecked = false;
|
|
this.gridPlanList.U_AllowOperatData = false;
|
|
this.gridPlanList.U_AllowShowPage = false;
|
|
|
|
//拆分列属性
|
|
this.gridPlanList.U_SplitPropertyType = "GOODS_TYPE";
|
|
this.gridPlanList.U_SplitGroupColumn = "GOODS_TYPE_ID";
|
|
this.gridPlanList.U_SplitGroupHeader = "GOODS_TYPE.GOODS_TYPE_NAME";
|
|
this.gridPlanList.U_SplitPropertyColumn = "GOODS_PROPERTY";
|
|
|
|
//明细属性
|
|
//this.gridPlanList.U_DetailTableName = "PLAN_DETAIL";
|
|
//this.gridPlanList.U_DetailRelatvieColumn = "PLAN_LIST_ID";
|
|
|
|
try
|
|
{
|
|
//初始化控件
|
|
this.gridPlanList.U_InitControl();
|
|
Register_DataTable_Event();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MainApp._MessageDialog.ShowException(ex);
|
|
}
|
|
}
|
|
|
|
private void BindListBind()
|
|
{
|
|
string STOCK_BARCODE = this.ucManagePosition.U_STOCK_BARCODE.ToUpper();
|
|
this.gridBindList.U_WindowName = this.GetType().Name;
|
|
this.gridBindList.U_TableName = "V_STORAGE_LIST";
|
|
this.gridBindList.U_XmlTableName = "V_STORAGE_LIST";
|
|
this.gridBindList.U_TotalColumnName = "STORAGE_LIST_QUANTITY";
|
|
this.gridBindList.U_OrderField = "STORAGE_LIST_ID DESC";
|
|
this.gridBindList.U_Where = string.Format(@" AREA_TYPE='XuNiKu' AND {0}", string.IsNullOrEmpty(STOCK_BARCODE) ? "1=1" : string.Format("STOCK_BARCODE = '{0}'", STOCK_BARCODE));
|
|
this.gridBindList.U_AllowOperatData = false;
|
|
this.gridBindList.U_AllowChecked = false;
|
|
this.gridBindList.U_AllowShowPage = false;
|
|
|
|
//拆分列属性
|
|
this.gridBindList.U_SplitPropertyType = "GOODS_TYPE";
|
|
this.gridBindList.U_SplitGroupColumn = "GOODS_TYPE_ID";
|
|
this.gridBindList.U_SplitGroupHeader = "GOODS_TYPE.GOODS_TYPE_NAME";
|
|
this.gridBindList.U_SplitPropertyColumn = "GOODS_PROPERTY";
|
|
|
|
this.gridBindList.U_InitControl();
|
|
}
|
|
|
|
//接收库区
|
|
private void Area_Bind()
|
|
{
|
|
this.cbbAREA.DisplayMemberPath = "AREA_NAME";
|
|
this.cbbAREA.SelectedValuePath = "AREA_ID";
|
|
try
|
|
{
|
|
this.cbbAREA.ItemsSource = MainApp._I_CellService.AREA_GetList(0, "XuNiKu").DefaultView;
|
|
|
|
if (this.cbbAREA.Items.Count > 0)
|
|
{
|
|
this.cbbAREA.SelectedIndex = this.cbbAREA.SelectedIndex < 0 ? 0 : this.cbbAREA.SelectedIndex;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MainApp._MessageDialog.ShowException(ex);
|
|
}
|
|
}
|
|
|
|
private void Register_DataTable_Event()
|
|
{
|
|
//当输入列值改变后验证数据是否合法
|
|
foreach (TabItem tabItem in this.gridPlanList.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["PLAN_LIST_QUANTITY"]) - Convert.ToDecimal(e.Row["PLAN_LIST_ORDERED_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);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 按钮事件
|
|
|
|
/// <summary>
|
|
/// 按钮事件
|
|
/// </summary>
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Button btn = e.OriginalSource as Button;
|
|
if (btn != null)
|
|
{
|
|
switch (btn.Name)
|
|
{
|
|
case "btnIN":
|
|
this.CreateTaskIN();
|
|
break;
|
|
case "btnBindIn":
|
|
this.CreateTaskBindIn();
|
|
break;
|
|
case "btnRefresh":
|
|
this.Refresh();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 入库-直接入库
|
|
/// </summary>
|
|
private void CreateTaskIN()
|
|
{
|
|
bool bResult = true;
|
|
string sResult = string.Empty;
|
|
|
|
try
|
|
{
|
|
MainWindow.mainWin.Cursor = Cursors.Wait;
|
|
|
|
//结束当前编辑操作
|
|
this.gridPlanList.U_EndCurrentEdit();
|
|
|
|
#region 校验数据表单
|
|
|
|
//检验数据是否合法
|
|
DataTable tableSource = this.gridPlanList.U_DataSource;
|
|
|
|
if (tableSource == null)
|
|
{
|
|
bResult = false;
|
|
MainApp._MessageDialog.Show(bResult, "请填写数据表单");
|
|
return;
|
|
}
|
|
|
|
//根据数据源获得数据列表
|
|
List<Model.MANAGE_LIST> lsMANAGE_LIST = new SiaSun.LMS.Common.CloneObjectValues().GetListFromDataTable<Model.MANAGE_LIST>(tableSource, null);
|
|
var list = from v in lsMANAGE_LIST
|
|
where v.MANAGE_LIST_QUANTITY > 0
|
|
select v;
|
|
|
|
lsMANAGE_LIST = list.ToList<Model.MANAGE_LIST>();
|
|
|
|
#region ------校验合法性
|
|
|
|
//判断是否填写数据
|
|
if (lsMANAGE_LIST.Count <= 0)
|
|
{
|
|
bResult = false;
|
|
MainApp._MessageDialog.Show(bResult, "请填写【入库数量】");
|
|
return;
|
|
}
|
|
|
|
//判断数据是否合法
|
|
if (tableSource.HasErrors)
|
|
{
|
|
bResult = false;
|
|
MainApp._MessageDialog.Show(bResult, "表单存在不合法的数据");
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 校验接收库区
|
|
|
|
if (this.cbbAREA.SelectedValue == null)
|
|
{
|
|
bResult = false;
|
|
sResult = string.Format("请选择接收库区");
|
|
MainApp._MessageDialog.Show(bResult, sResult);
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 校验接收地点
|
|
|
|
if (this.cbbCELL.SelectedValue == null)
|
|
{
|
|
bResult = false;
|
|
sResult = string.Format("请选择接收地点");
|
|
MainApp._MessageDialog.Show(bResult, sResult);
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
if (MainApp._MessageDialog.ShowDialog("确认不配盘,仅接收入库?") == Sid.Windows.Controls.TaskDialogResult.Cancel)
|
|
{
|
|
return;
|
|
}
|
|
|
|
#region 生成MANAGE_MAIN
|
|
|
|
MANAGE_MAIN mMANAGE_MAIN = new Model.MANAGE_MAIN();
|
|
|
|
mMANAGE_MAIN.PLAN_ID = this.intPlanID;
|
|
|
|
mMANAGE_MAIN.PLAN_TYPE_CODE = this.mPLAN_MAIN.PLAN_TYPE_CODE;
|
|
|
|
mMANAGE_MAIN.MANAGE_TYPE_CODE = mMANAGE_TYPE.MANAGE_TYPE_CODE.TrimEnd();
|
|
|
|
mMANAGE_MAIN.STOCK_BARCODE = string.Empty;
|
|
|
|
mMANAGE_MAIN.CELL_MODEL = string.Empty;
|
|
|
|
mMANAGE_MAIN.FULL_FLAG = string.Empty;
|
|
|
|
mMANAGE_MAIN.START_CELL_ID = Convert.ToInt32(this.cbbCELL.SelectedValue);
|
|
|
|
mMANAGE_MAIN.END_CELL_ID = Convert.ToInt32(this.cbbCELL.SelectedValue);
|
|
|
|
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;
|
|
|
|
#endregion
|
|
|
|
bResult = MainApp._I_BaseService.Invoke(mMANAGE_TYPE.MANAGE_TYPE_CLASS.TrimEnd(),
|
|
"ManageCreate",
|
|
new object[] { mMANAGE_MAIN,
|
|
lsMANAGE_LIST},
|
|
out sResult);
|
|
|
|
|
|
//检验执行结果
|
|
if (bResult)
|
|
{
|
|
this.gridPlanList.U_Update();
|
|
BindListBind();
|
|
}
|
|
|
|
MainApp._MessageDialog.Show(bResult, sResult);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MainApp._MessageDialog.ShowException(ex);
|
|
}
|
|
finally
|
|
{
|
|
MainWindow.mainWin.Cursor = Cursors.Arrow;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 入库-配盘入库
|
|
/// </summary>
|
|
private void CreateTaskBindIn()
|
|
{
|
|
bool bResult = true;
|
|
string sResult = string.Empty;
|
|
|
|
try
|
|
{
|
|
MainWindow.mainWin.Cursor = Cursors.Wait;
|
|
|
|
//结束当前编辑操作
|
|
this.gridPlanList.U_EndCurrentEdit();
|
|
|
|
#region 校验数据表单
|
|
|
|
//检验数据是否合法
|
|
DataTable tableSource = this.gridPlanList.U_DataSource;
|
|
|
|
if (tableSource == null)
|
|
{
|
|
bResult = false;
|
|
MainApp._MessageDialog.Show(bResult, "请填写数据表单");
|
|
return;
|
|
}
|
|
|
|
//根据数据源获得数据列表
|
|
List<Model.MANAGE_LIST> lsMANAGE_LIST = new SiaSun.LMS.Common.CloneObjectValues().GetListFromDataTable<Model.MANAGE_LIST>(tableSource, null);
|
|
var list = from v in lsMANAGE_LIST
|
|
where v.MANAGE_LIST_QUANTITY > 0
|
|
select v;
|
|
|
|
lsMANAGE_LIST = list.ToList<Model.MANAGE_LIST>();
|
|
|
|
#region ------校验合法性
|
|
|
|
//判断是否填写数据
|
|
if (lsMANAGE_LIST.Count <= 0)
|
|
{
|
|
bResult = false;
|
|
MainApp._MessageDialog.Show(bResult, "请填写【入库数量】");
|
|
return;
|
|
}
|
|
|
|
//判断数据是否合法
|
|
if (tableSource.HasErrors)
|
|
{
|
|
bResult = false;
|
|
MainApp._MessageDialog.Show(bResult, "表单存在不合法的数据");
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 校验接收库区
|
|
|
|
if (this.cbbAREA.SelectedValue == null)
|
|
{
|
|
bResult = false;
|
|
sResult = string.Format("请选择接收库区");
|
|
MainApp._MessageDialog.Show(bResult, sResult);
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 校验接收地点
|
|
|
|
if (this.cbbCELL.SelectedValue == null)
|
|
{
|
|
bResult = false;
|
|
sResult = string.Format("请选择接收地点");
|
|
MainApp._MessageDialog.Show(bResult, sResult);
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
//校验填写仓库信息是否合法
|
|
if (!this.ucManagePosition.U_CHECK_WAREHOUSE())
|
|
return;
|
|
|
|
#region 校验容器条码
|
|
|
|
string STOCK_BARCODE = this.ucManagePosition.U_STOCK_BARCODE.ToUpper();
|
|
|
|
if (string.IsNullOrEmpty(STOCK_BARCODE))
|
|
{
|
|
bResult = false;
|
|
sResult = string.Format("请输入容器条码", STOCK_BARCODE);
|
|
MainApp._MessageDialog.Show(bResult, sResult);
|
|
return;
|
|
}
|
|
|
|
if (MainApp._MessageDialog.ShowDialog(string.Format("确认[{0}]配盘入库?", STOCK_BARCODE)) == Sid.Windows.Controls.TaskDialogResult.Cancel)
|
|
{
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 生成MANAGE_MAIN
|
|
|
|
MANAGE_MAIN mMANAGE_MAIN = new Model.MANAGE_MAIN();
|
|
|
|
mMANAGE_MAIN.PLAN_ID = this.intPlanID;
|
|
|
|
mMANAGE_MAIN.PLAN_TYPE_CODE = this.mPLAN_MAIN.PLAN_TYPE_CODE;
|
|
|
|
mMANAGE_MAIN.MANAGE_TYPE_CODE = mMANAGE_TYPE.MANAGE_TYPE_CODE.TrimEnd();
|
|
|
|
mMANAGE_MAIN.STOCK_BARCODE = STOCK_BARCODE;
|
|
|
|
mMANAGE_MAIN.CELL_MODEL = string.Empty;
|
|
|
|
mMANAGE_MAIN.FULL_FLAG = this.ucManagePosition.U_OCCUPY_PERCENT;
|
|
|
|
mMANAGE_MAIN.START_CELL_ID = Convert.ToInt32(this.cbbCELL.SelectedValue);
|
|
|
|
mMANAGE_MAIN.END_CELL_ID = Convert.ToInt32(this.cbbCELL.SelectedValue);
|
|
|
|
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;
|
|
|
|
#endregion
|
|
|
|
bResult = MainApp._I_BaseService.Invoke(mMANAGE_TYPE.MANAGE_TYPE_CLASS.TrimEnd(),
|
|
"ManageCreate",
|
|
new object[] { mMANAGE_MAIN,
|
|
lsMANAGE_LIST},
|
|
out sResult);
|
|
|
|
|
|
//检验执行结果
|
|
if (bResult)
|
|
{
|
|
this.gridPlanList.U_Update();
|
|
BindListBind();
|
|
}
|
|
|
|
MainApp._MessageDialog.Show(bResult, sResult);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MainApp._MessageDialog.ShowException(ex);
|
|
}
|
|
finally
|
|
{
|
|
MainWindow.mainWin.Cursor = Cursors.Arrow;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 刷新
|
|
/// </summary>
|
|
private void Refresh()
|
|
{
|
|
this.ucManagePosition.U_Update();
|
|
this.gridPlanList.U_Update();
|
|
BindListBind();
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
}
|