private void MainForm_Load(object sender, EventArgs e) { FirstForm ff = new FirstForm(); ff.MdiParent = this; ff.Show(); }
public void LoadBook(string fileName) { if (File.Exists(fileName)) { Stream stream = File.Open(fileName, FileMode.Open, FileAccess.Read); IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); book = (Novel)formatter.Deserialize(stream); stream.Close(); this.treeListDirectory.DataSource = book.NovelChapters; OleDbConnection conn = new OleDbConnection(Properties.Settings.Default.novelConnectionString); try { conn.Open(); using (OleDbCommand cmd = conn.CreateCommand()) { cmd.CommandText = "select novelName from novel where novelName='" + this.book.NovelName + "'"; if (cmd.ExecuteNonQuery() < 1) { cmd.CommandText = "insert into novel (novelName,novelFileName,novelWebAddress,updateTime) values ('" + this.book.NovelName + "','" + fileName + "','" + this.book.NovelAddress + "','" + DateTime.Now + "')"; cmd.ExecuteNonQuery(); } } foreach (Form f in Globals.mainForm.MdiChildren) { if (f.GetType() == typeof(FirstForm)) { FirstForm ff = f as FirstForm; ff.UpdateNovelLink(); } } } finally { conn.Close(); } } }