Я пытаюсь установить значение для единицы из базы данных, когда продукт выбирается из выпадающего списка. Я хочу заполнить текстовое поле единицы, Оценить и затем умножить скорость и количество, чтобы установить значение в текстовом поле общей суммы, используя ext.net в проекте MVC
<- это мой Класс Продукта --->
public class ProductDto
{
[Field(FieldType = typeof(Ext.Net.Hidden))]
public int productId { get; set; }
[PresenceValidator]
public string productCode { get; set; }
[PresenceValidator]
public string productName { get; set; }
[PresenceValidator]
public int? groupId { get; set; }
[PresenceValidator]
public int? brandId { get; set; }
[PresenceValidator]
public int? unitId { get; set; }
[PresenceValidator]
public int? sizeId { get; set; }
[PresenceValidator]
public int? modelNoId { get; set; }
[PresenceValidator]
public int? taxId { get; set; }
[PresenceValidator]
public string taxapplicableOn { get; set; }
[PresenceValidator]
public decimal? purchaseRate { get; set; }
[PresenceValidator]
public decimal? salesRate { get; set; }
[PresenceValidator]
public decimal? mrp { get; set; }
[PresenceValidator]
public decimal? minimumStock { get; set; }
[PresenceValidator]
public decimal? maximumStock { get; set; }
[PresenceValidator]
public decimal? reorderLevel { get; set; }
[PresenceValidator]
public int? godownId { get; set; }
[PresenceValidator]
public int? rackId { get; set; }
[PresenceValidator]
public bool? isallowBatch { get; set; }
[PresenceValidator]
public bool? ismultipleunit { get; set; }
[PresenceValidator]
public bool? isBom { get; set; }
[PresenceValidator]
public bool? isopeningstock { get; set; }
[PresenceValidator]
public string narration { get; set; }
[PresenceValidator]
public bool? isActive { get; set; }
[PresenceValidator]
public bool? isshowRemember { get; set; }
[PresenceValidator]
public string extra1 { get; set; }
[PresenceValidator]
public string extra2 { get; set; }
[PresenceValidator]
public DateTime? extraDate { get; set; }
[PresenceValidator]
public string partNo { get; set; }
}
<- это модель, переданная в представлении, которое содержит productId ->
public partial class PurchaseDto
{
[Field(FieldType = typeof(Ext.Net.Hidden))]
public int purchaseDetailsId { get; set; }
public int? purchaseMasterId { get; set; }
[PresenceValidator]
public int? receiptDetailsId { get; set; }
[PresenceValidator]
public int? orderDetailsId { get; set; }
[PresenceValidator]
public int? productId { get; set; }
[PresenceValidator]
public int? qty { get; set; }
[PresenceValidator]
public int? rate { get; set; }
[PresenceValidator]
public int? unitId { get; set; }
[PresenceValidator]
public int? unitConversionId { get; set; }
[PresenceValidator]
public decimal? discount { get; set; }
[PresenceValidator]
public int? taxId { get; set; }
[PresenceValidator]
public int? batchId { get; set; }
[PresenceValidator]
public int? godownId { get; set; }
[PresenceValidator]
public int? rackId { get; set; }
[PresenceValidator]
public decimal? taxAmount { get; set; }
[PresenceValidator]
public decimal? grossAmount { get; set; }
[PresenceValidator]
public decimal? netAmount { get; set; }
[PresenceValidator]
public decimal? amount { get; set; }
[PresenceValidator]
public int? slNo { get; set; }
[PresenceValidator]
public DateTime? extraDate { get; set; }
[PresenceValidator]
public string extra1 { get; set; }
[PresenceValidator]
public string extra2 { get; set; }
[PresenceValidator]
public string voucherNo { get; set; }
[PresenceValidator]
public string invoiceNo { get; set; }
[PresenceValidator]
public int? suffixPrefixId { get; set; }
[PresenceValidator]
public int? voucherTypeId { get; set; }
[PresenceValidator]
public DateTime? date { get; set; }
[PresenceValidator]
public int? ledgerId { get; set; }
[PresenceValidator]
public string vendorInvoiceNo { get; set; }
[PresenceValidator]
public DateTime? vendorInvoiceDate { get; set; }
public string creditPeriod { get; set; }
[PresenceValidator]
public int? exchangeRateId { get; set; }
[PresenceValidator]
public string narration { get; set; }
[PresenceValidator]
public int? purchaseAccount { get; set; }
[PresenceValidator]
public int? purchaseOrderMasterId { get; set; }
[PresenceValidator]
public int? materialReceiptMasterId { get; set; }
[PresenceValidator]
public decimal? additionalCost { get; set; }
[PresenceValidator]
public decimal? totalTax { get; set; }
[PresenceValidator]
public decimal? billDiscount { get; set; }
[PresenceValidator]
public decimal? grandTotal { get; set; }
[PresenceValidator]
public decimal? totalAmount { get; set; }
[PresenceValidator]
public int? userId { get; set; }
[PresenceValidator]
public string lrNo { get; set; }
[PresenceValidator]
public string transportationCompany { get; set; }
[PresenceValidator]
public int? financialYearId { get; set; }
}
<- это мой набор полей в представлении ->
@model IEnumerable<Nmicros.Accounts.Web.Data.Dtos.Others.PurchaseDto>
@{
ViewBag.Title = "Purchase";
Layout = "~/Views/Shared/_Layout.cshtml";
var X = Html.X();
}
X.FieldSet()
.ColumnWidth(0.4)
.ID("purch")
.Title("Purchase Details")
.MarginSpec("0 0 0 10")
.Defaults(d =>
{ d.Add(new Parameter("LabelWidth", "130"));})
.Items(
X.TextField().Name("purchaseDetailsId").FieldLabel("Id").Hidden(true),
X.ComboBox().Name("purchaseAccount").FieldLabel("Account").ForceSelection(true).EmptyText("-- choose--").EmptyValue(0).Items(ViewBag.Ledger).Editable(false),
X.TextField().Name("purchaseMasterId").FieldLabel("Master"),
X.ComboBox().Name("productId").FieldLabel("Product").ForceSelection(true).EmptyText("-- choose--").EmptyValue(0).Items(ViewBag.Product).Editable(false),
X.TextField().Name("qty").FieldLabel("Quantity"),
X.TextField().Name("SalesRate").FieldLabel("Rate").ReadOnly(true),
X.TextField().Name("unitId").FieldLabel("Unit").ReadOnly(true).ID("unit"),
X.TextField().Name("discount").FieldLabel("Discount"),
X.ComboBox().Name("taxId").FieldLabel("Tax"),
X.ComboBox().Name("ledgerId").FieldLabel("Suspence Account").ForceSelection(true).EmptyText("-- choose--").EmptyValue(0).Items(ViewBag.Ledger).Editable(false),
X.TextField().Name("taxAmount").FieldLabel("Tax Amount"),
X.TextField().Name("amount").FieldLabel("Amount"),
X.TextField().Name("slNo").FieldLabel("Serial No"),
X.TextField().Name("voucherNo").FieldLabel("Voucher"),
X.TextField().Name("invoiceNo").FieldLabel("Invoice"),
X.TextField().Name("creditPeriod").FieldLabel("Credit Period"),
X.TextField().Name("exchangeRateId").FieldLabel("Exchange Rate"),
X.TextField().Name("narration").FieldLabel("Narration"),
X.ComboBox().Name("purchaseOrderMasterId").FieldLabel("PurchaseOrderMaster").ForceSelection(true).EmptyText("-- choose--").EmptyValue(0).Items(ViewBag.Order).Editable(false),
X.TextField().Name("totalAmount").FieldLabel("Total Amount").ReadOnly(true),
X.ComboBox().Name("financialYearId").FieldLabel("Financial Year"),
X.DateField().Name("date").FieldLabel("Date")
)
)
Я ожидаю, что при выборе продукта из выпадающего списка текстовые поля для unitId и salesRate должны заполняться автоматически, получая значения из таблицы продуктов в базе данных. тогда также totalAmount = количество * saleRate