Ejemplo n.º 1
0
        /// <summary>
        /// Get Products of BOM
        /// </summary>
        /// <param name="bom">bom</param>
        /// <returns>array of BOM Products</returns>
        public static MBOMProduct[] GetOfBOM(MBOM bom)
        {
            List <MBOMProduct> list = new List <MBOMProduct>();
            String             sql  = "SELECT * FROM M_BOMProduct WHERE M_BOM_ID=@bomid ORDER BY SeqNo";

            try
            {
                SqlParameter[] param = new SqlParameter[1];
                param[0] = new SqlParameter("@bomid", bom.GetM_BOM_ID());
                DataSet ds = DataBase.DB.ExecuteDataset(sql, param, bom.Get_Trx());
                if (ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        list.Add(new MBOMProduct(bom.GetCtx(), dr, bom.Get_Trx()));
                    }
                }
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql, e);
            }

            MBOMProduct[] retValue = new MBOMProduct[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get BOM Lines for Product given a specific BOM
        /// </summary>
        /// <param name="bom">BOM</param>
        /// <returns>array of BOMProducts.</returns>
        /// <writer>raghu</writer>
        /// <date>08-march-2011</date>
        public static MBOMProduct[] GetBOMLines(MBOM bom)
        {
            String             sql  = "SELECT * FROM M_BOMProduct WHERE M_BOM_ID=" + bom.GetM_BOM_ID() + " AND IsActive='Y' ORDER BY Line";
            List <MBOMProduct> list = new List <MBOMProduct>();
            IDataReader        idr  = null;

            try
            {
                DataTable dt = new DataTable();
                idr = DB.ExecuteReader(sql, null, bom.Get_Trx());
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    list.Add(new MBOMProduct(bom.GetCtx(), dr, bom.Get_Trx()));
                }
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                    idr = null;
                }
            }
            //
            MBOMProduct[] retValue = new MBOMProduct[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get BOM Lines for Product given a specific BOM
        /// The result is Ordered By Product Name.
        /// </summary>
        /// <param name="bom">Bom</param>
        /// <param name="isAscending">true is ascending, false if descending</param>
        /// <returns>array of BOMProducts.</returns>
        ///  /// <writer>raghu</writer>
        /// <date>08-march-2011</date>
        public static MBOMProduct[] GetBOMLinesOrderByProductName(MBOM bom, Boolean isAscending)
        {
            StringBuilder sql = new StringBuilder("SELECT * FROM M_BOMProduct WHERE M_BOM_ID=" + bom.GetM_BOM_ID() + " AND IsActive='Y'");

            if (isAscending)
            {
                sql.Append(" ORDER BY getProductName(M_ProductBOM_ID)");
            }
            else
            {
                sql.Append(" ORDER BY getProductName(M_ProductBOM_ID) DESC");
            }
            List <MBOMProduct> list = new List <MBOMProduct>();
            IDataReader        idr  = null;

            try
            {
                idr = DB.ExecuteReader(sql.ToString(), null, bom.Get_Trx());
                DataTable dt = new DataTable();
                dt.Load(idr);
                idr.Close();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    list.Add(new MBOMProduct(bom.GetCtx(), dt.Rows[i], bom.Get_Trx()));
                }
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql.ToString(), e);
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                    idr = null;
                }
            }
            //
            MBOMProduct[] retValue = new MBOMProduct[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Parent Constructor
 /// </summary>
 /// <param name="bom">product</param>
 public MBOMProduct(MBOM bom)
     : this(bom.GetCtx(), 0, bom.Get_Trx())
 {
     _bom = bom;
 }