Applied CurrencyTextBox to rest of pages

This commit is contained in:
Rick Falkvinge
2014-12-28 23:04:52 +01:00
parent e0ed96b146
commit a9dfd57dcd
5 changed files with 21 additions and 18 deletions
@@ -41,5 +41,10 @@ namespace Swarmops.Frontend.Controls.v5.Financial
}
// TODO: Add other-currency parsing
public new void Focus()
{
this.Input.Focus();
}
}
}
@@ -1,6 +1,7 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="CreateInboundInvoice.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Financial.CreateInboundInvoice" %>
<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %>
<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %>
<%@ Register TagPrefix="Swarmops5" TagName="CurrencyAmount" Src="~/Controls/v5/Financial/CurrencyTextBox.ascx" %>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
@@ -53,7 +54,7 @@
isValid = validateTextField('#<%=this.TextPurpose.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorPurpose" />") && isValid;
var jsonData = {};
jsonData.amount = $('#<%=this.TextAmount.ClientID %>').val();
jsonData.amount = $('#<%=this.CurrencyAmount.ClientID %>_Input').val();
$.ajax({
type: "POST",
@@ -65,9 +66,9 @@
success: function(msg) {
if (msg.d != true) {
isValid = false;
$('#TextAmount').addClass("entryError");
$('#<%=CurrencyAmount.ClientID %>_Input').addClass("entryError");
alertify.error("<asp:Literal runat="server" ID="LiteralErrorAmount" />");
$('#<%=this.TextAmount.ClientID %>').focus();
$('#<%=CurrencyAmount.ClientID %>_Input').focus();
}
}
});
@@ -114,7 +115,7 @@
<asp:HiddenField ID="HiddenTagSetIdentifiers" runat="server"/>
<div class="entryFields">
<asp:TextBox runat="server" ID="TextSupplier" />&#8203;<br/>
<asp:TextBox runat="server" ID="TextAmount" CssClass="alignRight" />&#8203;<br/>
<Swarmops5:CurrencyAmount runat="server" ID="CurrencyAmount" />&#8203;<br/>
<asp:TextBox runat="server" ID="TextPurpose" />&#8203;<br/>
<asp:TextBox runat="server" ID="TextDueDate" />&#8203;<br/>
<Swarmops5:ComboBudgets ID="ComboBudgets" runat="server" />&nbsp;<br/>
@@ -96,7 +96,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
{
// Prime bank details
this.TextAmount.Text = 0.ToString ("N2");
this.CurrencyAmount.Value = 0;
this.TextSupplier.Focus();
this.TextDueDate.Text = DateTime.Today.AddDays (30).ToShortDateString(); // Use current culture
@@ -137,9 +137,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
// The data has been validated client-side already. We'll throw unfriendly exceptions if invalid data is passed here.
// People who choose to disable JavaScript and then submit bad input almost deserve to be hurt.
double amount = Double.Parse (this.TextAmount.Text, NumberStyles.Number);
// parses in current culture - intentional
Int64 amountCents = (Int64) (amount*100);
Int64 amountCents = (Int64) (this.CurrencyAmount.Value*100.0);
string description = this.TextPurpose.Text;
@@ -200,7 +198,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
this.TextAccount.Text = String.Empty;
this.TextPurpose.Text = String.Empty;
this.TextReference.Text = String.Empty;
this.TextAmount.Text = 0.ToString ("N2");
this.CurrencyAmount.Value = 0;
this.TextDueDate.Text = DateTime.Today.AddDays (30).ToShortDateString(); // Use current culture
// the easyUI combo fields should reset automatically on form submission unless we explicitly reconstruct
@@ -1,6 +1,7 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="FileExpenseClaim.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Financial.FileExpenseClaim" %>
<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %>
<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %>
<%@ Register TagPrefix="Swarmops5" TagName="CurrencyAmount" Src="~/Controls/v5/Financial/CurrencyTextBox.ascx" %>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
@@ -50,7 +51,7 @@
isValid = validateTextField('#<%=this.TextPurpose.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorPurpose" />") && isValid;
var jsonData = {};
jsonData.amount = $('#<%=this.TextAmount.ClientID %>').val();
jsonData.amount = $('#<%=this.CurrencyAmount.ClientID %>_Input').val();
$.ajax({
type: "POST",
@@ -62,9 +63,9 @@
success: function (msg) {
if (msg.d != true) {
isValid = false;
$('#TextAmount').addClass("entryError");
$('#<%=this.CurrencyAmount.ClientID %>_Input').addClass("entryError");
alertify.error("<asp:Literal runat="server" ID="LiteralErrorAmount" />");
$('#<%=this.TextAmount.ClientID %>').focus();
$('#<%=this.CurrencyAmount.ClientID %>_Input').focus();
}
}
});
@@ -107,7 +108,7 @@
<h2><asp:Label runat="server" ID="BoxTitle" /></h2>
<asp:HiddenField ID="HiddenTagSetIdentifiers" runat="server"/>
<div class="entryFields">
<asp:TextBox runat="server" ID="TextAmount" CssClass="alignRight" />&#8203;<br/>
<Swarmops5:CurrencyAmount runat="server" ID="CurrencyAmount" />&#8203;<br/>
<asp:TextBox runat="server" ID="TextPurpose" />&#8203;<br/>
<Swarmops5:ComboBudgets ID="ComboBudgets" runat="server" />&nbsp;<br/>
<asp:Repeater ID="RepeaterTagDrop" runat="server"><ItemTemplate><span id="SpanDropTags<%# Eval("TagSetId") %>"><select class="easyui-combotree" url="/Automation/Json-TransactionTagsTree.aspx?TagSetId=<%# Eval("TagSetId") %>" name="DropTags<%# Eval("TagSetId") %>" id="DropTags<%# Eval("TagSetId") %>" animate="true" style="width:300px"></select></span>&nbsp;<br/></ItemTemplate></asp:Repeater>
@@ -104,8 +104,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
this.TextBank.Text = CurrentUser.BankName;
this.TextClearing.Text = CurrentUser.BankClearing;
this.TextAccount.Text = CurrentUser.BankAccount;
this.TextAmount.Text = 0.ToString ("N2");
this.TextAmount.Focus();
this.CurrencyAmount.Value = 0;
this.CurrencyAmount.Focus();
Localize();
}
@@ -144,9 +144,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
// The data has been validated client-side already. We'll throw unfriendly exceptions if invalid data is passed here.
// People who choose to disable JavaScript and then submit bad input almost deserve to be hurt.
double amount = Double.Parse (this.TextAmount.Text, NumberStyles.Number);
// parses in current culture - intentional
Int64 amountCents = (Int64) (amount*100.0);
Int64 amountCents = (Int64) (this.CurrencyAmount.Value*100.0);
string description = this.TextPurpose.Text;