alielie
2025-03-03 4c3eb7f334abb8129b57e86f2935d75d0b3070b4
HMI.ParameterManage/Model/SqlModel.cs
File was renamed from HMI.ParameterManage/ControlModel.cs
@@ -1,16 +1,40 @@
using System.Collections.ObjectModel;
using System.Data;
using System.IO;
using HMI.Core.Entity;
using HMI.Core.Util;
using HMI.ParameterManage.Entity;
namespace HMI.ParameterManage
namespace HMI.ParameterManage.Model
{
    public class ControlModel : NotifyBase
    public class SqlModel : NotifyBase
    {
        public ControlModel(SqliteHelper sqliteHelper)
        public SqlModel(string baseFolder)
        {
            SqliteHelper = sqliteHelper;
            string dbpath = Path.Combine(baseFolder, "ParameterManage.db");
            if (!File.Exists(dbpath))
            {
                SqliteHelper.CreateDatabase(dbpath);
            }
            SqliteHelper = new SqliteHelper(dbpath);
            SqliteHelper.ExecuteSql(@"CREATE TABLE IF NOT EXISTS product (
                    id INTEGER PRIMARY KEY AUTOINCREMENT,
                    name TEXT NOT NULL,
                    isMaster INTEGER,
                    parentId INTEGER,
                    UNIQUE(name)
                    );
CREATE TABLE IF NOT EXISTS parameter (
                    id INTEGER PRIMARY KEY AUTOINCREMENT,
                    name TEXT NOT NULL,
                    value TEXT,
                    unit TEXT,
                    description TEXT,
                    pGroup TEXT,
                    productName TEXT,
                    UNIQUE(productName,name)
                    );");
        }
        public SqliteHelper SqliteHelper { get; private set; }