private void beDelete_ButtonClick(object sender, ButtonPressedEventArgs e) { if (!Alert.Confirm("确认删除数据?")) { return; } switch (_typeFlag) { case FlagManangingMineName: // 矿井名称管理 DeleteInfo <Mine>(); gridControl1.DataSource = CollectionHelper.ConvertTo(Mine.FindAll()); break; case FlagManangingHorizontal: // 水平名称管理 DeleteInfo <Horizontal>(); gridControl1.DataSource = CollectionHelper.ConvertTo(Horizontal.FindAll()); break; case FlagManangingMiningArea: // 采区名称管理 DeleteInfo <MiningArea>(); gridControl1.DataSource = CollectionHelper.ConvertTo(MiningArea.FindAll()); break; case FlagManangingWorkingFace: // 工作面名称管理 DeleteInfo <Workingface>(); gridControl1.DataSource = CollectionHelper.ConvertTo(Workingface.FindAll()); break; } }
private void SelectTunnelSimple_Load(object sender, EventArgs e) { if (System.IO.File.Exists(@"RecentWorkingfaces.xml")) { var doc = new XmlDocument(); doc.Load(@"RecentWorkingfaces.xml"); if (doc.DocumentElement != null) { var nodes = doc.DocumentElement.SelectNodes("/Workingfaces/Workingface"); if (nodes != null) { foreach (var workingface in (from XmlNode node in nodes select node.SelectSingleNode("ID") into selectSingleNode where selectSingleNode != null select selectSingleNode.InnerText into id select Workingface.TryFind(Convert.ToInt32(id))).Where(workingface => workingface != null)) { cbxWorkingface.Items.Add(workingface); } } } } }
public void LoadData(Workingface workingface) { LoadData(); lstMineName.SelectedValue = workingface.mining_area.horizontal.mine.id; lstHorizontalName.SelectedValue = workingface.mining_area.horizontal.id; lstMiningAreaName.SelectedValue = workingface.mining_area.id; lstWorkingFaceName.SelectedValue = workingface.id; }
private void lstWorkingFaceName_SelectedIndexChanged(object sender, EventArgs e) { if (lstWorkingFaceName.SelectedItems.Count <= 0) { SelectedWorkingFace = null; } else { SelectedWorkingFace = (Workingface)lstWorkingFaceName.SelectedItem; } }
public static void LoadWorkingFaceName(ListControl lb, int miningAreaId, String selectedText = "") { var workingFaces = Workingface.FindAllByProperty("mining_area.id", miningAreaId); if (workingFaces != null) { DataBindListControl(lb, workingFaces, "name", "id", selectedText); } }
private Workingface AddWorkingFace(MiningArea miningArea, String workingFaceName) { var workingFace = new Workingface { name = workingFaceName, mining_area = miningArea, type = WorkingfaceTypeEnum.HC }; workingFace.Save(); return(workingFace); }
private void AddTunnelInfo() { // 验证 if (!Check()) { DialogResult = DialogResult.None; return; } DialogResult = DialogResult.OK; //创建巷道实体 var workingFace = selectWorkingFaceControl1.SelectedWorkingFace; using (new SessionScope()) { workingFace = Workingface.Find(workingFace.id); if (workingFace.tunnels.FirstOrDefault(u => u.name == txtTunnelName.Text) != null) { Alert.AlertMsg("该工作面下已有同名巷道!"); return; } } var tunnel = new Tunnel { name = txtTunnelName.Text, support_pattern = cboSupportPattern.Text, workingface = selectWorkingFaceControl1.SelectedWorkingFace, lithology = cboLithology.SelectedValue.ToString(), type = (TunnelTypeEnum)cboTunnelType.SelectedValue, coal_or_stone = cboCoalOrStone.Text, coal_seam = ConfigHelper.current_seam.name, bid = IdGenerator.NewBindingId(), width = 5 }; //设计长度 if (txtDesignLength.Text != "") { tunnel.design_length = Convert.ToInt32(txtDesignLength.Text); } if (txtDesignArea.Text != "") { tunnel.design_area = Convert.ToInt32(txtDesignLength.Text); } //巷道信息登录 tunnel.Save(); Alert.AlertMsg("提交成功!"); }
private Tunnel AddTunnel(Workingface workingface, string tunnelName) { var type = tunnelName.Contains("横川") ? TunnelTypeEnum.HENGCHUAN : TunnelTypeEnum.OTHER; var tunnel = new Tunnel { name = tunnelName, workingface = workingface, width = 5, bid = IdGenerator.NewBindingId(), type = type }; tunnel.Save(); return(tunnel); }
private void btnTXT_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog { RestoreDirectory = true, Filter = @"文本文件(*.txt)|*.txt|所有文件(*.*)|*.*" }; if (ofd.ShowDialog() != DialogResult.OK) { return; } var fileName = ofd.SafeFileName; if (fileName != null) { var strs = fileName.Split('-'); var miningAreaName = strs[0]; var workingFaceName = strs[1]; var tunnelName = strs[2].Split('.')[0]; using (new SessionScope()) { var miningArea = MiningArea.FindAllByProperty("name", miningAreaName).FirstOrDefault(); if (miningArea == null) { var newMiningArea = new MiningArea { name = miningAreaName, horizontal = Horizontal.FindFirst() }; newMiningArea.Save(); miningArea = newMiningArea; } var workingFace = Workingface.findone_by_workingface_name_and_mining_area_id(workingFaceName, miningArea.id); if (workingFace == null) { if (Alert.Confirm("该工作面不存在,是否创建该工作面?")) { workingFace = AddWorkingFace(miningArea, workingFaceName); } } if (workingFace == null) { return; } if (workingFace.tunnels != null && workingFace.tunnels.FirstOrDefault(u => u.name == tunnelName) != null) { var tunnel = workingFace.tunnels.FirstOrDefault(u => u.name == tunnelName); selectTunnelUserControl1.LoadData(tunnel); } else { if (Alert.Confirm("该巷道不存在,是否创建该巷道?")) { if (Tunnel.exists_by_tunnel_name_and_working_face_id(tunnelName, workingFace.id)) { Alert.AlertMsg("该巷道已经存在"); return; } var tunnel = AddTunnel(workingFace, tunnelName); selectTunnelUserControl1.LoadData(tunnel); } } } txtWireName.Text = tunnelName.Split('.').Length > 0 ? tunnelName.Split('.')[0] + "导线点" : tunnelName + "导线点"; } var sr = new StreamReader(ofd.FileName, Encoding.GetEncoding("GB2312")); string duqu; while ((duqu = sr.ReadLine()) != null) { var temp1 = duqu.Split('|'); if (temp1.Length == 1) { continue; } var daoxianname = temp1[0]; var daoxianx = temp1[1]; var daoxiany = temp1[2]; dgrdvWire.Rows.Add(1); dgrdvWire[0, dgrdvWire.Rows.Count - 2].Value = daoxianname; dgrdvWire[1, dgrdvWire.Rows.Count - 2].Value = daoxianx; dgrdvWire[2, dgrdvWire.Rows.Count - 2].Value = daoxiany; dgrdvWire[3, dgrdvWire.Rows.Count - 2].Value = "0"; dgrdvWire[4, dgrdvWire.Rows.Count - 2].Value = "2.5"; dgrdvWire[5, dgrdvWire.Rows.Count - 2].Value = "2.5"; } }
private Workingface AddWorkingFace(MiningArea miningArea, String workingFaceName) { var workingFace = new Workingface { name = workingFaceName, mining_area = miningArea, type = WorkingfaceTypeEnum.HC }; workingFace.Save(); return workingFace; }
public SelectTunnelDlg(Workingface workingface) { InitializeComponent(); selectTunnelUserControl1.LoadData(workingface); }
public SelectWorkingFaceControl(Workingface workingface) { LoadData(workingface); }
/// <summary> /// 带参数的构造方法 /// </summary> /// <params name="typeFlag"></params> /// <params name="id"></params> public CommonManagement(int typeFlag, int id) { InitializeComponent(); Id = id; _typeFlag = typeFlag; switch (typeFlag) { case FlagManangingMineName: { // 窗口标题 Text = @"矿井名称管理"; AddIdColumn("编号", "id"); // 矿井名称 gridView1.Columns.Add(new GridColumn { Caption = @"矿井名称", FieldName = "name", VisibleIndex = gridView1.Columns.Count }); AddDeleteButton(); gridControl1.DataSource = CollectionHelper.ConvertTo(Mine.FindAll()); } break; case FlagManangingHorizontal: { Text = @"水平名称管理"; AddIdColumn("编号", "id"); // 矿井名称 gridView1.Columns.Add(new GridColumn { Caption = @"水平名称", FieldName = "name", VisibleIndex = gridView1.Columns.Count }); gridView1.Columns.Add(new GridColumn { Caption = @"所在矿区", FieldName = "mine", ColumnEdit = lueMine, VisibleIndex = gridView1.Columns.Count, FilterMode = ColumnFilterMode.DisplayText }); AddDeleteButton(); lueMine.DataSource = Mine.FindAll(); gridControl1.DataSource = CollectionHelper.ConvertTo(Horizontal.FindAll()); } break; case FlagManangingMiningArea: { Text = @"采区名称管理"; AddIdColumn("编号", "id"); // 矿井名称 gridView1.Columns.Add(new GridColumn { Caption = @"采区名称", FieldName = "name", VisibleIndex = gridView1.Columns.Count }); // 所属水平 gridView1.Columns.Add(new GridColumn { Caption = @"所在水平", FieldName = "horizontal", ColumnEdit = lueHorizontal, VisibleIndex = gridView1.Columns.Count, FilterMode = ColumnFilterMode.DisplayText }); AddDeleteButton(); lueHorizontal.DataSource = Horizontal.FindAll(); gridControl1.DataSource = CollectionHelper.ConvertTo(MiningArea.FindAll()); } break; case FlagManangingWorkingFace: { Text = @"工作面名称管理"; AddIdColumn("编号", "id"); // 矿井名称 gridView1.Columns.Add(new GridColumn { Caption = @"工作面名称", FieldName = "name", VisibleIndex = gridView1.Columns.Count }); gridView1.Columns.Add(new GridColumn { Caption = @"所在采区", FieldName = "mining_area", ColumnEdit = lueMiningArea, VisibleIndex = gridView1.Columns.Count, FilterMode = ColumnFilterMode.DisplayText }); AddDeleteButton(); lueMiningArea.DataSource = MiningArea.FindAll(); gridControl1.DataSource = CollectionHelper.ConvertTo(Workingface.FindAll()); } break; } }
//public SelectWorkingFaceDlg(params WorkingfaceTypeEnum[] workingfaceTypes) //{ // InitializeComponent(); // //SetFilterOn(workingfaceTypes); // this.selectWorkingFaceControl1.LoadData(); //} //private void SetFilterOn(WorkingfaceTypeEnum workingfaceType) //{ // this.selectWorkingFaceControl1.SetFilterOn(workingfaceType); //} //private void SetFilterOn(params WorkingfaceTypeEnum[] types) //{ // //this.selectWorkingFaceControl1.SetFilterOn(types); //} private void btnOK_Click(object sender, EventArgs e) { SelectedWorkingFace = selectWorkingFaceControl1.SelectedWorkingFace; DialogResult = DialogResult.OK; }
public void cbxTunnel_SelectedIndexChanged(object sender, EventArgs e) { SelectedWorkingFace = cbxWorkingface.SelectedItem as Workingface; }
private Tunnel AddTunnel(Workingface workingface, string tunnelName) { var type = tunnelName.Contains("横川") ? TunnelTypeEnum.HENGCHUAN : TunnelTypeEnum.OTHER; var tunnel = new Tunnel { name = tunnelName, workingface = workingface, width = 5, bid = IdGenerator.NewBindingId(), type = type }; tunnel.Save(); return tunnel; }
private void lstWorkingFaceName_SelectedIndexChanged(object sender, EventArgs e) { if (lstWorkingFaceName.SelectedItems.Count <= 0) SelectedWorkingFace = null; else SelectedWorkingFace = (Workingface)lstWorkingFaceName.SelectedItem; }
///// <params name="verticesBtmRet">Vector3_DW数据</params> /// <summary> /// 根据导线点坐标绘制巷道 /// </summary> /// <summary> /// 获得导线边线点坐标集 /// </summary> /// <returns>导线边线点坐标集List</returns> //private List<IPoint> GetTunnelPts(Vector3_DW[] verticesBtmRet) //{ // var lstBtmRet = new List<IPoint>(); // try // { // Vector3_DW vector3dw; // IPoint pt; // for (int i = 0; i < verticesBtmRet.Length; i++) // { // vector3dw = new Vector3_DW(); // vector3dw = verticesBtmRet[i]; // pt = new PointClass(); // pt.X = vector3dw.X; // pt.Y = vector3dw.Y; // pt.Z = vector3dw.Z; // if (!lstBtmRet.Contains(pt)) // { // lstBtmRet.Add(pt); // } // } // return lstBtmRet; // } // catch // { // return null; // } //} #endregion 绘制导线点和巷道图形 private void btnMultTxt_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog { RestoreDirectory = true, Multiselect = true, Filter = @"文本文件(*.txt)|*.txt|所有文件(*.*)|*.*" }; _errorMsg = @"失败文件名:"; if (ofd.ShowDialog() != DialogResult.OK) { return; } var fileCount = ofd.FileNames.Length; pbCount.Maximum = fileCount * 2; pbCount.Value = 0; foreach (var fileName in ofd.FileNames) { lblTotal.Text = fileCount.ToString(CultureInfo.InvariantCulture); string safeFileName = null; try { using (new SessionScope()) { safeFileName = fileName.Substring(fileName.LastIndexOf(@"\", StringComparison.Ordinal) + 1); var strs = safeFileName.Split('-'); var miningAreaName = strs[0]; var workingFaceName = strs[1]; var tunnelName = strs[2].Split('.')[0]; var miningArea = MiningArea.FindAllByProperty("name", miningAreaName).FirstOrDefault(); if (miningArea == null) { var newMiningArea = new MiningArea { name = miningAreaName, horizontal = Horizontal.FindFirst() }; newMiningArea.Save(); miningArea = newMiningArea; } var workingFace = Workingface.findone_by_workingface_name_and_mining_area_id(workingFaceName, miningArea.id) ?? AddWorkingFace(miningArea, workingFaceName); if (workingFace == null) { return; } Tunnel tunnel; if (workingFace.tunnels != null && workingFace.tunnels.FirstOrDefault(u => u.name == tunnelName) != null) { tunnel = workingFace.tunnels.FirstOrDefault(u => u.name == tunnelName); } else { tunnel = AddTunnel(workingFace, tunnelName); } var sr = new StreamReader(fileName, Encoding.GetEncoding("GB2312")); string fileContent; var wire = Wire.FindAllByProperty("tunnel.id", tunnel.id).FirstOrDefault(); if (wire != null) { wire.name = tunnelName.Split('.').Length > 0 ? tunnelName.Split('.')[0] + "导线点" : tunnelName + "导线点"; } else { wire = new Wire { tunnel = tunnel, check_date = DateTime.Now, measure_date = DateTime.Now, count_date = DateTime.Now, name = tunnelName.Split('.').Length > 0 ? tunnelName.Split('.')[0] + "导线点" : tunnelName + "导线点" }; } wire.Save(); var wirePoints = new List <WirePoint>(); while ((fileContent = sr.ReadLine()) != null) { if (String.IsNullOrEmpty(fileContent)) { continue; } var temp1 = fileContent.Split('|'); var pointName = temp1[0]; var pointX = temp1[1]; var pointY = temp1[2]; wirePoints.Add(new WirePoint { bid = IdGenerator.NewBindingId(), name = pointName, wire = wire, coordinate_x = Convert.ToDouble(pointX), coordinate_y = Convert.ToDouble(pointY), coordinate_z = 0, left_distance = 2.5, right_distance = 2.5, top_distance = 0, bottom_distance = 0 }); } if (wirePoints.Count < 2) { throw new Exception(); } pbCount.Value++; DrawWirePoint(wirePoints, "CHANGE"); double hdwid; _dics = ConstructDics(tunnel, out hdwid); UpdateHdbyPnts(tunnel.id, wirePoints, _dics, hdwid); pbCount.Value++; lblSuccessed.Text = (Convert.ToInt32(lblSuccessed.Text) + 1).ToString(CultureInfo.InvariantCulture); } } catch (Exception ex) { pbCount.Value++; lblError.Text = (Convert.ToInt32(lblError.Text) + 1).ToString(CultureInfo.InvariantCulture); _errorMsg += safeFileName + "\n"; btnDetails.Enabled = true; } } Alert.AlertMsg("导入完成"); }