我正在 mvc 4 和 razor 中创建财务应用程序。因为有一个模块日志。 一个期刊可以有多个条目。没有日记帐分录就不能创建日记帐。
以下是我的模型
using Sms.Core;
using System;
using System.Collections.Generic;
namespace Sms.CoreSociety
{
public class Journal : BaseClass
{
public Journal()
{
this.JournalEntries = new List<JournalEntry>();
}
public virtual string VoucherNo { get; set; }
public virtual DateTime VoucherDate { get; set; }
public string VoucherDateView
{
get
{
return VoucherDate.ToShortDateString();
}
}
public IList<JournalEntry> JournalEntries { get; set; }
public IList<Ledger> Accounts { get; set; }
public double TotalAmount
{
get
{
double sum = 0;
if (JournalEntries != null && JournalEntries.Count > 0)
foreach (var journal in JournalEntries)
sum = journal.Principal + journal.Interest + sum;
return sum;
}
}
}
}
以下是我的看法
@model Sms.CoreSociety.Journal
@{
ViewBag.Title = "Create";
}
@using (Html.BeginForm(null, null, FormMethod.Post, new Dictionary<string, object>() { { "class", "form-horizontal" }, { "id", "document" } }))
{
@Html.ValidationSummary(true)
<fieldset>
<div class="row">
<div class="span1">
<label>
Voucher No</label>
</div>
<div class="span5">
@Html.TextBoxFor(model => model.VoucherNo)
</div>
</div>
<div class="row">
<div class="span1">
<label>
Voucher Date</label>
</div>
<div class="span5">
@Html.TextBoxFor(model => model.VoucherDate)
</div>
</div>
<div class="row">
<div class="span1">
<label>
Amount</label>
</div>
<div class="span5">
@Html.TextBoxFor(model => model.TotalAmount)
</div>
</div>
@Html.TextBox("JournalEntries[0].AccountName", Model.JournalEntries.FirstOrDefault().AccountName)
@Html.TextBox("JournalEntries[0].DebitCredit", Model.JournalEntries.FirstOrDefault().DebitCredit)
@Html.TextBox("JournalEntries[0].Interest", Model.JournalEntries.FirstOrDefault().Interest)
@Html.TextBox("JournalEntries[0].Narration", Model.JournalEntries.FirstOrDefault().Narration)
<input type="submit" value="Save" class="btn" id="submit" />
@if (Model.Id != new Guid())
{
<div style="float: right">
<a class="btn btn-danger" href='@Url.Action("Delete")/@Model.Id' aria-hidden="true">
Delete</a>
</div>
}
</fieldset>
}
<h4>
Journal Entry</h4>
<p>
@Html.ActionLink("Add Entry", "JournalEntry");
现在我可以获得 Journal 以及Single Journal Entry。但我的问题是我无法进行多次日记帐分录。