Commit 96d6ddde authored by keyongyu's avatar keyongyu

1.5.3.0

parent 1c6b771b
......@@ -13,437 +13,456 @@
namespace DataEditorX.Core
{
/// <summary>
/// Description of SQLite.
/// </summary>
public static class DataBase
{
#region 默认
static string defaultSQL;
static string defaultTableSQL;
static DataBase()
{
defaultSQL =
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id ";
StringBuilder st = new StringBuilder();
st.Append(@"CREATE TABLE texts(id integer primary key,name text,desc text");
for ( int i = 1; i <= 16; i++ )
{
st.Append(",str");
st.Append(i.ToString());
st.Append(" text");
}
st.Append(");");
st.Append(@"CREATE TABLE datas(");
st.Append("id integer primary key,ot integer,alias integer,");
st.Append("setcode integer,type integer,atk integer,def integer,");
st.Append("level integer,race integer,attribute integer,category integer) ");
defaultTableSQL=st.ToString();
st.Remove(0,st.Length);
st=null;
}
#endregion
#region 创建数据库
/// <summary>
/// 创建数据库
/// </summary>
/// <param name="Db">新数据库路径</param>
public static bool Create(string Db)
{
if ( File.Exists(Db) )
File.Delete(Db);
try{
SQLiteConnection.CreateFile(Db);
Command(Db, defaultTableSQL);
}
catch
{
return false;
}
return true;
}
public static bool CheckTable(string db)
{
try{
Command(db, defaultTableSQL);
}
catch
{
return false;
}
return true;
}
#endregion
/// <summary>
/// Description of SQLite.
/// </summary>
public static class DataBase
{
#region 默认
static string defaultSQL;
static string defaultTableSQL;
static DataBase()
{
defaultSQL =
"SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id ";
StringBuilder st = new StringBuilder();
st.Append(@"CREATE TABLE texts(id integer primary key,name text,desc text");
for ( int i = 1; i <= 16; i++ )
{
st.Append(",str");
st.Append(i.ToString());
st.Append(" text");
}
st.Append(");");
st.Append(@"CREATE TABLE datas(");
st.Append("id integer primary key,ot integer,alias integer,");
st.Append("setcode integer,type integer,atk integer,def integer,");
st.Append("level integer,race integer,attribute integer,category integer) ");
defaultTableSQL=st.ToString();
st.Remove(0,st.Length);
st=null;
}
#endregion
#region 创建数据库
/// <summary>
/// 创建数据库
/// </summary>
/// <param name="Db">新数据库路径</param>
public static bool Create(string Db)
{
if ( File.Exists(Db) )
File.Delete(Db);
try{
SQLiteConnection.CreateFile(Db);
Command(Db, defaultTableSQL);
}
catch
{
return false;
}
return true;
}
public static bool CheckTable(string db)
{
try{
Command(db, defaultTableSQL);
}
catch
{
return false;
}
return true;
}
#endregion
#region 执行sql语句
/// <summary>
/// 执行sql语句
/// </summary>
/// <param name="DB">数据库</param>
/// <param name="SQLs">sql语句</param>
/// <returns>返回影响行数</returns>
public static int Command(string DB, params string[] SQLs)
{
int result = 0;
if ( File.Exists(DB) && SQLs != null )
{
using ( SQLiteConnection con = new SQLiteConnection(@"Data Source=" + DB) )
{
con.Open();
using ( SQLiteTransaction trans = con.BeginTransaction() )
{
try
{
using ( SQLiteCommand cmd = new SQLiteCommand(con) )
{
foreach ( string SQLstr in SQLs )
{
cmd.CommandText = SQLstr;
result += cmd.ExecuteNonQuery();
}
}
}
catch
{
trans.Rollback();
result = -1;
}
finally
{
trans.Commit();
}
}
con.Close();
}
}
return result;
}
#endregion
#region 执行sql语句
/// <summary>
/// 执行sql语句
/// </summary>
/// <param name="DB">数据库</param>
/// <param name="SQLs">sql语句</param>
/// <returns>返回影响行数</returns>
public static int Command(string DB, params string[] SQLs)
{
int result = 0;
if ( File.Exists(DB) && SQLs != null )
{
using ( SQLiteConnection con = new SQLiteConnection(@"Data Source=" + DB) )
{
con.Open();
using ( SQLiteTransaction trans = con.BeginTransaction() )
{
try
{
using ( SQLiteCommand cmd = new SQLiteCommand(con) )
{
foreach ( string SQLstr in SQLs )
{
cmd.CommandText = SQLstr;
result += cmd.ExecuteNonQuery();
}
}
}
catch
{
trans.Rollback();
result = -1;
}
finally
{
trans.Commit();
}
}
con.Close();
}
}
return result;
}
#endregion
#region 数据读取
#region 根据SQL读取
static Card ReadCard(SQLiteDataReader reader,bool reNewLine)
{
Card c = new Card(0);
c.id = reader.GetInt64(0);
c.ot = reader.GetInt32(1);
c.alias = reader.GetInt64(2);
c.setcode = reader.GetInt64(3);
c.type = reader.GetInt64(4);
c.atk = reader.GetInt32(5);
c.def = reader.GetInt32(6);
c.level = reader.GetInt64(7);
c.race = reader.GetInt64(8);
c.attribute = reader.GetInt32(9);
c.category = reader.GetInt64(10);
c.name = reader.GetString(12);
c.desc = reader.GetString(13);
if(reNewLine)
c.desc=Retext(c.desc);
string temp = null;
for ( int i = 0; i < 0x10; i++ )
{
temp = reader.GetString(14 + i);
c.str[i]= ( temp == null ) ? "":temp;
}
return c;
}
static string Retext(string text)
{
StringBuilder sr = new StringBuilder(text);
sr.Replace("\r\n", "\n");
sr.Replace("\n", Environment.NewLine);//换为当前系统的换行符
text = sr.ToString();
sr.Remove(0, sr.Length);
return text;
}
/// <summary>
/// 根据密码集合,读取数据
/// </summary>
/// <param name="DB">数据库</param>
/// <param name="reNewLine">调整换行符</param>
/// <param name="SQLs">SQL/密码语句集合集合</param>
public static Card[] Read(string DB,bool reNewLine, params string[] SQLs)
{
List<Card> list=new List<Card>();
string SQLstr = "";
if ( File.Exists(DB) && SQLs != null )
{
using ( SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + DB) )
{
sqliteconn.Open();
using ( SQLiteTransaction trans = sqliteconn.BeginTransaction() )
{
using ( SQLiteCommand sqlitecommand = new SQLiteCommand(sqliteconn) )
{
foreach ( string str in SQLs )
{
if ( string.IsNullOrEmpty(str) )
SQLstr = defaultSQL;
else if ( str.Length < 20 )
SQLstr = defaultSQL + " and datas.id=" + str;
else
SQLstr = str;
sqlitecommand.CommandText = SQLstr;
using ( SQLiteDataReader reader = sqlitecommand.ExecuteReader() )
{
while ( reader.Read() )
{
list.Add(ReadCard(reader,reNewLine));
}
reader.Close();
}
}
}
trans.Commit();
}
sqliteconn.Close();
}
}
if(list.Count==0)
return null;
return list.ToArray();
}
#endregion
#region 数据读取
#region 根据SQL读取
static Card ReadCard(SQLiteDataReader reader,bool reNewLine)
{
Card c = new Card(0);
c.id = reader.GetInt64(0);
c.ot = reader.GetInt32(1);
c.alias = reader.GetInt64(2);
c.setcode = reader.GetInt64(3);
c.type = reader.GetInt64(4);
c.atk = reader.GetInt32(5);
c.def = reader.GetInt32(6);
c.level = reader.GetInt64(7);
c.race = reader.GetInt64(8);
c.attribute = reader.GetInt32(9);
c.category = reader.GetInt64(10);
c.name = reader.GetString(12);
c.desc = reader.GetString(13);
if(reNewLine)
c.desc=Retext(c.desc);
string temp = null;
for ( int i = 0; i < 0x10; i++ )
{
temp = reader.GetString(14 + i);
c.str[i]= ( temp == null ) ? "":temp;
}
return c;
}
static string Retext(string text)
{
StringBuilder sr = new StringBuilder(text);
sr.Replace("\r\n", "\n");
sr.Replace("\n", Environment.NewLine);//换为当前系统的换行符
text = sr.ToString();
sr.Remove(0, sr.Length);
return text;
}
/// <summary>
/// 根据密码集合,读取数据
/// </summary>
/// <param name="DB">数据库</param>
/// <param name="reNewLine">调整换行符</param>
/// <param name="SQLs">SQL/密码语句集合集合</param>
public static Card[] Read(string DB,bool reNewLine, params string[] SQLs)
{
List<Card> list=new List<Card>();
string SQLstr = "";
if ( File.Exists(DB) && SQLs != null )
{
using ( SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + DB) )
{
sqliteconn.Open();
using ( SQLiteTransaction trans = sqliteconn.BeginTransaction() )
{
using ( SQLiteCommand sqlitecommand = new SQLiteCommand(sqliteconn) )
{
foreach ( string str in SQLs )
{
if ( string.IsNullOrEmpty(str) )
SQLstr = defaultSQL;
else if ( str.Length < 20 )
SQLstr = defaultSQL + " and datas.id=" + str;
else
SQLstr = str;
sqlitecommand.CommandText = SQLstr;
using ( SQLiteDataReader reader = sqlitecommand.ExecuteReader() )
{
while ( reader.Read() )
{
list.Add(ReadCard(reader,reNewLine));
}
reader.Close();
}
}
}
trans.Commit();
}
sqliteconn.Close();
}
}
if(list.Count==0)
return null;
return list.ToArray();
}
#endregion
#region 根据文件读取数据库
public static Card[] ReadYdk(string dbfile, string ydkfile)
{
if ( File.Exists(dbfile) )
{
string[] ids = ReadYDK(ydkfile);
if(ids!=null)
return DataBase.Read(dbfile, true, ids);
}
return null;
}
/// <summary>
/// 读取ydk文件为密码数组
/// </summary>
/// <param name="file">ydk文件</param>
/// <returns>密码数组</returns>
static string[] ReadYDK(string ydkfile)
{
string str;
List<string> IDs = new List<string>();
if ( File.Exists(ydkfile) )
{
using ( FileStream f = new FileStream(ydkfile, FileMode.Open, FileAccess.Read) )
{
StreamReader sr = new StreamReader(f, Encoding.Default);
str = sr.ReadLine();
while ( str != null )
{
if ( !str.StartsWith("!") && !str.StartsWith("#") &&str.Length>0)
{
if ( IDs.IndexOf(str) < 0 )
IDs.Add(str);
}
str = sr.ReadLine();
}
sr.Close();
f.Close();
}
}
if(IDs.Count==0)
return null;
return IDs.ToArray();
}
#endregion
#region 根据文件读取数据库
public static Card[] ReadYdk(string dbfile, string ydkfile)
{
if ( File.Exists(dbfile) )
{
string[] ids = ReadYDK(ydkfile);
if(ids!=null)
return DataBase.Read(dbfile, true, ids);
}
return null;
}
/// <summary>
/// 读取ydk文件为密码数组
/// </summary>
/// <param name="file">ydk文件</param>
/// <returns>密码数组</returns>
static string[] ReadYDK(string ydkfile)
{
string str;
List<string> IDs = new List<string>();
if ( File.Exists(ydkfile) )
{
using ( FileStream f = new FileStream(ydkfile, FileMode.Open, FileAccess.Read) )
{
StreamReader sr = new StreamReader(f, Encoding.Default);
str = sr.ReadLine();
while ( str != null )
{
if ( !str.StartsWith("!") && !str.StartsWith("#") &&str.Length>0)
{
if ( IDs.IndexOf(str) < 0 )
IDs.Add(str);
}
str = sr.ReadLine();
}
sr.Close();
f.Close();
}
}
if(IDs.Count==0)
return null;
return IDs.ToArray();
}
#endregion
#region 根据图像读取数据库
public static Card[] ReadImage(string dbfile, string path)
{
if ( File.Exists(dbfile) )
{
string[] files = Directory.GetFiles(path, "*.jpg");
int n = files.Length;
for ( int i = 0; i < n; i++ )
{
files[i] = Path.GetFileNameWithoutExtension(files[i]);
}
return DataBase.Read(dbfile, true,files);
}
return null;
}
#endregion
#region 根据图像读取数据库
public static Card[] ReadImage(string dbfile, string path)
{
if ( File.Exists(dbfile) )
{
string[] files = Directory.GetFiles(path, "*.jpg");
int n = files.Length;
for ( int i = 0; i < n; i++ )
{
files[i] = Path.GetFileNameWithoutExtension(files[i]);
}
return DataBase.Read(dbfile, true,files);
}
return null;
}
#endregion
#endregion
#region 复制数据库
/// <summary>
/// 复制数据库
/// </summary>
/// <param name="DB">复制到的数据库</param>
/// <param name="cards">卡片集合</param>
/// <param name="ignore">是否忽略存在</param>
/// <returns>更新数x2</returns>
public static int CopyDB(string DB, bool ignore,params Card[] cards)
{
int result = 0;
if ( File.Exists(DB) &&cards!=null)
{
using ( SQLiteConnection con = new SQLiteConnection(@"Data Source=" + DB) )
{
con.Open();
using ( SQLiteTransaction trans = con.BeginTransaction() )
{
using ( SQLiteCommand cmd = new SQLiteCommand(con) )
{
foreach ( Card c in cards )
{
cmd.CommandText = DataBase.GetInsertSQL(c, ignore);
result += cmd.ExecuteNonQuery();
}
}
trans.Commit();
}
con.Close();
}
}
return result;
}
#endregion
#region SQL语句
#region 查询
static string toInt(long l)
{
unchecked{
return ((int)l).ToString();
}
}
public static string GetSelectSQL(Card c)
{
StringBuilder sb=new StringBuilder();
sb.Append("SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id ");
if(!string.IsNullOrEmpty(c.name))
sb.Append(" and texts.name like '%"+c.name+"%' ");
if(!string.IsNullOrEmpty(c.desc))
sb.Append(" and texts.desc like '%"+c.desc+"%' ");
if(c.ot>0)
sb.Append(" and datas.ot & "+c.ot.ToString()+" = "+c.ot.ToString());
if(c.attribute>0)
sb.Append(" and datas.attribute & "+c.attribute.ToString()+" = "+c.attribute.ToString());
if(c.level>0)
sb.Append(" and datas.level & "+toInt(c.level)+" = "+toInt(c.level));
if(c.race>0)
sb.Append(" and datas.race & "+toInt(c.race)+" = "+toInt(c.race));
if(c.type>0)
sb.Append(" and datas.type & "+toInt(c.type)+" = "+toInt(c.type));
if(c.category>0)
sb.Append(" and datas.category & "+toInt(c.category)+" = "+toInt(c.category));
#endregion
#region 复制数据库
/// <summary>
/// 复制数据库
/// </summary>
/// <param name="DB">复制到的数据库</param>
/// <param name="cards">卡片集合</param>
/// <param name="ignore">是否忽略存在</param>
/// <returns>更新数x2</returns>
public static int CopyDB(string DB, bool ignore,params Card[] cards)
{
int result = 0;
if ( File.Exists(DB) &&cards!=null)
{
using ( SQLiteConnection con = new SQLiteConnection(@"Data Source=" + DB) )
{
con.Open();
using ( SQLiteTransaction trans = con.BeginTransaction() )
{
using ( SQLiteCommand cmd = new SQLiteCommand(con) )
{
foreach ( Card c in cards )
{
cmd.CommandText = DataBase.GetInsertSQL(c, ignore);
result += cmd.ExecuteNonQuery();
}
}
trans.Commit();
}
con.Close();
}
}
return result;
}
#endregion
public static void Compression(string db)
{
if (File.Exists(db))
{
using ( SQLiteConnection con = new SQLiteConnection(@"Data Source=" + db) )
{
con.Open();
using(SQLiteCommand cmd = new SQLiteCommand(con) )
{
cmd.CommandText="vacuum";
cmd.ExecuteNonQuery();
}
con.Close();
}
}
}
#region SQL语句
#region 查询
static string toInt(long l)
{
unchecked{
return ((int)l).ToString();
}
}
public static string GetSelectSQL(Card c)
{
StringBuilder sb=new StringBuilder();
sb.Append("SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id ");
if(!string.IsNullOrEmpty(c.name))
sb.Append(" and texts.name like '%"+c.name+"%' ");
if(!string.IsNullOrEmpty(c.desc))
sb.Append(" and texts.desc like '%"+c.desc+"%' ");
if(c.ot>0)
sb.Append(" and datas.ot & "+c.ot.ToString()+" = "+c.ot.ToString());
if(c.attribute>0)
sb.Append(" and datas.attribute & "+c.attribute.ToString()+" = "+c.attribute.ToString());
if(c.level>0)
sb.Append(" and datas.level & "+toInt(c.level)+" = "+toInt(c.level));
if(c.race>0)
sb.Append(" and datas.race & "+toInt(c.race)+" = "+toInt(c.race));
if(c.type>0)
sb.Append(" and datas.type & "+toInt(c.type)+" = "+toInt(c.type));
if(c.category>0)
sb.Append(" and datas.category & "+toInt(c.category)+" = "+toInt(c.category));
if(c.id>0 && c.alias>0)
sb.Append(" and datas.id BETWEEN "+c.alias.ToString()+" and "+c.id.ToString());
else if(c.id>0)
{
sb.Append(" and ( datas.id="+c.id.ToString()+" or datas.alias="+c.id.ToString()+") ");
}
else if(c.alias>0)
sb.Append(" and datas.alias= "+c.alias.ToString());
return sb.ToString();
}
#endregion
#region 插入
/// <summary>
/// 转换为插入语句
/// </summary>
/// <param name="c">卡片数据</param>
/// <returns>SQL语句</returns>
public static string GetInsertSQL(Card c, bool ignore)
{
StringBuilder st = new StringBuilder();
if(ignore)
st.Append("INSERT or ignore into datas values(");
else
st.Append("INSERT or replace into datas values(");
st.Append(c.id.ToString()); st.Append(",");
st.Append(c.ot.ToString()); st.Append(",");
st.Append(c.alias.ToString()); st.Append(",");
st.Append(c.setcode.ToString()); st.Append(",");
st.Append(c.type.ToString()); st.Append(",");
st.Append(c.atk.ToString()); ; st.Append(",");
st.Append(c.def.ToString()); st.Append(",");
st.Append(c.level.ToString()); st.Append(",");
st.Append(c.race.ToString()); st.Append(",");
st.Append(c.attribute.ToString()); st.Append(",");
st.Append(c.category.ToString()); st.Append(")");
if(ignore)
st.Append(";INSERT or ignore into texts values(");
else
st.Append(";INSERT or replace into texts values(");
st.Append(c.id.ToString()); st.Append(",'");
st.Append(c.name.Replace("'", "''")); st.Append("','");
st.Append(c.desc.Replace("'", "''"));
for ( int i = 0; i < 0x10; i++ )
{
st.Append("','"); st.Append(c.str[i].Replace("'", "''"));
}
st.Append("');");
string sql = st.ToString();
st = null;
return sql;
}
#endregion
if(c.id>0 && c.alias>0)
sb.Append(" and datas.id BETWEEN "+c.alias.ToString()+" and "+c.id.ToString());
else if(c.id>0)
{
sb.Append(" and ( datas.id="+c.id.ToString()+" or datas.alias="+c.id.ToString()+") ");
}
else if(c.alias>0)
sb.Append(" and datas.alias= "+c.alias.ToString());
return sb.ToString();
}
#endregion
#region 插入
/// <summary>
/// 转换为插入语句
/// </summary>
/// <param name="c">卡片数据</param>
/// <returns>SQL语句</returns>
public static string GetInsertSQL(Card c, bool ignore)
{
StringBuilder st = new StringBuilder();
if(ignore)
st.Append("INSERT or ignore into datas values(");
else
st.Append("INSERT or replace into datas values(");
st.Append(c.id.ToString()); st.Append(",");
st.Append(c.ot.ToString()); st.Append(",");
st.Append(c.alias.ToString()); st.Append(",");
st.Append(c.setcode.ToString()); st.Append(",");
st.Append(c.type.ToString()); st.Append(",");
st.Append(c.atk.ToString()); ; st.Append(",");
st.Append(c.def.ToString()); st.Append(",");
st.Append(c.level.ToString()); st.Append(",");
st.Append(c.race.ToString()); st.Append(",");
st.Append(c.attribute.ToString()); st.Append(",");
st.Append(c.category.ToString()); st.Append(")");
if(ignore)
st.Append(";INSERT or ignore into texts values(");
else
st.Append(";INSERT or replace into texts values(");
st.Append(c.id.ToString()); st.Append(",'");
st.Append(c.name.Replace("'", "''")); st.Append("','");
st.Append(c.desc.Replace("'", "''"));
for ( int i = 0; i < 0x10; i++ )
{
st.Append("','"); st.Append(c.str[i].Replace("'", "''"));
}
st.Append("');");
string sql = st.ToString();
st = null;
return sql;
}
#endregion
#region 更新
/// <summary>
/// 转换为更新语句
/// </summary>
/// <param name="c">卡片数据</param>
/// <returns>SQL语句</returns>
public static string GetUpdateSQL(Card c)
{
StringBuilder st = new StringBuilder();
st.Append("update datas set ot="); st.Append(c.ot.ToString());
st.Append(",alias="); st.Append(c.alias.ToString());
st.Append(",setcode="); st.Append(c.setcode.ToString());
st.Append(",type="); st.Append(c.type.ToString());
st.Append(",atk="); st.Append(c.atk.ToString());
st.Append(",def="); st.Append(c.def.ToString());
st.Append(",level="); st.Append(c.level.ToString());
st.Append(",race="); st.Append(c.race.ToString());
st.Append(",attribute="); st.Append(c.attribute.ToString());
st.Append(",category="); st.Append(c.category.ToString());
st.Append(" where id="); st.Append(c.id.ToString());
st.Append("; update texts set name='"); st.Append(c.name.Replace("'", "''"));
st.Append("',desc='"); st.Append(c.desc.Replace("'", "''")); st.Append("', ");
for ( int i = 0; i < 0x10; i++ )
{
st.Append("str"); st.Append(( i + 1 ).ToString()); st.Append("='");
st.Append(c.str[i].Replace("'", "''"));
if ( i < 15 )
{
st.Append("',");
}
}
st.Append("' where id="); st.Append(c.id.ToString());
st.Append(";");
string sql = st.ToString();
st = null;
return sql;
}
#endregion
#region 更新
/// <summary>
/// 转换为更新语句
/// </summary>
/// <param name="c">卡片数据</param>
/// <returns>SQL语句</returns>
public static string GetUpdateSQL(Card c)
{
StringBuilder st = new StringBuilder();
st.Append("update datas set ot="); st.Append(c.ot.ToString());
st.Append(",alias="); st.Append(c.alias.ToString());
st.Append(",setcode="); st.Append(c.setcode.ToString());
st.Append(",type="); st.Append(c.type.ToString());
st.Append(",atk="); st.Append(c.atk.ToString());
st.Append(",def="); st.Append(c.def.ToString());
st.Append(",level="); st.Append(c.level.ToString());
st.Append(",race="); st.Append(c.race.ToString());
st.Append(",attribute="); st.Append(c.attribute.ToString());
st.Append(",category="); st.Append(c.category.ToString());
st.Append(" where id="); st.Append(c.id.ToString());
st.Append("; update texts set name='"); st.Append(c.name.Replace("'", "''"));
st.Append("',desc='"); st.Append(c.desc.Replace("'", "''")); st.Append("', ");
for ( int i = 0; i < 0x10; i++ )
{
st.Append("str"); st.Append(( i + 1 ).ToString()); st.Append("='");
st.Append(c.str[i].Replace("'", "''"));
if ( i < 15 )
{
st.Append("',");
}
}
st.Append("' where id="); st.Append(c.id.ToString());
st.Append(";");
string sql = st.ToString();
st = null;
return sql;
}
#endregion
#region 删除
/// <summary>
/// 转换删除语句
/// </summary>
/// <param name="c">卡片密码</param>
/// <returns>SQL语句</returns>
public static string GetDeleteSQL(Card c)
{
string id = c.id.ToString();
return "Delete from datas where id=" + id + ";Delete from texts where id=" + id + ";";
}
#endregion
#endregion
}
#region 删除
/// <summary>
/// 转换删除语句
/// </summary>
/// <param name="c">卡片密码</param>
/// <returns>SQL语句</returns>
public static string GetDeleteSQL(Card c)
{
string id = c.id.ToString();
return "Delete from datas where id=" + id + ";Delete from texts where id=" + id + ";";
}
#endregion
#endregion
}
}
......@@ -46,6 +46,7 @@ private void InitializeComponent()
this.menuitem_saveasmse = new System.Windows.Forms.ToolStripMenuItem();
this.tsep4 = new System.Windows.Forms.ToolStripSeparator();
this.menuitem_cutimages = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_convertimage = new System.Windows.Forms.ToolStripMenuItem();
this.tsep1 = new System.Windows.Forms.ToolStripSeparator();
this.menuitem_readydk = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_readimages = new System.Windows.Forms.ToolStripMenuItem();
......@@ -107,7 +108,8 @@ private void InitializeComponent()
this.lb_setcode = new System.Windows.Forms.Label();
this.btn_img = new System.Windows.Forms.Button();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.menuitem_convertimage = new System.Windows.Forms.ToolStripMenuItem();
this.tsep5 = new System.Windows.Forms.ToolStripSeparator();
this.menuitem_compdb = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
......@@ -127,6 +129,8 @@ private void InitializeComponent()
this.menuitem_file.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuitem_open,
this.menuitem_new,
this.menuitem_compdb,
this.tsep5,
this.menuitem_copyselectto,
this.menuitem_saveasmse_select,
this.menuitem_copyto,
......@@ -203,6 +207,13 @@ private void InitializeComponent()
this.menuitem_cutimages.Text = "Cut Images";
this.menuitem_cutimages.Click += new System.EventHandler(this.Menuitem_cutimagesClick);
//
// menuitem_convertimage
//
this.menuitem_convertimage.Name = "menuitem_convertimage";
this.menuitem_convertimage.Size = new System.Drawing.Size(232, 22);
this.menuitem_convertimage.Text = "Inport Images";
this.menuitem_convertimage.Click += new System.EventHandler(this.Menuitem_convertimageClick);
//
// tsep1
//
this.tsep1.Name = "tsep1";
......@@ -775,12 +786,17 @@ private void InitializeComponent()
this.btn_img.UseVisualStyleBackColor = true;
this.btn_img.Click += new System.EventHandler(this.Btn_imgClick);
//
// menuitem_convertimage
// tsep5
//
this.menuitem_convertimage.Name = "menuitem_convertimage";
this.menuitem_convertimage.Size = new System.Drawing.Size(232, 22);
this.menuitem_convertimage.Text = "Convert Images";
this.menuitem_convertimage.Click += new System.EventHandler(this.Menuitem_convertimageClick);
this.tsep5.Name = "tsep5";
this.tsep5.Size = new System.Drawing.Size(229, 6);
//
// menuitem_compdb
//
this.menuitem_compdb.Name = "menuitem_compdb";
this.menuitem_compdb.Size = new System.Drawing.Size(232, 22);
this.menuitem_compdb.Text = "Compression DataBase";
this.menuitem_compdb.Click += new System.EventHandler(this.Menuitem_compdbClick);
//
// DataEditForm
//
......@@ -847,6 +863,8 @@ private void InitializeComponent()
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.ToolStripSeparator tsep5;
private System.Windows.Forms.ToolStripMenuItem menuitem_compdb;
private System.Windows.Forms.ToolStripMenuItem menuitem_convertimage;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.ToolStripSeparator tsep2;
......
......@@ -983,7 +983,29 @@ void Menuitem_newClick(object sender, EventArgs e)
}
}
}
void Menuitem_compdbClick(object sender, EventArgs e)
{
if(!Check())
return;
DataBase.Compression(nowCdbFile);
MyMsg.Show(LMSG.CompDBOK);
}
void Menuitem_convertimageClick(object sender, EventArgs e)
{
if(isRun())
return;
using(FolderBrowserDialog fdlg=new FolderBrowserDialog())
{
fdlg.Description= LANG.GetMsg(LMSG.SelectImagePath);
if(fdlg.ShowDialog()==DialogResult.OK)
{
bool isreplace=MyMsg.Question(LMSG.IfReplaceExistingImage);
TaskHelper.SetTask(MyTask.ConvertImages, null,
fdlg.SelectedPath, GAMEPATH, isreplace.ToString());
Run(LANG.GetMsg(LMSG.ConvertImage));
}
}
}
void Menuitem_readydkClick(object sender, EventArgs e)
{
if(!Check())
......@@ -1281,23 +1303,5 @@ void Menuitem_saveasmseClick(object sender, EventArgs e)
}
#endregion
#region Convert images
void Menuitem_convertimageClick(object sender, EventArgs e)
{
if(isRun())
return;
using(FolderBrowserDialog fdlg=new FolderBrowserDialog())
{
fdlg.Description= LANG.GetMsg(LMSG.SelectImagePath);
if(fdlg.ShowDialog()==DialogResult.OK)
{
bool isreplace=MyMsg.Question(LMSG.IfReplaceExistingImage);
TaskHelper.SetTask(MyTask.ConvertImages, null,
fdlg.SelectedPath, GAMEPATH, isreplace.ToString());
Run(LANG.GetMsg(LMSG.ConvertImage));
}
}
}
#endregion
}
}
......@@ -66,6 +66,7 @@ public enum LMSG : uint
IfReplaceExistingImage,
ConvertImage,
ConvertImageOK,
CompDBOK,
COUNT,
}
}
......@@ -28,4 +28,4 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.5.2.1")]
[assembly: AssemblyVersion("1.5.3.0")]
......@@ -23,6 +23,7 @@ DataEditForm->lb4 /
DataEditForm->lb5 /
DataEditForm->lv_cardlist0 卡片密码
DataEditForm->lv_cardlist1 卡片名称
DataEditForm->menuitem_compdb 压缩当前数据库
DataEditForm->menuitem_convertimage 批量导入卡图
DataEditForm->menuitem_openLastDataBase 最后打开的数据库
DataEditForm->menuitem_cutimages 裁剪列表卡片的图片
......
......@@ -49,4 +49,5 @@
0x30 没有选中一张卡片
0x31 是否替换存在的图片?
0x32 正在转换图片
0x33 转换图片完成
\ No newline at end of file
0x33 转换图片完成
0x34 压缩数据库完成
\ No newline at end of file
......@@ -23,6 +23,8 @@ DataEditForm->lb4 /
DataEditForm->lb5 /
DataEditForm->lv_cardlist0 Card Code
DataEditForm->lv_cardlist1 Card Name
DataEditForm->menuitem_compdb Compression DataBase
DataEditForm->menuitem_convertimage Inport Images
DataEditForm->menuitem_openLastDataBase Open Last DataBase
DataEditForm->menuitem_cutimages Cut Images For Game
DataEditForm->menuitem_saveasmse_select Select Cards Save As...
......
......@@ -49,4 +49,5 @@
0x30 No Select Cards
0x31 If Replace Iamge When it's exisit?
0x32 Converting Images
0x33 Convert Images OK
\ No newline at end of file
0x33 Convert Images OK
0x34 Compression DataBase OK
\ No newline at end of file
[DataEditorX]1.5.2.1[DataEditorX]
[DataEditorX]1.5.3.0[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★使用前,请关联lua的打开方式,例如记事本,notepad++,等。
......@@ -47,6 +47,8 @@ DataEditorX.exe.config
描述不详细的bug,我修复不了。(都不知道是bug是什么)
★更新历史
1.5.3.0
增加压缩数据库
1.5.2.1
导入卡图的路径改为cdb的目录的pics
1.5.2.0
......
No preview for this file type
......@@ -23,6 +23,7 @@ DataEditForm->lb4 /
DataEditForm->lb5 /
DataEditForm->lv_cardlist0 卡片密码
DataEditForm->lv_cardlist1 卡片名称
DataEditForm->menuitem_compdb 压缩当前数据库
DataEditForm->menuitem_convertimage 批量导入卡图
DataEditForm->menuitem_openLastDataBase 最后打开的数据库
DataEditForm->menuitem_cutimages 裁剪列表卡片的图片
......
......@@ -49,4 +49,5 @@
0x30 没有选中一张卡片
0x31 是否替换存在的图片?
0x32 正在转换图片
0x33 转换图片完成
\ No newline at end of file
0x33 转换图片完成
0x34 压缩数据库完成
\ No newline at end of file
......@@ -23,6 +23,8 @@ DataEditForm->lb4 /
DataEditForm->lb5 /
DataEditForm->lv_cardlist0 Card Code
DataEditForm->lv_cardlist1 Card Name
DataEditForm->menuitem_compdb Compression DataBase
DataEditForm->menuitem_convertimage Inport Images
DataEditForm->menuitem_openLastDataBase Open Last DataBase
DataEditForm->menuitem_cutimages Cut Images For Game
DataEditForm->menuitem_saveasmse_select Select Cards Save As...
......
......@@ -49,4 +49,5 @@
0x30 No Select Cards
0x31 If Replace Iamge When it's exisit?
0x32 Converting Images
0x33 Convert Images OK
\ No newline at end of file
0x33 Convert Images OK
0x34 Compression DataBase OK
\ No newline at end of file
[DataEditorX]1.5.2.1[DataEditorX]
[DataEditorX]1.5.3.0[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★使用前,请关联lua的打开方式,例如记事本,notepad++,等。
......@@ -47,6 +47,8 @@ DataEditorX.exe.config
描述不详细的bug,我修复不了。(都不知道是bug是什么)
★更新历史
1.5.3.0
增加压缩数据库
1.5.2.1
导入卡图的路径改为cdb的目录的pics
1.5.2.0
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment