public async Task InsertClassPlanAsync(ClassPlan newClassPlan)
        {
            if (newClassPlan.TeacherId > 0)
            {
                using (EntityModel em = new EntityModel())
                {
                    var teacher = await em.Teacher
                                  .Where(z => z.TeacherId == newClassPlan.TeacherId)
                                  .Include(t => t.ClassPlan)
                                  .FirstOrDefaultAsync();

                    if (teacher != null)
                    {
                        teacher.ClassPlan.Add(newClassPlan);
                        await em.SaveChangesAsync();
                    }
                    else
                    {
                        throw new System.Exception(string.Format("ID de professor ({0}) não salvo na base de dados!", newClassPlan.TeacherId));
                    }
                }
            }
            else
            {
                throw new System.Exception(string.Format("ID de professor ({0}) inválido!", newClassPlan.TeacherId));
            }
        }
 public void DeleteClassPlan(ClassPlan classPlan)
 {
     using (EntityModel em = new EntityModel())
     {
         em.ClassPlan.Attach(classPlan);
         em.ClassPlan.Remove(classPlan);
         em.SaveChanges();
     }
 }
Example #3
0
        public PlanSetForm(ClassPlan temp_ClassPlan)
        {
            InitializeComponent();
            classplan = temp_ClassPlan;
            if (classplan == null)
            {
                MessageBox.Show("预案数据为空");
                return;
            }
            PlanSet ps_1 = new PlanSet(classplan, this);

            ps_1.TopLevel = false;
            panel1.Controls.Add(ps_1);
            ps_1.Show();
        }
        public async Task <ClassPlan> FindClassPlanAsync(long classPlanId)
        {
            ClassPlan classPlan = null;

            using (EntityModel em = new EntityModel())
            {
                classPlan = await em.ClassPlan
                            .Where(c => c.ClassPlanId == classPlanId)
                            .Include(c => c.Chores)
                            .Include(c => c.ClassGoals)
                            .Include(c => c.Evaluetions)
                            .Include(c => c.LessonsContents)
                            .FirstOrDefaultAsync();
            }
            return(classPlan);
        }
Example #5
0
        public PresetForm()
        {
            InitializeComponent();
            ASF.controllInitializeSize(this);
            bool result1 = CommunicationClass.Init();

            if (result1)
            {
                MessageBox.Show("通讯初始化成功!");
                ////初始化设备数据
                //Class1 class1 = new Class1();
                //class1.Init();
                //报警预案数据初始化
                classplan = new ClassPlan();
                classplan.PlanInit();
            }
            else
            {
                MessageBox.Show("通讯初始化失败!");
            }
            DataLoad();
            AnimateWindow(Handle, 300, AW_CENTER);//窗体弹出效果
        }
Example #6
0
 public async Task InsertClassPlanAsync(ClassPlan newClassPlan)
 {
     await _classPlanDAO.InsertClassPlanAsync(newClassPlan);
 }
Example #7
0
 public void UpdateClassPlan(ClassPlan classPlan)
 {
     _classPlanDAO.UpdateClassPlan(classPlan);
 }
Example #8
0
 public void InsertClassPlan(ClassPlan newClassPlan)
 {
     _classPlanDAO.InsertClassPlan(newClassPlan);
 }
Example #9
0
 public void DeleteClassPlan(ClassPlan classPlan)
 {
     _classPlanDAO.DeleteClassPlan(classPlan);
 }
