public static UOM UpdateUOM(PSsqmEntities entities, UOM uom, decimal convertToUOMID, double conversionFactor)
        {
            UOM ret;

            try
            {
                if (uom.UOM_ID > 0)
                {
                    ret = (from u in entities.UOM.Include("UOM_XREF") where u.UOM_ID == uom.UOM_ID select u).Single();
                    if (ret != null)
                    {
                        ret = (UOM)SQMModelMgr.CopyObjectValues(ret, uom, false);
                        ret.UOM_XREF.FirstOrDefault().UOM_TO     = convertToUOMID;
                        ret.UOM_XREF.FirstOrDefault().CONVERSION = Convert.ToDecimal(conversionFactor);
                        entities.SaveChanges();
                    }
                }
                else
                {
                    entities.AddToUOM(uom);
                    entities.SaveChanges();
                    if (convertToUOMID > 0 && uom.UOM_ID > 0)
                    {
                        UOM_XREF xref = new UOM_XREF();
                        xref.UOM_FROM   = uom.UOM_ID;
                        xref.UOM_TO     = convertToUOMID;
                        xref.CONVERSION = Convert.ToDecimal(conversionFactor);
                        xref.OPERATOR   = "MULT";
                        entities.AddToUOM_XREF(xref);
                        entities.SaveChanges();
                    }
                }

                ret = uom;
            }
            catch
            {
                ret = null;
            }

            return(ret);
        }