请帮助我,我已经陷入这些问题几天了.我有一个Web表单,将在asp.net中付款,语言是C#.
文本框用于接受来自用户的货币金额.我的要求是,如果用户输入例如75,则在_TextChanged事件中它将切换到75.00.我得到了这部分工作.但我的代码没有检查位置后的三个字符.并删除多余的零.我的问题:1.如果输入超过小数点后的两位数,如何删除多余的零?2.如果用户未在文本框中输入任何数字,我该怎么办?我试过,我只是得到错误或它弄乱了整个代码.
protected void txtAmount_TextChanged(object sender, EventArgs e)
{
string textBoxData = txtAmount.Text;
int textLength = textBoxData.Length;
int position = txtAmountToPay.Text.IndexOf("."); //Position is the decimal
if (position == -1)
{
textBoxData = textBoxData + ".50"; // when you enter 75 you get 75.50
}
if (position == textLength -2 )
{
textBoxData = textBoxData + "4"; // when you enter 75.0 you get 75.04
}
if (position == textLength -1)
{
textBoxData = textBoxData + "30"; // when you enter …Run Code Online (Sandbox Code Playgroud) 我正在构建一个SSIS包,我需要从前一天下午4:15:01到今天下午4:15:00获取数据,但到目前为止,我知道的唯一查询是如何获得这一天之前.我不知道如何在同一个查询中添加小时,分钟和秒.有人可以告诉我如何在这个SQL查询中添加小时,分钟和秒吗?以下是我到目前为止的查询.
SELECT Posted_Date, Total_Payment FROM
Table1
WHERE Posted_Date >= dateadd(day, datediff(day, 1, Getdate()), 0)
and Posted_date < dateadd(day, datediff(day, 0, getdate()), 0)
order by posted_date
Run Code Online (Sandbox Code Playgroud) 我有这个只有一行的文本文件.每个文件包含一个客户名称,但包含多个项目和描述.
以00(公司名称)开头的记录的字符长度为10
01(项目编号) - 字符长度为10
02(描述) - 字符长度为50
我知道如何读取文件,但我不知道如何只循环一行,查找记录00,01,02并根据长度抓取文本,最后从最后记录的位置开始并再次启动循环.有人可以告诉我如何读取这样的文件吗?
输出:
companyName 16622 Description
companyName 15522 Description
Run Code Online (Sandbox Code Playgroud)
输入文本文件示例
00Init 0115522 02Description 0116622 02Description
Run Code Online (Sandbox Code Playgroud)