Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //名称
            if (textBox1.Text.Trim().Equals(""))
            {
                MessageBox.Show("名称不可以为空!");
                return;
            }
            //操作系统
            int osid = -1;

            if (comboBox1.SelectedIndex >= 0)
            {
                foreach (SysguardWS.OsTypeInfo info in osTypeInfo.Values)
                {
                    if (info.osName.Equals(comboBox1.SelectedItem.ToString()))
                    {
                        osid = info.osId;
                        break;
                    }
                }
                if (osid < 0)
                {
                    MessageBox.Show("未找到操作系统!");
                    return;
                }
            }
            else
            {
                MessageBox.Show("请选择操作系统!");
                return;
            }
            sysguard.SysguardWS.GroupInfo group = new sysguard.SysguardWS.GroupInfo();
            group.description = this.textBox2.Text;
            group.groupName   = this.textBox1.Text;
            group.inputTime   = DateTime.Today;
            group.osId        = osid;

            DataLayerResult result = dataLayer.AddGroup(group);

            if (result == DataLayerResult.Success)
            {
                DialogResult resultDialo = MessageBox.Show("群组添加成功,是否退出?", "添加成功!", MessageBoxButtons.YesNo);
                if (resultDialo == DialogResult.Yes)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                else
                {
                    reset();
                    groupControl.Flush();
                }
            }
            else if (result == DataLayerResult.GroupNameAlreadyExist)
            {
                MessageBox.Show("群组名已经存在无法添加!", "添加群组失败", MessageBoxButtons.OK);
                this.textBox1.Text = string.Empty;
                this.textBox1.Focus();
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //名称
            if (this.textBox1.Text.Trim().Equals(""))
            {
                MessageBox.Show("名称不能为空!");
                return;
            }

            //描述
            if (this.textBox2.Text.Trim().Equals(""))
            {
                MessageBox.Show("描述不能为空!");
                return;
            }
            //操作系统
            if (this.comboBox1.SelectedIndex < 0)
            {
                MessageBox.Show("请选择操作系统!");
                return;
            }
            //ostype
            sysguard.SysguardWS.GroupInfo groupInfo = new sysguard.SysguardWS.GroupInfo();

            DataLayerResult result = dataLayer.GetAllOsTypeInfo();

            int osid = -1;

            foreach (sysguard.SysguardWS.OsTypeInfo info in dataLayer.OsTypeInfoList.Values)
            {
                if (this.comboBox1.Text.Equals(info.osName))
                {
                    osid = info.osId;

                    break;
                }
            }

            if (osid < 0)
            {
                MessageBox.Show("请选择操作系统!");
                return;
            }
            else
            {
                groupInfo.osId = osid;
            }

            //
            groupInfo.groupId     = group_id;
            groupInfo.groupName   = this.textBox1.Text;
            groupInfo.description = this.textBox2.Text;

            DataLayerResult result2 = dataLayer.ModifyGroupInf(groupInfo);

            if (result2 == DataLayerResult.Success)
            {
                DialogResult resultDialo = MessageBox.Show("群组修改成功,是否退出?", "修改成功!", MessageBoxButtons.YesNo);

                if (resultDialo == DialogResult.Yes)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                else
                {
                    groupControl.Flush();
                    GetData();
                }
            }
        }