using System; using System.Windows; using System.Data; using SSWMS.Common; using System.Collections.Generic; namespace SSWMS.Client { public partial class PLAN_OUT_CELL : AvalonDock.DocumentContent { private int PlanID = 0; public PLAN_OUT_CELL(int iPlanID) { InitializeComponent(); this.PlanID = iPlanID; this.Title = $"立库出库-[{this.PlanID}]"; DocumentContent_Loaded(null, null); } private void DocumentContent_Loaded(object sender, RoutedEventArgs e) { try { this.cbEndDevice.ItemsSource = SystemCodeData.DicDataView["CELL_CODE_OUT"]; //if (this.cbEndDevice.Items.Count > 0) //{ // this.cbEndDevice.SelectedIndex = 0; //} this.dgStorageList.U_WindowName = "COMMON"; this.dgStorageList.U_XmlTableName = "V_STORAGE_LIST"; this.dgStorageList.U_TableName = "V_STORAGE_LIST_CELL_OUT"; this.dgStorageList.U_OrderField = "STORAGE_ID,STORAGE_LIST_ID"; //this.dgStorageList.U_TotalColumnName = "STORAGE_LIST_QUANTITY"; this.dgStorageList.U_Where = "1<>1"; this.dgStorageList.U_AllowOperatData = false; this.dgStorageList.U_AllowChecked = true; this.dgStorageList.U_InitControl(); this.dgPlan.U_WindowName = "COMMON"; this.dgPlan.U_XmlTableName = "V_PLAN_LIST"; this.dgPlan.U_TableName = "V_PLAN_LIST"; this.dgPlan.U_Where = $"PLAN_ID={this.PlanID}"; this.dgPlan.U_OrderField = "PLAN_LIST_ID"; this.dgPlan.U_AllowOperatData = false; this.dgPlan.U_SelectedChanged += () => { DataRowView drv = this.dgPlan.gridApp.SelectedItem as DataRowView; if (drv == null) { this.dgStorageList.U_Where = "1<>1"; } else { string sStorageProperty01 = drv["STORAGE_PROPERTY_01"].ToString(); string sStorageProperty02 = drv["STORAGE_PROPERTY_02"].ToString(); string sStorageProperty03 = drv["STORAGE_PROPERTY_03"].ToString(); string sStorageProperty04 = drv["STORAGE_PROPERTY_04"].ToString(); string sStorageProperty05 = drv["STORAGE_PROPERTY_05"].ToString(); string sStorageProperty06 = drv["STORAGE_PROPERTY_06"].ToString(); string sStorageProperty07 = drv["STORAGE_PROPERTY_07"].ToString(); string sStorageProperty08 = drv["STORAGE_PROPERTY_08"].ToString(); string sStorageProperty09 = drv["STORAGE_PROPERTY_09"].ToString(); string sStorageProperty10 = drv["STORAGE_PROPERTY_10"].ToString(); string sBoxBarcode = drv["BOX_BARCODE"].ToString(); string sGoodsBarcode = drv["GOODS_BARCODE"].ToString(); string sWhere = $"STORAGE_ID in (select STORAGE_ID from STORAGE_LIST where GOODS_ID={drv["GOODS_ID"]}"; if (!string.IsNullOrWhiteSpace(sStorageProperty01)) { sWhere += $" and STORAGE_PROPERTY_01='{sStorageProperty01}'"; } if (!string.IsNullOrWhiteSpace(sStorageProperty02)) { sWhere += $" and STORAGE_PROPERTY_02='{sStorageProperty02}'"; } if (!string.IsNullOrWhiteSpace(sStorageProperty03)) { sWhere += $" and STORAGE_PROPERTY_03='{sStorageProperty03}'"; } if (!string.IsNullOrWhiteSpace(sStorageProperty04)) { sWhere += $" and STORAGE_PROPERTY_04='{sStorageProperty04}'"; } if (!string.IsNullOrWhiteSpace(sStorageProperty05)) { sWhere += $" and STORAGE_PROPERTY_05='{sStorageProperty05}'"; } if (!string.IsNullOrWhiteSpace(sStorageProperty06)) { sWhere += $" and STORAGE_PROPERTY_06='{sStorageProperty06}'"; } if (!string.IsNullOrWhiteSpace(sStorageProperty07)) { sWhere += $" and STORAGE_PROPERTY_07='{sStorageProperty07}'"; } if (!string.IsNullOrWhiteSpace(sStorageProperty08)) { sWhere += $" and STORAGE_PROPERTY_08='{sStorageProperty08}'"; } if (!string.IsNullOrWhiteSpace(sStorageProperty09)) { sWhere += $" and STORAGE_PROPERTY_09='{sStorageProperty09}'"; } if (!string.IsNullOrWhiteSpace(sStorageProperty10)) { sWhere += $" and STORAGE_PROPERTY_10='{sStorageProperty10}'"; } if (!string.IsNullOrWhiteSpace(sBoxBarcode)) { sWhere += $" and BOX_BARCODE='{sBoxBarcode}'"; } if (!string.IsNullOrWhiteSpace(sGoodsBarcode)) { sWhere += $" and GOODS_BARCODE='{sGoodsBarcode}'"; } sWhere += ")"; this.dgStorageList.U_Where = sWhere; } this.dgStorageList.U_InitControl(); }; this.dgPlan.U_InitControl(); PLAN_MAIN pm = WCFChannel._I_PlanService.GetPlanMain(this.PlanID); if (pm == null) { MessageDialog.ShowException(string.Format("未找到计划 {0}", this.PlanID)); return; } else { this.cbPlanType.ItemsSource = SystemCodeData.DicDataView["PLAN_TYPE"]; this.cbPlanType.SelectedValue = pm.PLAN_TYPE; //if (pm.PLAN_TYPE == SystemCode.PLAN_TYPE.PlanIn) //{ // this.cbPlanStation.ItemsSource = SystemCodeData.DicDataView["CELL_CODE_IN"]; //} //else if (pm.PLAN_TYPE == SystemCode.PLAN_TYPE.PlanOut) //{ // this.cbPlanStation.ItemsSource = SystemCodeData.DicDataView["CELL_CODE_OUT"]; //} //this.cbPlanStation.SelectedValue = pm.PLAN_STATION; this.tbPlanStation.Text = pm.PLAN_STATION; this.tbPlanCode.Text = pm.PLAN_CODE; this.tbRemark.Text = pm.PLAN_REMARK; } } catch (Exception ex) { MessageDialog.ShowException(ex); } } private void bOutPlan_Click(object sender, RoutedEventArgs e) { try { if (this.cbEndDevice.SelectedIndex == -1) { MessageDialog.ShowException("请选择目标位置"); return; } DataRowView[] drvArray = this.dgStorageList.U_GetCheckDataRow(); if (drvArray.Length == 0) { MessageDialog.ShowException("请选择库存"); return; } if (MessageDialog.ShowDialog("确认执行计划出库")) { List lStockBarcode = new List(); foreach (DataRowView drv in drvArray) { string sStockBarcode = drv["STOCK_BARCODE"].ToString(); if (!string.IsNullOrWhiteSpace(sStockBarcode) && drv["FORK_TYPE"].ToString() != SystemCode.FORK_TYPE.CellFar && !lStockBarcode.Contains(sStockBarcode)) { lStockBarcode.Add(sStockBarcode); } } foreach (DataRowView drv in drvArray) { string sStockBarcode = drv["STOCK_BARCODE"].ToString(); if (!string.IsNullOrWhiteSpace(sStockBarcode) && drv["FORK_TYPE"].ToString() == SystemCode.FORK_TYPE.CellFar && !lStockBarcode.Contains(sStockBarcode)) { lStockBarcode.Add(sStockBarcode); } } string sResult = string.Empty; bool bResult = WCFChannel._I_ManageService.ManageOutCellMulti(lStockBarcode, this.cbEndDevice.SelectedValue as string, this.PlanID, SystemCode.MANAGE_TYPE.OutCell, MainApp._USER.USER_NAME, out sResult); if (bResult) { this.dgPlan.U_InitControl(true); } MessageDialog.ShowResult(bResult, sResult); } } catch (Exception ex) { MessageDialog.ShowException(ex); } } private void bRefresh_Click(object sender, RoutedEventArgs e) { this.dgPlan.U_InitControl(); } } }