private void btn_OK_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(Server.NUM)) { MessageBox.Show("编号不能为空。"); return; } DC_Service dC_Service = new DC_Service(); try { if (IsModify) { dC_Service.ModifyDCServer(Server); } else { dC_Service.InsertDCServer(Server); } MessageBox.Show("操作成功。"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show("操作失败。" + ex.Message); } }