private bool UpdateStockCountShelfCnt(int id, int stationId) { try { SearchTaskCount st = new SearchTaskCount(id, stationId); st.ExecuteQuery(); int result = st.GetResult(); //if (this.IsHandleCreated) //{ // this.Invoke(new EventHandler(delegate // { label_pd_ShelfCnt.Text = result.ToString(); // })); //} if (result == 0) { findStockCount = true; //停止查找货架 button_stockcount.Text = "开始盘点"; ShowHint("该站点所有的盘点任务已经完成!", Color.Lime); } return(true); } catch (Exception ex) { ShowHint("UpdateShelfCount: " + ex.Message, Color.Red); return(false); } }
private int GetTaskCnt(string stationId) { try { SearchTaskCount st = new SearchTaskCount(2, int.Parse(stationId)); st.ExecuteQuery(); return(st.GetResult()); } catch (Exception ex) { MessageBox.Show("GetTaskCnt:" + ex.Message); return(-1); } }
private bool UpdateShelfCount(int id, int stationId) { try { SearchTaskCount st = new SearchTaskCount(id, stationId); st.ExecuteQuery(); int result = st.GetResult(); ShowShelfCount(result); return(true); } catch (Exception ex) { ShowHint("UpdateShelfCount: " + ex.Message, Color.Red); return(false); } }
private bool CreateStockCountTask() { Dictionary <string, object> dic = new Dictionary <string, object>(); DataTable dt = new DataTable(); string date = string.Format("{0:D4}{1:D2}{2:D2}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);; string plant = ""; string stock_id = ""; //string woid = ""; int qty = 0; try { SearchMaterialPickAssign sm = new SearchMaterialPickAssign(dic); sm.ExecuteQuery(); dt = sm.GetResult(); if (dt != null && dt.Rows.Count > 0) { date = dt.Rows[0]["StockOutNo"].ToString().Trim(); qty = int.Parse(dt.Rows[0]["Qty"].ToString().Trim()); if (qty != -1) { ShowHint("请先完成单号:" + woid + " 的出库任务", Color.Red); return(false); } } if (qty == -1) //存在盘点任务 { dic.Clear(); dic.Add("check_date", date); dic.Add("status", "0"); SearchInventoryCheckByMaterialNo sc = new SearchInventoryCheckByMaterialNo(dic); sc.ExecuteQuery(); dt = sc.GetResult(); if (dt != null && dt.Rows.Count > 0) { plant = dt.Rows[0]["Plant"].ToString(); stock_id = dt.Rows[0]["Stock_Id"].ToString(); string kpno = dt.Rows[0]["KpNo"].ToString(); if (kpno.Trim().Equals("*")) { ShowHint("请先完成:" + date + " 的全部盘点任务!", Color.Red); comboBox_pd.SelectedIndex = 1; } else { ShowHint("请先完成:" + date + " 的料号盘点任务!", Color.Red); comboBox_pd.SelectedIndex = 2; } } else { ShowHint("请先完成:" + date + " 的储位盘点任务!", Color.Red); comboBox_pd.SelectedIndex = 3; } return(true); } if (comboBox_pd.SelectedIndex == 0) { ShowHint("请选择一个盘点类型!", Color.Red); comboBox_pd.Focus(); return(false); } else if (comboBox_pd.SelectedIndex == 1) //全部盘点 { using (SetStockDate ss = new SetStockDate()) { if (ss.ShowDialog() != DialogResult.OK) { return(false); } date = ss.GetDate(); plant = ss.GetPlant(); stock_id = ss.GetStockId(); } } else if (comboBox_pd.SelectedIndex == 2)//料号盘点,导入数据 { using (ImportKpNoData ic = new ImportKpNoData()) { if (ic.ShowDialog() != DialogResult.OK) { return(false); } date = ic.GetWoId(); plant = ic.GetPlant(); stock_id = ic.GetStockId(); } //查询导入数据是否需要盘点,status=0 try { dic.Clear(); dic.Add("check_date", date); dic.Add("plant", plant); dic.Add("stock_id", stock_id); dic.Add("status", "0"); SearchInventoryCheckByMaterialNo sc = new SearchInventoryCheckByMaterialNo(dic); sc.ExecuteQuery(); dt = sc.GetResult(); if (dt == null || dt.Rows.Count == 0) { ShowHint("无料号需要盘点", Color.Red); return(false); } } catch (Exception ex) { ShowHint("SearchInventoryCheckByMaterialNo:" + ex.Message, Color.Red); return(false); } } else if (comboBox_pd.SelectedIndex == 3) { using (ImportLocIdData ic = new ImportLocIdData()) { if (ic.ShowDialog() != DialogResult.OK) { return(false); } date = ic.GetWoId(); plant = ic.GetPlant(); stock_id = ic.GetStockId(); } //查询导入数据是否需要盘点,status=0 try { dic.Clear(); dic.Add("check_date", date); dic.Add("plant", plant); dic.Add("stock_id", stock_id); dic.Add("status", "0"); SearchInventoryCheckByLocId sc = new SearchInventoryCheckByLocId(dic); sc.ExecuteQuery(); dt = sc.GetResult(); if (dt == null || dt.Rows.Count == 0) { ShowHint("无料号需要盘点", Color.Red); return(false); } } catch (Exception ex) { ShowHint("SearchInventoryCheckByLocId:" + ex.Message, Color.Red); return(false); } } //生成盘点任务 string result = DBPCaller.CreateCheckTask(date, comboBox_pd.SelectedIndex - 1); if (!result.ToUpper().Trim().Equals("OK")) { AddLog("生成任务失败:" + result); ShowHint("生成盘点任务失败:" + result, Color.Red); return(false); } AddLog("盘点日期:" + date); } catch (Exception ex) { ShowHint(ex.Message, Color.Red); return(false); } try { SearchTaskCount st = new SearchTaskCount(2, MyData.GetStationId()); st.ExecuteQuery(); int result = st.GetResult(); label_pd_ShelfCnt.Text = result.ToString(); if (result > 0) { AddLog("生成盘点任务成功!"); ShowHint("生成盘点任务成功!", Color.Lime); return(true); } else { AddLog("生成任务失败,不需要搬运货架!"); ShowHint("生成任务失败,不需要搬运货架!", Color.Red); return(false); } } catch (Exception ex) { ShowHint("获取货架数目异常: " + ex.Message, Color.Red); return(false); } }