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:
OlgunR
2026-05-11 16:28:55 +02:00
parent bf98432e20
commit a007842ab0

View File

@@ -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; }