Ejemplo n.º 1
0
        private void addGroupButton_Click(object sender, EventArgs e)
        {
            string orgin    = "填写或选择分组";
            bool   divCal   = false;
            int    DBNameID = 0;

            if (filOrChoGroupComboBox.Text != orgin)
            {
                if (!filOrChoGroupComboBox.Items.Contains(filOrChoGroupComboBox.Text) &&
                    filOrChoGroupComboBox.Text != "")
                {
                    using (DbConnection conn = new DbConnection())
                    {
                        DataBaseNameDic.GetDataBaseNameDic();
                        List <DataBaseName> dataBaseNameList = DataBaseNameDic.GetDataBaseNameDic().GetAllBaseNames();

                        for (int i = 0; i < dataBaseNameList.Count; i++)
                        {
                            if (DBLocation == dataBaseNameList[i].Location)
                            {
                                DBNameID = Convert.ToInt32(dataBaseNameList[i].ID);
                            }
                        }

                        int safetypeid = -1;

                        foreach (IDandName idandName in IdName)
                        {
                            if (idandName.Name == safeTypeComboBox.Text)
                            {
                                safetypeid = idandName.ID;
                            }
                        }
                        if (divCalCheckBox.Checked)
                        {
                            divCal = true;
                        }

                        GroupInfo group = new GroupInfo()
                        {
                            GroupName            = filOrChoGroupComboBox.Text,
                            DataBaseID           = DBNameID,
                            Safetyfactortypeid   = safetypeid,
                            CombinationCalculate = divCal
                        };
                        int groupId = GroupInfosDic.GetGroupInfoDic().CheckAdd(group);
                        if (AddSensorToGroup(groupId))
                        {
                            MessageBox.Show("添加成功");
                        }
                    }
                }
            }
            InitlizeFilOrChoGroupComboBox();
        }
Ejemplo n.º 2
0
        private void btnRemoveGroup_Click(object sender, EventArgs e)
        {
            if (filOrChoGroupComboBox.Text != "")
            {
                int groupId = 0;
                using (DbConnection conn = new DbConnection())
                {
                    List <GroupInfo> groupList = GroupInfosDic.GetGroupInfosDic().GetDic().Values.ToList();
                    for (int i = 0; i < groupList.Count; i++)
                    {
                        if (filOrChoGroupComboBox.Text == groupList[i].GroupName)
                        {
                            groupId = Convert.ToInt32(groupList[i].GroupID);
                            if (GroupInfosDic.GetGroupInfoDic().Delete(Convert.ToInt32(groupList[i].GroupID)))
                            {
                                MessageBox.Show(@"组删除成功");
                            }
                            break;
                        }
                        if (i == groupList.Count)
                        {
                            MessageBox.Show(@"组不存在");
                        }
                    }
                    if (groupList.Count == 0)
                    {
                        MessageBox.Show(@"还未添加组");
                    }
                }
                //组删除的同时删除掉组中的传感器

                List <GroupSensors> sensorsList = GroupSensorInfoDic.GetGroupInfosDic().GetDic().Values.ToList();
                bool ret = false;
                foreach (GroupSensors sensors in sensorsList)
                {
                    if (sensors.GroupID == groupId)
                    {
                        ret = GroupSensorInfoDic.GetGroupInfosDic().Delete(Convert.ToInt32(sensors.ID));
                    }
                }
                if (ret)
                {
                    MessageBox.Show(@"传感器删除成功");
                }
            }
            else
            {
                MessageBox.Show(@"请选择组名");
            }
            InitlizeFilOrChoGroupComboBox();
        }
Ejemplo n.º 3
0
 public void InitlizeFilOrChoGroupComboBox()
 {
     filOrChoList.Clear();
     using (DbConnection conn = new DbConnection())
     {
         List <GroupInfo> list = GroupInfosDic.GetGroupInfoDic().GetAllGroups();
         for (int i = 0; i < list.Count; i++)
         {
             filOrChoList.Add(list[i].GroupName);
         }
     }
     filOrChoSorSource.DataSource     = filOrChoList;
     filOrChoGroupComboBox.DataSource = filOrChoSorSource;
     filOrChoSorSource.ResetBindings(true);
     filOrChoGroupComboBox.SelectedIndex = -1;
 }
Ejemplo n.º 4
0
 public void InitlizeDic()
 {
     groupInfoDic      = GroupInfosDic.GetGroupInfoDic().GetDic();
     groupSensorsesDic = GroupSensorInfoDic.GetGroupInfosDic().GetDic();
 }