Example #1
0
        private void btnSaveSetting_Click(object sender, EventArgs e)
        {
            var deviceManagement  = (DeviceManagement)sender;
            var gridDevice        = deviceManagement.GridDeviceSelected;
            var swapDevice        = deviceManagement.SwapDeviceSelected;
            var swapOrdinalDevice = deviceManagement.SwapOrdinalDisplayDevice;

            using (var objDb = new clsDBUltity())
            {
                if (objDb.SaveDevice(gridDevice) && objDb.SaveDevice(swapDevice) && objDb.SaveDevice(swapOrdinalDevice))
                {
                    this.dvcManagement.SetListDevice(deviceManagement.ListDevice);
                    this.ChangeSetting = true;
                    ShowMsg(MessageBoxIcon.Information, MSG_SAVE_SETTING_SUCCESS);
                }
                else
                {
                    ShowMsg(MessageBoxIcon.Error, MSG_SAVE_SETTING_ERR);
                }
            }
        }
Example #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);
                }
            }
        }
Example #3
0
        public void UpdateListDevice(List <DeviceInfo> lstDevice)
        {
            using (var objDb = new clsDBUltity())
            {
                try
                {
                    foreach (var device in lstDevice)
                    {
                        if (!string.IsNullOrEmpty(device.MacAddress))
                        {
                            objDb.SaveDevice(device);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }

            FormSetting?.LoadInfoDevice();
        }