Exemplo n.º 1
0
        /// <summary>
        /// Get/Set Project
        /// </summary>
        /// <param name="issue">issue</param>
        /// <returns>project</returns>
        static public MIssueProject Get(MIssue issue)
        {
            if (issue.GetName() == null)
            {
                return(null);
            }
            MIssueProject pj  = null;
            String        sql = "SELECT * FROM R_IssueProject WHERE Name=@param";

            SqlParameter[] param = new SqlParameter[1];
            IDataReader    idr   = null;

            try
            {
                //pstmt = DataBase.prepareStatement (sql, null);
                //pstmt.setString (1, issue.getName());
                param[0] = new SqlParameter("@param", issue.GetName());
                idr      = DataBase.DB.ExecuteReader(sql, param, null);
                if (idr.Read())
                {
                    pj = new MIssueProject(issue.GetCtx(), idr, null);
                }
                idr.Close();
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            //	New
            if (pj == null)
            {
                pj = new MIssueProject(issue.GetCtx(), 0, null);
                pj.SetName(issue.GetName());
                pj.SetA_Asset_ID(issue);
            }
            pj.SetSystemStatus(issue.GetSystemStatus());
            pj.SetStatisticsInfo(issue.GetStatisticsInfo());
            pj.SetProfileInfo(issue.GetProfileInfo());
            if (!pj.Save())
            {
                return(null);
            }

            //	Set
            issue.SetR_IssueProject_ID(pj.GetR_IssueProject_ID());
            if (pj.GetA_Asset_ID() != 0)
            {
                issue.SetA_Asset_ID(pj.GetA_Asset_ID());
            }
            return(pj);
        }       //	get
Exemplo n.º 2
0
        /// <summary>
        /// Get/Set System
        /// </summary>
        /// <param name="issue">issue</param>
        /// <returns>system</returns>
        static public MIssueSystem Get(MIssue issue)
        {
            if (issue.GetDBAddress() == null)
            {
                return(null);
            }
            MIssueSystem system = null;

            SqlParameter[] param = new SqlParameter[1];
            IDataReader    idr   = null;
            String         sql   = "SELECT * FROM R_IssueSystem WHERE DBAddress=@param";

            try
            {
                //pstmt = DataBase.prepareStatement (sql, null);
                //pstmt.setString (1, issue.getDBAddress());
                param[0] = new SqlParameter("@param", issue.GetDBAddress());
                idr      = DataBase.DB.ExecuteReader(sql, param, null);
                if (idr.Read())
                {
                    system = new MIssueSystem(issue.GetCtx(), idr, null);
                }
                idr.Close();
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }

            //	New
            if (system == null)
            {
                system = new MIssueSystem(issue.GetCtx(), 0, null);
                system.SetDBAddress(issue.GetDBAddress());
                system.SetA_Asset_ID(issue.GetA_Asset_ID());
            }
            system.SetSystemStatus(issue.GetSystemStatus());
            system.SetStatisticsInfo(issue.GetStatisticsInfo());
            system.SetProfileInfo(issue.GetProfileInfo());
            if (issue.GetA_Asset_ID() != 0 &&
                system.GetA_Asset_ID() != issue.GetA_Asset_ID())
            {
                system.SetA_Asset_ID(issue.GetA_Asset_ID());
            }
            //
            if (!system.Save())
            {
                return(null);
            }

            //	Set
            issue.SetR_IssueSystem_ID(system.GetR_IssueSystem_ID());
            if (system.GetA_Asset_ID() != 0)
            {
                issue.SetA_Asset_ID(system.GetA_Asset_ID());
            }
            return(system);
        }       //	get