Ejemplo n.º 1
0
        //录入设备
        private void Add_NewEquipment(object sender, RoutedEventArgs e)
        {
            AddEquipment add = new AddEquipment(); ;
            EquipmentClass equip = new EquipmentClass();
            RoomClass room = new RoomClass();
            MySqlDataReader roomReader = room.queryRoomsName();
            MySqlDataReader typeReader = room.getTypeList();
            MySqlDataReader reader = equip.getMaxId();
            if (reader.Read())
            {
                // ReaderAndWriterConnection EpcNumber = new ReaderAndWriterConnection();
                int i = 1;
                if (reader["ID"].ToString().Equals("") || reader["ID"] == null)
                {

                    add.ID.Content = i;

                    add.numberStr.Text = ReaderAndWriterConnection.getEPCCode(i);

                }
                else
                {
                    add.ID.Content = reader["ID"];
                    add.numberStr.Text = ReaderAndWriterConnection.getEPCCode(int.Parse(reader["ID"].ToString()));

                }
            }
            ComboBox rooms = add.roomBox;
            ComboBoxItem check = new ComboBoxItem();
            check.Content = "请选择...";
            check.Tag = "";
            check.IsSelected = true;
            rooms.Items.Add(check);
            while (roomReader.Read())
            {
                check = new ComboBoxItem();
                check.Content = roomReader["ROOM_NAME"];
                check.Tag = roomReader["ID"];
                rooms.Items.Add(check);
            }
            ComboBox types = add.typeBox;
            ComboBoxItem checkType = new ComboBoxItem();
            checkType.Content = "请选择...";
            checkType.Tag = "";
            checkType.IsSelected = true;
            types.Items.Add(checkType);
            while (typeReader.Read())
            {
                if (int.Parse(typeReader["ID"].ToString()) == 4)
                {
                    continue;
                }
                else
                {
                    ComboBoxItem TypeItems = new ComboBoxItem();
                    TypeItems.Content = typeReader["TYPE_NAME"];
                    TypeItems.Tag = typeReader["ID"];
                    types.Items.Add(TypeItems);
                }
            }
            add.Owner = Window.GetWindow(this);
            add.ShowDialog();
        }