Esempio n. 1
0
        // 分配记录仪
        private void btnImportRec_Click(object sender, EventArgs e)
        {
            if (treeList1.Selection != null)
            {
                if (treeList1.Selection.Count == 0)
                {
                    return;
                }
                if (treeList1.Selection[0].Level == 1)
                {
                    return;
                }

                if (listBoxRec.Items.Count == 0)
                {
                    XtraMessageBox.Show("当前无记录仪可分配!", GlobalValue.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (listBoxRec.SelectedItems.Count == 0)
                {
                    XtraMessageBox.Show("请选择需要分配的记录仪!", GlobalValue.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                NoiseRecorderGroup gp = (from temp in GlobalValue.groupList
                                         where temp.ID == Convert.ToInt32(treeList1.Selection[0].GetValue("Name"))
                                         select temp).ToList()[0];
                if (gp == null)
                {
                    return;
                }

                for (int i = 0; i < listBoxRec.SelectedItems.Count; i++)
                {
                    NoiseRecorder tmp = (from item in GlobalValue.recorderList.AsEnumerable()
                                         where item.ID.ToString() == listBoxRec.SelectedItems[i].ToString()
                                         select item).ToList()[0];

                    tmp.GroupState = 1;
                    NoiseDataBaseHelper.AddRecorderGroupRelation(tmp.ID, gp.ID);
                    NoiseDataBaseHelper.UpdateRecorder(tmp);
                }

                gp.RecorderList          = NoiseDataBaseHelper.GetRecordersByGroupId(gp.ID);
                GlobalValue.recorderList = NoiseDataBaseHelper.GetRecorders();
                BindTree();
                BindListBox();
            }
        }
Esempio n. 2
0
        private void btnImportApply_Click(object sender, EventArgs e)
        {
            NoiseRecorderGroup gp = (from temp in GlobalValue.groupList
                                     where temp.ID == Convert.ToInt32(btnImportRec.Tag)
                                     select temp).ToList()[0];

            for (int i = 0; i < listBoxRec.SelectedItems.Count; i++)
            {
                NoiseRecorder tmp = (from item in GlobalValue.recorderList.AsEnumerable()
                                     where item.ID.ToString() == listBoxRec.SelectedItems[i].ToString()
                                     select item).ToList()[0];

                tmp.GroupState = 1;
                NoiseDataBaseHelper.AddRecorderGroupRelation(tmp.ID, gp.ID);
                NoiseDataBaseHelper.UpdateRecorder(tmp);
            }

            gp.RecorderList          = NoiseDataBaseHelper.GetRecordersByGroupId(gp.ID);
            GlobalValue.recorderList = NoiseDataBaseHelper.GetRecorders();
            BindTree();
            listBoxRec.Items.Clear();
        }