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_DONGJIE : AvalonDock.DocumentContent { Model.MANAGE_TYPE mMANAGE_TYPE = null; List listMANAGE_MAIN = null; List listMANAGE_LIST = null; DataRowView[] listDataRowView = null; string STORAGE_AREA_TYPE = string.Empty; string CELL_ADJUST = string.Empty; /// /// /// public MANAGE_DONGJIE() { InitializeComponent(); this.ucQuery.U_Query += new UC.ucQuickQuery.U_QueryEventHandler ((QueryWhere) => { QueryWhere = string.Format("{0} AND {1}{2}", this.ucSplitPanel.U_GetSplitPropertyWhere(), string.IsNullOrEmpty(QueryWhere) ? "1=1" : QueryWhere, this.STORAGE_AREA_TYPE == string.Empty ? string.Empty : string.Format(" AND V_STORAGE_LIST.AREA_TYPE = '{0}'", this.STORAGE_AREA_TYPE)); //string.Format(" order by V_STORAGE_LIST.CELL_FORK_TYPE asc ")); this.StorageListBind(QueryWhere); } ); } private void DocumentContent_Loaded(object sender, RoutedEventArgs e) { //属性控件 this.InitSplitPropertyPanel(); //查询控件 this.InitQueryControl(); } 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); } } } /// /// 表单数据校验 /// private void table_ColumnChanged(object sender, DataColumnChangeEventArgs e) { bool bResult = true; string sResult = string.Empty; //判断列 switch (e.Column.ColumnName) { case "MANAGE_LIST_QUANTITY": bResult = (Convert.ToDecimal(e.ProposedValue) <= Convert.ToDecimal(e.Row["STORAGE_LIST_QUANTITY"])); sResult = string.Format("出库数量不能大于库存数量!"); e.Row.ClearErrors(); if (bResult) { e.Row.SetColumnError(e.Column, null); } else { e.Row.SetColumnError(e.Column, sResult); } break; } } /// /// 初始化查询控件 /// private void InitQueryControl() { this.ucQuery.U_WindowName = this.GetType().Name; this.ucQuery.U_XmlTableName = "V_STORAGE_LIST"; this.ucQuery.U_InitControl(); } /// /// 初始化属性面板 /// private void InitSplitPropertyPanel() { this.ucSplitPanel.U_SplitGroupColumn = "GOODS_TYPE_ID"; this.ucSplitPanel.U_SplitGroupHeader = "GOODS_TYPE_NAME"; this.ucSplitPanel.U_SplitPropertyColumn = "GOODS_PROPERTY"; this.ucSplitPanel.U_SplitPropertyType = "GOODS_TYPE"; this.ucSplitPanel.U_InitControl(); } 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 cell_id not in ( select start_cell_id from manage_main) and {0} ",QueryWhere); this.ucStorageGroup.U_Where = string.Format("1=1 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(); } private void DoubleCellBind(string QueryWhere) { this.ucStorageGroup.U_WindowName = this.GetType().Name; this.ucStorageGroup.U_TableName = "V_WH_CELL_DOUBLE_TO_NORMAL"; this.ucStorageGroup.U_XmlTableName = "V_WH_CELL_DOUBLE_TO_NORMAL"; //this.ucStorageGroup.U_AppendFieldStyles = this.GetColumnDescriptionList(); //this.ucStorageGroup.U_TotalColumnName = "STORAGE_LIST_QUANTITY"; this.ucStorageGroup.U_OrderField = "CELL_ID_FAR"; //this.ucStorageGroup.U_Where = string.Format(" cell_status <> 'Pallet' and cell_id not in ( select start_cell_id from manage_main) and {0} ",QueryWhere); this.ucStorageGroup.U_Where = string.Format(" cell_id not in ( select start_cell_id from manage_main) 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(); } /// /// 按钮事件 /// private void WrapPanel_Click(object sender, RoutedEventArgs e) { Button btn = e.OriginalSource as Button; if (btn != null) { switch (btn.Name) { case "btnDongJie": this.CreateTask("2"); break; case "btnJieDong": this.CreateTask("1"); break; case "btnDongJie2": this.CreateTask("4"); break; } } } /// /// 创建输送任务 /// private void CreateTask(string goods_property9) { int i = 0;//记任务的数量 bool boolResult = true; bool boolSingleResult = true; string strResult = string.Empty; string sSingleReslut = string.Empty; try { //获得选中记录 listDataRowView = this.ucStorageGroup.U_GetCheckedDataRows(); this.ucStorageGroup.U_EndCurrentEdit(); //判断数据是否合法 if (this.ucStorageGroup.U_DataSource.HasErrors) { MainApp._MessageDialog.Show(Enum.MessageConverter.Data); return; } //根据数据源获得数据列表 //校验是否选中记录 if (listDataRowView.Length == 0) { MainApp._MessageDialog.Show(Enum.MessageConverter.SelectCount); return; } if (MainApp._MessageDialog.ShowDialog(Enum.MessageConverter.ConfirmCreateTask, this.Title) == Sid.Windows.Controls.TaskDialogResult.Ok) { foreach (var drv in listDataRowView) { MainApp._I_BaseService.ExecuteNonQuery_ReturnVoid(string.Format(@"update STORAGE_LIST set GOODS_PROPERTY9='{0}' where STORAGE_LIST_ID={1}", goods_property9, drv["STORAGE_LIST_ID"].ToString())); } //刷新 this.Refresh(); } //add by lhj 20200519 string sRnum = string.Empty; sRnum = string.Format("共计'{0}'个任务", i); strResult = strResult + sRnum; MainApp._MessageDialog.ShowResult(boolResult, strResult); } catch (Exception ex) { MainApp._MessageDialog.ShowException(ex); } } //private void CreateTask2(string goods_property8) //{ // int i = 0;//记任务的数量 // bool boolResult = true; // bool boolSingleResult = true; // string strResult = string.Empty; // string sSingleReslut = string.Empty; // try // { // //获得选中记录 // listDataRowView = this.ucStorageGroup.U_GetCheckedDataRows(); // this.ucStorageGroup.U_EndCurrentEdit(); // //判断数据是否合法 // if (this.ucStorageGroup.U_DataSource.HasErrors) // { // MainApp._MessageDialog.Show(Enum.MessageConverter.Data); // return; // } // //根据数据源获得数据列表 // //校验是否选中记录 // if (listDataRowView.Length == 0) // { // MainApp._MessageDialog.Show(Enum.MessageConverter.SelectCount); // return; // } // if (MainApp._MessageDialog.ShowDialog(Enum.MessageConverter.ConfirmCreateTask, this.Title) == Sid.Windows.Controls.TaskDialogResult.Ok) // { // foreach (var drv in listDataRowView) // { // MainApp._I_BaseService.ExecuteNonQuery_ReturnVoid(string.Format(@"update STORAGE_LIST set GOODS_PROPERTY8='{0}' where STORAGE_LIST_ID={1}", goods_property8, drv["STORAGE_LIST_ID"].ToString())); // } // //刷新 // this.Refresh(); // } // //add by lhj 20200519 // string sRnum = string.Empty; // sRnum = string.Format("共计'{0}'个任务", i); // strResult = strResult + sRnum; // MainApp._MessageDialog.ShowResult(boolResult, strResult); // } // catch (Exception ex) // { // MainApp._MessageDialog.ShowException(ex); // } //} /// /// 获得托盘集合列表 /// private IDictionary GetPalletKeyValuePair(DataRowView[] listDataRowView) { IDictionary dicStack = new Dictionary(); foreach (DataRowView rowView in listDataRowView) { string stack = rowView["STOCK_BARCODE"].ToString(); if (stack != string.Empty) { //获得货位编号 SiaSun.LMS.Model.WH_CELL mWH_CELL = (Model.WH_CELL)MainApp._I_BaseService.GetModel("WH_CELL_SELECT_BY_ID", Convert.ToInt32(rowView["CELL_ID"])).RequestObject; if (mWH_CELL != null && !dicStack.ContainsKey(stack)) { dicStack.Add(stack, mWH_CELL); } } } return dicStack; } /// /// 刷新 /// private void Refresh() { this.ucStorageGroup.U_InitControl(); } } }