using ryCommonDb;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static ryCommonDb.DataProvider;

namespace Itrycn_Project
{
    public static class Itrycn_Db
    {
        public static string SQLConnStr = "<app>\\UserDb\\myDb.dat|";
        public static ryCommonDb.DataProvider.DataProviderType dataType = ryCommonDb.DataProvider.DataProviderType.SQLiteDataProvider;
        public static IDbInterface CreateDataProvider()
        {
            return CreateDataProvider(dataType);
        }

        public static IDbInterface CreateDataProvider(DataProviderType dataProviderType)
        {
            switch (dataProviderType)
            {
                //case DataProviderType.OdbcDataProvider:
                //    return new OdbcDataProvider();
                //case DataProviderType.OleDbDataProvider:
                //    return new OleDbDataProvider();
                //case DataProviderType.OracleDataProvider:
                //    return new OracleDataProvider();
                case DataProviderType.SQLiteDataProvider:
                    return new SQLiteDataProvider();
                default:
                    return null;
            }
        }
        private static void CreateTable(ryCommonDb.DataProvider.DataProviderType dataType, string ConnStr)
        {
            DataProvider mydb = new DataProvider();
            IDbInterface db = CreateDataProvider(dataType);
            if (db.ConnDb(ConnStr) == 1)
            {
                #region 表1
                RyQuickSQL mySQL = new RyQuickSQL("表1");
                mySQL.AddField("", "");
                mySQL.AddField("addTime", DateTime.Now);
                mySQL.AddField("editTime", DateTime.Now);
                db.CreateDb(mySQL);
                #endregion
                //
                #region 表2
                mySQL.Clear();
                mySQL.TableName = "表2";
                mySQL.AddField("", "");
                db.CreateDb(mySQL);
                #endregion
            }
            db.Free();
        }
        public static void CreateTable()
        {
            CreateTable(dataType, SQLConnStr);
        }
    }
}
