public static CommCalcView LoadRecord(int commCalcId) { IDalSession session = NHSessionFactory.CreateSession(); CommCalc calc = CommCalcMapper.GetCommissionCalculation(session, commCalcId); CommCalcView commCalcView = new CommCalcView(); commCalcView.Name = calc.Name; commCalcView.MinValue = (calc.MinValue != null ? calc.MinValue.Quantity : 0m); if (calc.MaxValue != null) commCalcView.MaxValue = calc.MaxValue.Quantity; commCalcView.FixedSetup = (calc.FixedSetup != null ? calc.FixedSetup.Quantity : 0m); commCalcView.CalcType = (int) calc.CalcType; foreach (CommCalcLine calcLine in calc.CommLines) { CommCalcLineView lineView = new CommCalcLineView(); lineView.SerialNo = calcLine.SerialNo; lineView.LowerRange = calcLine.LowerRangeQuantity; lineView.StaticCharge = calcLine.StaticCharge; lineView.IsAmountBased = (calcLine.LineBasedType == CommCalcLineBasedTypes.AmountBased); if (lineView.IsAmountBased) lineView.FeePercentage = ((CommCalcLineAmountBased)calcLine).FeePercentage; else lineView.Tariff = ((CommCalcLineSizeBased)calcLine).Tariff.Quantity; commCalcView.LineViews.Add(lineView); } session.Close(); return commCalcView; }
/// <summary> /// Creates a CommCalcLineView object based on the FlatSlab control input /// </summary> /// <param name="uc">The FlatSlab user control</param> /// <returns>A CommCalcLineView object</returns> private CommCalcLineView createCommCalcLineView(FlatSlab uc) { CommCalcLineView lineView = new CommCalcLineView(); lineView.FeePercentage = uc.dBoxPercent.Value; lineView.LowerRange = uc.dBoxFrom.Value; lineView.StaticCharge = uc.dBoxStaticCharge.Value; lineView.Tariff = uc.dBoxTariff.Value; lineView.IsAmountBased = uc.IsAmountBased; return lineView; }