示例#1
0
        public List <DeviceInfo> GetListDevice()
        {
            lstDeviceInfo = new List <DeviceInfo>();

            using (var objDb = new clsDBUltity())
            {
                var deviceInfo = objDb.GetDeviceList();

                if (clsCommon.TableIsNullOrEmpty(deviceInfo))
                {
                    return(lstDeviceInfo);
                }

                foreach (DataRow row in deviceInfo.Rows)
                {
                    var device = new DeviceInfo();
                    device.DeviceId       = clsCommon.CnvNullToInt(row["device_id"]);
                    device.DeviceName     = clsCommon.CnvNullToString(row["device_name"]);
                    device.IpAddress      = clsCommon.CnvNullToString(row["ip_address"]).Trim();
                    device.Port           = clsCommon.CnvNullToInt(row["port"]);
                    device.AlarmValue     = clsCommon.CnvNullToInt(row["alarm_value"]);
                    device.Period         = clsCommon.CnvNullToInt(row["period"]);
                    device.FailLevel      = clsCommon.CnvNullToInt(row["fail_level"]);
                    device.Samples        = clsCommon.CnvNullToInt(row["samples"]);
                    device.WalkingMode    = clsCommon.CnvNullToInt(row["walking_mode"]) > 0;
                    device.OrdinalDisplay = clsCommon.CnvNullToInt(row["ordinal_display"]);
                    device.Active         = clsCommon.CnvNullToInt(row["active"]) > 0;
                    device.MacAddress     = clsCommon.CnvNullToString(row["mac_address"]);

                    lstDeviceInfo.Add(device);
                }

                return(lstDeviceInfo);
            }
        }
示例#2
0
        private void btSaveSetting_Click(object sender, EventArgs e)
        {
            if (!xValidateInputDevice())
            {
                return;
            }

            using (var objDb = new clsDBUltity())
            {
                var emDeviceType = clsDBUltity.emDeviceType.None;

                if (_devicetype == (int)clsDBUltity.emDeviceType.Device1)
                {
                    emDeviceType = clsDBUltity.emDeviceType.Device1;
                }
                else if (_devicetype == (int)clsDBUltity.emDeviceType.Device2)
                {
                    emDeviceType = clsDBUltity.emDeviceType.Device2;
                }

                if (objDb.SaveDevice(_deviceid,
                                     txtDeviceName.Text,
                                     txtIpAddress.Text,
                                     clsCommon.CnvNullToInt(txtPort.Text),
                                     clsCommon.CnvNullToInt(txtAlarmValue.Text),
                                     clsCommon.CnvNullToInt(txtPeriod.Text),
                                     clsCommon.CnvNullToInt(txtFailLevel.Text),
                                     clsCommon.CnvNullToInt(txtSamples.Text),
                                     chkActive.Checked,
                                     emDeviceType))
                {
                    var intColumnIndexCurrent = grvDevice.CurrentCell.ColumnIndex;
                    var intRowIndexCurrent    = grvDevice.CurrentCell.RowIndex;
                    grvDevice.DataSource = objDb.GetDeviceList();
                    grvDevice_CellClick(grvDevice, new DataGridViewCellEventArgs(intColumnIndexCurrent, intRowIndexCurrent));
                    _changeSetting = true;
                    ShowMsg(MessageBoxIcon.Information, MSG_SAVE_SETTING_SUCCESS);
                }
                else
                {
                    ShowMsg(MessageBoxIcon.Error, MSG_SAVE_SETTING_ERR);
                }
            }
        }
示例#3
0
 private void btResetDefault_Click(object sender, EventArgs e)
 {
     if (ComfirmMsg(MSG_COMFIRM_RESET))
     {
         using (var objDb = new clsDBUltity())
         {
             if (!objDb.ResetDefauleDevice(_deviceid, _devicetype))
             {
                 ShowMsg(MessageBoxIcon.Error, MSG_RESET_SETTING_ERR);
                 return;
             }
             var intColumnIndexCurrent = grvDevice.CurrentCell.ColumnIndex;
             var intRowIndexCurrent    = grvDevice.CurrentCell.RowIndex;
             grvDevice.DataSource = objDb.GetDeviceList();
             grvDevice_CellClick(grvDevice, new DataGridViewCellEventArgs(intColumnIndexCurrent, intRowIndexCurrent));
             _changeSetting = true;
         }
     }
 }
示例#4
0
        private void IntForm()
        {
            // Limit resize form
            this.MinimumSize = this.Size;
            this.MaximumSize = Screen.PrimaryScreen.Bounds.Size;

            grvUser.AutoGenerateColumns   = false;
            grvDevice.AutoGenerateColumns = false;
            txtPort.KeyPress       += onlyInputNumber;
            txtAlarmValue.KeyPress += onlyInputNumber;
            txtPeriod.KeyPress     += onlyInputNumber;
            txtFailLevel.KeyPress  += onlyInputNumber;
            txtSamples.KeyPress    += onlyInputNumber;

            tabMngt.TabPages.Remove(tabUsers);

            if (clsConfig.ModeApp != clsConfig.emModeApp.Admin)
            {
                tabMngt.TabPages.Remove(tabSetting);
                this.MaximizeBox     = false;
                this.MinimizeBox     = false;
                this.FormBorderStyle = FormBorderStyle.FixedDialog;
            }
            else
            {
                tabMngt.TabPages.Remove(tabChangePassword);
            }

            using (var objDb = new clsDBUltity())
            {
                grvDevice.DataSource = objDb.GetDeviceList();
                grvDevice.ClearSelection();
                if (grvDevice.Rows.Count > 0)
                {
                    grvDevice.Rows[0].Selected = true;
                    grvDevice_CellClick(grvDevice, new DataGridViewCellEventArgs(0, 0));
                }
            }
        }
示例#5
0
        public DeviceInfo[] GetListDevice()
        {
            var listDeviceInfo = new DeviceInfo[2];

            using (var objDb = new clsDBUltity())
            {
                var deviceInfo = objDb.GetDeviceList(false);

                if (clsCommon.TableIsNullOrEmpty(deviceInfo))
                {
                    return(listDeviceInfo);
                }

                var i = -1;

                foreach (DataRow row in deviceInfo.Rows)
                {
                    i++;

                    if (i > 1)
                    {
                        break;
                    }

                    listDeviceInfo[i].deviceId   = clsCommon.CnvNullToInt(row["device_id"]);
                    listDeviceInfo[i].deviceType = clsCommon.CnvNullToInt(row["device_type"]);
                    listDeviceInfo[i].ipAddress  = clsCommon.CnvNullToString(row["ip_address"]).Trim();
                    listDeviceInfo[i].port       = clsCommon.CnvNullToInt(row["port"]);
                    listDeviceInfo[i].AlarmValue = clsCommon.CnvNullToInt(row["alarm_value"]);
                    listDeviceInfo[i].period     = clsCommon.CnvNullToInt(row["period"]);
                    listDeviceInfo[i].failLevel  = clsCommon.CnvNullToInt(row["fail_level"]);
                    listDeviceInfo[i].samples    = clsCommon.CnvNullToInt(row["samples"]);
                    listDeviceInfo[i].active     = clsCommon.CnvNullToInt(row["active"]) > 0;
                }

                return(listDeviceInfo);
            }
        }