private void ListViewMachineType_OnLoaded(object sender, RoutedEventArgs e) { //throw new NotImplementedException(); try { using (var machineTypeDao = new MachineTypeDao()) { Datalist.Clear(); var condition = new Dictionary <string, object>(); var list = machineTypeDao.SelectMachineType(condition); foreach (var type in list) { var machineTypeData = new MachineTypeData(); machineTypeData.Id = type.Id; machineTypeData.Name = type.Name; machineTypeData.Description = type.Description; string bgColor = type.BgColor; if (bgColor != "" && bgColor != null) { Brush bgBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(bgColor)); machineTypeData.BgColor = bgBrush; } else { machineTypeData.BgColor = Brushes.Gray; } Datalist.Add(machineTypeData); } } if (Datalist.Count != 0) { ListViewMachineType.SelectedIndex = 0; } } catch (Exception ex) { MainWindow.Log.WriteInfoConsole("In CMachineType.xaml.cs:ListViewMachineType_OnLoaded exception messsage: " + ex.Message); } }
//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 treatTypeDao = new TreatTypeDao()) // { // var treatType = new TreatType(); // treatType.Name = this.NameTextBox.Text; // treatType.Description = this.DescriptionTextBox.Text; // treatType.BgColor = ((SolidColorBrush)Buttonrectangle.Fill).Color.ToString(); // int lastInsertId = -1; // treatTypeDao.InsertTreatType(treatType, ref lastInsertId); // //UI // var treatTypeData = new TreatTypeData(); // treatTypeData.Id = treatType.Id; // treatTypeData.Name = treatType.Name; // treatTypeData.Description = treatType.Description; // string bgColor = treatType.BgColor; // Brush bgBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(bgColor)); // if (bgColor != "" && bgColor != null) // treatTypeData.BgColor = bgBrush; // else // treatTypeData.BgColor = Brushes.Gray; // Datalist.Add(treatTypeData); // } // } // catch (Exception ex) // { // MainWindow.Log.WriteInfoConsole("In CTreatType.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 treatTypeDao = new TreatTypeDao()) // { // var condition = new Dictionary<string, object>(); // condition["ID"] = Datalist[ListView1.SelectedIndex].Id; // var fileds = new Dictionary<string, object>(); // fileds["NAME"] = NameTextBox.Text; // fileds["DESCRIPTION"] = DescriptionTextBox.Text; // fileds["BGCOLOR"] = ((SolidColorBrush)Buttonrectangle.Fill).Color.ToString(); // treatTypeDao.UpdateTreatType(fileds, condition); // RefreshData(); // } //} private void RefreshData() { try { using (var machineTypeDao = new MachineTypeDao()) { Datalist.Clear(); var condition = new Dictionary <string, object>(); var list = machineTypeDao.SelectMachineType(condition); foreach (var pa in list) { var machineTypeData = new MachineTypeData(); machineTypeData.Id = pa.Id; machineTypeData.Name = pa.Name; machineTypeData.Description = pa.Description; string bgColor = pa.BgColor; if (bgColor != "" && bgColor != null) { Brush bgBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(bgColor)); machineTypeData.BgColor = bgBrush; } else { machineTypeData.BgColor = Brushes.Gray; } Datalist.Add(machineTypeData); } } } catch (Exception ex) { MainWindow.Log.WriteInfoConsole("In CMachineType.xaml.cs:RefreshData exception messsage: " + ex.Message); } }