private void button2_Click(object sender, EventArgs e) { if (CheckFileName(textBox1.Text)) { if (productName.Contains(textBox1.Text)) { Product.Inst.Save(textBox1.Text); SetSelectProduct(textBox1.Text); } else { MessageShowForm2 messageShowForm = new MessageShowForm2(); messageShowForm.Word.Text = "没有当前名字的产品,是否新建立?"; if (messageShowForm.ShowDialog() == DialogResult.OK) { Product.Inst.Save(textBox1.Text); DisplayProductList(); SetSelectProduct(textBox1.Text); } } } else { MessageShowForm1 messageShowForm = new MessageShowForm1(); messageShowForm.Word.Text = "文件名不符合要求"; messageShowForm.ShowDialog(); } }
private void button3_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { MessageShowForm2 messageShowForm = new MessageShowForm2(); messageShowForm.Word.Text = "确定是否覆盖选中的产品?"; if (messageShowForm.ShowDialog() == DialogResult.OK) { if (CheckFileName(textBox1.Text)) { if (this.productName.Contains(textBox1.Text)) { MessageShowForm1 messageShowForm3 = new MessageShowForm1(); messageShowForm3.Word.Text = "存在相同名字的产品"; messageShowForm3.ShowDialog(); return; } string productName = listView1.SelectedItems[0].SubItems[1].Text; DirectoryInfo directoryInfo = new DirectoryInfo(Product.Inst.Path); foreach (var product in directoryInfo.GetDirectories()) { if (product.Name == productName) { product.Delete(true); break; } } Product.Inst.Save(textBox1.Text); DisplayProductList(); SetSelectProduct(textBox1.Text); } else { MessageShowForm1 messageShowForm2 = new MessageShowForm1(); messageShowForm2.Word.Text = "文件名不符合要求"; messageShowForm2.ShowDialog(); } } } else { MessageShowForm1 messageShowForm = new MessageShowForm1(); messageShowForm.Word.Text = "选中产品"; messageShowForm.ShowDialog(this); } }
private void button1_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { MessageShowForm2 messageShowForm = new MessageShowForm2(); messageShowForm.label1.Text = "是否读取该产品?"; if (messageShowForm.ShowDialog(this) == DialogResult.OK) { string productName = listView1.SelectedItems[0].SubItems[1].Text; Product.Inst.Load(productName); this.textBox1.Text = Product.Inst.Info.Name; } } else { MessageShowForm1 messageShowForm = new MessageShowForm1(); messageShowForm.label1.Text = "选中产品"; messageShowForm.ShowDialog(this); } }