|
|
@@ -17,16 +17,25 @@
|
|
|
@foreach (var state in (IEnumerable<GreenTree.Nachtragsmanagement.Core.Domain.Appendix.State>)ViewData["AllStates"])
|
|
|
{
|
|
|
if (state.IsZeroValue)
|
|
|
- {
|
|
|
+ {
|
|
|
ViewContext.Writer.Write(state.Id);
|
|
|
}
|
|
|
}
|
|
|
];
|
|
|
|
|
|
+ var initialValueStates =
|
|
|
+ [
|
|
|
+ @foreach (var state in (IEnumerable<GreenTree.Nachtragsmanagement.Core.Domain.Appendix.State>)ViewData["AllStates"])
|
|
|
+ {
|
|
|
+ ViewContext.Writer.Write("{ Id: " + state.Id + ", Value: " + state.InitialPercentage.ToString().Replace(',','.') + " },");
|
|
|
+ }
|
|
|
+ ];
|
|
|
+
|
|
|
function saveAppendix() {
|
|
|
CategoryEntities.SelectAll();
|
|
|
var form = $("#appendixEditForm");
|
|
|
$(form).submit(function (e) {
|
|
|
+ PercentageAppendix.SetValue(PercentageAppendix.GetValue() / 100);
|
|
|
$.ajax({
|
|
|
type: "POST",
|
|
|
url: '@Url.Action("EditAppendix", "Appendix")',
|
|
|
@@ -123,14 +132,21 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- function isZeroValueState() {
|
|
|
+ function setInitialValueState() {
|
|
|
var selectedValue = StateId.GetSelectedItem().value;
|
|
|
if (!selectedValue) return;
|
|
|
+ var controls = ASPxClientControl.GetControlCollection();
|
|
|
+ var percentage = controls.GetByName("Percentage");
|
|
|
+ for (var i = 0; i < initialValueStates.length; i++) {
|
|
|
+ if (initialValueStates[i].Id == selectedValue) {
|
|
|
+ var per = parseFloat(initialValueStates[i].Value * 100).toFixed(2);
|
|
|
+ percentage.SetValue(per);
|
|
|
+ calculateValueAppendix();
|
|
|
+ }
|
|
|
+ }
|
|
|
for (var i = 0; i < zeroValueStates.length; i++) {
|
|
|
- if (zeroValueStates == selectedValue) {
|
|
|
- var controls = ASPxClientControl.GetControlCollection();
|
|
|
+ if (zeroValueStates[i] == selectedValue) {
|
|
|
var offeringValue = controls.GetByName("OfferingValue");
|
|
|
- var percentage = controls.GetByName("Percentage");
|
|
|
var percentageValue = controls.GetByName("PercentageValue");
|
|
|
offeringValue.SetValue(0.00);
|
|
|
percentage.SetValue(0.00);
|
|
|
@@ -185,7 +201,7 @@
|
|
|
}
|
|
|
|
|
|
function calculateValueAppendix() {
|
|
|
- PercentageValueAppendix.SetValue(OfferingValueAppendix.GetValue() * PercentageAppendix.GetValue());
|
|
|
+ PercentageValueAppendix.SetValue((OfferingValueAppendix.GetValue() / 100) * PercentageAppendix.GetValue());
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
@@ -351,15 +367,16 @@
|
|
|
t.Width = new Unit(88, UnitType.Percentage);
|
|
|
t.ReadOnly = isReadOnly;
|
|
|
t.Properties.ClientInstanceName = "PercentageAppendix";
|
|
|
- t.Properties.MaxValue = 1;
|
|
|
+ t.Properties.MaxValue = 100;
|
|
|
t.Properties.MinValue = 0;
|
|
|
- t.Properties.Increment = (decimal)0.1;
|
|
|
+ t.Properties.Increment = (decimal)1;
|
|
|
t.Properties.NumberType = SpinEditNumberType.Float;
|
|
|
- t.Properties.NumberFormat = SpinEditNumberFormat.Percent;
|
|
|
- t.Properties.DisplayFormatString = "p0";
|
|
|
+ t.Properties.NumberFormat = SpinEditNumberFormat.Custom;
|
|
|
+ t.Properties.DisplayFormatString = "{0,00} %";
|
|
|
t.Properties.DisplayFormatInEditMode = true;
|
|
|
t.Properties.ClientSideEvents.ValueChanged = "function (s, e) { calculateValueAppendix(); }";
|
|
|
- }).Render();
|
|
|
+ t.Properties.ClientSideEvents.Init = "function (s, e) { calculateValueAppendix(); }";
|
|
|
+ }).Bind(Model.Percentage * 100).Render();
|
|
|
}
|
|
|
ViewContext.Writer.Write("</div>");
|
|
|
ViewContext.Writer.Write("<div class='inlineModelProperty' style='width: 22%'>");
|
|
|
@@ -461,7 +478,7 @@
|
|
|
Type = Model.GetType().FullName
|
|
|
};
|
|
|
|
|
|
- t.Properties.ClientSideEvents.SelectedIndexChanged = "function (s, e) { isZeroValueState(); }";
|
|
|
+ t.Properties.ClientSideEvents.SelectedIndexChanged = "function (s, e) { setInitialValueState(); }";
|
|
|
}));
|
|
|
ViewData.Add("StatesComboBoxSettings", "AppendixStatesComboBoxSettings");
|
|
|
Html.RenderPartial("~/Views/Shared/DataEditorTemplates/_StatesComboBox.cshtml", Model, ViewData);
|