Exemple #1
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,
                                     Common.CnvNullToInt(txtPort.Text),
                                     Common.CnvNullToInt(txtAlarmValue.Text),
                                     Common.CnvNullToInt(txtPeriod.Text),
                                     Common.CnvNullToInt(txtFailLevel.Text),
                                     Common.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;
                    Common.ShowMsg(MessageBoxIcon.Information, MSG_SAVE_SETTING_SUCCESS);
                }
                else
                {
                    Common.ShowMsg(MessageBoxIcon.Error, MSG_SAVE_SETTING_ERR);
                }
            }
        }
Exemple #2
0
 private void btResetDefault_Click(object sender, EventArgs e)
 {
     if (Common.ComfirmMsg(MSG_COMFIRM_RESET))
     {
         using (var objDb = new clsDBUltity())
         {
             if (!objDb.ResetDefauleDevice(_deviceid, _devicetype))
             {
                 Common.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;
         }
     }
 }
Exemple #3
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 (Common.ModeApp != Common.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));
                }
            }
        }