private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { ComboBoxItem <LayerGrade> item = comboBox1.SelectedItem as ComboBoxItem <LayerGrade>; if (item == null) { return; } string uid = Itop.Common.ConfigurationHelper.GetValue("SvgID"); if (string.IsNullOrEmpty(uid)) { return; } SVG_LAYER lar = new SVG_LAYER(); lar.svgID = uid; lar.YearID = "'" + item.Value.SUID + "'"; IList <SVG_LAYER> larlist = Services.BaseService.GetList <SVG_LAYER>("SelectSVG_LAYERByYearID", lar); layerList.Items.Clear(); hs.Clear(); foreach (SVG_LAYER layer in larlist) { layerList.Items.Add(new DevExpress.XtraEditors.Controls.CheckedListBoxItem(layer.NAME)); hs.Add(layer.NAME, layer); } }
private void LayerGradeDel(object sender, EventArgs e) { if (treeList1.FocusedNode == null) { return; } IList list = this.SymbolDoc.getLayerList(); foreach (Layer lay in list) { if (treeList1.FocusedNode[treeListColumn2].ToString() == lay.ID) { return; } } if (treeList1.FocusedNode.Nodes.Count > 0) { MsgBox.Show("有下级目录,不能删除!"); return; } string uid = treeList1.FocusedNode[treeListColumn2].ToString(); SVG_LAYER lar = new SVG_LAYER(); lar.svgID = strSvgDataUid; lar.YearID = " YearID='" + uid + "' "; IList <SVG_LAYER> list4 = Services.BaseService.GetList <SVG_LAYER>("SelectSVG_LAYERByWhere", lar); if (list4.Count > 0) { MsgBox.Show("当前分级下有图形数据,不能删除!"); return; } //请求确认 //if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes) //{ // return; //} if (MessageBox.Show("删除分级会对其它的卷宗有影响并且不可恢复,确定要删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes) { return; } //执行删除操作 try { Services.BaseService.DeleteByKey <LayerGrade>(uid); } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return; } this.treeList1.Nodes.Remove(this.treeList1.FocusedNode); InitData(strSvgDataUid); }
private void LayerGradeChange(object sender, EventArgs e) { if (treeList1.FocusedNode == null) { return; } string uid = treeList1.FocusedNode[treeListColumn2].ToString(); LayerGrade obj = Services.BaseService.GetOneByKey <LayerGrade>(uid); frmLayerGradeInPut dlg = new frmLayerGradeInPut(strSvgDataUid); dlg.TextInPut = treeList1.FocusedNode[treeListColumn1].ToString(); //LayerGrade objParent = Services.BaseService.GetOneByKey<LayerGrade>((string)treeList1.FocusedNode[treeListColumn4]); dlg.ParentID = treeList1.FocusedNode[treeListColumn4].ToString(); if (obj != null) { dlg.textBoxEnabled = true; } else { dlg.textBoxEnabled = false; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.TextInPut == "") { MessageBox.Show("分级名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } SVG_LAYER lar = new SVG_LAYER(); lar.svgID = strSvgDataUid; lar.SUID = uid; lar = (SVG_LAYER)Services.BaseService.GetObject("SelectSVG_LAYERByKey", lar); if (lar != null) { lar.YearID = dlg.ParentID; Services.BaseService.Update <SVG_LAYER>(lar); } if (obj != null) { obj.Name = dlg.TextInPut; obj.ParentID = dlg.ParentID; foreach (LayerGrade lay in ilist) { if (obj.Name == lay.Name && obj.Name != treeList1.FocusedNode[treeListColumn1].ToString()) { MessageBox.Show("分级已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } if (obj.ParentID == obj.SUID) { MessageBox.Show("不能将分级设置成自己的子级!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } treeList1.FocusedNode.SetValue("Name", obj.Name); treeList1.FocusedNode.SetValue("ParentID", obj.ParentID); Services.BaseService.Update("UpdateLayerGrade", obj); } else { Layer lay = SymbolDoc.GetLayerByID(uid); treeList1.FocusedNode.SetValue("Name", dlg.TextInPut); treeList1.FocusedNode.SetValue("ParentID", dlg.ParentID); //lay.Label = dlg.TextInPut; lay.SetAttribute("ParentID", dlg.ParentID); } } else { return; } InitData(strSvgDataUid); }
private void simpleButton1_Click_1(object sender, EventArgs e) { string text1 = textEdit1.Text; string text2 = textEdit2.Text; if (textEdit1.Text == "") { MessageBox.Show("请指定要复制的年份。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textEdit1.Focus(); return; } if (textEdit2.Text == "") { MessageBox.Show("请指定要复制到的目标年份。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textEdit2.Focus(); return; } LayerGrade gra = new LayerGrade(); gra.Name = text2 + "%"; IList <LayerGrade> list = Services.BaseService.GetList <LayerGrade>("SelectLayerGradeByYear", gra); if (list.Count == 0) { MessageBox.Show("没有找到指定的年份信息,请先建立对应年份的图层分级。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int itemcount = checkedListBox1.Items.Count; if (checkedListBox1.Items != null) { f.SetText("复制中,请等待......"); f.Show(); for (int num = 0; num < itemcount; num++) { string itemname = checkedListBox1.Items[num].ToString(); string item4 = itemname.Substring(0, 4); if ((item4 == text1) && (text2 != "") && checkedListBox1.GetItemChecked(num) == true) { Layer layer = this.checkedListBox1.Items[num] as Layer; f.SetText("共选择" + checkedListBox1.CheckedItems.Count + "层,正在复制" + layer.Label + "层。"); string str = layer.GetAttribute("layerType"); Layer layer2 = CopyLayer2(layer, text2); if (layer2 != null) { if (layer.Visible) { layer.Visible = false; layer.Visible = true; } layer2.SetAttribute("layerType", str); this.checkedListBox1.Items.Add(layer2); layer2.Visible = false; string xml = ""; XmlNodeList oldList = symbolDoc.SelectNodes("//*[@layer=\"" + layer2.ID + "\"]"); for (int i = 0; i < oldList.Count; i++) { xml = xml + ((SvgElement)oldList[i]).OuterXml; } SVG_LAYER obj = new SVG_LAYER(); obj.SUID = layer2.ID; obj.svgID = symbolDoc.SvgdataUid; obj.NAME = layer2.Label; obj.MDATE = System.DateTime.Now; obj.OrderID = num + 10; obj.YearID = ((LayerGrade)list[0]).SUID; obj.layerType = "电网规划层"; obj.visibility = "visible"; obj.IsSelect = "true"; obj.XML = xml; Services.BaseService.Create <SVG_LAYER>(obj); } } } f.Hide(); } }
public void InitData() { IList svglist = Services.BaseService.GetList("SelectLayerFileList", svg); LayerGrade lg = new LayerGrade(); IList ilist = Services.BaseService.GetList("SelectLayerGradeList", lg); DataTable dataTable = DataConverter.ToDataTable(ilist, typeof(LayerGrade)); SVG_LAYER sl = new SVG_LAYER(); IList list = Services.BaseService.GetList("SelectSVG_LAYERList", sl); treeList1.DataSource = dataTable; string ide = treeList1.Nodes[0].GetValue(0).ToString();//获取某一节点的值 foreach (SVG_LAYER lay in list) { if (lay.layerType == "电网规划层") { LayerGrade obj = new LayerGrade(); obj.SUID = lay.SUID; obj.Name = lay.NAME; obj.ParentID = lay.YearID; string tempobj = ""; string tempyear = ""; if (obj.Name.ToString().Length >= 3) { tempobj = obj.Name.ToString().Substring(obj.Name.ToString().Length - 3, 3); } if (obj.Name.ToString().Length >= 4) { tempyear = obj.Name.ToString().Substring(0, 4); } if (tempobj == "变电站") { for (int j = 0; j < treeList1.Nodes.Count; j++) { if (treeList1.Nodes[j].GetValue(0).ToString().Length > 3) { if (treeList1.Nodes[j].GetValue(0).ToString().Substring(0, 4) == tempyear) { substation _substat = new substation(); _substat.LayerID = obj.SUID; _substat.ObligateField1 = "220"; IList subList = Services.BaseService.GetList("SelectsubstationByLayerIDandObligateField1", _substat); int templ = treeList1.Nodes[j].Nodes.Count; treeList1.AppendNode(obj.Name, treeList1.Nodes[j]); treeList1.Nodes[j].Nodes[templ].SetValue(0, obj.Name); if (subList.Count != 0) { int jj = 0; foreach (substation temps in subList) { treeList1.AppendNode(temps, treeList1.Nodes[j].Nodes[templ]); treeList1.Nodes[j].Nodes[templ].Nodes[jj].SetValue(0, temps.EleName); jj++; } } _substat.ObligateField1 = "110"; subList = Services.BaseService.GetList("SelectsubstationByLayerIDandObligateField1", _substat); templ = treeList1.Nodes[j].Nodes.Count; treeList1.AppendNode(obj.Name, treeList1.Nodes[j]); treeList1.Nodes[j].Nodes[templ].SetValue(0, obj.Name); if (subList.Count != 0) { int jj = 0; foreach (substation temps in subList) { treeList1.AppendNode(temps, treeList1.Nodes[j].Nodes[templ]); treeList1.Nodes[j].Nodes[templ].Nodes[jj].SetValue(0, temps.EleName); jj++; } } _substat.ObligateField1 = "66"; subList = Services.BaseService.GetList("SelectsubstationByLayerIDandObligateField1", _substat); templ = treeList1.Nodes[j].Nodes.Count; treeList1.AppendNode(obj.Name, treeList1.Nodes[j]); treeList1.Nodes[j].Nodes[templ].SetValue(0, obj.Name); if (subList.Count != 0) { int jj = 0; foreach (substation temps in subList) { treeList1.AppendNode(temps, treeList1.Nodes[j].Nodes[templ]); treeList1.Nodes[j].Nodes[templ].Nodes[jj].SetValue(0, temps.EleName); jj++; } } _substat.ObligateField1 = "500"; subList = Services.BaseService.GetList("SelectsubstationByLayerIDandObligateField1", _substat); templ = treeList1.Nodes[j].Nodes.Count; treeList1.AppendNode(obj.Name, treeList1.Nodes[j]); treeList1.Nodes[j].Nodes[templ].SetValue(0, obj.Name); if (subList.Count != 0) { int jj = 0; foreach (substation temps in subList) { treeList1.AppendNode(temps, treeList1.Nodes[j].Nodes[templ]); treeList1.Nodes[j].Nodes[templ].Nodes[jj].SetValue(0, temps.EleName); jj++; } } } } } } } } Application.DoEvents(); }
private Layer CopyLayer(Layer layer) { Layer layer2 = Layer.CreateNew(layer.Label + " 副本", this.SymbolDoc); layer2.SetAttribute("ParentID", layer.GetAttribute("ParentID")); //foreach (SvgElement g in layer.GraphList) //{ // layer2.GraphList.Add(g); //} SVG_LAYER la = new SVG_LAYER(); la.SUID = layer.ID; la.svgID = symbolDoc.SvgdataUid; la = (SVG_LAYER)Services.BaseService.GetObject("SelectSVG_LAYERByKey", la); if (la != null) { la.SUID = layer2.ID; la.NAME = layer2.Label; Services.BaseService.Create <SVG_LAYER>(la); } this.SymbolDoc.NumberOfUndoOperations = (2 * layer2.GraphList.Count) + 200; SvgElementCollection sc = layer.GraphList; for (int i = layer.GraphList.Count - 1; i >= 0; i--) { SvgElement element = sc[i] as SvgElement; SvgElement temp = element.Clone() as SvgElement; //if (temp.Name=="use"){ if (temp.GetAttribute("CopyOf") == "") { temp.SetAttribute("CopyOf", temp.ID); } //else //{ // temp.SetAttribute("CopyOf", temp.ID); //} //} IGraph graph = (IGraph)layer2.AddElement(temp); graph.Layer = layer2; /* LineInfo _line = new LineInfo(); * _line.EleID = element.ID; * _line.SvgUID = this.SymbolDoc.SvgdataUid; * IList lineInfoList = Services.BaseService.GetList("SelectLineInfoByEleID", _line); * foreach (LineInfo line in lineInfoList) * { * line.UID = Guid.NewGuid().ToString(); * line.LayerID = layer2.ID; * line.EleID = temp.ID; * Services.BaseService.Create<LineInfo>(line); * } * glebeProperty gle = new glebeProperty(); * gle.EleID = element.ID; * gle.SvgUID = this.SymbolDoc.SvgdataUid; * IList gleProList = Services.BaseService.GetList("SelectglebePropertyByEleID", gle); * foreach (glebeProperty gleP in gleProList) * { * gleP.UID = Guid.NewGuid().ToString(); * gleP.LayerID = layer2.ID; * gleP.EleID = temp.ID; * Services.BaseService.Create<glebeProperty>(gleP); * } * substation _sub = new substation(); * _sub.EleID = element.ID; * _sub.SvgUID = this.SymbolDoc.SvgdataUid; * IList substationList = Services.BaseService.GetList("SelectsubstationByEleID", _sub); * foreach (substation sub in substationList) * { * sub.UID = Guid.NewGuid().ToString(); * sub.LayerID = layer2.ID; * sub.EleID = temp.ID; * Services.BaseService.Create<substation>(sub); * }*/ } this.SymbolDoc.NotifyUndo(); return(layer2); }