Parcourir la source

Merge branch 'master' of ssh://10.10.101.21/source/mes-client

章政 il y a 7 ans
Parent
commit
bae44123af

+ 14 - 1
UAS-MES/Login.cs

@@ -11,6 +11,7 @@ using System.Threading;
 using System.Drawing.Drawing2D;
 using System.Drawing;
 using UAS_MES.Properties;
+using System.Globalization;
 
 namespace UAS_MES
 {
@@ -60,7 +61,7 @@ namespace UAS_MES
                 UserName.Select();
             BaseUtil.SetFormCenter(this);
         }
-
+ 
         private void LoadMaster()
         {
             try
@@ -73,6 +74,18 @@ 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);
             }
             catch (Exception ex)
             {

+ 66 - 0
UAS-MES/PublicMethod/SYSDATE.cs

@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace UAS_MES.PublicMethod
+{
+    class SYSDATE
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        public struct SYSTEMTIME
+        {
+            public ushort wYear;
+            public ushort wMonth;
+            public ushort wDayOfWeek;
+            public ushort wDay;
+            public ushort wHour;
+            public ushort wMinute;
+            public ushort wSecond;
+            public ushort wMilliseconds;
+
+            /// <summary>
+            /// 从System.DateTime转换。
+            /// </summary>
+            /// <param name="time">System.DateTime类型的时间。</param>
+            public void FromDateTime(DateTime time)
+            {
+                wYear = (ushort)time.Year;
+                wMonth = (ushort)time.Month;
+                wDayOfWeek = (ushort)time.DayOfWeek;
+                wDay = (ushort)time.Day;
+                wHour = (ushort)time.Hour;
+                wMinute = (ushort)time.Minute;
+                wSecond = (ushort)time.Second;
+                wMilliseconds = (ushort)time.Millisecond;
+            }
+            /// <summary>
+            /// 转换为System.DateTime类型。
+            /// </summary>
+            /// <returns></returns>
+            public DateTime ToDateTime()
+            {
+                return new DateTime(wYear, wMonth, wDay, wHour, wMinute, wSecond, wMilliseconds);
+            }
+            /// <summary>
+            /// 静态方法。转换为System.DateTime类型。
+            /// </summary>
+            /// <param name="time">SYSTEMTIME类型的时间。</param>
+            /// <returns></returns>
+            public static DateTime ToDateTime(SYSTEMTIME time)
+            {
+                return time.ToDateTime();
+            }
+        }
+        public class Win32API
+        {
+            [DllImport("Kernel32.dll")]
+            public static extern bool SetLocalTime(ref SYSTEMTIME Time);
+            [DllImport("Kernel32.dll")]
+            public static extern void GetLocalTime(ref SYSTEMTIME Time);
+        }
+    }
+}

+ 10 - 12
UAS_CustomerInterface/MesHelper.cs

@@ -1257,21 +1257,19 @@ namespace UAS.MES
         [Description("设置账套信息")]
         public bool SetMaster(string iMaster)
         {
-            for (int i = 0; i < MasterDB.Rows.Count; i++)
+            DataTable dt = (DataTable)ExecuteSql("select ms_pwd,ma_user,ma_inneraddress from master where ma_user='" + iMaster + "'", "select");
+            if (dt.Rows.Count > 0)
             {
-                if (MasterDB.Rows[i]["ma_user"].ToString() == iMaster)
+                ConnectionStrings = "Data Source=" + dt.Rows[0]["ma_inneraddress"].ToString() + "/orcl;User ID=" + iMaster + ";PassWord=" + dt.Rows[0]["ms_pwd"].ToString() + ";";
+                try
                 {
-                    ConnectionStrings = "Data Source=" + MasterDB.Rows[i]["ma_inneraddress"].ToString() + "/orcl;User ID=" + iMaster + ";PassWord=" + MasterDB.Rows[i]["ms_pwd"].ToString();
-                    try
-                    {
-                        connection = new OracleConnection(ConnectionStrings);
-                    }
-                    catch (Exception)
-                    {
-                        return false;
-                    }
-                    return true;
+                    connection = new OracleConnection(ConnectionStrings);
                 }
+                catch (Exception)
+                {
+                    return false;
+                }
+                return true;
             }
             return false;
         }

+ 12 - 14
UAS_MesInterface(4.0)/MesHelper.cs

@@ -13,7 +13,7 @@ namespace BenQGuru.eMES.DLLService
     [InterfaceType(ComInterfaceType.InterfaceIsDual)]
     public interface IMESHelper
     {
-        [DispId(14)]
+        [DispId(17)]
         bool CheckRoutePassed(string iSN, string iResCode, out string oErrMessage);
         bool GetRcardMOInfo(string iSN, out string oMoCode, out string oErrMessage);
         bool GetMaster(out string Master);
@@ -43,7 +43,7 @@ namespace BenQGuru.eMES.DLLService
         //用于存放批量执行的SQL
         List<string> sqls = new List<string>();
         //系统默认的的连接字符串
-        private string ConnectionStrings = "Data Source=117.25.180.218/orcl;User ID=MES;PassWord=select!#%*(;";
+        private string ConnectionStrings = "Data Source=192.168.230.200/orcl;User ID=MES;PassWord=select!#%*(;";
         //用户选择的数据库的连接字符串
         private OracleConnection connection;
         //用户选择的数据库的连接字符串
@@ -1192,21 +1192,19 @@ namespace BenQGuru.eMES.DLLService
         [Description("设置账套信息")]
         public bool SetMaster(string iMaster)
         {
-            for (int i = 0; i < MasterDB.Rows.Count; i++)
+            DataTable dt = (DataTable)ExecuteSql("select ms_pwd,ma_user,ma_inneraddress from master where ma_user='" + iMaster + "'", "select");
+            if (dt.Rows.Count > 0)
             {
-                if (MasterDB.Rows[i]["ma_user"].ToString() == iMaster)
+                ConnectionStrings = "Data Source=" + dt.Rows[0]["ma_inneraddress"].ToString() + "/orcl;User ID=" + iMaster + ";PassWord=" + dt.Rows[0]["ms_pwd"].ToString() + ";";
+                try
                 {
-                    ConnectionStrings = "Data Source="+ MasterDB.Rows[i]["ma_inneraddress"].ToString() + "/orcl;User ID=" + iMaster + ";PassWord=" + MasterDB.Rows[i]["ms_pwd"].ToString();
-                    try
-                    {
-                        connection = new OracleConnection(ConnectionStrings);
-                    }
-                    catch (Exception)
-                    {
-                        return false;
-                    }
-                    return true;
+                    connection = new OracleConnection(ConnectionStrings);
                 }
+                catch (Exception)
+                {
+                    return false;
+                }
+                return true;
             }
             return false;
         }

+ 10 - 12
UAS_MesInterface/MESHelper.cs

@@ -1106,21 +1106,19 @@ namespace BenQGuru.eMES.DLLService
 
         public bool SetMaster(string iMaster)
         {
-            for (int i = 0; i < MasterDB.Rows.Count; i++)
+            DataTable dt = (DataTable)ExecuteSql("select ms_pwd,ma_user,ma_inneraddress from master where ma_user='" + iMaster + "'", "select");
+            if (dt.Rows.Count > 0)
             {
-                if (MasterDB.Rows[i]["ma_user"].ToString() == iMaster)
+                ConnectionStrings = "Data Source=" + dt.Rows[0]["ma_inneraddress"].ToString() + "/orcl;User ID=" + iMaster + ";PassWord=" + dt.Rows[0]["ms_pwd"].ToString() + ";";
+                try
                 {
-                    ConnectionStrings = "Data Source=" + MasterDB.Rows[i]["ma_inneraddress"].ToString() + "/orcl;User ID=" + iMaster + ";PassWord=" + MasterDB.Rows[i]["ms_pwd"].ToString();
-                    try
-                    {
-                        connection = new OracleConnection(ConnectionStrings);
-                    }
-                    catch (Exception)
-                    {
-                        return false;
-                    }
-                    return true;
+                    connection = new OracleConnection(ConnectionStrings);
                 }
+                catch (Exception)
+                {
+                    return false;
+                }
+                return true;
             }
             return false;
         }