Esempio n. 1
0
        private void EnableLotControl()
        {
            //Clear Lot
            CtrlUtil.ClearControlData(txtPackNo, txtLotNo, txtCustomerLotNo, txtFGNo);

            if (cboStoredLoc.SelectedIndex < 0)
            {
                return;
            }

            //----- Enable Customer Lot No ------//
            DealingConstraintDTO constriant = null;

            string strProcess = cboStoredLoc.SelectedValue.ToString();

            constriant = bizConstraint.LoadDealingConstraint(strProcess.ToNZString());

            if (constriant != null && constriant.ENABLE_LOT_FLAG.StrongValue == 1)
            {
                CtrlUtil.EnabledControl(rdoIncrease.Checked, txtLotNo, txtCustomerLotNo, txtFGNo);
                CtrlUtil.EnabledControl(true, btnLotNo);
            }
            else
            {
                CtrlUtil.EnabledControl(false, txtLotNo, btnLotNo, txtCustomerLotNo, txtFGNo);
            }
        }
Esempio n. 2
0
        private void ValidateBeforeSave()
        {
            AdjustmentValidator  adjustmentValidator = new AdjustmentValidator();
            ItemValidator        itemValidator       = new ItemValidator();
            DealingValidator     locationValidator   = new DealingValidator();
            TransactionValidator valTran             = new TransactionValidator();
            CommonBizValidator   commonVal           = new CommonBizValidator();

            ValidateException.ThrowErrorItem(adjustmentValidator.CheckEmptyAdjustDate(new NZDateTime(dtAdjustDate, dtAdjustDate.Value)));
            ValidateException.ThrowErrorItem(adjustmentValidator.CheckEmptyReasonCode(new NZString(cboReasonCode, cboReasonCode.SelectedValue)));
            ValidateException.ThrowErrorItem(valTran.DateIsInCurrentPeriod(new NZDateTime(dtAdjustDate, dtAdjustDate.Value)));
            ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(new NZString(txtMasterNo, txtMasterNo.Text.Trim())));
            ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(new NZString(cboStoredLoc, cboStoredLoc.SelectedValue)));

            if (cboStoredLoc.SelectedValue == null)
            {
                return;
            }

            string strProcess = cboStoredLoc.SelectedValue.ToString();
            DealingConstraintDTO constriant = bizConstraint.LoadDealingConstraint(strProcess.ToNZString());

            AdjustmentValidator validator = new AdjustmentValidator();
            ErrorItem           errorItem = null;

            //if (constriant != null && constriant.ENABLE_PACK_FLAG.StrongValue == 1)
            //{
            //    errorItem = validator.CheckEmptyPackNo(txtPackNo.ToNZString());
            //    if (null != errorItem)
            //        ValidateException.ThrowErrorItem(errorItem);//error.AddError(errorItem);
            //}

            if (rdoDecrease.Checked && constriant != null && constriant.ENABLE_PACK_FLAG.StrongValue == 1)
            {
                errorItem = validator.CheckEmptyPackNo(txtPackNo.ToNZString());
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }
            }

            if (constriant != null && constriant.ENABLE_LOT_FLAG.StrongValue == 1)
            {
                errorItem = validator.CheckEmptyLotNo(txtLotNo.ToNZString());
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);//error.AddError(errorItem);
                }
                FormatUtil.CheckFormatLotNo(new NZString(txtLotNo, txtLotNo.Text.Trim()));

                //errorItem = validator.CheckEmptyCustomerLotNo(txtCustomerLotNo.ToNZString());
                //if (null != errorItem)
                //    ValidateException.ThrowErrorItem(errorItem);//error.AddError(errorItem);
            }

            ValidateException.ThrowErrorItem(adjustmentValidator.CheckEmptyAdjustQty(new NZDecimal(txtAdjustQty, txtAdjustQty.Decimal)));
            ValidateException.ThrowErrorItem(adjustmentValidator.CheckIsZeroAdjustQty(new NZDecimal(txtAdjustQty, txtAdjustQty.Decimal)));
        }
Esempio n. 3
0
        /// <summary>
        /// Check exist before manipulate data. If found record will update data. Otherwise insert new data.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public int AddNewOrUpdate(Database database, DealingConstraintDTO data)
        {
            Database db = UseDatabase(database);

            if (Exist(database, data.LOC_CD))
            {
                return(UpdateWithoutPK(db, data));
            }

            return(AddNew(db, data));
        }
