/// <summary> /// 点击"添加" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddLayerButton_Click(object sender, RoutedEventArgs e) { LayerDetail layerDetail = new LayerDetail(); layerDetail.ShowDialog(); if (layerDetail.DialogResult == true) { string number = layerDetail.LayerNumberTextBox.Text; string name = layerDetail.LayerNameTextBox.Text; string geo = layerDetail.LayerGeoComboBox.Text; string description = layerDetail.LayerDescriptionTextBox.Text; AddRowToDataTable(number, name, geo, description); } }
/// <summary> /// 点击"编辑" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditLayerButton_Click(object sender, RoutedEventArgs e) { // 赋值传递数据 DataRowView drv = (DataRowView)this.LayerListDataGrid.SelectedItem; string oldNumber = (string)drv[0]; string oldName = (string)drv[1]; string oldGeo = (string)drv[2]; string oldDescription = (string)drv[3]; int selectIndex = this.LayerListDataGrid.SelectedIndex; // 实例化窗口 LayerDetail layerDetail = new LayerDetail(oldNumber, oldName, oldGeo, oldDescription); layerDetail.ShowDialog(); if (layerDetail.DialogResult == true) { string number = layerDetail.LayerNumberTextBox.Text; string name = layerDetail.LayerNameTextBox.Text; string geo = layerDetail.LayerGeoComboBox.Text; string description = layerDetail.LayerDescriptionTextBox.Text; EditRowDataTable(selectIndex, number, name, geo, description); } }