public bool GetDeviceTime(int dwMachineNumber, ref int dwYear, ref int dwMonth, ref int dwDay, ref int dwHour, ref int dwMinute, ref int dwSecond)
 {
     return(objCZKEM.GetDeviceTime(dwMachineNumber, ref dwYear, ref dwMonth, ref dwDay, ref dwHour, ref dwMinute, ref dwSecond));
 }
Exemple #2
0
        private void prcGetTime()
        {
            ArrayList arQuery = new ArrayList();

            GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection();

            string sqlQuery = "", DeviceIP = "", GetDeviceIP = "";
            Int32  NewId = 0;
            Int32  RowID;

            string DeviceIp = "", pDate = "", pTime = "";

            int idwYear = 0, idwMonth = 0, idwDay = 0;
            int idwHour = 0, idwMinute = 0, idwSecond = 0;

            int idwErrorCode = 0;


            try
            {
                //Data Clear
                sqlQuery = "Truncate table tblTempCount_GTR";
                arQuery.Add(sqlQuery);
                clsCon.GTRSaveDataWithSQLCommand(arQuery);


                foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.gridDetails.Rows)
                {
                    if (row.Cells["Id"].Text.ToString().Length != 0 &&
                        row.Cells["isChecked"].Value.ToString() == "1" && row.Cells["Active"].Value.ToString() == "1")
                    {
                        GetDeviceIP = "" + row.Cells["IpAddress"].Text.ToString() + "";

                        bIsConnected = axCZKEM1.Connect_Net(GetDeviceIP, 4370);
                        if (bIsConnected == true)
                        {
                            iMachineNumber = 1;
                            axCZKEM1.RegEvent(iMachineNumber, 65535);
                        }

                        Cursor = Cursors.WaitCursor;
                        if (axCZKEM1.GetDeviceTime(iMachineNumber, ref idwYear, ref idwMonth, ref idwDay, ref idwHour, ref idwMinute, ref idwSecond))
                        {
                            DeviceIp = GetDeviceIP;
                            pDate    = idwYear + "-" + idwMonth + "-" + idwDay;
                            pTime    = idwHour + ":" + idwMinute + ":" + idwSecond;

                            sqlQuery = "Insert into tblTempCount_GTR(ComId,IpAddress,dtDate,dtTime) values(" + Common.Classes.clsMain.intComId + ",'" +
                                       DeviceIp + "','" + pDate + "','" + pTime + "')";
                            arQuery.Add(sqlQuery);
                        }
                        else
                        {
                            axCZKEM1.GetLastError(ref idwErrorCode);
                            MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error");
                        }
                        Cursor = Cursors.Default;
                    }

                    axCZKEM1.Disconnect();
                }

                clsCon.GTRSaveDataWithSQLCommand(arQuery);

                prcGetDate();
            }

            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                arQuery = null;
                clsCon  = null;
            }
        }