private void btnLoad_Click(object sender, EventArgs e) { try { var result = MessageBox.Show("Current content will be overwrite!\nChoose YES to confirm, Choose NO to abort.", "Load Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (DialogResult.No == result) { return; } var dlg = new OpenFileDialog() { Filter = "json text|*.json|plain text|*.txt|All files(*.*)|*.*" }; var load = dlg.ShowDialog(); if (DialogResult.OK == load) { using (StreamReader sr = File.OpenText(dlg.FileName)) { var obj = BISpecification.Deserialize(sr.ReadToEnd()); sr.Close(); LoadBISpecification(obj); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnLoadFromList_Click(object sender, EventArgs e) { try { var result = MessageBox.Show("Current content will be overwrite!\nChoose YES to confirm, Choose NO to abort.", "Load Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (DialogResult.No == result) { return; } string content = (string)dgvSpecificationList.SelectedRows[0].Cells["Content"].Value; LoadBISpecification(BISpecification.Deserialize(content)); this.tabControl1.SelectTab(this.tabPage1); this.tabPage1.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }