private void ButtonParaNew_OnClick(object sender, RoutedEventArgs e)
        {
            if (this.ListViewPatientGroup.SelectedIndex == -1)
            {
                return;
            }

            isNewPara = true;

            PatientGroupParaData patientGroupParaData = new PatientGroupParaData();

            patientGroupParaData.Id          = -1;
            patientGroupParaData.GroupId     = Datalist[this.ListViewPatientGroup.SelectedIndex].Id;
            patientGroupParaData.Left        = "";
            patientGroupParaData.Key         = "";
            patientGroupParaData.Symbol      = "";
            patientGroupParaData.Value       = "";
            patientGroupParaData.Right       = "";
            patientGroupParaData.Logic       = "";
            patientGroupParaData.Description = "";
            DatalistPara.Add(patientGroupParaData);

            this.ButtonParaNew.IsEnabled    = false;
            this.ButtonParaDelete.IsEnabled = false;
            this.ButtonParaApply.IsEnabled  = true;
            this.ButtonParaCancel.IsEnabled = true;

            GroupSettingGrid.IsEnabled     = false;
            ListViewPatientGroup.IsEnabled = false;

            ParSettingGrid.IsEnabled           = true;
            ListViewPatientGroupPara.IsEnabled = true;
        }
        private void RefreshDataPara(int index)
        {
            try
            {
                using (var patientGroupParaDao = new PatientGroupParaDao())
                {
                    DatalistPara.Clear();

                    var condition = new Dictionary <string, object>();
                    condition["GROUPID"] = index;
                    var list = patientGroupParaDao.SelectPatientGroupPara(condition);
                    foreach (var pa in list)
                    {
                        var patientGroupParaData = new PatientGroupParaData();
                        patientGroupParaData.Id          = pa.Id;
                        patientGroupParaData.GroupId     = pa.GroupId;
                        patientGroupParaData.Left        = pa.Left;
                        patientGroupParaData.Key         = pa.Key;
                        patientGroupParaData.Symbol      = pa.Symbol;
                        patientGroupParaData.Value       = pa.Value;
                        patientGroupParaData.Right       = pa.Right;
                        patientGroupParaData.Logic       = pa.Logic;
                        patientGroupParaData.Description = pa.Description;
                        DatalistPara.Add(patientGroupParaData);
                    }
                }
            }
            catch (Exception ex)
            {
                MainWindow.Log.WriteInfoConsole("In CPatientGroup.xaml.cs:RefreshDataPara exception messsage: " + ex.Message);
            }
        }
        private void ListViewPatientGroup_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                currnetIndex = this.ListViewPatientGroup.SelectedIndex;
                if (currnetIndex == -1)
                {
                    this.ButtonDelete.IsEnabled  = false;
                    this.ButtonParaNew.IsEnabled = false;
                }
                else
                {
                    this.ButtonDelete.IsEnabled  = true;
                    this.ButtonParaNew.IsEnabled = true;
                }

                using (var patientGroupParaDao = new PatientGroupParaDao())
                {
                    DatalistPara.Clear();
                    var condition = new Dictionary <string, object>();
                    condition["GROUPID"] = Datalist[this.ListViewPatientGroup.SelectedIndex].Id;
                    var list = patientGroupParaDao.SelectPatientGroupPara(condition);
                    foreach (var type in list)
                    {
                        var patientGroupParaData = new PatientGroupParaData
                        {
                            Id          = type.Id,
                            GroupId     = type.GroupId,
                            Left        = type.Left,
                            Key         = type.Key,
                            Symbol      = type.Symbol,
                            Value       = type.Value,
                            Right       = type.Right,
                            Logic       = type.Logic,
                            Description = type.Description
                        };
                        DatalistPara.Add(patientGroupParaData);
                    }
                }
            }
            catch (Exception ex)
            {
                MainWindow.Log.WriteInfoConsole("In CPatientGroup.xaml.cs:ListViewPatientGroup_OnSelectionChanged exception messsage: " + ex.Message);
            }
        }
        private void ListViewPatientGroupPara_OnLoaded(object sender, RoutedEventArgs e)
        {
            //throw new NotImplementedException();
            if (this.ListViewPatientGroup.SelectedIndex == -1)
            {
                return;
            }

            try
            {
                using (var patientGroupParaDao = new PatientGroupParaDao())
                {
                    DatalistPara.Clear();
                    var condition = new Dictionary <string, object>();
                    condition["GROUPID"] = Datalist[this.ListViewPatientGroup.SelectedIndex].Id;
                    var list = patientGroupParaDao.SelectPatientGroupPara(condition);
                    foreach (var type in list)
                    {
                        var patientGroupParaData = new PatientGroupParaData
                        {
                            Id          = type.Id,
                            GroupId     = type.GroupId,
                            Left        = type.Left,
                            Key         = type.Key,
                            Symbol      = type.Symbol,
                            Value       = type.Value,
                            Right       = type.Right,
                            Logic       = type.Logic,
                            Description = type.Description
                        };
                        DatalistPara.Add(patientGroupParaData);
                    }
                }
            }
            catch (Exception ex)
            {
                MainWindow.Log.WriteInfoConsole("In CPatientGroup.xaml.cs:ListViewPatientGroupPara_OnLoaded exception messsage: " + ex.Message);
            }
        }
        private void ButtonParaApply_OnClick(object sender, RoutedEventArgs e)
        {
            for (int index = 0; index < DatalistPara.Count; index++)
            {
                PatientGroupParaData patientGroupParaData = DatalistPara[index];
                if (patientGroupParaData.Id == -1)
                {
                    //throw new NotImplementedException();
                    try
                    {
                        //int index = ListViewPatientGroupPara.SelectedIndex;
                        //if (index == -1) return;

                        //if (DatalistPara[index].Name.Equals("") || !CheckNameIsExist(DatalistPara[index].Name))
                        //{
                        //    var a = new RemindMessageBox1();
                        //    a.remindText.Text = (string)FindResource("Message1001"); ;
                        //    a.ShowDialog();
                        //    return;
                        //}

                        using (PatientGroupParaDao patientGroupParaDao = new PatientGroupParaDao())
                        {
                            PatientGroupPara patientGroupPara = new PatientGroupPara();
                            patientGroupPara.GroupId     = Datalist[ListViewPatientGroup.SelectedIndex].Id;
                            patientGroupPara.Left        = patientGroupParaData.Left;
                            patientGroupPara.Key         = patientGroupParaData.Key;
                            patientGroupPara.Symbol      = patientGroupParaData.Symbol;
                            patientGroupPara.Value       = patientGroupParaData.Value;
                            patientGroupPara.Right       = patientGroupParaData.Right;
                            patientGroupPara.Logic       = patientGroupParaData.Logic;
                            patientGroupPara.Description = patientGroupParaData.Description;
                            int lastInsertId = -1;
                            patientGroupParaDao.InsertPatientGroupPara(patientGroupPara, ref lastInsertId);
                            //UI
                            //PatientGroupData patientGroupData = new PatientGroupData();
                            //patientGroupData.Id = lastInsertId;
                            //patientGroupData.Name = patientGroup.Name;
                            //patientGroupData.Description = patientGroup.Description;

                            //Datalist.Add(patientGroupData);
                            patientGroupParaData.Id = lastInsertId;
                        }
                    }
                    catch (Exception ex)
                    {
                        MainWindow.Log.WriteInfoConsole(
                            "In CPatientGroup.xaml.cs:ButtonParaApply_OnClick exception messsage: " + ex.Message);
                        return;
                    }
                    this.ButtonParaNew.IsEnabled    = true;
                    this.ButtonParaDelete.IsEnabled = true;
                    this.ButtonParaApply.IsEnabled  = true;
                    this.ButtonParaCancel.IsEnabled = true;
                    isNewPara = false;
                }
                else
                {
                    //int index = ListViewPatientGroupPara.SelectedIndex;
                    //if (index == -1)
                    //{
                    //    this.ButtonParaApply.IsEnabled = false;
                    //    ButtonParaCancel.IsEnabled = false;
                    //    return;
                    //}

                    //if (this.DatalisParat[index].Name.Equals(""))
                    //{
                    //    var a = new RemindMessageBox1();
                    //    a.remindText.Text = (string)FindResource("Message1001"); ;
                    //    a.ShowDialog();
                    //    return;
                    //}

                    //throw new NotImplementedException();
                    using (var patientGroupParaDao = new PatientGroupParaDao())
                    {
                        var condition = new Dictionary <string, object>();
                        condition["ID"] = patientGroupParaData.Id;

                        var fileds = new Dictionary <string, object>();
                        fileds["LEFT"]        = patientGroupParaData.Left;
                        fileds["KEY"]         = patientGroupParaData.Key;
                        fileds["SYMBOL"]      = patientGroupParaData.Symbol;
                        fileds["VALUE"]       = patientGroupParaData.Value;
                        fileds["RIGHT"]       = patientGroupParaData.Right;
                        fileds["LOGIC"]       = patientGroupParaData.Logic;
                        fileds["DESCRIPTION"] = patientGroupParaData.Description;
                        patientGroupParaDao.UpdatePatientGroupPara(fileds, condition);
                        //int temp = this.ListViewPatientGroupPara.SelectedIndex;
                        //RefreshDataPara((int) Datalist[ListViewPatientGroup.SelectedIndex].Id);
                        //this.ListViewPatientGroupPara.SelectedIndex = temp;
                    }
                }
            }


            this.ButtonParaDelete.IsEnabled = true;
            this.ButtonParaApply.IsEnabled  = false;
            ButtonParaCancel.IsEnabled      = false;

            GroupSettingGrid.IsEnabled     = true;
            ListViewPatientGroup.IsEnabled = true;

            Basewindow.patientGroupPanel.RefreshData();
            Basewindow.reeportContent.InitPatientGroupComboBox();
        }