Esempio n. 1
0
        /// <summary>
        /// Load lookup for lot number by item and location code
        /// If these lot no has no onhand qty will be supressed.
        /// </summary>
        /// <param name="ItemCD"></param>
        /// <param name="LocationCD"></param>
        /// <returns></returns>
        public LookupData LoadLookupLotNo(NZString ItemCD, NZString LocationCD, NZString YearMonth)
        {
            InventoryOnhandDAO dao = new InventoryOnhandDAO(CommonLib.Common.CurrentDatabase);
            InventoryPeriodBIZ inventoryPeriodBIZ = new InventoryPeriodBIZ();
            InventoryPeriodDTO inventoryPeriodDTO = inventoryPeriodBIZ.LoadCurrentPeriod();

            List <InventoryOnhandDTO> listOnhand = dao.LoadLotNoWithHasOnhandQty(null, YearMonth, inventoryPeriodDTO.YEAR_MONTH, ItemCD, LocationCD);
            DataTable dt = DTOUtility.ConvertListToDataTable(listOnhand);

            LookupData lookupData = new LookupData(dt,
                                                   InventoryOnhandDTO.eColumns.LOT_NO.ToString(),
                                                   InventoryOnhandDTO.eColumns.LOT_NO.ToString());

            return(lookupData);
        }
Esempio n. 2
0
        public void RunStockTakingUpdateProcess(StockTakingDTO argStockTaking)
        {
            CommonLib.Common.CurrentDatabase.KeepConnection = true;
            CommonLib.Common.CurrentDatabase.BeginTransaction();

            try
            {
                argStockTaking.CRT_BY = CommonLib.Common.CurrentUserInfomation.UserCD;
                argStockTaking.CRT_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine;
                argStockTaking.UPD_BY = CommonLib.Common.CurrentUserInfomation.UserCD;
                argStockTaking.UPD_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine;

                StockTakingDAO dao = new StockTakingDAO(CommonLib.Common.CurrentDatabase);

                //load stock taking entry data and set flag as adjusted
                DataTable dtStockTakingEntry = dao.LoadStockTakingForUpdateProcess(argStockTaking);

                InventoryBIZ inventoryBIZ = new InventoryBIZ();

                InventoryPeriodBIZ bizPeriod = new InventoryPeriodBIZ();
                InventoryPeriodDTO dtoPeriod = bizPeriod.LoadCurrentPeriod();

                DateTime dtmCurrentDate = Common.GetDatabaseDateTime().Date;

                DateTime dtmAdjustDate = dtmCurrentDate;

                if (dtmCurrentDate < dtoPeriod.PERIOD_BEGIN_DATE.StrongValue)
                {
                    dtmAdjustDate = dtoPeriod.PERIOD_BEGIN_DATE.StrongValue;
                }
                else
                {
                    if (dtmCurrentDate > dtoPeriod.PERIOD_END_DATE.StrongValue)
                    {
                        dtmAdjustDate = dtoPeriod.PERIOD_END_DATE.StrongValue;
                    }
                    else
                    {
                        dtmAdjustDate = dtmCurrentDate;
                    }
                }

                //adjust inventory
                foreach (DataRow dr in dtStockTakingEntry.Rows)
                {
                    InventoryTransactionDTO invTrans = ConvertToInventoryTransactionDTO(argStockTaking.STOCK_TAKING_DATE, dtmAdjustDate, dr);

                    inventoryBIZ.AddInventoryTransaction(CommonLib.Common.CurrentDatabase, invTrans, true);
                }

                CommonLib.Common.CurrentDatabase.Commit();
            }
            catch (Exception ex)
            {
                CommonLib.Common.CurrentDatabase.Rollback();

                throw ex;
            }
            finally
            {
                CommonLib.Common.CurrentDatabase.KeepConnection = false;
            }
        }