宜昌华友原料库管理软件
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.

408 lines
14 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.MANAGE
{
public partial class MANAGE_IN : AvalonDock.DocumentContent
{
Model.MANAGE_TYPE mMANAGE_TYPE = null;
public MANAGE_IN(string MANAGE_TYPE_CODE)
{
InitializeComponent();
this.ucQueryGoods.U_Query += new UC.ucQuickQuery.U_QueryEventHandler(ucQueryGoods_U_Query);
this.gridGoods.gridApp.MouseDoubleClick += new MouseButtonEventHandler(gridApp_MouseDoubleClick);
this.mMANAGE_TYPE =(Model.MANAGE_TYPE) MainApp._I_BaseService.GetModel("MANAGE_TYPE_SELECT_BY_MANAGE_TYPE_CODE", MANAGE_TYPE_CODE).RequestObject;
}
private void DocumentContent_Loaded(object sender, RoutedEventArgs e)
{
try
{
this.InitQueryControl();
this.GoodsBind(string.Empty);
this.InitManagePosition();
this.ManageList_Bind();
}
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);
}
}
private void InitQueryControl()
{
this.ucQueryGoods.U_WindowName = this.GetType().Name;
this.ucQueryGoods.U_XmlTableName = "GOODS_MAIN";
this.ucQueryGoods.U_InitControl();
}
private void GoodsBind(string QueryWhere)
{
try
{
this.gridGoods.U_WindowName = this.GetType().Name;
this.gridGoods.U_TableName = "V_GOODS";
this.gridGoods.U_XmlTableName = "GOODS_MAIN";
this.gridGoods.U_OrderField = "GOODS_CODE";
this.gridGoods.U_Where = string.Format("{0}", string.IsNullOrEmpty(QueryWhere) ? "1=1" : QueryWhere);
this.gridGoods.U_AllowOperatData = false;
this.gridGoods.U_AllowChecked = false;
this.gridGoods.U_InitControl();
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
}
void ucQueryGoods_U_Query(string QueryWhere)
{
this.GoodsBind(QueryWhere);
}
void gridApp_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (gridGoods.gridApp.SelectedItem == null)
return;
//获得物料记录
DataRowView rowViewGoods = this.gridGoods.gridApp.SelectedItem as DataRowView;
//获得添加行
DataTable tablePlanList = this.MANAGE_LIST_Add_By_GOODS( new string[] { rowViewGoods["GOODS_ID"].ToString() });
//添加行数据
this.gridManageList.U_AddTabPageRows(tablePlanList.Rows.Cast<DataRow>().ToArray());
//注册事件
Register_DataTable_Event();
}
private void Register_DataTable_Event()
{
//当输入列值改变后验证数据是否合法
foreach (TabItem tabItem in this.gridManageList.tabSplitProperty.Items)
{
if (tabItem.HasContent)
{
DataTable tableSource = (tabItem.Content as UC.ucCommonDataGrid).U_DataSource.Table;
tableSource.RowChanged -= new DataRowChangeEventHandler(tableSource_RowChanged);
tableSource.RowChanged += new DataRowChangeEventHandler(tableSource_RowChanged);
tableSource.ColumnChanged -= new DataColumnChangeEventHandler(table_ColumnChanged);
tableSource.ColumnChanged += new DataColumnChangeEventHandler(table_ColumnChanged);
}
}
}
/// <summary>
/// 表单数据校验
/// </summary>
void tableSource_RowChanged(object sender, DataRowChangeEventArgs e)
{
if (e.Row.RowState == DataRowState.Added || e.Row.RowState == DataRowState.Modified)
{
//判断数量
if (e.Row.IsNull("MANAGE_LIST_QUANTITY") || Convert.ToDecimal(e.Row["MANAGE_LIST_QUANTITY"]) <= 0 || string.IsNullOrEmpty(e.Row["MANAGE_LIST_QUANTITY"].ToString()))
{
e.Row.RowError = string.Format("请检查数量是否合法!");
}
}
}
/// <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() && !string.IsNullOrEmpty(e.ProposedValue.ToString()) && Convert.ToInt32(e.ProposedValue) > 0);
sResult = string.Format("{0}{1}不能小于等于0!", e.Column.ColumnName, e.ProposedValue.ToString());
e.Row.ClearErrors();
if (bResult)
{
e.Row.SetColumnError(e.Column, null);
}
else
{
e.Row.SetColumnError(e.Column, sResult);
}
break;
}
}
/// <summary>
/// 添加计划信息返回表单集合
/// </summary>
public DataTable MANAGE_LIST_Add_By_GOODS( IList<string> listGOODS_ID)
{
//创建集合
string strSql = string.Format("SELECT * FROM V_MANAGE_LIST WHERE MANAGE_ID={0}", 0);
using (DataTable tableManageList = MainApp._I_BaseService.GetList(strSql))
{
foreach (string strGoodsID in listGOODS_ID)
{
//获得物料实体
SiaSun.LMS.Model.GOODS_MAIN mGOODS_MAIN = MainApp._I_GoodsService.GoodsGetModelGoodsID(Convert.ToInt32(strGoodsID));
SiaSun.LMS.Model.GOODS_CLASS mGOODS_CLASS = MainApp._I_GoodsService.GoodsClassGetModelGoodsClassID(mGOODS_MAIN.GOODS_CLASS_ID);
if (mGOODS_MAIN != null && mGOODS_CLASS != null)
{
DataRow rowManageList = tableManageList.NewRow();
rowManageList["GOODS_ID"] = mGOODS_MAIN.GOODS_ID;
rowManageList["GOODS_CODE"] = mGOODS_MAIN.GOODS_CODE;
rowManageList["GOODS_NAME"] = mGOODS_MAIN.GOODS_NAME;
rowManageList["GOODS_CONST_PROPERTY1"] = mGOODS_MAIN.GOODS_CONST_PROPERTY1;
rowManageList["GOODS_TYPE_ID"] = mGOODS_CLASS.GOODS_TYPE_ID;
rowManageList["GOODS_UNITS"] = mGOODS_MAIN.GOODS_UNITS;
rowManageList["MANAGE_LIST_QUANTITY"] = 0;
tableManageList.Rows.Add(rowManageList);
}
}
return tableManageList;
}
}
/// <summary>
/// 任务列表绑定
/// </summary>
private void ManageList_Bind()
{
this.gridManageList.U_Clear();
//设置属性
this.gridManageList.U_WindowName = this.GetType().Name;
this.gridManageList.U_TableName = "V_MANAGE_LIST";
this.gridManageList.U_XmlTableName = "V_MANAGE_LIST";
this.gridManageList.U_OrderField = "MANAGE_LIST_ID";
this.gridManageList.U_Where = "MANAGE_LIST_ID=0";
this.gridManageList.U_AllowAdd = System.Windows.Visibility.Collapsed;
this.gridManageList.U_AllowSave = System.Windows.Visibility.Collapsed;
this.gridManageList.U_AllowEdit = System.Windows.Visibility.Collapsed;
this.gridManageList.U_AllowChecked = false;
this.gridManageList.U_AllowShowPage = false;
this.gridManageList.U_SplitGroupColumn = "GOODS_TYPE_ID";
this.gridManageList.U_SplitGroupHeader = "GOODS_TYPE_NAME";
this.gridManageList.U_SplitPropertyType = "GOODS_TYPE";
this.gridManageList.U_SplitPropertyColumn = "GOODS_PROPERTY";
try
{
this.gridManageList.U_InitControl();
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
}
/// <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.gridManageList.U_EndCurrentEdit();
//检验数据是否合法
DataTable tableSource = this.gridManageList.U_DataSource;
if (tableSource == null)
{
MainApp._MessageDialog.Show(Enum.MessageConverter.Input);
return;
}
//根据数据源获得数据列表
List<Model.MANAGE_LIST> listMANAGE_LIST = new SiaSun.LMS.Common.CloneObjectValues().GetListFromDataTable<Model.MANAGE_LIST>(tableSource, null);
#region ------校验合法性
//判断是否填写数据
if (listMANAGE_LIST.Count <= 0)
{
MainApp._MessageDialog.Show(Enum.MessageConverter.Input);
return;
}
//判断数据是否合法
if (tableSource.HasErrors)
{
MainApp._MessageDialog.Show(Enum.MessageConverter.Data);
return;
}
//检查拆分属性填写是否合法
if (!this.gridManageList.U_Check_Split_Property("GOODS_PROPERTY", out strResult))
{
MainApp._MessageDialog.ShowResult(false, strResult);
return;
}
//校验填写仓库信息是否合法
if (!this.ucManagePosition.U_CHECK_WAREHOUSE())
return;
#endregion
//提示确认
if (MainApp._MessageDialog.ShowDialog(Enum.MessageConverter.ConfirmAssembly, 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_END_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.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.gridManageList.U_Update();
this.Refresh();
}
MainApp._MessageDialog.ShowResult(bResult, strResult);
}
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
finally
{
MainWindow.mainWin.Cursor = Cursors.Arrow;
}
}
/// <summary>
/// 刷新
/// </summary>
private void Refresh()
{
this.ucManagePosition.U_Refresh();
}
}
}