public Guid Insert(Pre_arrangedPlanning entityToInsert) { using (Conn) { return(Conn.Insert <Guid>(entityToInsert)); } }
public int Delete(Pre_arrangedPlanning entityToInsert) { using (Conn) { return(Conn.Delete(entityToInsert)); } }
private void button4_Click(object sender, EventArgs e) { if (dataGridView1.CurrentCell != null) { if (radioButton1.Checked == false && radioButton2.Checked == false && radioButton3.Checked == false) { MessageBox.Show("请选择具体的时间设置类型!"); return; } int index = dataGridView1.CurrentCell.RowIndex; AlarmMessageForAll temp_AlarmMessageForAll = new AlarmMessageForAll(); Pre_arrangedPlanning temp_Pre_arrangedPlanning = new Pre_arrangedPlanning(); string temp_PlanDeviceID = dataGridView1.Rows[index].Cells[9].Value.ToString(); temp_Pre_arrangedPlanning = ClassPlan.pre_arrangedPlanning.Find(_ => _.PlanDeviceID.ToString() == temp_PlanDeviceID); if (temp_Pre_arrangedPlanning == null) { return; } temp_AlarmMessageForAll.StartDate = Start_data1.Value.Date.ToString("yyyy/MM/dd"); temp_AlarmMessageForAll.StartWeek = Start_data1.Value.DayOfWeek.ToString(); temp_AlarmMessageForAll.StartTime = Start_time1.Text; temp_AlarmMessageForAll.EndDate = Start_data2.Value.Date.ToString("yyyy/MM/dd"); temp_AlarmMessageForAll.EndWeek = Start_data2.Value.DayOfWeek.ToString(); temp_AlarmMessageForAll.EndTime = Start_time2.Text; temp_AlarmMessageForAll.Description = temp_Pre_arrangedPlanning.Description; temp_AlarmMessageForAll.DeviceID = temp_Pre_arrangedPlanning.DeviceID.ToString(); temp_AlarmMessageForAll.DeviceType = temp_Pre_arrangedPlanning.DeviceType.ToString(); temp_AlarmMessageForAll.Mark = temp_Pre_arrangedPlanning.Mark; temp_AlarmMessageForAll.PlanDeviceID = temp_Pre_arrangedPlanning.PlanDeviceID.ToString(); temp_AlarmMessageForAll.PlanType = temp_Pre_arrangedPlanning.PlanType; temp_AlarmMessageForAll.PlanTypeID = temp_Pre_arrangedPlanning.PlanTypeID; if (radioButton1.Checked == true) { temp_AlarmMessageForAll.TimeType = "1"; } else if (radioButton2.Checked == true) { temp_AlarmMessageForAll.TimeType = "2"; } else if (radioButton3.Checked == true) { temp_AlarmMessageForAll.TimeType = "3"; } classplan.PlanRevise(temp_AlarmMessageForAll); } //classplan = new ClassPlan(); classplan.PlanInit();//重新获取所有预案数据 DataLoad(); }
public override void ExecuteCommand(AppSession session, StringRequestInfo requestInfo) { PlanData data = new PlanData(); AlarmMessageForAll dataForOne = new AlarmMessageForAll(); switch (requestInfo[0]) { case "Add": //添加 { string str = requestInfo.Body.Substring(4); dataForOne = JsonConvert.DeserializeObject <AlarmMessageForAll>(str); try { //插入预案数据 Pre_arrangedPlanning temp_Pre_arrangedPlanning = new Pre_arrangedPlanning(); temp_Pre_arrangedPlanning.PlanDeviceID = new Guid(dataForOne.PlanDeviceID); temp_Pre_arrangedPlanning.PlanType = dataForOne.PlanType; temp_Pre_arrangedPlanning.PlanTypeID = dataForOne.PlanTypeID; temp_Pre_arrangedPlanning.DeviceID = dataForOne.DeviceID; temp_Pre_arrangedPlanning.DeviceType = int.Parse(dataForOne.DeviceType); temp_Pre_arrangedPlanning.StartDate = dataForOne.StartDate; temp_Pre_arrangedPlanning.StartTime = dataForOne.StartTime; temp_Pre_arrangedPlanning.StartWeek = dataForOne.StartWeek; temp_Pre_arrangedPlanning.TimeType = dataForOne.TimeType; temp_Pre_arrangedPlanning.EndDate = dataForOne.EndDate; temp_Pre_arrangedPlanning.EndTime = dataForOne.EndTime; temp_Pre_arrangedPlanning.EndWeek = dataForOne.EndWeek; temp_Pre_arrangedPlanning.Description = dataForOne.Description; temp_Pre_arrangedPlanning.Mark = dataForOne.Mark; Pre_arrangedPlanning.Insert(temp_Pre_arrangedPlanning); //插入联动数据 LinkageData Trigger_LinkageData = dataForOne.Trigger_LinkageData; //联动数据 if (Trigger_LinkageData != null) { LinkageDataComand.Insert(Trigger_LinkageData); } LinkageData Disposal_LinkageData = dataForOne.Disposal_LinkageData; //处置数据 if (Disposal_LinkageData != null) { LinkageDataComand.Insert(Disposal_LinkageData); } LinkageData Untreated_LinkageData = dataForOne.Untreated_LinkageData; //未处置数据 if (Untreated_LinkageData != null) { LinkageDataComand.Insert(Untreated_LinkageData); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } break; case "Del": //删除 { string str = requestInfo.Body.Substring(4); dataForOne = JsonConvert.DeserializeObject <AlarmMessageForAll>(str); try { Pre_arrangedPlanning.Delete(new Guid(dataForOne.PlanDeviceID)); LinkageData Trigger_LinkageData = dataForOne.Trigger_LinkageData; //联动数据 if (Trigger_LinkageData != null) { LinkageDataComand.Delete(Trigger_LinkageData); } LinkageData Disposal_LinkageData = dataForOne.Disposal_LinkageData; //处置数据 if (Disposal_LinkageData != null) { LinkageDataComand.Delete(Disposal_LinkageData); } LinkageData Untreated_LinkageData = dataForOne.Untreated_LinkageData; //未处置数据 if (Untreated_LinkageData != null) { LinkageDataComand.Delete(Untreated_LinkageData); } } catch (Exception) { throw; } } break; case "Revise": //修改 { string str = requestInfo.Body.Substring(7); dataForOne = JsonConvert.DeserializeObject <AlarmMessageForAll>(str); try { //插入预案数据 Pre_arrangedPlanning temp_Pre_arrangedPlanning = new Pre_arrangedPlanning(); temp_Pre_arrangedPlanning.PlanDeviceID = new Guid(dataForOne.PlanDeviceID); temp_Pre_arrangedPlanning.PlanType = dataForOne.PlanType; temp_Pre_arrangedPlanning.PlanTypeID = dataForOne.PlanTypeID; temp_Pre_arrangedPlanning.DeviceID = dataForOne.DeviceID; temp_Pre_arrangedPlanning.DeviceType = int.Parse(dataForOne.DeviceType); temp_Pre_arrangedPlanning.StartDate = dataForOne.StartDate; temp_Pre_arrangedPlanning.StartTime = dataForOne.StartTime; temp_Pre_arrangedPlanning.StartWeek = dataForOne.StartWeek; temp_Pre_arrangedPlanning.TimeType = dataForOne.TimeType; temp_Pre_arrangedPlanning.EndDate = dataForOne.EndDate; temp_Pre_arrangedPlanning.EndTime = dataForOne.EndTime; temp_Pre_arrangedPlanning.EndWeek = dataForOne.EndWeek; temp_Pre_arrangedPlanning.Description = dataForOne.Description; temp_Pre_arrangedPlanning.Mark = dataForOne.Mark; Pre_arrangedPlanning.Update(temp_Pre_arrangedPlanning); //插入联动数据 LinkageData Trigger_LinkageData = dataForOne.Trigger_LinkageData; //联动数据 if (Trigger_LinkageData != null) { LinkageDataComand.Update(Trigger_LinkageData); } LinkageData Disposal_LinkageData = dataForOne.Disposal_LinkageData; //处置数据 if (Disposal_LinkageData != null) { LinkageDataComand.Update(Disposal_LinkageData); } LinkageData Untreated_LinkageData = dataForOne.Untreated_LinkageData; //未处置数据 if (Untreated_LinkageData != null) { LinkageDataComand.Update(Untreated_LinkageData); } } catch (Exception) { throw; } } break; case "Query": //查询 { List <Pre_arrangedPlanning> pre_arrangedPlanning; List <ArmAndDisarmList> armAndDisarmList; List <LinkageData> linkageData; List <CameraList> cameraList; List <StreamMediaList> streamMediaList; List <StreamServerList> streamServerList; //获取数据库的所有设备信息 pre_arrangedPlanning = Pre_arrangedPlanning.GetList(); armAndDisarmList = ArmAndDisArm.GetList(); linkageData = LinkageDataComand.GetList(); cameraList = CameraList.GetList(); streamMediaList = StreamMediaList.GetList(); streamServerList = StreamServerList.GetList(); //组装数据 data.pre_arrangedPlanning = pre_arrangedPlanning; data.armAndDisarmList = armAndDisarmList; data.linkageData = linkageData; data.cameraList = cameraList; data.streamMediaList = streamMediaList; data.streamServerList = streamServerList; //转json string str = JsonConvert.SerializeObject(data); session.Send(str); } break; case "Query1": List <Pre_arrangedPlanning> pre_arrangedPlanning1; pre_arrangedPlanning1 = Pre_arrangedPlanning.GetList(); for (int i = 0; i < pre_arrangedPlanning1.Count; i++) { if (pre_arrangedPlanning1[i].PlanType != 2) { pre_arrangedPlanning1.Remove(pre_arrangedPlanning1[i]); } } //转json string str1 = JsonConvert.SerializeObject(pre_arrangedPlanning1); session.Send(str1); break; } }