private void Form1_Load(object sender, EventArgs e) { //File.AppendAllLines(@"E:\代码\C#\Winform\私单\打印管理20190916\20190820\打印管理\打印管理\bin\Debug\log\logtext 20190926 171728.txt",new string[] { "123456"}); bool b = SQLiteHelper.SQLiteInit(string.Format(@"Data Source={0}\PrintDB.db", Application.StartupPath), "jtmes"); if (b) { KeyPreview = true; try { foreach (var v in toolStrip1.Items) { if (v is ToolStripButton) { ToolStripButton Tbtn = v as ToolStripButton; if (Convert.ToString(Tbtn.Tag) == "1") { Tbtn.Paint += toolStrip1_Paint; Tbtn.MouseMove += toolStrip1_MouseMove; } } } logFlag = Convert.ToBoolean(ConfigClass.GetConfigString("sys", "log", "true")); LogOperate.Init(); LogOperate.Start(); LogOperate.Add("软件运行"); CurrentPath = ConfigClass.GetConfigString("File", "path", ""); if (!Directory.Exists(CurrentPath)) { FolderBrowserDialog f = new FolderBrowserDialog(); if (f.ShowDialog() == DialogResult.OK) { CurrentPath = f.SelectedPath; ConfigClass.SetConfigString("File", "path", CurrentPath); } else { unInit = true; Application.Exit(); } } string strFastPrint = ConfigClass.GetConfigString("Printer", "speed", "false"); CK_fastPrint.Checked = strFastPrint.ToUpper() == "TRUE" ? true : false; nFastPrint = CK_fastPrint.Checked; bool bConvert = Convert.ToBoolean(ConfigClass.GetConfigString("sys", "Convert", "false")); if (bConvert) { timer2.Interval = 1000; timer2.Enabled = true; } else { fileWatcher.Path = CurrentPath; fileWatcher.EnableRaisingEvents = true; } sysConfigData.printerName = ConfigClass.GetConfigString("sys", "小票打印机", ""); sysConfigData.ShopName = ConfigClass.GetConfigString("sys", "店铺名称", ""); sysConfigData.BarcodePath = ConfigClass.GetConfigString("sys", "二维码路径", ""); sound = new System.Media.SoundPlayer("Audio.wav"); sound.Load(); //main.groupList = ConfigClass.LoadCookie<GroupMsg>("cookie.dat"); main.groupList = SqlModlus.selectTmpUserMsg(); if (main.groupList == null) { main.groupList = new List <GroupMsg>(); } foreach (var v in main.groupList) { if (!v.isManual) { List <FileMsg> fmsg = SqlModlus.selectTmpFileMsg(v.UserID); v.FileMsgList = fmsg; } } main.groupList.ForEach(t => t.isPrint = false); main.groupList.RemoveAll(t => t.isRemove == true); txt_Date.Text = DateTime.Now.Date.ToLongDateString(); CurrentDate = txt_Date.Text; FileHelper.timelist = GetPeopleMsg.GetTimeList(); FileHelper.addrList = GetPeopleMsg.GetAddrList(); FileHelper.rowMsg = GetDefaultAddMsg.getMsg(); GetPaperType.UpdatePaperList(); GetPrinterType.UpdatePrinterList(); GetPaperPrice.getPrice(); GetUserMsg(CurrentPath); WordToPdf.Start(); DealControl(new int[] { 0, 0, 0 }); CheckForIllegalCrossThreadCalls = false; treeView1.ExpandAll(); treeView1.MouseDoubleClick += new MouseEventHandler(treeView1_DoubleClick); txt_path.Text = CurrentPath; //FileHelper.act.BeginInvoke(frm_Main.CurrentPath, callback, null); frm_MainMenu = New_Form(frm_MainMenu); tooldoWork = frm_MainMenu.doWork; if (frm_MainMenu != null) { frm_MainMenu.setdgvPos(panel_Parent.Width, panel_Parent.Height); } ExcelHelper.Start(); frm_MainMenu.refresh(""); toolStrip2.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.toolStrip2_ItemClicked); unInit = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("数据库连接异常!"); } }