Esempio n. 4
0
        /// <summary>
        /// Insert new record into database.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public int AddNew(Database database, DealingConstraintDTO data)
        {
            Database db = UseDatabase(database);

            StringBuilder sb = new StringBuilder();

            #region SQL Statement
            sb.AppendLine(" INSERT INTO " + data.TableName + "(");
            sb.AppendLine("  " + DealingConstraintDTO.eColumns.LOC_CD);
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.NO_CONSUMPTION_FLAG);
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.COMPONENT_ITEM_USAGE);
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.ENABLE_SUPPLIER_FLAG);
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.ENABLE_LOT_FLAG);
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.ENABLE_PACK_FLAG);
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.ENABLE_CUST_LOT_FLAG);
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.NO_MOVE_FLAG);
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.NO_PRODUCTION_REPORT_FLAG);
            sb.AppendLine(") VALUES(");
            sb.AppendLine("   @LOC_CD");
            sb.AppendLine("   ,@NO_CONSUMPTION_FLAG");
            sb.AppendLine("   ,@COMPONENT_ITEM_USAGE");
            sb.AppendLine("   ,@ENABLE_SUPPLIER_FLAG");
            sb.AppendLine("   ,@ENABLE_LOT_FLAG");
            sb.AppendLine("   ,@ENABLE_PACK_FLAG");
            sb.AppendLine("   ,@ENABLE_CUST_LOT_FLAG");
            sb.AppendLine("   ,@NO_MOVE_FLAG");
            sb.AppendLine("   ,@NO_PRODUCTION_REPORT_FLAG");
            sb.AppendLine(" )");
            #endregion

            DataRequest req = new DataRequest(sb.ToString());
            #region Parameters
            req.Parameters.Add("@LOC_CD", DataType.NVarChar, data.LOC_CD.Value);
            req.Parameters.Add("@NO_CONSUMPTION_FLAG", DataType.Default, data.NO_CONSUMPTION_FLAG.Value);
            req.Parameters.Add("@COMPONENT_ITEM_USAGE", DataType.Default, data.COMPONENT_ITEM_USAGE.Value);
            req.Parameters.Add("@ENABLE_SUPPLIER_FLAG", DataType.Default, data.ENABLE_SUPPLIER_FLAG.Value);
            req.Parameters.Add("@ENABLE_LOT_FLAG", DataType.Default, data.ENABLE_LOT_FLAG.Value);
            req.Parameters.Add("@ENABLE_PACK_FLAG", DataType.Default, data.ENABLE_PACK_FLAG.Value);
            req.Parameters.Add("@ENABLE_CUST_LOT_FLAG", DataType.Default, data.ENABLE_CUST_LOT_FLAG.Value);
            req.Parameters.Add("@NO_MOVE_FLAG", DataType.Default, data.NO_MOVE_FLAG.Value);
            req.Parameters.Add("@NO_PRODUCTION_REPORT_FLAG", DataType.Default, data.NO_PRODUCTION_REPORT_FLAG.Value);
            #endregion

            return(db.ExecuteNonQuery(req));
        }
Esempio n. 5
0
        /// <summary>
        /// Update record by using the table's primary key.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="data">Data which to update.</param>
        /// <param name="oldLOC_CD">Old Key #1</param>
        /// <returns></returns>
        public int UpdateWithPK(Database database, DealingConstraintDTO data, String oldLOC_CD)
        {
            Database db = UseDatabase(database);

            StringBuilder sb = new StringBuilder();

            #region SQL Statement
            sb.AppendLine(" UPDATE " + data.TableName);
            sb.AppendLine(" SET ");
            sb.AppendLine("  " + DealingConstraintDTO.eColumns.LOC_CD + "=@LOC_CD");
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.NO_CONSUMPTION_FLAG + "=@NO_CONSUMPTION_FLAG");
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.COMPONENT_ITEM_USAGE + "=@COMPONENT_ITEM_USAGE");
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.ENABLE_SUPPLIER_FLAG + "=@ENABLE_SUPPLIER_FLAG");
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.ENABLE_LOT_FLAG + "=@ENABLE_LOT_FLAG");
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.ENABLE_PACK_FLAG + "=@ENABLE_PACK_FLAG");
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.ENABLE_CUST_LOT_FLAG + "=@ENABLE_CUST_LOT_FLAG");
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.NO_MOVE_FLAG + "=@NO_MOVE_FLAG");
            sb.AppendLine("  ," + DealingConstraintDTO.eColumns.NO_PRODUCTION_REPORT_FLAG + "=@NO_PRODUCTION_REPORT_FLAG");
            sb.AppendLine(" WHERE ");
            sb.AppendLine("  " + DealingConstraintDTO.eColumns.LOC_CD + "=@oldLOC_CD");
            #endregion

            DataRequest req = new DataRequest(sb.ToString());
            #region Parameters
            req.Parameters.Add("@LOC_CD", DataType.NVarChar, data.LOC_CD.Value);
            req.Parameters.Add("@NO_CONSUMPTION_FLAG", DataType.Default, data.NO_CONSUMPTION_FLAG.Value);
            req.Parameters.Add("@COMPONENT_ITEM_USAGE", DataType.Default, data.COMPONENT_ITEM_USAGE.Value);
            req.Parameters.Add("@ENABLE_SUPPLIER_FLAG", DataType.Default, data.ENABLE_SUPPLIER_FLAG.Value);
            req.Parameters.Add("@ENABLE_LOT_FLAG", DataType.Default, data.ENABLE_LOT_FLAG.Value);
            req.Parameters.Add("@ENABLE_PACK_FLAG", DataType.Default, data.ENABLE_PACK_FLAG.Value);
            req.Parameters.Add("@ENABLE_CUST_LOT_FLAG", DataType.Default, data.ENABLE_CUST_LOT_FLAG.Value);
            req.Parameters.Add("@NO_MOVE_FLAG", DataType.Default, data.NO_MOVE_FLAG.Value);
            req.Parameters.Add("@NO_PRODUCTION_REPORT_FLAG", DataType.Default, data.NO_PRODUCTION_REPORT_FLAG.Value);
            req.Parameters.Add("@oldLOC_CD", DataType.NVarChar, oldLOC_CD);
            #endregion

            return(db.ExecuteNonQuery(req));
        }
