请教各位大哥一个C#问题

来源:百度知道 编辑:UC知道 时间:2024/05/31 04:45:58
最近工厂里管出勤的一位同事委托我写一个统计加班的程序(我是厂里的网管),头都疼S。我自学过点C#的编程,所以我想用C#来编写,但遇到很大的一个问题。希望各位前辈能帮下小弟!
(惨了,不能上传图片,望有人帮忙)
程序的界面里只有3个textbox,分别命名为:tb1,tb2,tb3和一个按钮btn1;
代码如下:
namespace Timer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void DifTime()
{
string oldtime = tb1.Text;
string nowtime = tb2.Text;
try
{
DataTime old = DataTime.Parse(oldtime);
DataTime now = DataTime.Parse(nowtime);
if (old > now)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "s", " <script>alert('输入 错误!第一个文本框的时间比第二个文本框的时间早。按确定

string oldtime = "2009-12-3 12:12:12";
string nowtime = "2009-12-2 13:11:11";

DateTime old = DateTime.Parse(oldtime);
DateTime now = DateTime.Parse(nowtime);

//开始时间
TimeSpan oldTime = new TimeSpan(old.Ticks);
//结束时间
TimeSpan nowTime = new TimeSpan(now.Ticks);
//时间间隔
TimeSpan ts = oldTime.Subtract(nowTime);
if (ts.TotalMilliseconds <= 0)
{
Response.Write("错误时间");
}

是DateTime 不是DataTime!!!!

一楼说对了

你呀。。。。。。