//编辑新添加设备 private void Edit_Click(object sender, RoutedEventArgs e) { EditEquipments edit = new EditEquipments(); var a = this.comingGrild.SelectedItem; var b = a as DataRowView; int _Eid = Convert.ToInt32(b.Row[0]); EquipmentClass _Eclass = new EquipmentClass(); RoomClass room = new RoomClass(); MySqlDataReader reader = _Eclass.editNewEquipment(_Eid); ComboBox rooms = edit.roomBox; ComboBoxItem roomItem = new ComboBoxItem(); if (reader.Read()) { edit.ID.Content = reader["ID"]; edit.numberStr.Text = reader["NUMBER"].ToString(); edit.Ename.Text = reader["NAME"].ToString(); edit.Etype.Content = reader["TYPE_NAME"]; roomItem.Content = reader["ROOM_NAME"]; roomItem.Tag = reader["RID"]; roomItem.IsSelected = true; rooms.Items.Add(roomItem); edit.UserName.Content = reader["USER_NAME"]; edit.CreateTime.Content = Convert.ToDateTime(reader["STORAGE_TIME"]).ToString(BaseRequest.DATE_TIME_FORMAT); } MySqlDataReader roomReader = room.queryRoomsName(); while (roomReader.Read()) { if (!reader["RID"].ToString().Equals(roomReader["ID"].ToString())) { roomItem = new ComboBoxItem(); roomItem.Content = roomReader["ROOM_NAME"]; roomItem.Tag = roomReader["ID"]; rooms.Items.Add(roomItem); } } edit.Owner = Window.GetWindow(this); edit.ShowDialog(); }