コード例 #1
0
        private void btnAddGroup_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtGroupName.Text) || string.IsNullOrEmpty(txtGroupNote.Text))
                {
                    XtraMessageBox.Show("分组名称/分组备注未输入!", GlobalValue.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                NoiseRecorderGroup newGrp = new NoiseRecorderGroup();
                newGrp.ID     = NoiseDataBaseHelper.GetGroupID();
                newGrp.Name   = txtGroupName.Text;
                newGrp.Remark = txtGroupNote.Text;
                int query = NoiseDataBaseHelper.AddGroup(newGrp);

                if (query != -1)
                {
                    GlobalValue.groupList = NoiseDataBaseHelper.GetGroups();
                    BindTree();
                }
                else
                {
                    throw new Exception("数据入库发生错误。");
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("添加失败:" + ex.Message, GlobalValue.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }