public ActionResult EditTable(string tableName, string oldTableName, int[] Ordinal, string[] Name, bool[] IsPrimaryKey, string[] DataTypeName, int[] MaxLength, bool[] AllowDBNull, FormCollection collection) { ViewBag.TableName = tableName; if (!string.IsNullOrEmpty(tableName) && Name != null) { var tlts = new List <SqliteDBHelper.ColumnInfo>(); for (int i = 0; i < Name.Length; i++) { SqliteDBHelper.ColumnInfo ct = new SqliteDBHelper.ColumnInfo(); ct.Ordinal = Ordinal[i]; ct.Name = Name[i]; ct.IsPrimaryKey = IsPrimaryKey[i]; ct.DataTypeName = DataTypeName[i]; ct.MaxLength = MaxLength[i]; ct.AllowDBNull = AllowDBNull[i]; tlts.Add(ct); } if (SqliteDBHelper.ExistsTable(oldTableName)) { if (tableName != oldTableName && !SqliteDBHelper.ExistsTable(tableName)) { if (SqliteDBHelper.ReNameTable(tableName, oldTableName)) { SqliteDBHelper.CreateTable(tableName, tlts); } } else { SqliteDBHelper.CreateTable(tableName, tlts); } } } return(Redirect("/Manager/SqliteDataBase/Tables")); }
public ActionResult CreateTable(string tableName, bool basicFiled, int[] Ordinal, string[] Name, bool[] IsPrimaryKey, string[] DataTypeName, int[] MaxLength, bool[] AllowDBNull, FormCollection collection) { if (!string.IsNullOrEmpty(tableName) && Name != null) { var tlts = new List <SqliteDBHelper.ColumnInfo>(); if (basicFiled) { tlts.AddRange(new List <SqliteDBHelper.ColumnInfo>() { new SqliteDBHelper.ColumnInfo() { Ordinal = 0, Name = "ID", IsPrimaryKey = true, AutoIncrement = true, DataTypeName = SqliteDBHelper.SqliteDBDataType.INTEGER.ToString(), AllowDBNull = false }, new SqliteDBHelper.ColumnInfo() { Ordinal = 0, Name = "CreateUserID", IsPrimaryKey = false, DataTypeName = SqliteDBHelper.SqliteDBDataType.INTEGER.ToString(), AllowDBNull = false }, new SqliteDBHelper.ColumnInfo() { Ordinal = 0, Name = "LastUpdateUserID", IsPrimaryKey = false, DataTypeName = SqliteDBHelper.SqliteDBDataType.INTEGER.ToString(), AllowDBNull = false }, new SqliteDBHelper.ColumnInfo() { Ordinal = 0, Name = "CreateDate", IsPrimaryKey = false, DataTypeName = SqliteDBHelper.SqliteDBDataType.DATETIME.ToString(), AllowDBNull = false }, new SqliteDBHelper.ColumnInfo() { Ordinal = 0, Name = "LastUpdateDate", IsPrimaryKey = false, DataTypeName = SqliteDBHelper.SqliteDBDataType.DATETIME.ToString(), AllowDBNull = false }, new SqliteDBHelper.ColumnInfo() { Ordinal = 0, Name = "IsDeleted", IsPrimaryKey = false, DataTypeName = SqliteDBHelper.SqliteDBDataType.BIT.ToString(), AllowDBNull = false } }); } for (int i = 0; i < Name.Length; i++) { SqliteDBHelper.ColumnInfo ct = new SqliteDBHelper.ColumnInfo(); ct.Ordinal = Ordinal[i]; ct.Name = Name[i]; ct.IsPrimaryKey = IsPrimaryKey[i]; ct.DataTypeName = DataTypeName[i]; ct.MaxLength = MaxLength[i]; ct.AllowDBNull = AllowDBNull[i]; tlts.Add(ct); } if (!SqliteDBHelper.ExistsTable(tableName)) { SqliteDBHelper.CreateTable(tableName, tlts); } } return(Redirect("/Manager/SqliteDataBase/Tables")); }