private void button1_Click(object sender, EventArgs e) { try { ConfigClass.SetConfigString("sys", "小票打印机", comb_Printer.Text); ConfigClass.SetConfigString("sys", "店铺名称", txt_ShopName.Text); ConfigClass.SetConfigString("sys", "二维码路径", txt_Barcode.Text); ConfigClass.SetConfigString("sys", "二维码宽度", numericUpDown1.Value.ToString()); ConfigClass.SetConfigString("sys", "log", cb_Log.Checked.ToString()); ConfigClass.SetConfigString("sys", "Convert", cb_timerConvert.Checked.ToString()); MessageBox.Show("保存成功!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } //this.Close(); }
public static void AddPic(int rows, Worksheet ws, int count, string PicturePath) { int picWidth = int.Parse(ConfigClass.GetConfigString("sys", "二维码宽度", "100")); Range range = ws.Range["A" + rows.ToString(), "C" + (rows + count - 1).ToString()]; range.Merge(); range.Select(); float PicLeft, PicTop, PicWidth, PicHeight; //距离左边距离,顶部距离,图片宽度、高度 using (Image img = Image.FromFile(PicturePath)) { PicWidth = picWidth; PicHeight = ((PicWidth / (float)img.Width) * (img.Height)) - 1; range.RowHeight = (int)(PicHeight / 4); } double l = range.Height; PicTop = Convert.ToSingle(range.Top); PicLeft = (Convert.ToSingle(range.Width) - PicWidth) / 2; ws.Shapes.AddPicture(PicturePath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, PicLeft + 5, PicTop + 5, PicWidth - 10, PicHeight - 10); }
private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (tooldoWork != null) { if (HitFlag) { if (e.ClickedItem.Name.Substring(0, 2) == "刷新") { ContextMenu contextMenu = new ContextMenu(); contextMenu.MenuItems.Add(0, new MenuItem("保存", subMenuItemClick)); int i = contextMenu.MenuItems.Add(1, new MenuItem("上次刷新" + ((int)((DateTime.Now - RefreshDateTime).TotalMinutes)).ToString() + "min")); contextMenu.MenuItems[i].Enabled = false; Point p = PointToClient(MousePosition); contextMenu.Show(toolStrip1, p); } else if (e.ClickedItem.Name.Substring(0, 2) == "开始") { ContextMenu contextMenu = new ContextMenu(); contextMenu.MenuItems.Add(0, new MenuItem("封面输出", subMenuItemClick)); contextMenu.MenuItems.Add(0, new MenuItem("合并输出", subMenuItemClick)); contextMenu.MenuItems.Add(0, new MenuItem("定时输出", subMenuItemClick)); contextMenu.MenuItems.Add(0, new MenuItem("多线输出", subMenuItemClick)); Point p = PointToClient(MousePosition); contextMenu.Show(toolStrip1, p); } else if (e.ClickedItem.Name.Substring(0, 2) == "删除") { ContextMenu contextMenu = new ContextMenu(); contextMenu.MenuItems.Add(0, new MenuItem("复制", subMenuItemClick)); contextMenu.MenuItems.Add(0, new MenuItem("合并", subMenuItemClick)); contextMenu.MenuItems.Add(0, new MenuItem("拆分", subMenuItemClick)); contextMenu.MenuItems.Add(0, new MenuItem("预览", subMenuItemClick)); contextMenu.MenuItems.Add(0, new MenuItem("中止", subMenuItemClick)); Point p = PointToClient(MousePosition); contextMenu.Show(toolStrip1, p); } } else { if (e.ClickedItem.Name.Substring(0, 2) == "刷新") { txt_user.Text = ""; RefreshDateTime = DateTime.Now; } tooldoWork.Invoke(e.ClickedItem.Name.Substring(0, 2)); if (e.ClickedItem.Name.Substring(0, 2) == "设置") { 系统设置 frm_sys = new 系统设置(); frm_sys.ShowDialog(); sysConfigData.printerName = ConfigClass.GetConfigString("sys", "小票打印机", ""); sysConfigData.ShopName = ConfigClass.GetConfigString("sys", "店铺名称", ""); sysConfigData.BarcodePath = ConfigClass.GetConfigString("sys", "二维码路径", ""); FileHelper.timelist = GetPeopleMsg.GetTimeList(); FileHelper.addrList = GetPeopleMsg.GetAddrList(); FileHelper.rowMsg = GetDefaultAddMsg.getMsg(); GetPaperType.UpdatePaperList(); GetPrinterType.UpdatePrinterList(); GetPaperPrice.getPrice(); } } } }
private void CK_fastPrint_CheckedChanged(object sender, EventArgs e) { ConfigClass.SetConfigString("Printer", "speed", CK_fastPrint.Checked.ToString()); nFastPrint = CK_fastPrint.Checked; }
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("数据库连接异常!"); } }