Esempio n. 6
0
        public void SaveNewProductionReport(ProductionReportEntryUIDM data)
        {
            try
            {
                ItemValidator itemValidator = new ItemValidator();
                ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(data.MASTER_NO));

                BusinessException businessException = itemValidator.CheckItemNotExist(data.MASTER_NO);
                if (businessException != null)
                {
                    ValidateException.ThrowErrorItem(businessException.Error);
                }

                InventoryBIZ         bizInv        = new InventoryBIZ();
                DealingConstraintBIZ bizConstraint = new DealingConstraintBIZ();
                DealingConstraintDTO constriant    = bizConstraint.LoadDealingConstraint(data.PROCESS);

                InventoryTransactionDTO dtoInvMainTransIn  = new InventoryTransactionDTO();
                InventoryTransactionDTO dtoInvMainTransOut = null;

                #region Main Transaction : for good qty
                dtoInvMainTransIn.CRT_BY = Common.CurrentUserInfomation.UserCD;
                //dtoInvMainTransIn.CRT_DATE =
                dtoInvMainTransIn.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                dtoInvMainTransIn.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                //dtoInvMainTransIn.UPD_DATE =
                dtoInvMainTransIn.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                //dtoInvMainTransIn.TRANS_ID =
                dtoInvMainTransIn.ITEM_CD = data.MASTER_NO;
                dtoInvMainTransIn.LOC_CD  = data.PROCESS;
                //dtoInvMainTransIn.LOT_NO =
                //dtoInvMainTransIn.PACK_NO =
                dtoInvMainTransIn.EXTERNAL_LOT_NO = data.CUST_LOT_NO;
                dtoInvMainTransIn.TRANS_DATE      = data.PRODUCTION_REPORT_DATE;
                dtoInvMainTransIn.TRANS_CLS       = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.WorkResult).ToNZString();
                dtoInvMainTransIn.IN_OUT_CLS      = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In).ToNZString();
                dtoInvMainTransIn.QTY             = data.QTY;
                dtoInvMainTransIn.WEIGHT          = data.WEIGHT;
                //dtoInvMainTransIn.OBJ_ITEM_CD =
                //dtoInvMainTransIn.OBJ_ORDER_QTY =
                //dtoInvMainTransIn.REF_NO =
                //dtoInvMainTransIn.REF_SLIP_NO =
                //dtoInvMainTransIn.REF_SLIP_CLS =
                //dtoInvMainTransIn.OTHER_DL_NO =
                //dtoInvMainTransIn.SLIP_NO =
                dtoInvMainTransIn.REMARK     = data.REMARK;
                dtoInvMainTransIn.DEALING_NO = data.SUPPLIER;
                //dtoInvMainTransIn.PRICE =
                //dtoInvMainTransIn.AMOUNT =
                //dtoInvMainTransIn.FOR_CUSTOMER =
                dtoInvMainTransIn.FOR_MACHINE = data.MACHINE_NO;
                dtoInvMainTransIn.SHIFT_CLS   = data.SHIFT;
                //dtoInvMainTransIn.REF_SLIP_NO2 =
                dtoInvMainTransIn.NG_QTY = data.NG_QTY;
                //dtoInvMainTransIn.NG_WEIGHT =
                //dtoInvMainTransIn.TRAN_SUB_CLS = new NZString(null, data.REWORK.StrongValue);
                dtoInvMainTransIn.TRAN_SUB_CLS = Convert.ToInt32(data.REWORK.StrongValue) == (int)DataDefine.eTRAN_SUB_CLS.RW ?
                                                 new NZString(null, DataDefine.eTRAN_SUB_CLS.RW.ToString()) :
                                                 new NZString(null, DataDefine.eTRAN_SUB_CLS.WR.ToString());
                dtoInvMainTransIn.REWORK_FLAG = new NZInt(data.REWORK.Owner, Convert.ToInt32(data.REWORK));//(data.REWORK.NVL("WR") == DataDefine.eTRAN_SUB_CLS.RW.ToString() ? 1 : 0).ToNZInt();

                dtoInvMainTransIn.SCREEN_TYPE = DataDefine.ScreenType.WorkResultEntry.ToNZString();
                //dtoInvMainTransIn.GROUP_TRANS_ID =
                //dtoInvMainTransIn.RESERVE_QTY =
                //dtoInvMainTransIn.NG_REASON =
                dtoInvMainTransIn.EFFECT_STOCK     = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.In);
                dtoInvMainTransIn.LOT_REMARK       = data.LOT_NO;
                dtoInvMainTransIn.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                //dtoInvMainTransIn.CURRENCY =
                dtoInvMainTransIn.OLD_DATA = new NZInt(null, 0);

                #endregion

                if (constriant == null || constriant.NO_CONSUMPTION_FLAG.StrongValue == 0)
                {
                    dtoInvMainTransOut = new InventoryTransactionDTO();

                    #region Main Transaction for used qty(qty + ng)
                    dtoInvMainTransOut.CRT_BY = Common.CurrentUserInfomation.UserCD;
                    //dtoInvMainTransOut.CRT_DATE =
                    dtoInvMainTransOut.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                    dtoInvMainTransOut.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                    //dtoInvMainTransOut.UPD_DATE =
                    dtoInvMainTransOut.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                    //dtoInvMainTransOut.TRANS_ID =
                    dtoInvMainTransOut.ITEM_CD = data.MASTER_NO;
                    dtoInvMainTransOut.LOC_CD  = data.PROCESS;
                    //dtoInvMainTransOut.LOT_NO =
                    //dtoInvMainTransOut.PACK_NO =
                    dtoInvMainTransOut.EXTERNAL_LOT_NO = data.CUST_LOT_NO;
                    dtoInvMainTransOut.TRANS_DATE      = data.PRODUCTION_REPORT_DATE;
                    dtoInvMainTransOut.TRANS_CLS       = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Consumption).ToNZString();
                    dtoInvMainTransOut.IN_OUT_CLS      = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out).ToNZString();
                    dtoInvMainTransOut.QTY             = new NZDecimal(null, data.QTY.StrongValue + data.NG_QTY.StrongValue);
                    dtoInvMainTransOut.WEIGHT          = data.WEIGHT;
                    //dtoInvMainTransOut.OBJ_ITEM_CD =
                    //dtoInvMainTransOut.OBJ_ORDER_QTY =
                    //dtoInvMainTransOut.REF_NO =
                    //dtoInvMainTransOut.REF_SLIP_NO =
                    //dtoInvMainTransOut.REF_SLIP_CLS =
                    //dtoInvMainTransOut.OTHER_DL_NO =
                    //dtoInvMainTransOut.SLIP_NO =
                    dtoInvMainTransOut.REMARK     = data.REMARK;
                    dtoInvMainTransOut.DEALING_NO = data.SUPPLIER;
                    //dtoInvMainTransOut.PRICE =
                    //dtoInvMainTransOut.AMOUNT =
                    //dtoInvMainTransOut.FOR_CUSTOMER =
                    dtoInvMainTransOut.FOR_MACHINE = data.MACHINE_NO;
                    dtoInvMainTransOut.SHIFT_CLS   = data.SHIFT;
                    //dtoInvMainTransOut.REF_SLIP_NO2 =
                    //dtoInvMainTransOut.NG_QTY = data.NG_QTY;
                    //dtoInvMainTransOut.NG_WEIGHT =
                    //dtoInvMainTransOut.TRAN_SUB_CLS = new NZString(null, DataDefine.eTRAN_SUB_CLS.WR.ToString());
                    dtoInvMainTransOut.SCREEN_TYPE = DataDefine.ScreenType.WorkResultEntry.ToNZString();
                    //dtoInvMainTransOut.GROUP_TRANS_ID =
                    //dtoInvMainTransOut.RESERVE_QTY =
                    //dtoInvMainTransOut.NG_REASON =
                    dtoInvMainTransOut.EFFECT_STOCK     = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.Out);
                    dtoInvMainTransOut.LOT_REMARK       = data.LOT_NO;
                    dtoInvMainTransOut.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                    //dtoInvMainTransOut.CURRENCY =
                    dtoInvMainTransOut.OLD_DATA = new NZInt(null, 0);

                    #endregion
                }

                #region NG Transaction

                List <InventoryTransactionDTO> listNG = new List <InventoryTransactionDTO>();

                DataTable dtData = data.DataView;
                foreach (DataRow dr in dtData.Rows)
                {
                    InventoryTransactionDTO dtoNG = new InventoryTransactionDTO();
                    dtoNG.CRT_BY = Common.CurrentUserInfomation.UserCD;
                    //dtoNG.CRT_DATE =
                    dtoNG.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                    dtoNG.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                    //dtoNG.UPD_DATE =
                    dtoNG.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                    //dtoNG.TRANS_ID =
                    dtoNG.ITEM_CD = data.MASTER_NO;
                    dtoNG.LOC_CD  = data.PROCESS;
                    //dtoNG.LOT_NO =
                    //dtoNG.PACK_NO =
                    dtoNG.EXTERNAL_LOT_NO = data.CUST_LOT_NO;
                    dtoNG.TRANS_DATE      = data.PRODUCTION_REPORT_DATE;
                    dtoNG.TRANS_CLS       = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.NGWorkResult).ToNZString();
                    dtoNG.IN_OUT_CLS      = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.None).ToNZString();
                    if (dr[(int)ProductionReportEntryViewDTO.eColumns.NG_QTY] == null || dr[(int)ProductionReportEntryViewDTO.eColumns.NG_QTY] == (object)DBNull.Value)
                    {
                        dtoNG.QTY    = new NZDecimal(null, 0);
                        dtoNG.NG_QTY = new NZDecimal(null, 0);
                    }
                    else
                    {
                        dtoNG.QTY    = new NZDecimal(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_QTY]);
                        dtoNG.NG_QTY = new NZDecimal(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_QTY]);
                    }
                    dtoNG.WEIGHT = new NZDecimal(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_WEIGHT]);
                    //dtoNG.OBJ_ITEM_CD =
                    //dtoNG.OBJ_ORDER_QTY =
                    //dtoNG.REF_NO =
                    //dtoNG.REF_SLIP_NO =
                    //dtoNG.REF_SLIP_CLS =
                    //dtoNG.OTHER_DL_NO =
                    //dtoNG.SLIP_NO =
                    dtoNG.REMARK     = data.REMARK;
                    dtoNG.DEALING_NO = data.SUPPLIER;
                    //dtoNG.PRICE =
                    //dtoNG.AMOUNT =
                    //dtoNG.FOR_CUSTOMER =
                    dtoNG.FOR_MACHINE = data.MACHINE_NO;
                    dtoNG.SHIFT_CLS   = data.SHIFT;
                    //dtoNG.REF_SLIP_NO2 =
                    //dtoNG.NG_QTY = new NZDecimal(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_QTY]);
                    dtoNG.NG_WEIGHT    = new NZDecimal(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_WEIGHT]);
                    dtoNG.TRAN_SUB_CLS = new NZString(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_CRITERIA_CD]);
                    dtoNG.SCREEN_TYPE  = DataDefine.ScreenType.WorkResultEntry.ToNZString();
                    //dtoNG.GROUP_TRANS_ID =
                    //dtoNG.RESERVE_QTY =
                    //dtoNG.NG_REASON =
                    dtoNG.EFFECT_STOCK     = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.None);
                    dtoNG.LOT_REMARK       = data.LOT_NO;
                    dtoNG.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                    //dtoNG.CURRENCY =
                    dtoNG.OLD_DATA = new NZInt(null, 0);

                    //save only qty > 0
                    if (dtoNG.QTY > 0)
                    {
                        listNG.Add(dtoNG);
                    }
                }

                #endregion

                bizInv.AddProductionReport(dtoInvMainTransIn, dtoInvMainTransOut, listNG);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 7
