时间加法计算器

Default.aspx.cs

 

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;

Default.aspx.cs

 

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        txtDateTime.Text = DateTime.Now.ToString();
        lblResult.Text = "";
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        int intM = Convert.ToInt32(txtMinute.Text);
        int intH = Convert.ToInt32(txtHour.Text);
        int intD = Convert.ToInt32(txtDay.Text);
        //lblResult.Text = Convert.ToDateTime(txtDateTime.Text).AddMinutes(intM).ToString();
        lblResult.Text = Convert.ToDateTime(txtDateTime.Text).AddHours(intH).AddMinutes(intM).AddDays(intD).ToString();
    }
}
 

 

default.aspx

 

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>时间加法计算器</title>
</head>
<body>
    <p>
        时间加法器</p>
    <p>
        &nbsp;</p>
    <form id="form1" runat="server">
    <div>
   
        当前时间:<asp:TextBox ID="txtDateTime" runat="server" ></asp:TextBox>
        <br />
        <br />
        增加的时间:<br />
        分钟:<asp:TextBox ID="txtMinute" runat="server">0</asp:TextBox>
        小时:<asp:TextBox ID="txtHour" runat="server">0</asp:TextBox>
&nbsp;天:<asp:TextBox ID="txtDay" runat="server">0</asp:TextBox>
        <br />
        <br />
        <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="执行计算" />
        <br />
        <br />
        <br />
        <asp:Label ID="lblResult" runat="server" Text="Label"></asp:Label>
        <br />
   
    </div>
    </form>
</body>
</html>
 

发表评论

电子邮件地址不会被公开。 必填项已用*标注