Refactor Amount field to use decimal and DxSpinEdit
Replaced string-based Amount handling with a decimal property in the edit model. Switched input from DxTextBox to DxSpinEdit, removing manual parsing and validation logic for Amount. This improves data binding, input reliability, and code clarity.
This commit is contained in:
@@ -137,7 +137,7 @@ else
|
||||
<DxTextBox @bind-Text="editModel.CustomerName" Width="100%" />
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption="Amount">
|
||||
<DxTextBox @bind-Text="editModel.AmountText" Width="100%" />
|
||||
<DxSpinEdit @bind-Value="editModel.Amount" MinValue="0" DisplayFormat="c2" Width="100%" />
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption="Category">
|
||||
<DxTextBox @bind-Text="editModel.Category" Width="100%" ReadOnly="@(!editModel.IsNew)" />
|
||||
@@ -285,7 +285,7 @@ else
|
||||
{
|
||||
Id = item.Id,
|
||||
CustomerName = item.CustomerName,
|
||||
AmountText = item.Amount.ToString("0.00"),
|
||||
Amount = item.Amount,
|
||||
Category = item.Category,
|
||||
StatusFlag = item.StatusFlag,
|
||||
UpdateProcedure = procedureOptions[0].Value,
|
||||
@@ -302,12 +302,6 @@ else
|
||||
validationMessageStore?.Clear();
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
var editModel = (MassDataEditModel)e.EditModel;
|
||||
if (!decimal.TryParse(editModel.AmountText, out var amount))
|
||||
{
|
||||
AddValidationError(editModel, nameof(MassDataEditModel.AmountText), "Amount ist ungültig.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
if (editModel.IsNew)
|
||||
{
|
||||
var existing = await Api.GetByCustomerNameAsync(editModel.CustomerName);
|
||||
@@ -321,7 +315,7 @@ else
|
||||
var dto = new MassDataWriteDto
|
||||
{
|
||||
CustomerName = editModel.CustomerName,
|
||||
Amount = amount,
|
||||
Amount = editModel.Amount,
|
||||
Category = editModel.Category,
|
||||
StatusFlag = editModel.StatusFlag
|
||||
};
|
||||
@@ -357,7 +351,7 @@ else
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string CustomerName { get; set; } = string.Empty;
|
||||
public string AmountText { get; set; } = string.Empty;
|
||||
public decimal Amount { get; set; }
|
||||
public string Category { get; set; } = string.Empty;
|
||||
public bool StatusFlag { get; set; }
|
||||
public int UpdateProcedure { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user