Example #10
0
 public PlanSet(ClassPlan temp_ClassPlan, Guid temp_Add_AlarmDeviceID, Guid temp_PlanDeviceID, Guid temp_Add_DeviceID, int temp_DeviceType)
 {
     InitializeComponent();
     ASF.controllInitializeSize(this);
     classplan         = temp_ClassPlan;
     Add_AlarmDeviceID = temp_Add_AlarmDeviceID;
     Add_PlanDeviceID  = temp_PlanDeviceID;
     Add_DeviceID      = temp_Add_DeviceID;
     Add_DeviceType    = temp_DeviceType;
     temp_AlarmMessageForAll.Trigger_LinkageData   = new Client.Entities.AlarmEntity.LinkageData();
     temp_AlarmMessageForAll.Disposal_LinkageData  = new Client.Entities.AlarmEntity.LinkageData();
     temp_AlarmMessageForAll.Untreated_LinkageData = new Client.Entities.AlarmEntity.LinkageData();
     if (Add_PlanDeviceID == new Guid("00000000-0000-0000-0000-000000000000"))
     {
         Add_PlanDeviceID = Guid.NewGuid();
         temp_AlarmMessageForAll.PlanDeviceID = Add_PlanDeviceID.ToString();
         Bool_Add = false;
     }
     else
     {
         temp_AlarmMessageForAll = ClassPlan.temp_PlanDataforAll[Add_PlanDeviceID.ToString()];
         Bool_Add = true;
         DataFresh();
     }
     #region
     //----------------------测试数据-------------------------------------------
     //StreamMediaList temp_StreamMediaList = new StreamMediaList();
     //temp_StreamMediaList.DeviceID = new Guid();
     //temp_StreamMediaList.VideoIP = "192.168.1.64";
     //temp_StreamMediaList.Name = "测试NVR";
     //CameraList temp_CameraList_1 = new CameraList();
     //temp_CameraList_1.StreamMedia_DeviceID = temp_StreamMediaList.DeviceID;
     //temp_CameraList_1.DeviceID= Guid.NewGuid();
     //temp_CameraList_1.VideoName = "测试摄像机";
     //CameraList temp_CameraList_2 = new CameraList();
     //temp_CameraList_2.StreamMedia_DeviceID = temp_StreamMediaList.DeviceID;
     //temp_CameraList_2.DeviceID = Guid.NewGuid();
     //temp_CameraList_2.VideoName = "测试摄像机2";
     //ClassPlan.streamMediaList = new List<StreamMediaList>();
     //ClassPlan.cameraList = new List<CameraList>();
     //ClassPlan.streamMediaList.Add(temp_StreamMediaList);
     //ClassPlan.cameraList.Add(temp_CameraList_1);
     //ClassPlan.cameraList.Add(temp_CameraList_2);
     for (int i = 0; i < ClassPlan.cameraList.Count; i++)
     {
         Video_Preset temp_Video_Preset = new Video_Preset();
         temp_Video_Preset.CameraID   = ClassPlan.cameraList[i].DeviceID.ToString();
         temp_Video_Preset.CameraName = ClassPlan.cameraList[i].VideoName;
         temp_Video_Preset.PresetName_ID.Add("预置位1");
         temp_Video_Preset.PresetName_ID.Add("预置位2");
         temp_Video_Preset.PresetName_ID.Add("预置位3");
         if (!dic_Video_Preset.ContainsKey(temp_Video_Preset.CameraID))
         {
             dic_Video_Preset.Add(temp_Video_Preset.CameraID, temp_Video_Preset);
         }
     }
     //-----------------------end------------------------------------------------
     #endregion
     if (classplan == null)
     {
         MessageBox.Show("预案数据为空");
         //return;
     }
     //给"显示区域"添加显示屏
     for (int i = 1; i <= 16; i++)
     {
         DataGridViewRow Dgvr = this.dataGridView2.Rows[this.dataGridView2.Rows.Add()];
         Dgvr.Cells[0].Value = "分屏" + i;
     }
     comboBox1.SelectedIndex = 0;
     //处理掉DataGridViewComboBoxColumn绑定数据源后,再绑定到DataTable中的Column时,提示"System.ArgumentException:DagaGridViewComboBoxCell值无效"的错误
     //this.dataGridView1.DataError += delegate (object sender, DataGridViewDataErrorEventArgs e) { };
     Init();
     AnimateWindow(Handle, 300, AW_CENTER);//窗体弹出效果
 }
Example #11
0
        public void UpdateClassPlan(ClassPlan classPlan)
        {
            using (EntityModel em = new EntityModel())
            {
                var current = em.ClassPlan
                              .Where(c => c.ClassPlanId == classPlan.ClassPlanId)
                              .Include(c => c.Chores)
                              .Include(c => c.ClassGoals)
                              .Include(c => c.Evaluetions)
                              .Include(c => c.LessonsContents)
                              .FirstOrDefault();
                if (current == null)
                {
                    return;
                }

                current.Chores.RemoveAll(c => classPlan.Chores.Exists(ch => ch.ChoresId == c.ChoresId) == false);
                current.ClassGoals.RemoveAll(c => classPlan.ClassGoals.Exists(ch => ch.ClassGoalsId == c.ClassGoalsId) == false);
                current.Evaluetions.RemoveAll(c => classPlan.Evaluetions.Exists(ch => ch.EvaluetionId == c.EvaluetionId) == false);
                current.LessonsContents.RemoveAll(c => classPlan.LessonsContents.Exists(ch => ch.LessonsContentId == c.LessonsContentId) == false);

                foreach (var chore in classPlan.Chores)
                {
                    var currentChore = current.Chores.FirstOrDefault(c => c.ChoresId == chore.ChoresId);
                    if (currentChore == null)
                    {
                        current.Chores.Add(chore);
                    }
                    else
                    {
                        em.Entry(currentChore).CurrentValues.SetValues(chore);
                    }
                }

                foreach (var classGoals in classPlan.ClassGoals)
                {
                    var currentClassGoals = current.ClassGoals.FirstOrDefault(c => c.ClassGoalsId == classGoals.ClassGoalsId);
                    if (currentClassGoals == null)
                    {
                        current.ClassGoals.Add(classGoals);
                    }
                    else
                    {
                        em.Entry(currentClassGoals).CurrentValues.SetValues(classGoals);
                    }
                }

                foreach (var evaluations in classPlan.Evaluetions)
                {
                    var currentEvaluation = current.Evaluetions.FirstOrDefault(c => c.EvaluetionId == evaluations.EvaluetionId);
                    if (currentEvaluation == null)
                    {
                        current.Evaluetions.Add(evaluations);
                    }
                    else
                    {
                        em.Entry(currentEvaluation).CurrentValues.SetValues(evaluations);
                    }
                }

                foreach (var lessonsContent in classPlan.LessonsContents)
                {
                    var currentLessonContent = current.LessonsContents.FirstOrDefault(c => c.LessonsContentId == lessonsContent.LessonsContentId);
                    if (currentLessonContent == null)
                    {
                        current.LessonsContents.Add(lessonsContent);
                    }
                    else
                    {
                        em.Entry(currentLessonContent).CurrentValues.SetValues(lessonsContent);
                    }
                }

                em.Entry(current).CurrentValues.SetValues(classPlan);
                em.SaveChanges();
            }
        }