예제 #1
0
 private void ListViewInfectType_OnLoaded(object sender, RoutedEventArgs e)
 {
     //throw new NotImplementedException();
     try
     {
         using (var infectTypeDao = new InfectTypeDao())
         {
             Datalist.Clear();
             var infectType = new InfectType();
             var condition  = new Dictionary <string, object>();
             var list       = infectTypeDao.SelectInfectType(condition);
             foreach (var type in list)
             {
                 var infectTypeData = new InfectTypeData
                 {
                     Id          = type.Id,
                     Name        = type.Name,
                     Description = type.Description
                 };
                 Datalist.Add(infectTypeData);
             }
         }
         if (Datalist.Count != 0)
         {
             ListViewInfectType.SelectedIndex = 0;
         }
     }
     catch (Exception ex)
     {
         MainWindow.Log.WriteInfoConsole("In CInfectType.xaml.cs:ListViewCInfectType_OnLoaded exception messsage: " + ex.Message);
     }
 }
예제 #2
0
        private void RefreshData()
        {
            try
            {
                using (var infectTypeDao = new InfectTypeDao())
                {
                    Datalist.Clear();

                    var condition = new Dictionary <string, object>();
                    var list      = infectTypeDao.SelectInfectType(condition);
                    foreach (var pa in list)
                    {
                        var infectTypeData = new InfectTypeData();
                        infectTypeData.Id          = pa.Id;
                        infectTypeData.Name        = pa.Name;
                        infectTypeData.Description = pa.Description;
                        Datalist.Add(infectTypeData);
                    }
                }
            }
            catch (Exception ex)
            {
                MainWindow.Log.WriteInfoConsole("In CInfectType.xaml.cs:AddButton_OnClick exception messsage: " + ex.Message);
            }
        }
예제 #3
0
        private void ButtonApply_OnClick(object sender, RoutedEventArgs e)
        {
            if (isNew)
            {
                //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 infectTypeDao = new InfectTypeDao())
                    {
                        var infectType = new InfectType();
                        infectType.Name        = this.NameTextBox.Text;
                        infectType.Description = this.DescriptionTextBox.Text;
                        int lastInsertId = -1;
                        infectTypeDao.InsertInfectType(infectType, ref lastInsertId);
                        //UI
                        var infectTypeData = new InfectTypeData();
                        infectTypeData.Id          = infectType.Id;
                        infectTypeData.Name        = infectType.Name;
                        infectTypeData.Description = infectType.Description;
                        Datalist.Add(infectTypeData);
                    }
                }
                catch (Exception ex)
                {
                    MainWindow.Log.WriteInfoConsole("In CInfectType.xaml.cs:AddButton_OnClick exception messsage: " + ex.Message);
                }
            }
            else
            {
                if (ListViewInfectType.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 infectTypeDao = new InfectTypeDao())
                {
                    var condition = new Dictionary <string, object>();
                    condition["ID"] = Datalist[ListViewInfectType.SelectedIndex].Id;

                    var fileds = new Dictionary <string, object>();
                    fileds["NAME"]        = NameTextBox.Text;
                    fileds["DESCRIPTION"] = DescriptionTextBox.Text;
                    infectTypeDao.UpdateInfectType(fileds, condition);
                    int temp = this.ListViewInfectType.SelectedIndex;
                    RefreshData();
                    this.ListViewInfectType.SelectedIndex = temp;
                }
                isNew = false;
            }
            this.ButtonApply.IsEnabled = false;
        }