Deployed CurrencyTextBox; testing on Mono
This commit is contained in:
@@ -1 +1,5 @@
|
||||
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CurrencyTextBox.ascx.cs" Inherits="Swarmops.Frontend.Controls.v5.Financial.CurrencyTextBox" %>
|
||||
|
||||
<!-- TODO: Add nice autocomplete stuff -->
|
||||
|
||||
<asp:TextBox ID="Input" runat="server" CssClass="alignRight" />
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace Swarmops.Frontend.Controls.v5.Financial
|
||||
@@ -12,5 +13,31 @@ namespace Swarmops.Frontend.Controls.v5.Financial
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public double Value
|
||||
{
|
||||
get
|
||||
{
|
||||
// Try to parse the Double in two steps: first as a Culture.CurrentCulture, and if that doesn't work out, as a Culture.InvariantCulture.
|
||||
|
||||
double outParse = 0.0;
|
||||
string contents = Input.Text;
|
||||
|
||||
if (Double.TryParse (contents, NumberStyles.Currency, CultureInfo.CurrentCulture, out outParse))
|
||||
{
|
||||
return outParse;
|
||||
}
|
||||
if (Double.TryParse (contents, NumberStyles.Currency, CultureInfo.InvariantCulture, out outParse))
|
||||
{
|
||||
return outParse;
|
||||
}
|
||||
|
||||
// Unparsable. Sorry.
|
||||
|
||||
throw new InvalidCastException("The text field cannot be parsed to a Double: \"" + contents + "\"");
|
||||
|
||||
}
|
||||
set { this.Input.Text = value.ToString ("N2", CultureInfo.CurrentCulture); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="RequestCashAdvance.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Financial.RequestCashAdvance" %>
|
||||
<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %>
|
||||
<%@ Register TagPrefix="Swarmops5" TagName="CurrencyTextBox" Src="~/Controls/v5/Financial/CurrencyTextBox.ascx" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
|
||||
|
||||
@@ -20,7 +21,7 @@
|
||||
isValid = validateTextField('#<%=this.TextPurpose.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorPurpose" />") && isValid;
|
||||
|
||||
var jsonData = {};
|
||||
jsonData.amount = $('#<%=this.TextAmount.ClientID %>').val();
|
||||
jsonData.amount = $('#<%=this.TextAmount.ClientID %>_Input').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
@@ -33,7 +34,7 @@
|
||||
if (msg.d != true) {
|
||||
isValid = false;
|
||||
alertify.error("<asp:Literal runat="server" ID="LiteralErrorAmount" />");
|
||||
$('#<%=this.TextAmount.ClientID %>').addClass("entryError").focus();
|
||||
$('#<%=this.TextAmount.ClientID %>_Input').addClass("entryError").focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -59,7 +60,7 @@
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
|
||||
<h2><asp:Label ID="BoxTitle" runat="server" /></h2>
|
||||
<div class="entryFields">
|
||||
<asp:TextBox runat="server" ID="TextAmount" CssClass="alignRight" />​<br/>
|
||||
<Swarmops5:CurrencyTextBox runat="server" ID="TextAmount" CssClass="alignRight" />​<br/>
|
||||
<asp:TextBox runat="server" ID="TextPurpose" />​<br/>
|
||||
<Swarmops5:ComboBudgets ID="ComboBudgets" runat="server" /> <br/>
|
||||
<br/><!-- placeholder for label-side H2 -->
|
||||
|
||||
@@ -26,7 +26,7 @@ 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.Value = 0.0;
|
||||
this.TextAmount.Focus();
|
||||
|
||||
Localize();
|
||||
@@ -62,8 +62,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.
|
||||
|
||||
double amount = Double.Parse (this.TextAmount.Text, NumberStyles.Number);
|
||||
// parses in current culture - intentional
|
||||
double amount = this.TextAmount.Value;
|
||||
Int64 amountCents = (Int64) amount*100;
|
||||
|
||||
string description = this.TextPurpose.Text;
|
||||
|
||||
Reference in New Issue
Block a user