vendredi 25 décembre 2015

I am geting checkbox items checked after collapsing the Grid and click again to visible the grid

I am getting ID from database in event handler.

private void buttonAddRooms_Click(object sender, RoutedEventArgs e) { EditRoomsDataGrid.Visibility = Visibility.Collapsed; AddRoomsDataGrid.Visibility = Visibility.Visible;

        Room room = new Room();
        RoomFactory fac = new RoomFactory();
        room.Room_ID = fac.RoomID();
        txtRoomID.Text = room.Room_ID.ToString();


        //COBbadspace.SelectedItem = -1;


     }

as button savedclick all the values from the form once inserted into the data base but again when i click addroombutton to visible the grid all the last checked items show checked so i want a way that when i click addroombutton to visible grid all the checkboxes unchecked and textboxes cleared/empty because as i click again to visible grid all the values still there. clbfacilities is a checklist box containing comboboxItems.

private void btnSaveRoom_Click(object sender, RoutedEventArgs e)
    {
        Room room = new Room();
        RoomFactory fac=new RoomFactory();
        room.RoomType = COBbadspace.SelectionBoxItem.ToString();
       // room.RoomType = txtbadsapace.Text;

        foreach (var item in clbFacilities.SelectedItems)
        {
            room.RoomFacilities += (item as ComboBoxItem).Content + ",";
        }
        String price = txtRoomPrice.Text;
        room.Room_Price = Convert.ToInt32(price);
        if (rbAvailable.IsChecked ?? false)
            room.Room_Status = true;
        else
            room.Room_Status = false;
        if (fac.Insert(room))

         {
            MessageBox.Show("insert");

         }
        else
            MessageBox.Show("not insert");

        AddRoomsDataGrid.Visibility = Visibility.Collapsed;
        EditRoomsDataGrid.Visibility = Visibility.Collapsed;
        viewRoomsGrid.Visibility = Visibility.Visible;


    }




Aucun commentaire:

Enregistrer un commentaire