コード例 #1
0
        /// <summary>
        /// 保存Keypad Setting
        /// </summary>
        private void SaveKeypadSet()
        {
            new SystemData().GetKeypadList();

            for (int i = 0; i < 10; i++)
            {
                KeypadInfo keypadInfo = new KeypadInfo();
                keypadInfo.KeyName = @"Key" + (i + 1);
                keypadInfo.KeyCode = txtKey[i].Text;

                try
                {
                    if (CommonData.Keypad.Any(s => s.KeyName.Equals(keypadInfo.KeyName)))
                    {
                        keypadInfo.ID = CommonData.Keypad.FirstOrDefault(s => s.KeyName.Equals(keypadInfo.KeyName)).ID;
                        _control.UpdateEntity(keypadInfo);
                    }
                    else
                    {
                        _control.AddEntity(keypadInfo);
                    }
                }
                catch (Exception ex) { LogHelper.Error(this.Name, ex); }
            }
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtKeyName.Text))
            {
                CommonTool.ShowMessage("Keypad Name can not NULL!");
                return;
            }

            if (string.IsNullOrEmpty(txtKeyCode.Text))
            {
                CommonTool.ShowMessage("Keypad Name can not NULL!");
                return;
            }

            new SystemData().GetKeypadList();

            KeypadInfo keypadInfo = new KeypadInfo();

            keypadInfo.KeyName = txtKeyName.Text;
            keypadInfo.KeyCode = txtKeyCode.Text;

            try
            {
                if (isAdd)
                {
                    _control.AddEntity(keypadInfo);
                    isAdd = false;
                }
                else
                {
                    keypadInfo.ID = Convert.ToInt32(gvKeypad.GetRowCellValue(gvKeypad.FocusedRowHandle, "ID"));
                    _control.UpdateEntity(keypadInfo);
                }

                BindData();
            }
            catch (Exception ex) { LogHelper.Error(this.Name, ex); }

            CommonTool.ShowMessage("Save successful!");
        }