private void AppendGroupSwitchNode(TreeNode aNode) { string[] str = aNode.Tag.ToString().Split(';'); int key = int.Parse(str[0]); GroupSwitchGroup groupSwitchGroup = _listGroupSwitchGroup[key]; if (groupSwitchGroup.ListGroupSwitchDetailInfo == null) { return; } foreach (KeyValuePair <int, GroupSwitchDetailInfo> keyValuePair in groupSwitchGroup.ListGroupSwitchDetailInfo) { var node = new TreeNode(keyValuePair.Value.SynGroupName + "_" + keyValuePair.Value.TickTime); //G-群组切换群组ID //S-同步群组ID //D-Detail ID //T-TickYime node.Tag = keyValuePair.Key + ";D;" + key + ";G;" + keyValuePair.Value.SynGroupId + ";S;" + keyValuePair.Value.TickTime + ";T"; if (_lastSelectedGroupSwitchGroupTreeNode != null) { if (_lastSelectedGroupSwitchGroupTreeNode.Tag.ToString() == node.Tag.ToString()) { node.BackColor = Color.Gray; _lastSelectedGroupSwitchGroupTreeNode = node; } } aNode.Nodes.Add(node); } }
public Dictionary <int, GroupSwitchGroup> GetAllGroupSwitchGroups(ref string errMessage) { Database db = DatabaseFactory.CreateDatabase(); errMessage = ""; var list = new Dictionary <int, GroupSwitchGroup>(); try { GroupSwitchGroup groupSwitchGroup; DataSet ds = GroupSwitchGroupDataAccess.GetAllGroupSwitchGroupInfo(db); DataSet groupSwitchDetail; GroupSwitchDetailInfo groupSwitchDetailInfo; CameraMonitorPairInfo cameraMonitorPairInfo; //对于每一个群组切换的组 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { groupSwitchGroup = new GroupSwitchGroup(ds.Tables[0].Rows[i]); groupSwitchDetail = GroupSwitchDetailDataAccess.GetGroupSwitchDetailByGroupSwitchId(db, groupSwitchGroup.Id); groupSwitchGroup.ListGroupSwitchDetailInfo = new Dictionary <int, GroupSwitchDetailInfo>(); //对于一个组中的所有与同步群组有联系的记录 foreach (DataRow drgsdi in groupSwitchDetail.Tables[0].Rows) { groupSwitchDetailInfo = new GroupSwitchDetailInfo(drgsdi); //根据同步群组获取同步群组与摄像机、监视器的配对信息 DataSet dsCamMonPair = CameraMonitorPairDataAccess.GetCameraMonitorPairBySynGroupId(db, groupSwitchDetailInfo.SynGroupId); groupSwitchDetailInfo.ListCameraMonitorPair = new Dictionary <int, CameraMonitorPairInfo>(); foreach (DataRow drCmP in dsCamMonPair.Tables[0].Rows) { cameraMonitorPairInfo = new CameraMonitorPairInfo(drCmP); groupSwitchDetailInfo.ListCameraMonitorPair.Add(cameraMonitorPairInfo.CameraMonitorPairId, cameraMonitorPairInfo); } groupSwitchGroup.ListGroupSwitchDetailInfo.Add(groupSwitchDetailInfo.Id, groupSwitchDetailInfo); } list.Add(groupSwitchGroup.Id, groupSwitchGroup); } return(list); } catch (Exception ex) { errMessage = ex.Message + ex.StackTrace; Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace); return(null); } }
public int Update(ref string errMessage, GroupSwitchGroup groupSwitchGroup) { Database db = DatabaseFactory.CreateDatabase(); errMessage = ""; try { return(GroupSwitchGroupDataAccess.Update(db, groupSwitchGroup)); } catch (Exception ex) { errMessage = ex.Message + ex.StackTrace; Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace); return(-1); } }
public GroupSwitchGroup GetGroupSwitchGroupById(ref string errMessage, int groupSwitchGroupId) { Database db = DatabaseFactory.CreateDatabase(); errMessage = ""; try { DataSet ds = GroupSwitchGroupDataAccess.GetGroupSwitchGroupById(db, groupSwitchGroupId); if (ds.Tables[0].Rows.Count == 0) { return(null); } var groupSwitchGroup = new GroupSwitchGroup(ds.Tables[0].Rows[0]) { ListGroupSwitchDetailInfo = new Dictionary <int, GroupSwitchDetailInfo>() }; var groupSwitchDetail = GroupSwitchDetailDataAccess.GetGroupSwitchDetailByGroupSwitchId(db, groupSwitchGroup.Id); groupSwitchGroup.ListGroupSwitchDetailInfo = new Dictionary <int, GroupSwitchDetailInfo>(); //对于一个组中的所有与同步群组有联系的记录 foreach (DataRow drgsdi in groupSwitchDetail.Tables[0].Rows) { var groupSwitchDetailInfo = new GroupSwitchDetailInfo(drgsdi); //根据同步群组获取同步群组与摄像机、监视器的配对信息 DataSet dsCamMonPair = CameraMonitorPairDataAccess.GetCameraMonitorPairBySynGroupId(db, groupSwitchDetailInfo.SynGroupId); groupSwitchDetailInfo.ListCameraMonitorPair = new Dictionary <int, CameraMonitorPairInfo>(); foreach (DataRow drCmP in dsCamMonPair.Tables[0].Rows) { var cameraMonitorPairInfo = new CameraMonitorPairInfo(drCmP); groupSwitchDetailInfo.ListCameraMonitorPair.Add(cameraMonitorPairInfo.CameraMonitorPairId, cameraMonitorPairInfo); } groupSwitchGroup.ListGroupSwitchDetailInfo.Add(groupSwitchDetailInfo.Id, groupSwitchDetailInfo); } return(groupSwitchGroup); } catch (Exception ex) { errMessage = ex.Message + ex.StackTrace; Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace); return(null); } }
public static int Update(Database db, GroupSwitchGroup oGroupInfo) { StringBuilder sb = new StringBuilder(); sb.Append("update GroupSwitchGroup set"); sb.AppendFormat(" Name='{0}'", oGroupInfo.Name); sb.AppendFormat(",Description='{0}'", oGroupInfo.Description); sb.AppendFormat(" where ID={0})", oGroupInfo.Id); string cmdText = sb.ToString(); try { return(db.ExecuteNonQuery(CommandType.Text, cmdText)); } catch (Exception ex) { throw ex; } }
private void DisplayGroupSwitchDetail() { dgvGroupSwitchDetail.Rows.Clear(); lblGroupSwitchName.Text = ""; if (_lastSelectedGroupSwitchGroupTreeNode == null) { return; } string str = _lastSelectedGroupSwitchGroupTreeNode.Tag.ToString(); if (str.IndexOf("D") < 0) { string[] strs = str.Split(';'); int gsID = int.Parse(strs[0]); GroupSwitchGroup groupSwitchGroup = _listGroupSwitchGroup[gsID]; lblGroupSwitchName.Text = groupSwitchGroup.Name; foreach (KeyValuePair <int, GroupSwitchDetailInfo> keyValuePair in groupSwitchGroup.ListGroupSwitchDetailInfo) { int index = dgvGroupSwitchDetail.Rows.Add(); DataGridViewRow dgvr = dgvGroupSwitchDetail.Rows[index]; dgvr.Cells["SynGroup"].Value = keyValuePair.Value.SynGroupName; dgvr.Cells["Tick"].Value = keyValuePair.Value.TickTime; dgvr.Cells["Id"].Value = keyValuePair.Key; } } else if (str.IndexOf("D") >= 0) { string[] strs = str.Split(';'); int gsID = int.Parse(strs[2]); GroupSwitchGroup groupSwitchGroup = _listGroupSwitchGroup[gsID]; lblGroupSwitchName.Text = groupSwitchGroup.Name; int detailId = int.Parse(strs[0]); GroupSwitchDetailInfo groupSwitchDetailInfo = groupSwitchGroup.ListGroupSwitchDetailInfo[detailId]; int index = dgvGroupSwitchDetail.Rows.Add(); DataGridViewRow dgvr = dgvGroupSwitchDetail.Rows[index]; dgvr.Cells["SynGroup"].Value = groupSwitchDetailInfo.SynGroupName; dgvr.Cells["Tick"].Value = groupSwitchDetailInfo.TickTime; dgvr.Cells["Id"].Value = groupSwitchDetailInfo.Id; } }
public static int Insert(Database db, GroupSwitchGroup oGroupInfo) { StringBuilder sbField = new StringBuilder(); StringBuilder sbValue = new StringBuilder(); sbField.Append("INSERT INTO GroupSwitchGroup("); sbValue.Append("values("); sbField.Append("Name"); sbValue.AppendFormat("'{0}'", oGroupInfo.Name); sbField.Append(",Description)"); sbValue.AppendFormat(",'{0}')", oGroupInfo.Description); string cmdText = sbField.ToString() + " " + sbValue.ToString() + ""; try { return(db.ExecuteNonQuery(CommandType.Text, cmdText)); } catch (Exception ex) { throw ex; } }
private void btnDeleteGroupSwitchDetail_Click(object sender, EventArgs e) { if (_lastSelectedGroupSwitchGroupTreeNode == null) { return; } string selectTagStr = _lastSelectedGroupSwitchGroupTreeNode.Tag.ToString(); if (selectTagStr.IndexOf("D") < 0) { if (_lastSelectedGroupSwitchGroupTreeNode.FirstNode != null) { XtraMessageBox.Show("群组切换非空,不能直接删除!"); } else { string[] strs = selectTagStr.Split(';'); int groupSwitchGroupId = int.Parse(strs[0]); _lastSelectedGroupSwitchGroupTreeNode = tvGroupSwitchGroup.SelectedNode.PrevNode; GroupSwitchGroup groupSwitchGroup = GroupSwitchGroupBusiness.Instance.GetGroupSwitchGroupById(ref errMessage, groupSwitchGroupId); GroupSwitchGroupBusiness.Instance.Delete(ref errMessage, groupSwitchGroupId); OperateLogBusiness.Instance.Insert(ref errMessage, new OperateLog { ClientUserId = MainForm.CurrentUser.UserId, ClientUserName = MainForm.CurrentUser.UserName, Content = groupSwitchGroup.ToString(), HappenTime = DateTime.Now, OperateTypeId = (int)(OperateLogTypeId.GroupSwitchDelete), OperateTypeName = OperateLogTypeName.GroupSwitchDelete, OperateUserName = MainForm.CurrentUser.UserName }); } } else { string[] tagStrs = selectTagStr.Split(';'); int detailId = int.Parse(tagStrs[0]); GroupSwitchDetailInfo groupSwitchDetailInfo = GroupSwitchDetailBusiness.Instance.GetGroupSwitchDetailById(ref errMessage, detailId); GroupSwitchDetailBusiness.Instance.DeleteGroupSwitchDetailById(ref errMessage, detailId); OperateLogBusiness.Instance.Insert(ref errMessage, new OperateLog { ClientUserId = MainForm.CurrentUser.UserId, ClientUserName = MainForm.CurrentUser.UserName, Content = groupSwitchDetailInfo.ToString(), HappenTime = DateTime.Now, OperateTypeId = (int)(OperateLogTypeId.GroupSwitchDetailDelete), OperateTypeName = OperateLogTypeName.GroupSwitchDetailDelete, OperateUserName = MainForm.CurrentUser.UserName }); _lastSelectedGroupSwitchGroupTreeNode = _lastSelectedGroupSwitchGroupTreeNode.PrevNode ?? _lastSelectedGroupSwitchGroupTreeNode.Parent; } LoadGroupSwitch(); }