private bool AddNextSupply(string lineCode, string channelGroup, string channelType, int sortNo)
        {
            bool result = false;

            try
            {
                using (PersistentManager pm = new PersistentManager())
                {
                    StockOutBatchDao batchDao  = new StockOutBatchDao();
                    SupplyDao        supplyDao = new SupplyDao();
                    StockOutDao      outDao    = new StockOutDao();
                    batchDao.SetPersistentManager(pm);
                    supplyDao.SetPersistentManager(pm);
                    outDao.SetPersistentManager(pm);

                    DataTable supplyTable = supplyDao.FindNextSupply(lineCode, channelGroup, channelType, sortNo);

                    if (supplyTable.Rows.Count != 0)
                    {
                        Logger.Info(string.Format("收到补货请求,分拣线 '{0}',烟道组 '{1}',烟道类型 '{2}',流水号 '{3}'", lineCode, channelGroup, channelType, sortNo));
                        try
                        {
                            pm.BeginTransaction();

                            int batchNo = batchDao.FindMaxBatchNo() + 1;
                            batchDao.InsertBatch(batchNo, lineCode, channelGroup, channelType, sortNo, supplyTable.Rows.Count);

                            int outID = outDao.FindMaxOutID();
                            outDao.Insert(outID, supplyTable);

                            pm.Commit();
                            result = true;

                            Logger.Info("生成出库任务成功");
                        }
                        catch (Exception e)
                        {
                            Logger.Error("生成出库任务失败,原因:" + e.Message);
                            pm.Rollback();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error("生成出库任务失败,原因:" + e.Message);
            }

            return(result);
        }
Ejemplo n.º 2
0
        private bool AddFirstSupply()
        {
            bool result = false;

            try
            {
                using (PersistentManager pm = new PersistentManager())
                {
                    StockOutBatchDao batchDao  = new StockOutBatchDao();
                    SupplyDao        supplyDao = new SupplyDao();
                    StockOutDao      outDao    = new StockOutDao();
                    batchDao.SetPersistentManager(pm);
                    supplyDao.SetPersistentManager(pm);
                    outDao.SetPersistentManager(pm);

                    DataTable supplyTable = supplyDao.FindFirstSupply();

                    if (supplyTable.Rows.Count != 0)
                    {
                        try
                        {
                            pm.BeginTransaction();

                            int batchNo = batchDao.FindMaxBatchNo() + 1;
                            batchDao.InsertBatch(batchNo, "00", "0", "0", 0, supplyTable.Rows.Count);

                            int outID = outDao.FindMaxOutID();
                            outDao.Insert(outID, supplyTable);

                            pm.Commit();
                            result = true;

                            Logger.Info("生产第一批次出库任务成功");
                        }
                        catch (Exception e)
                        {
                            Logger.Error("生成第一批次出库任务失败,原因:" + e.Message);
                            pm.Rollback();
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                Logger.Error("生成第一批次出库任务失败,原因:" + ee.Message);
            }

            return(result);
        }