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 { /// /// MANAGE_MOVE.xaml 的交互逻辑 /// public partial class MANAGE_ADJUST : AvalonDock.DocumentContent { Model.MANAGE_TYPE mMANAGE_TYPE = null; int currentCellID = 0; /// /// 构造函数 /// public MANAGE_ADJUST(string MANAGE_TYPE_CODE) { InitializeComponent(); 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) { this.InitManagePosotion(); this.ucManagePosition.U_StockBarcodeKeyDown += new UC.ucManagePosition.U_StockBarcodeKeyDownHandler (() => { //校验托盘条码是否合法 if (!SiaSun.LMS.Common.RegexValid.GetCodeCheck(this.ucManagePosition.U_STOCK_BARCODE, "StockCodeCheck")) { MainApp._MessageDialog.Show(false,string.Format("检查托盘条码[{0}]是否合法", this.ucManagePosition.U_STOCK_BARCODE)); return; } //显示库存 StorageListBind(); } ); this.ucManagePosition.U_StartPositionChanged += new UC.ucManagePosition.U_StartPositionValueChangedHandler (() => { //显示库存 currentCellID = this.ucManagePosition.U_START_POSITION_ID; StorageListBind(); } ); this.ucManagePosition.U_EndPositionChanged += new UC.ucManagePosition.U_EndPositionValueChangedHandler (() => { //显示库存 currentCellID = this.ucManagePosition.U_END_POSITION_ID; StorageListBind(); } ); } /// /// 初始化输送位置控件 /// private void InitManagePosotion() { //设置输送任务控件参数 this.ucManagePosition.U_AllowAutoEndPostion = true; this.ucManagePosition.U_AllowAutoStartPostion = false; //初始化 this.ucManagePosition.U_InitControl(mMANAGE_TYPE.MANAGE_TYPE_ID); } /// /// 库存明细绑定 /// private void StorageListBind() { this.gridStorageList.U_WindowName = this.GetType().Name; this.gridStorageList.U_TableName = "V_STORAGE_LIST"; this.gridStorageList.U_XmlTableName = "V_STORAGE_LIST"; this.gridStorageList.U_TotalColumnName = "STORAGE_LIST_QUANTITY"; this.gridStorageList.U_OrderField = "STORAGE_LIST_ID"; this.gridStorageList.U_Where = string.Format(" CELL_ID={0} ", currentCellID) ; this.gridStorageList.U_AllowOperatData = false; this.gridStorageList.U_AllowChecked = true; this.gridStorageList.U_AllowShowPage = false; //拆分列属性 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(); } /// /// 点击按钮确认 /// private void WrapPanel_Click(object sender, RoutedEventArgs e) { Button btn = e.OriginalSource as Button; if (btn != null) { switch (btn.Name) { case "btnConfirm": this.CreateTask(); break; case "btnRefresh": this.Refresh(); break; } } } /// /// 创建输送任务 /// private void CreateTask() { string strResult = string.Empty; try { MainWindow.mainWin.Cursor = Cursors.Wait; //结束当前编辑操作 this.gridStorageList.U_EndCurrentEdit(); DataRowView[] dataRowItems = this.gridStorageList.U_GetCheckedDataRows(); DataTable tableAdjust= this.gridStorageList.U_DataSource.Copy(); tableAdjust.Clear(); foreach (DataRowView dr in dataRowItems) { tableAdjust.ImportRow(dr.Row); } foreach (DataRow dr in tableAdjust.Rows) { dr["MANAGE_LIST_QUANTITY"] = Convert.ToDecimal(dr["MANAGE_LIST_QUANTITY"]) - Convert.ToDecimal(dr["STORAGE_LIST_QUANTITY"]); dr["PLAN_LIST_ID"] = 0; } //根据数据源获得数据列表 List listMANAGE_LIST = new SiaSun.LMS.Common.CloneObjectValues().GetListFromDataTable(tableAdjust, null); var list = from v in listMANAGE_LIST where v.MANAGE_LIST_QUANTITY != 0 select v; listMANAGE_LIST = list.ToList(); #region ------校验合法性 //判断是否填写数据 if (listMANAGE_LIST.Count==0) { MainApp._MessageDialog.Show(false, "是否已经输入数据"); return; } //校验填写仓库信息是否合法 if (!this.ucManagePosition.U_CHECK_WAREHOUSE()) return; #endregion //提示确认 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 = currentCellID; 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) { this.Refresh(); } MainApp._MessageDialog.Show(bResult, strResult); } } catch (Exception ex) { MainApp._MessageDialog.ShowException(ex); } finally { MainWindow.mainWin.Cursor = Cursors.Arrow; } } /// /// 刷新 /// private void Refresh() { this.StorageListBind(); this.ucManagePosition.U_Update(); } } }