1 public string GetShiXian(string fadanshijian) 2 { 3 string result,chulishijian; 4 5 DateTime fdTime, dqTime; 6 TimeSpan ts; 7 int cha = 0; 8 9 // 获取配置文件中处理时限 10 chulishijian = "24"; // System.Configuration.ConfigurationManager.AppSettings["YibanAnJian"]; //小时 11 // 获取发单时间 12 fdTime = Convert.ToDateTime(fadanshijian); 13 // 设置完成时限 14 fdTime = fdTime.AddHours(Convert.ToInt32(chulishijian)); 15 // 获取当前时间 16 dqTime = DateTime.Now; 17 18 ts = fdTime - dqTime; 19 cha = dqTime.CompareTo(fdTime); 20 if (cha < 0) 21 { 22 result = "距离完成时限还有" + ts.Days + "天" + ts.Hours + "小时"; 23 } 24 else 25 { 26 result = "案件已超时" + Math.Abs(ts.Days) + "天" + Math.Abs(ts.Hours) + "小时"; 27 } 28 29 30 31 return result; 32 }