Exemplo n.º 1
0
        private void lvTube_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TubeDTO tube = (TubeDTO)lvTube.SelectedItem;

            if (tube != null)
            {
                this.txtLocation.Text = tube.Location;
                this.txtStatus.Text   = tube.Status;
            }
        }
Exemplo n.º 2
0
        void MainWindow_KeyDown(object sender, KeyEventArgs e)
        {
            TubeDTO tube = (TubeDTO)lvTube.SelectedItem;

            switch (e.Key)
            {
            case Key.F1:
                tcMain.SelectedIndex = 0;
                break;

            case Key.F2:
                tcMain.SelectedIndex = 1;
                break;

            case Key.F3:
                tcMain.SelectedIndex = 2;
                break;

            case Key.F4:
                tcMain.SelectedIndex = 3;
                break;

            case Key.F5:
                tcMain.SelectedIndex = 4;
                break;

            case Key.F6:
                TubeCollect.Add(new TubeDTO()
                {
                    Status   = "1",
                    Category = "2",
                    Location = "3",
                    SetDate  = "4"
                });
                lvTube.ItemsSource = TubeCollect;
                break;

            case Key.Delete:
                TubeCollect.Remove(tube);
                lvTube.ItemsSource   = TubeCollect;
                lvTube.SelectedIndex = 0;
                lvTube.Focus();
                break;

            case Key.Enter:
                if (tube.SetDate.Equals("新增"))
                {
                    //新增
                    lvTube.IsEnabled          = false;
                    pgSurgeryModify.IsEnabled = true;

                    ////dpSurgeryTime.Text = "";
                    //tvDignosis.Text = "";
                    //tvSurgeryName.Text = "";
                    //tvSurgeryEvaluation.Text = "";
                }
                else
                {
                    //修改
                    lvTube.IsEnabled          = false;
                    pgSurgeryModify.IsEnabled = true;

                    tube = (TubeDTO)lvTube.SelectedItem;
                }
                break;

            case Key.Escape:
                //離開
                if (pgSurgeryModify.IsEnabled == true && tcMain.SelectedIndex == 1)
                {
                    lvTube.IsEnabled          = true;
                    pgSurgeryModify.IsEnabled = false;
                    MessageBoxResult result = MessageBox.Show("是否要存檔?", "警告", MessageBoxButton.YesNo);
                    switch (result)
                    {
                    case MessageBoxResult.Yes:
                        //surgery = lvSurgery.SelectedItem as Surgery;
                        //int surgeryIndex = MemberCollect.FindIndex(x => x.surgeryName.Contains(surgery.surgeryName));
                        //surgery.surgeryTime = dpSurgeryTime.Text;
                        //surgery.diagnosis = tvDignosis.Text;
                        //surgery.surgeryName = tvSurgeryName.Text;
                        //surgery.surgeryEvaluation = tvSurgeryEvaluation.Text;
                        //MemberCollect[surgeryIndex] = surgery;
                        int     index = lvTube.SelectedIndex;
                        var     value = lvTube.SelectedValue;
                        TubeDTO obj   = new TubeDTO
                        {
                            //surgeryTime = dpSurgeryTime.Text,
                            //diagnosis = tvDignosis.Text,
                            //surgeryName = tvSurgeryName.Text,
                            //surgeryEvaluation = tvSurgeryEvaluation.Text
                        };
                        this.TubeCollect[index] = obj;
                        this.lvTube.ItemsSource = TubeCollect;
                        break;

                    case MessageBoxResult.No:

                        break;
                    }
                    lvTube.SelectedIndex = 0;
                    lvTube.Focus();
                }

                break;

            default:
                break;
            }
        }