Beispiel #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtGroupName.Text == string.Empty)
                {
                    txtGroupName.Select();
                    MessageBox.Show("组名称不能为空!", Constants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (!DataValidation.IsWindowsFileName(txtGroupName.Text))
                {
                    txtGroupName.Select();
                    MessageBox.Show("组名称不能包含下列任何字符之一:\r\n\\/:*?\"<>|", Constants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                this.Cursor = Cursors.WaitCursor;
                _groupname  = txtGroupName.Text;

                string ret = ConfigCtrl.AddGroup(_groupname);
                if (ret != Constants.STATUS_SUCCESS)
                {
                    MessageBox.Show(ret, Constants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtGroupName.Select();
                    return;
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                ErrorHandler.ShowMessageBox(TreeConstants.EXCEPTION_MODULE, ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }