예제 #1
0
 bool selectClassCarVM_Update(SelectClassVM vm)
 {
     try
     {
         var settings = FileHelper.ReadSettings();
         if (settings.SelectCourseCar == null)
         {
             return(false);
         }
         else
         {
             var item = settings.SelectCourseCar.Where(t => t.TeachClassId == vm.TeachClassId).SingleOrDefault();
             if (item == null)
             {
                 return(false);
             }
             else
             {
                 var index = settings.SelectCourseCar.IndexOf(item);
                 settings.SelectCourseCar[index] = vm;
                 FileHelper.WriteSettings(settings);
                 return(true);
             }
         }
     }
     catch
     {
         return(false);
     }
 }
예제 #2
0
        private void btu_addToSelectCar_Click(object sender, RoutedEventArgs e)
        {
            Button        btu          = sender as Button;
            string        TeachClassId = btu.CommandParameter as string;
            SelectClassVM cla          = selectClassVM.Where(
                t => t.TeachClassId == TeachClassId).SingleOrDefault();
            var settings = FileHelper.ReadSettings();

            if (settings.SelectCourseCar == null)
            {
                settings.SelectCourseCar = new List <SelectClassVM>();
                settings.SelectCourseCar.Add(cla);
                FileHelper.WriteSettings(settings);
            }
            else
            {
                if (settings.SelectCourseCar.Where(t => t.TeachClassId == cla.TeachClassId).Count()
                    == 0)
                {
                    settings.SelectCourseCar.Add(cla);
                    FileHelper.WriteSettings(settings);
                    MessageBox.Show("加入选课车成功");
                }
                else
                {
                    MessageBox.Show("该课程已存在于选课车");
                }
            }
        }
예제 #3
0
        private async Task RefreshSelectCarStatus(SelectClassVM item = null)
        {
            try
            {
                await RefreshSheet();

                if (item == null)
                {
                    var selected = selectedClassVM.ToList();
                    var list     = selectClassCarVM.ToList();
                    for (int i = 0; i < list.Count; i++)
                    {
                        var cla   = list[i];
                        var count = selected.Where(t => t.TeachClassId == cla.TeachClassId).Count();
                        cla.SelectStatus = (count == 0) ? "未选上" : "已成功";
                        selectClassCarVM_Update(cla);
                        await RrefreshSelectCar();
                    }
                }
                else
                {
                    var selected = selectedClassVM.ToList();
                    var count    = selected.Where(t => t.TeachClassId == item.TeachClassId).Count();
                    item.SelectStatus = (count == 0) ? "未选上" : "已成功";
                    selectClassCarVM_Update(item);
                    await RrefreshSelectCar();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }