예제 #1
0
        private Unit GetUnit(string UnitName)
        {
            if (dictUnit == null)
            {
                dictUnit = new Dictionary<string, Unit>();
                XPCollection<Unit> units = new XPCollection<Unit>(session);

                foreach (Unit unit in units)
                {
                    dictUnit.Add(unit.UnitName.ToUpper(), unit);
                }
            }

            if (dictUnit.ContainsKey(UnitName.ToUpper()))
            {
                return dictUnit[UnitName.ToUpper()];
            }
            else
            {
                Unit unit = new Unit(session);
                unit.UnitName = UnitName;
                unit.Type = Unit.UnitType.Dimension;
                unit.Decimal = 0;
                unit.Save();

                dictUnit.Add(UnitName.ToUpper(), unit);

                return unit;
            }
        }
예제 #2
0
        protected void UpdateWHQty(WHTotal whTotal)
        {
            if (whTotal.Unit != null)
            {
                _WHUnit = whTotal.Unit;
                OnChanged("WHUnit");
            }
            if (_OriginalUnit == null)
                return;
            if (_OriginalUnit == _WHUnit)
            {
                _WHQty = _OriginalQty;
                _ExchangeRate = 1;
            }
            else
                if (_OriginalUnit.Type  == Unit.UnitType.Qty)
                {
                    _ExchangeRate = _OriginalUnit.GetExchangeRate(_WHUnit);
                    _WHQty = _OriginalQty / _ExchangeRate;
                }
                else
                    if (_OriginalUnit.Type  == Unit.UnitType.Dimension)
                    {
                        _WHQty = _OriginalQty; // Cannot Calculate the WHQty
                        _ExchangeRate = 1;
                    }
                    else
                        if (_OriginalUnit.Type  == Unit.UnitType.Weight)
                        {
                            _ExchangeRate = Item.NetWeight;
                            _WHQty = _OriginalQty / _ExchangeRate;
                        }

            OnChanged("WHQty");
            OnChanged("ExchangeRate");
        }
예제 #3
0
파일: Unit.cs 프로젝트: kamchung322/Namwah
        public float GetExchangeRate(Unit ToUnit)
        {
            float ExchangeRate = 1;

            foreach (UnitConvert unitConvert in ToUnits)
            {
                if (unitConvert.ToUnit == ToUnit)
                {
                    ExchangeRate = unitConvert.ExchangeRate;
                    break;
                }
            }

            return ExchangeRate;
        }