private void reset(string filepath) { FilesOper fo = new FilesOper(); StdNames = (List <string>)(fo.Get(filepath)); if (StdNames == null) { StdNames = new List <string>(); StdNames.Add("请增加学员系统"); StdName.Text = "请增加学员系统"; } else { StdName.Text = "开始提问"; } lboxHaveNot.Items.Clear(); for (int i = 0; i < StdNames.Count; i++) { lboxHaveNot.Items.Add(StdNames[i]); } lboxHave.Items.Clear(); XmlDocument doc = new XmlDocument(); doc.Load("havenot.xml"); XmlNode root = doc.GetElementsByTagName("StdInfo")[0]; root.RemoveAll(); doc.Save("havenot.xml"); doc.Load("have.xml"); root = doc.GetElementsByTagName("StdInfo")[0]; root.RemoveAll(); doc.Save("have.xml"); }
private void butSave_Click(object sender, EventArgs e) { List <string> StdNames = new List <string>(); if (NamesView.Rows.Count > 1) { for (int i = 0; i < NamesView.Rows.Count - 1; i++) { StdNames.Add(NamesView.Rows[i].Cells[0].Value.ToString()); } if (!string.IsNullOrEmpty(tboxfilename.Text.Trim())) { string file = tboxfilename.Text.Trim() + ".txt"; if (File.Exists(@"StdSystem\" + tboxfilename.Text.Trim() + ".dat")) { if (MessageBox.Show("文件已存在,是否覆盖?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { FilesOper fo = new FilesOper(); ClassSerializers cs = new ClassSerializers(); fo.Save(@"StdSystem\" + tboxfilename.Text.Trim() + ".dat", cs.SerializeBinary(StdNames)); MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); GetFileDb(); } } else { FilesOper fo = new FilesOper(); ClassSerializers cs = new ClassSerializers(); fo.Save(@"StdSystem\" + tboxfilename.Text.Trim() + ".dat", cs.SerializeBinary(StdNames)); MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); GetFileDb(); } } else { MessageBox.Show("文件名为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("没有数据记录!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void butModify_Click(object sender, EventArgs e) { FilesOper fo = new FilesOper(); List <string> StdNames = (List <string>)(fo.Get(cboxFileDb.SelectedItem.ToString())); DataGridViewRow row; DataGridViewTextBoxCell cell; NamesView.Rows.Clear(); foreach (string name in StdNames) { cell = new DataGridViewTextBoxCell(); row = new DataGridViewRow(); cell.Value = name; row.Cells.Add(cell); NamesView.Rows.Add(row); } string[] name1 = cboxFileDb.SelectedItem.ToString().Split('\\'); string[] name2 = name1[1].Split('.'); tboxfilename.Text = name2[0]; }