private void toolStripMenuItem1_Click(object sender, EventArgs e) { Dictionary <string, object> dic = new Dictionary <string, object>(); DataTable dt = new DataTable(); string woid = string.Empty; try { SearchMaterialPickAssign sm = new SearchMaterialPickAssign(dic); sm.ExecuteQuery(); dt = sm.GetResult(); if (dt == null || dt.Rows.Count == 0) { ShowHint("无盘点任务需要暂停!", Color.Red); return; } woid = dt.Rows[0]["StockOutNo"].ToString(); } catch (Exception ex) { ShowHint("SearchMaterialPickAssign:" + ex.Message, Color.Red); return; } //暂停任务 if (MessageBox.Show("确认暂停日期:" + woid + " 的所有盘点任务?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes) { return; } try { StopPickTask sp = new StopPickTask(woid); sp.ExecuteQuery(); ShowHint("暂停盘点任务成功!", Color.Lime); } catch (Exception ex) { ShowHint("暂停盘点任务失败:" + ex.Message, Color.Red); return; } }
public static string GetImcompletePickNo(int stationId) { try { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("StationId", stationId); SearchMaterialPickAssign sp = new SearchMaterialPickAssign(dic); sp.ExecuteQuery(); DataTable dt = sp.GetResult(); if (dt == null || dt.Rows.Count == 0) { return(string.Empty); } return(dt.Rows[0]["StockOutNo"].ToString()); } catch (Exception ex) { throw ex; } }
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); } }