public CouponsPopForm(CouponPicInfo info, MainFrame myFrame) { InitializeComponent(); this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.UserPaint, true); this.Panel_Background.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(Panel_Background, true, null); this.Location = new Point(10, 10); this.pi = info; this.Frame = myFrame; this.Label_Top.Text = GlobalVariables.StrPhone; pd.BeginPrint += new PrintEventHandler(pd_BeginPrint); pd.EndPrint += new PrintEventHandler(pd_EndPrint); pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); pd.DocumentName = "coupon"; if (pi.intSendBySM == 1) { btn_SM.Visible = true; Button_Print.Location = new Point(1, 695); Button_Close.Location = new Point(249, 695); } else { btn_SM.Visible = false; Button_Print.Location = new Point(47, 695); Button_Close.Location = new Point(199, 695); } }
/// <summary> /// 预加载所有的图片信息 /// </summary> private void InitData() { AccessCmd cmd = new AccessCmd(); OleDbDataReader reader; //初始化参数 tradeName = GetTradeName(); //加载参数 string strSql = "select * from t_bz_terminal_param"; reader = cmd.ExecuteReader(strSql); while (reader.Read()) { try { string strParamName = reader.GetString(1); if (strParamName.Equals("strExitPwd")) GlobalVariables.StrExitPwd = reader.GetString(2); else if (strParamName.Equals("intMemberSec")) GlobalVariables.UserWaitTime = Int16.Parse(reader.GetString(2)); else if (strParamName.Equals("intRefreshSec")) GlobalVariables.IntRefreshSec = Int16.Parse(reader.GetString(2)); else if (strParamName.Equals("strPhone")) GlobalVariables.StrPhone = reader.GetString(2); else if (strParamName.Equals("intAdSec")) GlobalVariables.WindowWaitTime = Int16.Parse(reader.GetString(2)); else if (strParamName.Equals("intAdImg")) GlobalVariables.IntAdImg = Int16.Parse(reader.GetString(2)); else if (strParamName.Equals("intHistory")) GlobalVariables.IntHistory = Int16.Parse(reader.GetString(2)); else if (strParamName.Equals("intCouponPrint")) GlobalVariables.IntCouponPrint = Int16.Parse(reader.GetString(2)); else if (strParamName.Equals("strTerminalNo")) GlobalVariables.StrTerminalNo = reader.GetString(2); else if (strParamName.Equals("strServerUrl")) GlobalVariables.StrServerUrl = reader.GetString(2); else if (strParamName.Equals("intPrintLimit")) GlobalVariables.PrintLimit = Int16.Parse(reader.GetString(2)); else if (strParamName.Equals("intSmsReceive")) GlobalVariables.MessageRegetTime = reader.GetInt32(2); } catch (Exception) { continue; } } reader.Close(); //读取数据库 strSql = "select * from t_bz_shop order by intType desc,intSort asc"; try { reader = cmd.ExecuteReader(strSql); } catch (Exception e0) { ErrorLog.log(e0); cmd.Close(); return; } FileStream pFileStream; LP_shop = new List<PicInfo>(); String lPath, sPath, pPath, name, id, trade, shopid; double flaPrice; int intVip, intType; while (reader.Read()) { try { PicInfo pi = new PicInfo(); if (!reader.IsDBNull(9)) { lPath = reader.GetString(9); if (lPath != "") { pi.lpath = path + "\\shop\\" + lPath; if (!File.Exists(pi.lpath)) { pi.lpath = path + "\\shop\\null.jpg"; } } else { pi.lpath = path + "\\shop\\null.jpg"; } } else { pi.lpath = path + "\\shop\\null.jpg"; } if (!reader.IsDBNull(8)) { sPath = reader.GetString(8); if (sPath != "") { pi.spath = path + "\\shop\\" + sPath; if (!File.Exists(pi.spath)) { pi.spath = path + "\\shop\\null.jpg"; } } else { pi.spath = path + "\\shop\\null.jpg"; } } else { pi.spath = path + "\\shop\\null.jpg"; } pFileStream = new FileStream(pi.spath, FileMode.Open, FileAccess.Read); pi.image = new Bitmap(Image.FromStream(pFileStream), 119, 138); pFileStream.Close(); pFileStream.Dispose(); if (!reader.IsDBNull(0)) { id = reader.GetString(0); if (id != "") { pi.id = id; } else { pi.id = "000000000000"; } } else { pi.id = "000000000000"; } if (!reader.IsDBNull(1)) { name = reader.GetString(1); if (name != "") { pi.name = name; } else { pi.name = "无名称"; } } else { pi.name = "无名称"; } trade = reader.GetString(3); if (trade != "" && trade != null) { pi.trade = trade; } intType = reader.GetInt32(10); pi.intType = intType; LP_shop.Add(pi); } catch (Exception) { continue; } } reader.Close(); string date = DateTime.Now.ToString("yyyy/M/d H:mm:ss"); strSql = "select * from t_bz_coupon where #" + date + "#>=dtActiveTime and #" + date + "#<dtExpireTime"; reader = cmd.ExecuteReader(strSql); LP_coupon = new List<CouponPicInfo>(); while (reader.Read()) { try { CouponPicInfo pi = new CouponPicInfo(); if (!reader.IsDBNull(13)) { pi.intSendBySM = reader.GetInt32(13); } if (!reader.IsDBNull(9)) { lPath = reader.GetString(9); if (lPath != "") { pi.lpath = path + "\\coupon\\" + lPath; if (!File.Exists(pi.lpath)) { pi.lpath = path + "\\coupon\\null.jpg"; } } else { pi.lpath = path + "\\coupon\\null.jpg"; } } else { pi.lpath = path + "\\coupon\\null.jpg"; } if (!reader.IsDBNull(10)) { pPath = reader.GetString(10); if (pPath != "") { pi.pPath = path + "\\coupon\\" + pPath; if (!File.Exists(pi.pPath)) { pi.pPath = path + "\\coupon\\null.jpg"; } } else { pi.pPath = path + "\\coupon\\null.jpg"; } } else { pi.pPath = path + "\\coupon\\null.jpg"; } if (!reader.IsDBNull(8)) { sPath = reader.GetString(8); if (sPath != "") { pi.spath = path + "\\coupon\\" + sPath; if (!File.Exists(pi.spath)) { pi.spath = path + "\\coupon\\null.jpg"; } } else { pi.spath = path + "\\coupon\\null.jpg"; } } else { pi.spath = path + "\\coupon\\null.jpg"; } pFileStream = new FileStream(pi.spath, FileMode.Open, FileAccess.Read); pi.image = new Bitmap(Image.FromStream(pFileStream), 240, 120); pFileStream.Close(); pFileStream.Dispose(); if (!reader.IsDBNull(1)) { name = reader.GetString(1); if (name != "") { pi.name = name; } else { pi.name = "null"; } } else { pi.name = "null"; } if (!reader.IsDBNull(0)) { id = reader.GetString(0); if (id != "") { pi.id = id; } else { pi.id = "00000000"; } } else { pi.id = "00000000"; } if (!reader.IsDBNull(4)) { shopid = reader.GetString(4); if (shopid != "") { pi.shopId = shopid; strSql = "select strTrade from t_bz_shop where strId='" + shopid + "'"; OleDbDataReader oddr = cmd.ExecuteReader(strSql); if (oddr.Read()) { if (!reader.IsDBNull(0)) { pi.trade = oddr.GetString(0); } } oddr.Close(); } } if (!reader.IsDBNull(5)) { intVip = reader.GetInt32(5); pi.vip = intVip; } else { pi.vip = 0; } if (!reader.IsDBNull(7)) { flaPrice = reader.GetDouble(7); pi.flaPrice = flaPrice; } else { pi.flaPrice = 0; } LP_coupon.Add(pi); } catch (Exception) { continue; } } reader.Close(); cmd.Close(); InitParam(); }