diff --git a/AsmrManage/AsmrManage/Form1.Designer.cs b/AsmrManage/AsmrManage/Form1.Designer.cs index fd55a4d..cae0864 100644 --- a/AsmrManage/AsmrManage/Form1.Designer.cs +++ b/AsmrManage/AsmrManage/Form1.Designer.cs @@ -196,6 +196,7 @@ checkBox2.TabIndex = 8; checkBox2.Text = "转换时使用源文件位置"; checkBox2.UseVisualStyleBackColor = true; + checkBox2.CheckedChanged += CheckBox2_CheckedChanged; // // checkBox1 // diff --git a/AsmrManage/AsmrManage/Form1.cs b/AsmrManage/AsmrManage/Form1.cs index 7e62e86..0d927d4 100644 --- a/AsmrManage/AsmrManage/Form1.cs +++ b/AsmrManage/AsmrManage/Form1.cs @@ -1,5 +1,6 @@ using OfficeOpenXml; using System.Data.SQLite; +using System.Diagnostics; namespace AsmrManage { @@ -38,13 +39,23 @@ namespace AsmrManage private void Log(string message) { logBox1.AppendText(message + Environment.NewLine); + logBox1.ScrollToCaret(); } private void Button3_Click(object sender, EventArgs e) { Log("ʼ"); string excelFilePath = textBox1.Text; - string databaseLocation = textBox2.Text; + string? databaseLocation; + if (checkBox2.Checked) + { + databaseLocation = Path.GetDirectoryName(excelFilePath); + } + else + { + databaseLocation = textBox2.Text; + } + if (string.IsNullOrEmpty(excelFilePath) || string.IsNullOrEmpty(databaseLocation)) { Log("TextBox1 TextBox2 Ϊգ޷"); @@ -68,6 +79,21 @@ namespace AsmrManage Log("ĿDBļڣ׼"); SQLiteConnection.CreateFile(databasePath); } + else + { + if (checkBox1.Checked) //allow override + { + Log("ļѴڣ15s󸲸Ѵڵļ練뼰ʱ"); + Task.Delay(15000).Wait(); // ʱ15 + File.Delete(databasePath); + SQLiteConnection.CreateFile(databasePath); + } + else + { + Log("ļѴڣǰ趨ļ˳"); + return; + } + } string connectionString = $"Data Source={databasePath};Version=3;"; @@ -130,13 +156,21 @@ namespace AsmrManage { Log("SUCCESS"); })); + if (checkBox3.Checked) + { + Process.Start("explorer.exe", databaseLocation); + } }); } - + private void CheckBox2_CheckedChanged(object sender, EventArgs e) + { + textBox2.Enabled = !checkBox2.Checked; + } private void CheckBox4_CheckedChanged(object sender, EventArgs e) { textBox3.ReadOnly = !checkBox4.Checked; } + } } \ No newline at end of file