From 5eac60bd7ea2b837cc69dd768f23e84e1ca3cee6 Mon Sep 17 00:00:00 2001 From: Chenx221 Date: Wed, 4 Oct 2023 22:16:51 +0800 Subject: [PATCH] update --- AsmrManage/AsmrManage/Form1.Designer.cs | 1 + AsmrManage/AsmrManage/Form1.cs | 38 +++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) 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