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.
414 lines
16 KiB
414 lines
16 KiB
10 months ago
|
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.MANAGE
|
||
|
{
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
public partial class MANAGE_STORAGE_IN : AvalonDock.DocumentContent
|
||
|
{
|
||
|
int intPlanID = 0;
|
||
|
|
||
|
Dictionary<string, bool> dicStoageLoad = new Dictionary<string, bool>();
|
||
|
|
||
|
Model.PLAN_MAIN mPLAN_MAIN = null;
|
||
|
|
||
|
Model.MANAGE_TYPE mMANAGE_TYPE = null;
|
||
|
|
||
|
string xmlTableName = string.Empty;
|
||
|
|
||
|
public MANAGE_STORAGE_IN(int PLAN_ID, string MANAGE_TYPE_CODE,string xmlTableName):this( PLAN_ID, MANAGE_TYPE_CODE)
|
||
|
{
|
||
|
this.xmlTableName = xmlTableName;
|
||
|
}
|
||
|
|
||
|
public MANAGE_STORAGE_IN(int PLAN_ID, string MANAGE_TYPE_CODE)
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
|
||
|
this.intPlanID = PLAN_ID;
|
||
|
|
||
|
|
||
|
|
||
|
this.mMANAGE_TYPE = (Model.MANAGE_TYPE)MainApp._I_BaseService.GetModel("MANAGE_TYPE_SELECT_BY_MANAGE_TYPE_CODE", MANAGE_TYPE_CODE).RequestObject;
|
||
|
|
||
|
this.ucManageIn.U_CheckedDataGridRows += new UC.ucManageInInput.U_CheckedDataGridRowsHandler
|
||
|
(() =>
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
DataRowView[] arRow = this.ucManageIn.U_CheckedDataRowViews;
|
||
|
|
||
|
if (arRow.Length == 0)
|
||
|
{
|
||
|
MainApp._MessageDialog.Show(false,"请检查是否选中配盘数据!");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (this.ucManagePosition.U_AllowShowStockBarcode && this.ucManagePosition.U_STOCK_BARCODE == string.Empty)
|
||
|
{
|
||
|
MainApp._MessageDialog.Show(false,"请输入托盘条码");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (this.ucManagePosition.U_AllowShowStartPosition && this.ucManagePosition.U_START_POSITION_ID == 0)
|
||
|
{
|
||
|
MainApp._MessageDialog.Show(false,"请选择起始位置");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
if (!this.dicStoageLoad.ContainsKey(this.ucManagePosition.U_STOCK_BARCODE.TrimEnd()))
|
||
|
{
|
||
|
this.StorageListBind();
|
||
|
}
|
||
|
|
||
|
if (this.gridStorageList.U_DataSource==null || this.gridStorageList.U_DataSource.Rows.Count == 0)
|
||
|
{
|
||
|
MainApp._MessageDialog.Show(false,"空托盘不能进行补盘");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
List<DataRow> listRowManageList = new List<DataRow>();
|
||
|
|
||
|
foreach (DataRowView rowView in arRow)
|
||
|
{
|
||
|
int intPlanListID = rowView.Row.Table.Columns.Contains("PLAN_LIST_ID") ? Convert.ToInt32(rowView["PLAN_LIST_ID"]) : 0;
|
||
|
|
||
|
if (rowView.Row.Table.Columns.Contains("STOCK_BARCODE")&& rowView["STOCK_BARCODE"].ToString() == this.ucManagePosition.U_STOCK_BARCODE.TrimEnd())
|
||
|
return;
|
||
|
|
||
|
DataRow rowManageList;
|
||
|
|
||
|
using (DataTable tableManageList = MainApp._I_BaseService.GetList(string.Format("SELECT * FROM V_MANAGE_LIST WHERE MANAGE_ID={0}", -1)))
|
||
|
{
|
||
|
new CustomerDescriptions().SetDefaultValue(tableManageList, this.GetType().Name, "V_MANAGE_LIST");
|
||
|
|
||
|
rowManageList = tableManageList.NewRow();
|
||
|
|
||
|
Dictionary<string, object> dicDefault = new Dictionary<string, object>();
|
||
|
dicDefault.Add("MANAGE_LIST_QUANTITY", 1);
|
||
|
dicDefault.Add("PLAN_LIST_ID", intPlanListID);
|
||
|
new SiaSun.LMS.Common.CloneObjectValues().CloneDataRowValue(rowView.Row, rowManageList, dicDefault);
|
||
|
tableManageList.Rows.Add(rowManageList);
|
||
|
|
||
|
listRowManageList.Add(rowManageList);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.gridStorageList.U_AddTabPageRows(listRowManageList.ToArray());
|
||
|
|
||
|
foreach (TabItem page in this.gridStorageList.tabSplitProperty.Items)
|
||
|
{
|
||
|
if (page.HasContent)
|
||
|
{
|
||
|
using (DataTable tableSource = (page.Content as UC.ucCommonDataGrid).U_DataSource.Table)
|
||
|
{
|
||
|
tableSource.ColumnChanged -= new DataColumnChangeEventHandler(table_ColumnChanged);
|
||
|
tableSource.ColumnChanged += new DataColumnChangeEventHandler(table_ColumnChanged);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
MainApp._MessageDialog.ShowException(ex);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
);
|
||
|
|
||
|
}
|
||
|
|
||
|
void table_ColumnChanged(object sender, DataColumnChangeEventArgs e)
|
||
|
{
|
||
|
bool bResult = true;
|
||
|
string sResult = string.Empty;
|
||
|
|
||
|
switch (e.Column.ColumnName)
|
||
|
{
|
||
|
case "STORAGE_LIST_QUANTITY":
|
||
|
bResult = (string.Empty != e.ProposedValue.ToString()) && Convert.ToInt32(e.ProposedValue) > 0;
|
||
|
sResult = "填写数量必须是大于0!";
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (bResult)
|
||
|
{
|
||
|
e.Row.RowError = null;
|
||
|
e.Row.SetColumnError(e.Column, null);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
e.Row.RowError = "该行数据有错误!";
|
||
|
e.Row.SetColumnError(e.Column, sResult);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <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.InitManagePosition();
|
||
|
|
||
|
this.ucManagePosition.U_StockBarcodeKeyDown += new UC.ucManagePosition.U_StockBarcodeKeyDownHandler
|
||
|
(() =>
|
||
|
{
|
||
|
this.StorageListBind();
|
||
|
}
|
||
|
);
|
||
|
this.ucManagePosition.U_StartPositionChanged += new UC.ucManagePosition.U_StartPositionValueChangedHandler
|
||
|
(() =>
|
||
|
{
|
||
|
this.StorageListBind();
|
||
|
}
|
||
|
);
|
||
|
this.InitManageInControl();
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
MainApp._MessageDialog.ShowException(ex);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
private void InitManagePosition()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
this.ucManagePosition.U_InitControl(mMANAGE_TYPE.MANAGE_TYPE_ID);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
MainApp._MessageDialog.ShowException(ex);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
private void InitManageInControl()
|
||
|
{
|
||
|
this.ucManageIn.U_WindowName = this.GetType().ToString();
|
||
|
this.ucManageIn.U_PLAN_ID = this.intPlanID;
|
||
|
this.ucManageIn.U_PLAN_OUT = Enum.PLAN_INOUT.In;
|
||
|
this.ucManageIn.U_ShowType = this.ucManagePosition.U_AssembleResource;
|
||
|
|
||
|
this.ucManageIn.U_InitControl();
|
||
|
|
||
|
this.ucManageIn.Data_Bind(string.Empty);
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 库存明细绑定
|
||
|
/// </summary>
|
||
|
private void StorageListBind()
|
||
|
{
|
||
|
if( !dicStoageLoad.ContainsKey(this.ucManagePosition.U_STOCK_BARCODE.TrimEnd()))
|
||
|
{
|
||
|
dicStoageLoad.Clear();
|
||
|
dicStoageLoad.Add(this.ucManagePosition.U_STOCK_BARCODE.TrimEnd(), true);
|
||
|
}
|
||
|
|
||
|
|
||
|
this.gridStorageList.U_WindowName = this.GetType().Name;
|
||
|
this.gridStorageList.U_TableName = "V_STORAGE_LIST";
|
||
|
this.gridStorageList.U_XmlTableName = this.xmlTableName== string.Empty?"V_STORAGE_LIST":this.xmlTableName;
|
||
|
this.gridStorageList.U_TotalColumnName = "STORAGE_LIST_QUANTITY";
|
||
|
this.gridStorageList.U_OrderField = "STORAGE_LIST_ID";
|
||
|
this.gridStorageList.U_Where = string.Format("CELL_ID ={0} AND AREA_TYPE= 'XuNiKu'", this.ucManagePosition.U_START_POSITION_ID);
|
||
|
|
||
|
//this.gridStorageList.U_AllowOperatData = true;
|
||
|
this.gridStorageList.U_AllowChecked = false;
|
||
|
this.gridStorageList.U_AllowShowPage = false;
|
||
|
|
||
|
this.gridStorageList.U_AllowAdd = System.Windows.Visibility.Collapsed;
|
||
|
this.gridStorageList.U_AllowEdit = System.Windows.Visibility.Collapsed;
|
||
|
this.gridStorageList.U_AllowSave = System.Windows.Visibility.Collapsed;
|
||
|
|
||
|
//拆分列属性
|
||
|
this.gridStorageList.U_SplitPropertyType = "GOODS_TYPE";
|
||
|
this.gridStorageList.U_SplitGroupColumn = "GOODS_TYPE_ID";
|
||
|
this.gridStorageList.U_SplitPropertyColumn = "GOODS_PROPERTY";
|
||
|
this.gridStorageList.U_SplitGroupHeader = "GOODS_TYPE.GOODS_TYPE_NAME";
|
||
|
|
||
|
this.gridStorageList.U_InitControl();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 按钮事件
|
||
|
/// </summary>
|
||
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||
|
{
|
||
|
Button btn = e.OriginalSource as Button;
|
||
|
if (btn != null)
|
||
|
{
|
||
|
switch (btn.Name)
|
||
|
{
|
||
|
case "btnSave":
|
||
|
this.Confirm();
|
||
|
break;
|
||
|
case "btnRefresh":
|
||
|
this.Refresh();
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 确认
|
||
|
/// </summary>
|
||
|
private void Confirm()
|
||
|
{
|
||
|
string strResult = string.Empty;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
MainWindow.mainWin.Cursor = Cursors.Wait;
|
||
|
|
||
|
this.gridStorageList.U_EndCurrentEdit();
|
||
|
|
||
|
DataTable tableSource = this.gridStorageList.U_DataSource;
|
||
|
|
||
|
foreach (DataRow dr in tableSource.Rows)
|
||
|
{
|
||
|
if (Convert.ToDecimal(dr["MANAGE_LIST_QUANTITY"]) > 0)
|
||
|
dr["MANAGE_LIST_QUANTITY"] = dr["STORAGE_LIST_QUANTITY"];
|
||
|
}
|
||
|
|
||
|
List<Model.MANAGE_LIST> listMANAGE_LIST = new SiaSun.LMS.Common.CloneObjectValues().GetListFromDataTable<Model.MANAGE_LIST>(tableSource, null);
|
||
|
|
||
|
var list = from v in listMANAGE_LIST
|
||
|
where v.MANAGE_LIST_QUANTITY > 0
|
||
|
select v;
|
||
|
|
||
|
listMANAGE_LIST = list.ToList<Model.MANAGE_LIST>();
|
||
|
|
||
|
if (tableSource == null || tableSource.Rows.Count == 0 || listMANAGE_LIST.Count == 0)
|
||
|
{
|
||
|
MainApp._MessageDialog.Show(false, "是否已经输入数据");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (tableSource.HasErrors)
|
||
|
{
|
||
|
MainApp._MessageDialog.Show(false, "检查数据是否合法");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!this.gridStorageList.U_Check_Split_Property("GOODS_PROPERTY", out strResult))
|
||
|
{
|
||
|
MainApp._MessageDialog.Show(false, strResult);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!this.ucManagePosition.U_CHECK_WAREHOUSE())
|
||
|
return;
|
||
|
|
||
|
if (MainApp._MessageDialog.ShowDialog(string.Format("确认配盘[{0}]操作", this.ucManagePosition.U_STOCK_BARCODE)) == Sid.Windows.Controls.TaskDialogResult.Ok)
|
||
|
{
|
||
|
|
||
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = new Model.MANAGE_MAIN();
|
||
|
|
||
|
mMANAGE_MAIN.MANAGE_TYPE_CODE = mMANAGE_TYPE.MANAGE_TYPE_CODE.TrimEnd();
|
||
|
|
||
|
mMANAGE_MAIN.STOCK_BARCODE = this.ucManagePosition.U_STOCK_BARCODE;
|
||
|
|
||
|
mMANAGE_MAIN.CELL_MODEL = this.ucManagePosition.U_CELL_MODEL;
|
||
|
|
||
|
mMANAGE_MAIN.START_CELL_ID = this.ucManagePosition.U_START_POSITION_ID;
|
||
|
|
||
|
mMANAGE_MAIN.END_CELL_ID = this.ucManagePosition.U_START_POSITION_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.WaitingSend.ToString();
|
||
|
|
||
|
mMANAGE_MAIN.FULL_FLAG = this.ucManagePosition.U_OCCUPY_PERCENT;
|
||
|
|
||
|
mMANAGE_MAIN.MANAGE_LEVEL = string.Empty;
|
||
|
|
||
|
mMANAGE_MAIN.MANAGE_REMARK = string.Empty;
|
||
|
|
||
|
bool bResult = false;
|
||
|
|
||
|
bResult = MainApp._I_BaseService.Invoke(mMANAGE_TYPE.MANAGE_TYPE_CLASS.TrimEnd(),
|
||
|
"ManageCreate",
|
||
|
new object[] { mMANAGE_MAIN,
|
||
|
listMANAGE_LIST,
|
||
|
true,
|
||
|
this.ucManagePosition.U_CheckStockExistStorage,
|
||
|
this.ucManagePosition.U_AutoCompleteTask,
|
||
|
this.ucManagePosition.U_AutoDownloadControlTask,
|
||
|
},
|
||
|
out strResult);
|
||
|
|
||
|
|
||
|
//检验执行结果
|
||
|
if (bResult)
|
||
|
{
|
||
|
if( !this.rbRefresh.IsChecked.Value)
|
||
|
this.gridStorageList.U_Update();
|
||
|
|
||
|
this.Refresh();
|
||
|
}
|
||
|
|
||
|
MainApp._MessageDialog.Show(bResult, strResult);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
MainApp._MessageDialog.ShowException(ex);
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
MainWindow.mainWin.Cursor = Cursors.Arrow;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
private void Refresh()
|
||
|
{
|
||
|
this.ucManagePosition.U_Refresh();
|
||
|
this.ucManageIn.Data_Bind(string.Empty);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|