Пример #1
0
 public static ChargeSwapModel From(ChargeSwap chargeSwap)
 {
     return new ChargeSwapModel(chargeSwap);
 }
Пример #2
0
        public ActionResult SaveOrUpdate(ChargeSwap item)
        {
            try
            {
                if (item.Id > 0)
                {
                    item = this.ChargeSwapRepository.Get(item.Id);

                    TryUpdateModel(item);
                }
                else
                {
                    if(item.OrigAccount == null)
                        throw new Exception("请选择源账户");

                    if (item.DestAccount == null)
                        throw new Exception("请选择目的账户");

                    if (item.Amount == 0)
                        throw new Exception("请输入记账金额");

                    item.OrigAmount = item.OrigAccount.CurAmount;
                    item.OrigAccount.CurAmount -= item.Amount;

                    item.DestAmount = item.DestAccount.CurAmount;
                    item.DestAccount.CurAmount += item.Amount;

                }

                item.AuditState = AuditState.未审核;

                item = this.ChargeSwapRepository.SaveOrUpdate(item);

                return JsonSuccess(item);

            }
            catch (Exception ex)
            {
                return JsonError(ex.Message);
            }
        }
Пример #3
0
        public ChargeSwapModel(ChargeSwap chargeSwap)
            : base(chargeSwap)
        {
            this.Id = chargeSwap.Id;

            if (chargeSwap.OrigAccount != null)
            {
                this.OrigAccountId = chargeSwap.OrigAccount.Id;
                this.OrigAccountName = chargeSwap.OrigAccount.Name;
            }

            if (chargeSwap.DestAccount != null)
            {
                this.DestAccountId = chargeSwap.DestAccount.Id;
                this.DestAccountName = chargeSwap.DestAccount.Name;
            }

            this.OrigAmount = chargeSwap.OrigAmount;
            this.DestAmount = chargeSwap.DestAmount;
            this.Amount = chargeSwap.Amount;
            this.Note = chargeSwap.Note;
        }
Пример #4
0
        public ActionResult Info(int? id)
        {
            ChargeSwap item = null;

            if (id.HasValue)
            {
                item = this.ChargeSwapRepository.Get(id.Value);
            }

            if (item == null)
            {
                item = new ChargeSwap();
            }

            return View(item);
        }