コード例 #1
0
        /// <summary>
        /// Work
        /// </summary>
        protected override void DoWork()
        {
            _summary = new StringBuilder();
            //	Get Schemata
            if (_modelLocal.GetC_AcctSchema_ID() == 0)
            {
                _ass = MAcctSchema.GetClientAcctSchema(GetCtx(), _modelLocal.GetAD_Client_ID());
            }
            else        //	only specific accounting schema
            {
                _ass = new MAcctSchema[] { new MAcctSchema(GetCtx(), _modelLocal.GetC_AcctSchema_ID(), null) };
            }
            //
            PostSession();
            MCost.Create(_clientLocal);
            //
            int no = _modelLocal.DeleteLog();

            _summary.Append("Logs deleted=").Append(no);
            //
            MAcctProcessorLog pLog = new MAcctProcessorLog(_modelLocal, _summary.ToString());

            pLog.SetReference("#" + Utility.Util.GetValueOfString(_runCount) // String.valueOf(p_runCount)
                              + " - " + TimeUtil.FormatElapsed(_startWork)); //new DateTime(_startWork)));
            pLog.Save();
        }
コード例 #2
0
ファイル: MProduct.cs プロジェクト: vuongthai91/ERP-CMR-DMS
        /**
         *  After Save
         *	@param newRecord new
         *	@param success success
         *	@return success
         */
        protected override bool AfterSave(bool newRecord, bool success)
        {
            if (!success)
            {
                return(success);
            }

            //	Value/Name change in Account
            if (!newRecord && (Is_ValueChanged("Value") || Is_ValueChanged("Name")))
            {
                MAccount.UpdateValueDescription(GetCtx(), "M_Product_ID=" + GetM_Product_ID(), Get_TrxName());
            }

            //	Name/Description Change in Asset	MAsset.setValueNameDescription
            if (!newRecord && (Is_ValueChanged("Name") || Is_ValueChanged("Description")))
            {
                //String sql = "UPDATE A_Asset a "
                //    + "SET (Name, Description)="
                //        + "(SELECT SUBSTR(bp.Name || ' - ' || p.Name,1,60), p.Description "
                //        + "FROM M_Product p, C_BPartner bp "
                //        + "WHERE p.M_Product_ID=a.M_Product_ID AND bp.C_BPartner_ID=a.C_BPartner_ID) "
                //    + "WHERE IsActive='Y'"
                //    //	+ " AND GuaranteeDate > SysDate"
                //    + "  AND M_Product_ID=" + GetM_Product_ID();



                String sql = " UPDATE A_Asset a SET Name=(SELECT SUBSTR(bp.Name || ' - ' || p.Name,1,60) FROM M_Product p, C_BPartner bp  WHERE p.M_Product_ID=a.M_Product_ID AND bp.C_BPartner_ID=a.C_BPartner_ID)," +
                             "Description=(SELECT  p.Description FROM M_Product p, C_BPartner bp WHERE p.M_Product_ID=a.M_Product_ID AND bp.C_BPartner_ID=a.C_BPartner_ID)" +
                             "WHERE IsActive='Y'  AND M_Product_ID=" + GetM_Product_ID();

                int no = 0;
                try
                {
                    no = Utility.Util.GetValueOfInt(DataBase.DB.ExecuteQuery(sql, null, Get_TrxName()));
                }
                catch { }
                log.Fine("Asset Description updated #" + no);
            }

            //	New - Acct, Tree, Old Costing
            if (newRecord)
            {
                Insert_Accounting("M_Product_Acct", "M_Product_Category_Acct",
                                  "p.M_Product_Category_ID=" + GetM_Product_Category_ID());
                //
                MAcctSchema[] mass = MAcctSchema.GetClientAcctSchema(GetCtx(), GetAD_Client_ID(), Get_TrxName());
                for (int i = 0; i < mass.Length; i++)
                {
                    //	Old
                    MProductCosting pcOld = new MProductCosting(this, mass[i].GetC_AcctSchema_ID());
                    pcOld.Save();
                }
            }

            //	New Costing
            if (newRecord || Is_ValueChanged("M_Product_Category_ID"))
            {
                MCost.Create(this);
            }

            return(success);
        }