From e47a565b1e34370cd9402b88fc64cdde9ad4a019 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 11 一月 2024 09:55:44 +0800 Subject: [PATCH] 1.JiangSu:添加删除全部接口 2.TEWin: 添加测试单元 --- JiangSu/Controllers/OpController.cs | 14 +++++++ JiangSu/cs/SQLiteHelper.cs | 2 JiangSu/cs/GridDAL.cs | 5 ++ JiangSu/cs/ModelDAL.cs | 5 ++ JiangSu/Controllers/GridController.cs | 14 +++++++ JiangSu/Controllers/ImgController.cs | 14 +++++++ TEWin/FrmTool.cs | 18 +++++++++ JiangSu/cs/ImgDAL.cs | 5 ++ TEWin/FrmTool.Designer.cs | 16 +++++++- 9 files changed, 90 insertions(+), 3 deletions(-) diff --git a/JiangSu/Controllers/GridController.cs b/JiangSu/Controllers/GridController.cs index 8a942b6..896fa88 100644 --- a/JiangSu/Controllers/GridController.cs +++ b/JiangSu/Controllers/GridController.cs @@ -97,6 +97,20 @@ } } + [HttpGet] + public int DelAll() + { + try + { + return GridDAL.DelAll(); + } + catch (Exception ex) + { + LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); + return 0; + } + } + [HttpPost] public int Insert([FromBody] Grid grid) { diff --git a/JiangSu/Controllers/ImgController.cs b/JiangSu/Controllers/ImgController.cs index ab6ef18..60f4ce3 100644 --- a/JiangSu/Controllers/ImgController.cs +++ b/JiangSu/Controllers/ImgController.cs @@ -63,6 +63,20 @@ } } + [HttpGet] + public int DelAll() + { + try + { + return ImgDAL.DelAll(); + } + catch (Exception ex) + { + LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); + return 0; + } + } + [HttpPost] public int Insert([FromBody] Img img) { diff --git a/JiangSu/Controllers/OpController.cs b/JiangSu/Controllers/OpController.cs index e0d8473..5ca7962 100644 --- a/JiangSu/Controllers/OpController.cs +++ b/JiangSu/Controllers/OpController.cs @@ -55,6 +55,20 @@ } } + [HttpGet] + public int DelAll() + { + try + { + return ModelDAL.DelAll(); + } + catch (Exception ex) + { + LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); + return 0; + } + } + [HttpPost] public int Insert([FromBody] Model model) { diff --git a/JiangSu/cs/GridDAL.cs b/JiangSu/cs/GridDAL.cs index 6288f62..5d5b504 100644 --- a/JiangSu/cs/GridDAL.cs +++ b/JiangSu/cs/GridDAL.cs @@ -51,6 +51,11 @@ return SQLiteHelper.ExecuteNonQuery(sql); } + public static int DelAll() + { + return SQLiteHelper.ExecuteNonQuery("delete from grid"); + } + public static int Insert(Grid grid) { string sql = "insert into grid (json) values (@json); select last_insert_rowid();"; diff --git a/JiangSu/cs/ImgDAL.cs b/JiangSu/cs/ImgDAL.cs index 059288b..ee5e628 100644 --- a/JiangSu/cs/ImgDAL.cs +++ b/JiangSu/cs/ImgDAL.cs @@ -54,6 +54,11 @@ return SQLiteHelper.ExecuteNonQuery(sql); } + public static int DelAll() + { + return SQLiteHelper.ExecuteNonQuery("delete from img"); + } + public static int Insert(Img img) { string sql = "insert into img (name, path, json, x, y, z) values (@name, @path, @json, @x, @y, @z); select last_insert_rowid();"; diff --git a/JiangSu/cs/ModelDAL.cs b/JiangSu/cs/ModelDAL.cs index bcae797..8dba837 100644 --- a/JiangSu/cs/ModelDAL.cs +++ b/JiangSu/cs/ModelDAL.cs @@ -53,6 +53,11 @@ return SQLiteHelper.ExecuteNonQuery(sql); } + public static int DelAll() + { + return SQLiteHelper.ExecuteNonQuery("delete from model"); + } + public static int Insert(Model model) { string sql = "insert into model (name, json) values (@name, @json); select last_insert_rowid();"; diff --git a/JiangSu/cs/SQLiteHelper.cs b/JiangSu/cs/SQLiteHelper.cs index 4840ecc..e199159 100644 --- a/JiangSu/cs/SQLiteHelper.cs +++ b/JiangSu/cs/SQLiteHelper.cs @@ -102,7 +102,7 @@ { using (SQLiteConnection conn = new SQLiteConnection(ConnectionString)) { - LoadDrivers(conn); + //LoadDrivers(conn); using (SQLiteCommand cmd = new SQLiteCommand(cmdText, conn)) { diff --git a/TEWin/FrmTool.Designer.cs b/TEWin/FrmTool.Designer.cs index 7f46823..8768815 100644 --- a/TEWin/FrmTool.Designer.cs +++ b/TEWin/FrmTool.Designer.cs @@ -30,14 +30,15 @@ { this.txtCode = new System.Windows.Forms.TextBox(); this.btnTest = new System.Windows.Forms.Button(); + this.cbCode = new System.Windows.Forms.ComboBox(); this.SuspendLayout(); // // txtCode // this.txtCode.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.txtCode.Location = new System.Drawing.Point(13, 32); + this.txtCode.Location = new System.Drawing.Point(244, 32); this.txtCode.Name = "txtCode"; - this.txtCode.Size = new System.Drawing.Size(391, 26); + this.txtCode.Size = new System.Drawing.Size(160, 26); this.txtCode.TabIndex = 1; this.txtCode.Text = "0xc0"; // @@ -52,11 +53,21 @@ this.btnTest.UseVisualStyleBackColor = true; this.btnTest.Click += new System.EventHandler(this.btnTest_Click); // + // cbCode + // + this.cbCode.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.cbCode.FormattingEnabled = true; + this.cbCode.Location = new System.Drawing.Point(23, 34); + this.cbCode.Name = "cbCode"; + this.cbCode.Size = new System.Drawing.Size(198, 24); + this.cbCode.TabIndex = 2; + // // FrmTool // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(504, 89); + this.Controls.Add(this.cbCode); this.Controls.Add(this.btnTest); this.Controls.Add(this.txtCode); this.Name = "FrmTool"; @@ -71,5 +82,6 @@ private System.Windows.Forms.TextBox txtCode; private System.Windows.Forms.Button btnTest; + private System.Windows.Forms.ComboBox cbCode; } } \ No newline at end of file diff --git a/TEWin/FrmTool.cs b/TEWin/FrmTool.cs index 44da8ac..11894a9 100644 --- a/TEWin/FrmTool.cs +++ b/TEWin/FrmTool.cs @@ -13,10 +13,28 @@ { FrmWin win; + List<string> codes = new List<string> { "閲嶇疆榧犳爣", "鎵撳紑鏂规", "淇濆瓨鏂规", "鐭㈤噺鏁版嵁", "褰卞儚鏁版嵁", "鍦板舰鏁版嵁", "妯″瀷鏁版嵁(osgb)", "妯″瀷鏁版嵁(obj)", "缂栬緫瀵硅薄", "鐐归噺绠�", "鍧″悜鍒嗘瀽", "绾块噺绠�", "闈㈤噺绠�", "浣撻噺绠�", "瑙掗噺绠�", "绌洪棿缁熻", "绌洪棿鍒嗘瀽", "鍓栭潰鍒嗘瀽", "鍧″害鍒嗘瀽", "绛夊�肩嚎", "鍓栭潰鍒嗘瀽", "鍦扮悊鍦烘櫙浜у搧缁勮", "浼犵粺4D浜у搧娲剧敓", "鎵撳紑fly" }; + public FrmTool(FrmWin win) { this.win = win; InitializeComponent(); + this.Load += FrmTool_Load; + } + + void FrmTool_Load(object sender, EventArgs e) + { + cbCode.DataSource = codes; + cbCode.SelectedIndex = 0; + this.cbCode.SelectedIndexChanged += cbCode_SelectedIndexChanged; + } + + private void cbCode_SelectedIndexChanged(object sender, EventArgs e) + { + ComboBox cb = sender as ComboBox; + + int idx = cb.SelectedIndex; + this.txtCode.Text = "0x" + (0xc0 + idx).ToString("X").ToLower(); } private void btnTest_Click(object sender, EventArgs e) -- Gitblit v1.9.3