Esempio n. 1
0
        private void itemDelete_Click(object sender, RoutedEventArgs e)
        {
            DTO_ScorpionAccess.ListViewItem item = (DTO_ScorpionAccess.ListViewItem)lbListSockets.SelectedItem;
            if (item == null)
            {
                return;
            }

            MessageBoxResult result = MessageBox.Show("Bạn có muốn xóa terminal này không?", "Xác nhận", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                DTO_DoorSocket socket    = door.Sockets.FirstOrDefault(s => s.Id == item.Key);
                SQLResult      sQLResult = bUS_DoorSocket.DeleteSocket(socket.Id, socket.ConnectedDeviceSocketId);
                if (sQLResult.Result)
                {
                    DTO_Door selectedDoor = Repository.lstAllDoor.FirstOrDefault(d => d.Id == door.Id);
                    if (selectedDoor != null)
                    {
                        selectedDoor.Sockets.Remove(socket);
                    }
                    BindSocketToListItemView();
                }
                else
                {
                    MessageBox.Show(sQLResult.Detail, "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Esempio n. 2
0
        private void lbListSockets_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DTO_ScorpionAccess.ListViewItem selectedItem = (DTO_ScorpionAccess.ListViewItem)lbListSockets.SelectedItem;
            if (selectedItem != null)
            {
                DTO_DoorSocket socket = door.Sockets.FirstOrDefault(s => s.Id == selectedItem.Key);
                if (socket != null)
                {
                    cbDevice.SelectedValue       = socket.ConnectedDeviceId;
                    cbDeviceSocket.SelectedValue = socket.ConnectedDeviceSocketId;

                    cbSocketType.SelectedValue = socket.Type;
                }
            }
        }
Esempio n. 3
0
        private void itemEdit_Click(object sender, RoutedEventArgs e)
        {
            DTO_ScorpionAccess.ListViewItem item = (DTO_ScorpionAccess.ListViewItem)lbListSockets.SelectedItem;
            if (item == null)
            {
                return;
            }
            DTO_DoorSocket socket = door.Sockets.FirstOrDefault(s => s.Id == item.Key);

            DoorSocketDetailView view = new DoorSocketDetailView(EType.WindowMode.EDIT_MODE, socket, door.Id);

            if (view.ShowDialog() == true)
            {
                BindSocketToListItemView();
            }
        }
Esempio n. 4
0
        private void BindSocketToListItemView()
        {
            door          = Repository.lstAllDoor.FirstOrDefault(d => d.Id == door.Id);
            listViewItems = new List <DTO_ScorpionAccess.ListViewItem>();
            foreach (DTO_DoorSocket socket in door.Sockets)
            {
                DTO_ScorpionAccess.ListViewItem listViewItem = new DTO_ScorpionAccess.ListViewItem();
                switch (socket.Type)
                {
                case EType.DoorSocketType.CONTACT:
                    if (socket.ConnectedDevice != null)
                    {
                        listViewItem.ImageSource = "/Icon/c_character_gray_50px.png";
                    }
                    else
                    {
                        listViewItem.ImageSource = "/Icon/c_character_green_50px.png";
                    }
                    break;

                case EType.DoorSocketType.LOCK:
                    if (socket.ConnectedDevice != null)
                    {
                        listViewItem.ImageSource = "/Icon/l_character_gray_50px.png";
                    }
                    else
                    {
                        listViewItem.ImageSource = "/Icon/l_character_green_50px.png";
                    }
                    break;

                case EType.DoorSocketType.READER:
                    if (socket.ConnectedDevice != null)
                    {
                        listViewItem.ImageSource = "/Icon/e_character_gray_50px.png";
                    }
                    else
                    {
                        listViewItem.ImageSource = "/Icon/e_character_green_50px.png";
                    }
                    break;

                case EType.DoorSocketType.REX:
                    if (socket.ConnectedDevice != null)
                    {
                        listViewItem.ImageSource = "/Icon/r_character_gray_50px.png";
                    }
                    else
                    {
                        listViewItem.ImageSource = "/Icon/r_character_green_50px.png";
                    }
                    break;
                }

                listViewItem.TextBinding = socket.Name;
                listViewItem.Key         = socket.Id;

                listViewItems.Add(listViewItem);
            }

            lbListSockets.ItemsSource = listViewItems;
        }