//private void AddButton_OnClick(object sender, RoutedEventArgs e) //{ // //throw new NotImplementedException(); // try // { // if (this.NameTextBox.Text.Equals("") || !CheckNameIsExist(this.NameTextBox.Text)) // { // var a = new RemindMessageBox1(); // a.remindText.Text = (string)FindResource("Message1001"); ; // a.ShowDialog(); // return; // } // using (var treatMethodDao = new TreatMethodDao()) // { // var treatMethod = new TreatMethod(); // treatMethod.Name = this.NameTextBox.Text; // var condition = new Dictionary<string, object>(); // using (var treatTypeDao = new TreatTypeDao()) // { // condition.Clear(); // condition["Name"] = ComboBoxTreatType.Text; // var arealist = treatTypeDao.SelectTreatType(condition); // if (arealist.Count == 1) // { // treatMethod.TreatTypeId = arealist[0].Id; // } // } // treatMethod.Description = this.DescriptionTextBox.Text; // treatMethod.BgColor = ((SolidColorBrush)Buttonrectangle.Fill).Color.ToString(); // int lastInsertId = -1; // treatMethodDao.InsertTreatMethod(treatMethod, ref lastInsertId); // //UI // TreatMethodData treatMethodData = new TreatMethodData(); // treatMethodData.Id = lastInsertId; // treatMethodData.Name = treatMethod.Name; // treatMethodData.Type = ComboBoxTreatType.Text; // treatMethodData.Description = treatMethod.Description; // treatMethodData.BgColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString(treatMethod.BgColor)); // treatMethodData.IsAvailable = treatMethod.IsAvailable; // Datalist.Add(treatMethodData); // } // } // catch (Exception ex) // { // MainWindow.Log.WriteInfoConsole("In CTreatMethod.xaml.cs:AddButton_OnClick exception messsage: " + ex.Message); // } //} //private void UpdateButton_OnClick(object sender, RoutedEventArgs e) //{ // if (ListView1.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 treatMethodDao = new TreatMethodDao()) // { // var condition = new Dictionary<string, object>(); // condition["ID"] = Datalist[ListView1.SelectedIndex].Id; // var fileds = new Dictionary<string, object>(); // fileds["NAME"] = NameTextBox.Text; // var condition2 = new Dictionary<string, object>(); // using (var treatTypeDao = new TreatTypeDao()) // { // condition2.Clear(); // condition2["Name"] = ComboBoxTreatType.Text; // var arealist = treatTypeDao.SelectTreatType(condition2); // if (arealist.Count == 1) // { // fileds["TREATTYPEID"] = arealist[0].Id; // } // } // fileds["DESCRIPTION"] = DescriptionTextBox.Text; // fileds["ISAVAILABLE"] = CheckBoxIsAvailable.IsChecked; // fileds["BGCOLOR"] = ((SolidColorBrush)Buttonrectangle.Fill).Color.ToString(); // var messageBox2 = new RemindMessageBox2(); // messageBox2.textBlock1.Text = "执行该操作将影响医嘱及排班"; // messageBox2.ShowDialog(); // if (messageBox2.remindflag == 1) // { // treatMethodDao.UpdateTreatMethod(fileds, condition); // RefreshData(); // } // } //} private void RefreshData() { try { using (var treatMethodDao = new TreatMethodDao()) { Datalist.Clear(); Dictionary <string, object> condition = new Dictionary <string, object>(); var list = treatMethodDao.SelectTreatMethod(condition); foreach (TreatMethod pa in list) { var treatMethodData = new TreatMethodData(); treatMethodData.Id = pa.Id; treatMethodData.Name = pa.Name; treatMethodData.SinglePump = pa.SinglePump; treatMethodData.DoublePump = pa.DoublePump; treatMethodData.IsAvailable = pa.IsAvailable; treatMethodData.Description = pa.Description; treatMethodData.BgColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString(pa.BgColor)); Datalist.Add(treatMethodData); } } if (Datalist.Count != 0) { ListViewTreatMethod.SelectedIndex = 0; } } catch (Exception ex) { MainWindow.Log.WriteInfoConsole("In CTreatMethod.xaml.cs:AddButton_OnClick exception messsage: " + ex.Message); } }
private void ListViewTreatMethod_OnLoaded(object sender, RoutedEventArgs e) { //throw new NotImplementedException(); try { using (TreatMethodDao treatMethodDao = new TreatMethodDao()) { Datalist.Clear(); Dictionary <string, object> condition = new Dictionary <string, object>(); var list = treatMethodDao.SelectTreatMethod(condition); foreach (TreatMethod pa in list) { TreatMethodData treatMethodData = new TreatMethodData(); treatMethodData.Id = pa.Id; treatMethodData.Name = pa.Name; treatMethodData.SinglePump = pa.SinglePump; treatMethodData.DoublePump = pa.DoublePump; treatMethodData.IsAvailable = pa.IsAvailable; string bgColor = pa.BgColor; if (bgColor != "" && bgColor != null) { Brush bgBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(bgColor)); treatMethodData.BgColor = bgBrush; } else { treatMethodData.BgColor = Brushes.Gray; } treatMethodData.Description = pa.Description; Datalist.Add(treatMethodData); } } if (Datalist.Count != 0) { ListViewTreatMethod.SelectedIndex = 0; } } catch (Exception ex) { MainWindow.Log.WriteInfoConsole("In CTreatMethod.xaml.cs:ListViewTreatMethod_OnLoaded exception messsage: " + ex.Message); } }