Browse Source

时间修改方法回退

Hcsy 7 years ago
parent
commit
251d4d0d92
1 changed files with 17 additions and 12 deletions
  1. 17 12
      UAS-MES/Login.cs

+ 17 - 12
UAS-MES/Login.cs

@@ -74,18 +74,23 @@ namespace UAS_MES
                 DB.ValueMember = "db_user";
                 DB.Text = BaseUtil.GetCacheData("LastLoginSob").ToString();
                 LoginButton.Enabled = true;
-
-                string nowtime = dh.getFieldDataByCondition("dual", "to_char(sysdate,'yyyy-MM-dd HH24:mm:ss')", "1=1").ToString();
-                //取得数据库时间
-                DateTime dt;
-                DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
-                dtFormat.ShortDatePattern = "yyyy-MM-dd hh:mm:ss";
-                dt = Convert.ToDateTime(nowtime, dtFormat);
-                //转换System.DateTime到SYSTEMTIME
-                SYSDATE.SYSTEMTIME st = new SYSDATE.SYSTEMTIME();
-                st.FromDateTime(dt);
-                //调用Win32 API设置系统时间
-                SYSDATE.Win32API.SetLocalTime(ref st);
+                //获取数据库时间与系统当前时间比较
+                //string nowtime = dh.getFieldDataByCondition("dual", "to_char(sysdate,'yyyy-MM-dd HH24:mm:ss')", "1=1").ToString();
+                //string sysdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                ////系统当前时间如果小于数据库时间则更新至数据库时间
+                //if (nowtime.CompareTo(sysdate) > 0)
+                //{
+                //    //取得数据库时间
+                //    DateTime dt;
+                //    DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
+                //    dtFormat.ShortDatePattern = "yyyy-MM-dd hh:mm:ss";
+                //    dt = Convert.ToDateTime(nowtime, dtFormat);
+                //    //转换System.DateTime到SYSTEMTIME
+                //    SYSDATE.SYSTEMTIME st = new SYSDATE.SYSTEMTIME();
+                //    st.FromDateTime(dt);
+                //    //调用Win32 API设置系统时间
+                //    SYSDATE.Win32API.SetLocalTime(ref st);
+                //}
             }
             catch (Exception ex)
             {