0
        internal void SaveNewMovePart(MovePartUIDM model)
        {
            #region Validate
            ItemValidator itemValidator = new ItemValidator();

            BusinessException businessException = itemValidator.CheckItemNotExist(model.MASTER_NO);
            if (businessException != null)
            {
                ValidateException.ThrowErrorItem(businessException.Error);
            }
            #endregion

            InventoryBIZ         bizInv        = new InventoryBIZ();
            DealingConstraintBIZ bizConstraint = new DealingConstraintBIZ();

            InventoryTransactionDTO dtoInvTrnsFrom = new InventoryTransactionDTO();
            InventoryTransactionDTO dtoInvTrnsTo   = new InventoryTransactionDTO();

            #region From
            dtoInvTrnsFrom.CRT_BY      = CommonLib.Common.CurrentUserInfomation.UserCD;
            dtoInvTrnsFrom.CRT_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine;
            dtoInvTrnsFrom.UPD_BY      = CommonLib.Common.CurrentUserInfomation.UserCD;
            dtoInvTrnsFrom.UPD_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine;
            //dtoInvTrnsListFrom.TRANS_ID =
            dtoInvTrnsFrom.ITEM_CD = model.MASTER_NO;
            dtoInvTrnsFrom.LOC_CD  = model.FROM_PROCESS;
            //dtoInvTrnsFrom.LOT_NO = model.LOT_NO;
            //dtoInvTrnsListFrom.PACK_NO = string.Empty;
            dtoInvTrnsFrom.TRANS_DATE = model.MOVE_DATE;
            dtoInvTrnsFrom.TRANS_CLS  = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.MovePart).ToNZString();
            dtoInvTrnsFrom.IN_OUT_CLS = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out).ToNZString();
            dtoInvTrnsFrom.QTY        = model.MOVE_QTY;
            //dtoInvTrnsListFrom.OBJ_ITEM_CD =
            //dtoInvTrnsListFrom.OBJ_ORDER_QTY =
            //dtoInvTrnsListFrom.REF_NO =
            //dtoInvTrnsListFrom.REF_SLIP_NO =
            //dtoInvTrnsListFrom.REF_SLIP_CLS =
            //dtoInvTrnsListFrom.OTHER_DL_NO =
            //dtoInvTrnsListFrom.SLIP_NO =
            dtoInvTrnsFrom.REMARK = model.REMARK;
            //dtoInvTrnsListFrom.DEALING_NO =
            //dtoInvTrnsListFrom.EXTERNAL_LOT_NO =
            //dtoInvTrnsListFrom.PRICE =
            //dtoInvTrnsListFrom.FOR_CUSTOMER =
            //dtoInvTrnsListFrom.FOR_MACHINE =
            dtoInvTrnsFrom.SHIFT_CLS = model.SHIFT_CLS;
            //dtoInvTrnsListFrom.REF_SLIP_NO2 =
            //dtoInvTrnsListFrom.NG_QTY =
            dtoInvTrnsFrom.TRAN_SUB_CLS = model.REASON;
            dtoInvTrnsFrom.SCREEN_TYPE  = DataDefine.ScreenType.MovePartEntry.ToNZString();
            //dtoInvTrnsListFrom.GROUP_TRANS_ID =
            //dtoInvTrnsListFrom.RESERVE_QTY =
            //dtoInvTrnsListFrom.NG_REASON =
            dtoInvTrnsFrom.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.Out);
            dtoInvTrnsFrom.LOT_REMARK   = model.LOT_NO;
            dtoInvTrnsFrom.OLD_DATA     = new NZInt(null, 0);
            dtoInvTrnsFrom.WEIGHT       = model.WEIGHT;

            #endregion

            #region To

            dtoInvTrnsTo.CRT_BY      = CommonLib.Common.CurrentUserInfomation.UserCD;
            dtoInvTrnsTo.CRT_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine;
            dtoInvTrnsTo.UPD_BY      = CommonLib.Common.CurrentUserInfomation.UserCD;
            dtoInvTrnsTo.UPD_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine;
            //dtoInvTrnsListFrom.TRANS_ID =
            dtoInvTrnsTo.ITEM_CD = model.MASTER_NO;
            dtoInvTrnsTo.LOC_CD  = model.TO_PROCESS;
            //dtoInvTrnsTo.LOT_NO = model.LOT_NO;
            //dtoInvTrnsListFrom.PACK_NO = string.Empty;
            dtoInvTrnsTo.TRANS_DATE = model.MOVE_DATE;
            dtoInvTrnsTo.TRANS_CLS  = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.MovePart).ToNZString();
            dtoInvTrnsTo.IN_OUT_CLS = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In).ToNZString();
            dtoInvTrnsTo.QTY        = model.MOVE_QTY;
            //dtoInvTrnsListFrom.OBJ_ITEM_CD =
            //dtoInvTrnsListFrom.OBJ_ORDER_QTY =
            //dtoInvTrnsListFrom.REF_NO =
            //dtoInvTrnsListFrom.REF_SLIP_NO =
            //dtoInvTrnsListFrom.REF_SLIP_CLS =
            //dtoInvTrnsListFrom.OTHER_DL_NO =
            //dtoInvTrnsListFrom.SLIP_NO =
            dtoInvTrnsTo.REMARK = model.REMARK;
            //dtoInvTrnsListFrom.DEALING_NO =
            //dtoInvTrnsListFrom.EXTERNAL_LOT_NO =
            //dtoInvTrnsListFrom.PRICE =
            //dtoInvTrnsListFrom.FOR_CUSTOMER =
            //dtoInvTrnsListFrom.FOR_MACHINE =
            dtoInvTrnsTo.SHIFT_CLS = model.SHIFT_CLS;
            //dtoInvTrnsListFrom.REF_SLIP_NO2 =
            //dtoInvTrnsListFrom.NG_QTY =
            dtoInvTrnsTo.TRAN_SUB_CLS = model.REASON;
            dtoInvTrnsTo.SCREEN_TYPE  = DataDefine.ScreenType.MovePartEntry.ToNZString();
            //dtoInvTrnsListFrom.GROUP_TRANS_ID =
            //dtoInvTrnsListFrom.RESERVE_QTY =
            //dtoInvTrnsListFrom.NG_REASON =
            dtoInvTrnsTo.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.In);
            dtoInvTrnsTo.LOT_REMARK   = model.LOT_NO;
            dtoInvTrnsTo.OLD_DATA     = new NZInt(null, 0);
            dtoInvTrnsTo.WEIGHT       = model.WEIGHT;

            #endregion

            #region Consumption

            List <InventoryTransactionDTO> listComponent = new List <InventoryTransactionDTO>();
            DealingConstraintDTO           dtoConstraint = bizConstraint.LoadDealingConstraint(model.FROM_PROCESS);
            if (dtoConstraint != null && dtoConstraint.COMPONENT_ITEM_USAGE.StrongValue == 1)
            {
                //get component usage
                BOMBIZ bizBOM = new BOMBIZ();
                List <ComponentUsageDTO> components = bizBOM.LoadComponentUsage(model.MASTER_NO, model.MOVE_QTY);
                if (components != null)
                {
                    foreach (ComponentUsageDTO component in components)
                    {
                        InventoryTransactionDTO dtoComponent = new InventoryTransactionDTO();
                        dtoComponent.CRT_BY      = CommonLib.Common.CurrentUserInfomation.UserCD;
                        dtoComponent.CRT_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine;
                        dtoComponent.UPD_BY      = CommonLib.Common.CurrentUserInfomation.UserCD;
                        dtoComponent.UPD_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine;
                        //dtoComponent.TRANS_ID =
                        dtoComponent.ITEM_CD = component.LOWER_ITEM_CD;
                        dtoComponent.LOC_CD  = model.FROM_PROCESS;
                        //dtoComponent.LOT_NO = model.LOT_NO;
                        //dtoComponent.PACK_NO = string.Empty;
                        dtoComponent.TRANS_DATE = model.MOVE_DATE;
                        dtoComponent.TRANS_CLS  = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.MoveConsumption).ToNZString();
                        dtoComponent.IN_OUT_CLS = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out).ToNZString();
                        dtoComponent.QTY        = component.USAGE_QTY;
                        //dtoComponent.OBJ_ITEM_CD =
                        //dtoComponent.OBJ_ORDER_QTY =
                        //dtoComponent.REF_NO =
                        //dtoComponent.REF_SLIP_NO =
                        //dtoComponent.REF_SLIP_CLS =
                        //dtoComponent.OTHER_DL_NO =
                        //dtoComponent.SLIP_NO =
                        dtoComponent.REMARK = model.REMARK;
                        //dtoComponent.DEALING_NO =
                        //dtoComponent.EXTERNAL_LOT_NO =
                        //dtoComponent.PRICE =
                        //dtoComponent.FOR_CUSTOMER =
                        //dtoComponent.FOR_MACHINE =
                        dtoComponent.SHIFT_CLS = model.SHIFT_CLS;
                        //dtoComponent.REF_SLIP_NO2 =
                        //dtoComponent.NG_QTY =
                        dtoComponent.TRAN_SUB_CLS = model.REASON;
                        dtoComponent.SCREEN_TYPE  = DataDefine.ScreenType.MovePartEntry.ToNZString();
                        //dtoComponent.GROUP_TRANS_ID =
                        //dtoComponent.RESERVE_QTY =
                        //dtoComponent.NG_REASON =
                        dtoComponent.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.Out);
                        dtoComponent.LOT_REMARK   = model.LOT_NO;
                        dtoComponent.OLD_DATA     = new NZInt(null, 0);
                        //dtoComponent.WEIGHT = model.WEIGHT;
                        listComponent.Add(dtoComponent);
                    }
                }

                #endregion
            }

            bizInv.AddMovePart(dtoInvTrnsFrom, dtoInvTrnsTo, listComponent);
        }
