private void RefreshData()
        {
            try
            {
                using (PatientAreaDao patientAreaDao = new PatientAreaDao())
                {
                    Datalist.Clear();
                    Dictionary <string, object> condition = new Dictionary <string, object>();
                    var list = patientAreaDao.SelectPatientArea(condition);
                    foreach (PatientArea pa in list)
                    {
                        PatientAreaData patientAreaData = new PatientAreaData();
                        patientAreaData.Id       = pa.Id;
                        patientAreaData.Name     = pa.Name;
                        patientAreaData.Type     = pa.Type;
                        patientAreaData.Position = pa.Position;
                        patientAreaData.Seq      = pa.Seq;

                        {
                            using (var infectTypeDao = new InfectTypeDao())
                            {
                                condition.Clear();
                                condition["ID"] = pa.InfectTypeId;
                                var arealist = infectTypeDao.SelectInfectType(condition);
                                if (arealist.Count == 1)
                                {
                                    patientAreaData.InfectionType = arealist[0].Name;
                                }
                            }
                        }
                        if (patientAreaData.Type.Equals("0"))
                        {
                            this.InfectionComboBox.IsEnabled = false;
                            this.RadioButton1.IsChecked      = true;
                            patientAreaData.InfectionType    = "阴性";
                        }

                        else if (patientAreaData.Type.Equals("1"))
                        {
                            this.InfectionComboBox.IsEnabled = true;
                            this.RadioButton2.IsChecked      = true;
                        }
                        patientAreaData.Description = pa.Description;
                        Datalist.Add(patientAreaData);
                    }
                }
            }
            catch (Exception ex)
            {
                MainWindow.Log.WriteInfoConsole("In CPatientArea.xaml.cs:AddButton_OnClick exception messsage: " + ex.Message);
            }
        }
        private void ListViewCPatientArea_OnLoaded(object sender, RoutedEventArgs e)
        {
            //throw new NotImplementedException();
            try
            {
                using (PatientAreaDao patientAreaDao = new PatientAreaDao())
                {
                    Datalist.Clear();
                    Dictionary <string, object> condition = new Dictionary <string, object>();
                    var list = patientAreaDao.SelectPatientArea(condition);
                    foreach (PatientArea pa in list)
                    {
                        PatientAreaData patientAreaData = new PatientAreaData();
                        patientAreaData.Id       = pa.Id;
                        patientAreaData.Name     = pa.Name;
                        patientAreaData.Type     = pa.Type;
                        patientAreaData.Position = pa.Position;
                        patientAreaData.Seq      = pa.Seq;
                        {
                            using (var infectTypeDao = new InfectTypeDao())
                            {
                                condition.Clear();
                                condition["ID"] = pa.InfectTypeId;
                                var arealist = infectTypeDao.SelectInfectType(condition);
                                if (arealist.Count == 1)
                                {
                                    patientAreaData.InfectionType = arealist[0].Name;
                                }
                            }
                        }
                        if (patientAreaData.Type.Equals("0"))
                        {
                            this.InfectionComboBox.IsEnabled = false;
                            this.RadioButton1.IsChecked      = true;
                            patientAreaData.InfectionType    = "阴性";
                        }

                        else if (patientAreaData.Type.Equals("1"))
                        {
                            this.InfectionComboBox.IsEnabled = true;
                            this.RadioButton2.IsChecked      = true;
                        }
                        patientAreaData.Description = pa.Description;
                        Datalist.Add(patientAreaData);
                    }
                }
                if (Datalist.Count != 0)
                {
                    ListViewPatientArea.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MainWindow.Log.WriteInfoConsole("In CPatientArea.xaml.cs:AddButton_OnClick exception messsage: " + ex.Message);
            }
            InfectionComboBox.Items.Clear();
            try
            {
                using (var infectTypeDao = new InfectTypeDao())
                {
                    //Datalist1.Clear();
                    var condition = new Dictionary <string, object>();
                    var list      = infectTypeDao.SelectInfectType(condition);
                    foreach (var type in list)
                    {
                        InfectionComboBox.Items.Add(type.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                MainWindow.Log.WriteInfoConsole("In CPatientArea.xaml.cs:ListViewCInfectType_OnLoaded exception messsage: " + ex.Message);
            }
        }
        private void ButtonApply_OnClick(object sender, RoutedEventArgs e)
        {
            if (isNew)
            {
                //throw new NotImplementedException();
                try
                {
                    if (this.NameTextBox.Text.Equals("") || !CheckNameIsExist(this.NameTextBox.Text) || SeqTextBox.Text.Equals(""))
                    {
                        var a = new RemindMessageBox1();
                        a.remindText.Text = "请完善信息!";
                        a.ShowDialog();
                        return;
                    }

                    using (PatientAreaDao patientAreaDao = new PatientAreaDao())
                    {
                        PatientArea patientArea = new PatientArea();
                        patientArea.Name = this.NameTextBox.Text;
                        var condition = new Dictionary <string, object>();
                        using (var infectTypeDao = new InfectTypeDao())
                        {
                            condition.Clear();
                            condition["Name"] = InfectionComboBox.Text;
                            var arealist = infectTypeDao.SelectInfectType(condition);
                            if (arealist.Count == 1)
                            {
                                patientArea.InfectTypeId = arealist[0].Id;
                            }
                            else
                            {
                                patientArea.InfectTypeId = 1;
                            }
                        }
                        if ((bool)this.RadioButton1.IsChecked)
                        {
                            patientArea.Type = "0";
                        }
                        else if ((bool)this.RadioButton2.IsChecked)
                        {
                            patientArea.Type = "1";
                        }
                        patientArea.Description = this.DescriptionTextBox.Text;
                        patientArea.Position    = this.PositionTextBox.Text;
                        patientArea.Seq         = int.Parse(this.SeqTextBox.Text);
                        int lastInsertId = -1;
                        patientAreaDao.InsertPatientArea(patientArea, ref lastInsertId);
                        //UI
                        PatientAreaData patientAreaData = new PatientAreaData();
                        patientAreaData.Name = patientArea.Name;
                        if ((bool)this.RadioButton1.IsChecked)
                        {
                            patientAreaData.InfectionType = "阴性";
                            patientAreaData.Type          = "0";
                        }

                        else if ((bool)this.RadioButton2.IsChecked)
                        {
                            patientAreaData.Type = "1";
                        }

                        patientAreaData.Description = patientArea.Description;
                        patientAreaData.Position    = patientArea.Position;
                        patientAreaData.Seq         = patientArea.Seq;

                        Datalist.Add(patientAreaData);
                    }
                }
                catch (Exception ex)
                {
                    MainWindow.Log.WriteInfoConsole("In CPatientArea.xaml.cs:ButtonApply_OnClick exception messsage: " + ex.Message);
                    return;
                }
                this.ButtonNew.IsEnabled    = true;
                this.ButtonDelete.IsEnabled = true;
                this.ButtonApply.IsEnabled  = true;
                this.ButtonCancel.IsEnabled = true;
            }
            else
            {
                if (ListViewPatientArea.SelectedIndex == -1)
                {
                    return;
                }

                if (this.NameTextBox.Text.Equals(""))
                {
                    var a = new RemindMessageBox1();
                    a.remindText.Text = (string)FindResource("Message1001");;
                    a.ShowDialog();
                    return;
                }

                //throw new NotImplementedException();
                using (var patientAreaDao = new PatientAreaDao())
                {
                    var condition = new Dictionary <string, object>();
                    condition["ID"] = Datalist[ListViewPatientArea.SelectedIndex].Id;

                    var fileds = new Dictionary <string, object>();
                    fileds["NAME"] = NameTextBox.Text;
                    var condition2 = new Dictionary <string, object>();
                    using (var infectTypeDao = new InfectTypeDao())
                    {
                        condition2.Clear();
                        condition2["NAME"] = InfectionComboBox.Text;
                        var arealist = infectTypeDao.SelectInfectType(condition2);
                        if (arealist.Count == 1)
                        {
                            fileds["INFECTTYPEID"] = arealist[0].Id;
                        }
                        else
                        {
                            fileds["INFECTTYPEID"] = 1;
                        }
                    }
                    if ((bool)this.RadioButton1.IsChecked)
                    {
                        fileds["TYPE"] = "0";
                    }
                    else if ((bool)this.RadioButton2.IsChecked)
                    {
                        fileds["TYPE"] = "1";
                    }
                    fileds["SEQ"]         = SeqTextBox.Text;
                    fileds["POSITION"]    = PositionTextBox.Text;
                    fileds["DESCRIPTION"] = DescriptionTextBox.Text;
                    patientAreaDao.UpdatePatientArea(fileds, condition);
                    int temp = this.ListViewPatientArea.SelectedIndex;
                    RefreshData();
                    this.ListViewPatientArea.SelectedIndex = temp;
                }
                isNew = false;
            }
            this.ButtonApply.IsEnabled  = false;
            this.ButtonCancel.IsEnabled = false;
        }