/// <summary> /// 点击"添加分层" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddLayerButton_Click(object sender, RoutedEventArgs e) { // 传递上一层的层底深度,如果没有上一层,则将lastDepth赋值为-1 double lastDepth = -1; if (this.LayerListDataGrid.Items.Count > 0) { DataRowView drv = (DataRowView)this.LayerListDataGrid.Items[this.LayerListDataGrid.Items.Count - 1]; lastDepth = (double)drv[3]; } // 实例化窗口 ZkLayerDetail newLayer = new ZkLayerDetail(lastDepth); newLayer.ShowDialog(); if (newLayer.DialogResult == true) { string number = newLayer.LayerNumberComboBox.Text; string name = newLayer.LayerNameComboBox.Text; string geo = newLayer.LayerGeoComboBox.Text; double depth = Convert.ToDouble(newLayer.LayerDepthTextBox.Text); string description = newLayer.LayerDescriptionTextBox.Text; AddRowToLayerListDataTable(number, name, geo, depth, description); // 绘图 DrawJk(); } }
/// <summary> /// 点击"编辑分层" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditLayerButton_Click(object sender, RoutedEventArgs e) { // 传递上一层的层底深度,如果没有上一层,则将lastDepth赋值为-1 double lastDepth = -1; int selectIndex = this.LayerListDataGrid.SelectedIndex; if (selectIndex > 0) { DataRowView drv0 = (DataRowView)this.LayerListDataGrid.Items[selectIndex - 1]; lastDepth = (double)drv0[3]; } // 赋值传递数据 DataRowView drv = (DataRowView)this.LayerListDataGrid.SelectedItem; string number = (string)drv[0]; string name = (string)drv[1]; string geo = (string)drv[2]; double depth = (double)drv[3]; string description = (string)drv[4]; // 实例化窗口 ZkLayerDetail editLayer = new ZkLayerDetail(lastDepth, number, depth, description); editLayer.ShowDialog(); if (editLayer.DialogResult == true) { string newNumber = editLayer.LayerNumberComboBox.Text; string newName = editLayer.LayerNameComboBox.Text; string newGeo = editLayer.LayerGeoComboBox.Text; double newDepth = Convert.ToDouble(editLayer.LayerDepthTextBox.Text); string newDescription = editLayer.LayerDescriptionTextBox.Text; EditRowLayerListDataTable(selectIndex, newNumber, newName, newGeo, newDepth, newDescription); // 绘图 DrawJk(); } }