Esempio n. 8
0
        /// <summary>
        /// Save new data.
        /// </summary>
        /// <param name="model"></param>
        public void SaveAdd(AdjustmentEntryUIDM model)
        {
            try
            {
                CommonLib.Common.CurrentDatabase.KeepConnection = true;
                CommonLib.Common.CurrentDatabase.BeginTransaction(System.Data.IsolationLevel.Serializable);

                AdjustmentValidator  adjustmentValidator = new AdjustmentValidator();
                ItemValidator        itemValidator       = new ItemValidator();
                DealingValidator     locationValidator   = new DealingValidator();
                TransactionValidator valTran             = new TransactionValidator();
                CommonBizValidator   commonVal           = new CommonBizValidator();

                //ValidateException.ThrowErrorItem(adjustmentValidator.CheckEmptyAdjustDate(model.AdjustDate));
                //ValidateException.ThrowErrorItem(adjustmentValidator.CheckEmptyReasonCode(model.ReasonCode));
                //ValidateException.ThrowErrorItem(valTran.DateIsInCurrentPeriod(model.AdjustDate));
                //ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(model.ItemCode));

                BusinessException businessException = itemValidator.CheckItemNotExist(model.ItemCode);
                if (businessException != null)
                {
                    ValidateException.ThrowErrorItem(businessException.Error);
                }

                //ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(model.StoredLoc));
                ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(model.StoredLoc));
                ValidateException.ThrowErrorItem(commonVal.CheckInputLot(model.ItemCode, new NZString(), model.LotNo, false));

                //ValidateException.ThrowErrorItem(adjustmentValidator.CheckEmptyAdjustQty(model.AdjustQty));
                //ValidateException.ThrowErrorItem(adjustmentValidator.CheckIsZeroAdjustQty(model.AdjustQty));

                #region Lock Running Number gen.

                TransactionLockDAO daoTrans = new TransactionLockDAO(CommonLib.Common.CurrentDatabase);
                TransactionLockDTO dtoTrans = new TransactionLockDTO();
                NZString           key1     = new NZString(null, "ADJUST_NO");
                NZString           key2     = new NZString(null, "INV_TRANS_TR");
                if (!daoTrans.Exist(null, key1, key2))
                {
                    dtoTrans.KEY1           = key1;
                    dtoTrans.KEY2           = key2;
                    dtoTrans.CRT_BY         = CommonLib.Common.CurrentUserInfomation.UserCD;
                    dtoTrans.CRT_DATE.Value = DateTime.Now;
                    dtoTrans.CRT_MACHINE    = CommonLib.Common.CurrentUserInfomation.Machine;
                    daoTrans.AddNew(null, dtoTrans);
                }

                // lock transaction
                daoTrans.SelectWithKeys(null, key1, key2);
                // end of lock transaction

                #endregion

                RunningNumberBIZ bizRunning = new RunningNumberBIZ();
                NZString         SlipNo     = bizRunning.GetCompleteRunningNo(new NZString(null, "ADJUST_NO"), new NZString(null, "TB_INV_TRANS_TR"));
                model.AdjustNo = SlipNo;

                NZString GroupTransID = bizRunning.GetCompleteRunningNo(new NZString(null, "TRAN_GROUP_ID"), new NZString(null, "TB_INV_TRANS_TR"));
                model.GroupTransID = GroupTransID;

                #region Generate pack_no if it is empty

                DealingConstraintBIZ bizConstraint = new DealingConstraintBIZ();

                string strProcess = model.StoredLoc.StrongValue;
                DealingConstraintDTO constriant = bizConstraint.LoadDealingConstraint(strProcess.ToNZString());
                if (constriant != null && constriant.ENABLE_PACK_FLAG.StrongValue == 1 && model.PackNo.IsNull)
                {
                    NZString PackNo = bizRunning.GetCompleteRunningNo(new NZString(null, "PACK_NO_AUTO_GEN"), new NZString(null, "TB_INV_TRANS_TR"));
                    model.PackNo = PackNo;
                }

                #endregion

                InventoryBIZ inventoryBIZ = new InventoryBIZ();

                InventoryTransactionDTO dto = ConvertUIDMToDTO(model);
                inventoryBIZ.AddInventoryTransaction(CommonLib.Common.CurrentDatabase, dto, true);

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