public bool CouponPrint() { AccessCmd cmd = new AccessCmd(); try { //读取数据库 string strSql = "select * from t_bz_coupon_print"; OleDbDataReader reader = cmd.ExecuteReader(strSql); StringBuilder sbPrintInfo = new StringBuilder(); StringBuilder sbId = new StringBuilder(); while (reader.Read()) { sbId.Append("'").Append(reader.GetString(0)).Append("',"); sbPrintInfo.Append(reader.GetString(1)).Append("$").Append(reader.GetString(2)).Append("$").Append(reader.GetDateTime(3).ToString()).Append("$") .Append(reader.GetString(4)).Append("@"); } reader.Close(); if (sbPrintInfo.Length > 0) { string strPrintInfo = sbPrintInfo.ToString(0, sbPrintInfo.Length - 1); string strIds = sbId.ToString(0, sbId.Length - 1); //上传数据 request.OpenRequest(GlobalVariables.StrServerUrl + "/servlet/CouponPrint?strTerminalNo=" + GlobalVariables.StrTerminalNo + "&strPrintContent=" + strPrintInfo, ""); XmlDocument doc = new XmlDocument(); string strXml = request.HtmlDocument; doc.LoadXml(strXml); string strReturn = doc.GetElementsByTagName("return").Item(0).InnerText.Trim(); if (strReturn.Equals("OK")) { //删除数据库记录 strSql = "delete from t_bz_coupon_print where strId in (" + strIds + ")"; cmd.ExecuteNonQuery(strSql); } } return true; } catch (Exception e) { ErrorLog.log(e); return false; } finally { cmd.Close(); } }
internal void SynParam() { //下载参数信息 request.OpenRequest(GlobalVariables.StrServerUrl + "/servlet/TerminalParam?strTerminalNo=" + GlobalVariables.StrTerminalNo, ""); string strXml = request.HtmlDocument; if (strXml.IndexOf("<params>") > 0) { XmlDocument doc = new XmlDocument(); doc.LoadXml(strXml); //删除原纪录 AccessCmd cmd = new AccessCmd(); string strSql = "delete from t_bz_terminal_param where strParamName<>'strTerminalNo' and strParamName<>'strServerUrl'"; cmd.ExecuteNonQuery(strSql); //增加新纪录 XmlNodeList xnl = doc.GetElementsByTagName("param"); for (int i = 0; i < xnl.Count; i++) { XmlElement xe = (XmlElement)xnl.Item(i); //获取信息 string strId = xe.ChildNodes.Item(0).InnerText.Trim(); string strParamName = xe.ChildNodes.Item(1).InnerText.Trim(); string strParamValue = xe.ChildNodes.Item(2).InnerText.Trim(); //更新数据库 strSql = "insert into t_bz_terminal_param (strId,strParamName,strParamValue) values ('" + strId + "','" + strParamName + "','" + strParamValue + "')"; cmd.ExecuteNonQuery(strSql); } cmd.Close(); } }
public void download() { AccessCmd cmd = new AccessCmd(); AccessCmd comd = new AccessCmd(0); //下载界面元素信息 try { request.OpenRequest(GlobalVariables.StrServerUrl + "/servlet/TemplateParam?strTerminalNo=" + GlobalVariables.StrTerminalNo, ""); XmlDocument doc = new XmlDocument(); string strXml = request.HtmlDocument; Console.WriteLine(strXml); if (strXml.IndexOf("<templates>") >= 0) { //加载服务器信息 doc.LoadXml(strXml); //加载顶部框架信息 XmlNodeList xnlTop = doc.GetElementsByTagName("top").Item(0).ChildNodes; XmlNodeList xnlBottom = doc.GetElementsByTagName("bottom").Item(0).ChildNodes; XmlNodeList xnlMiddle = doc.GetElementsByTagName("middle").Item(0).ChildNodes; List<XmlNodeList> lst_xnl = new List<XmlNodeList>(); lst_xnl.Add(xnlTop); for (int j = 0; j < xnlMiddle.Count; j++) { lst_xnl.Add(xnlMiddle[j].ChildNodes); } lst_xnl.Add(xnlBottom); //加载本地信息 string strSql = "select * from t_bz_templates order by strId asc"; OleDbDataReader reader = comd.ExecuteReader(strSql); List<Element> lstLocal = new List<Element>(); while (reader.Read()) { Element element = new Element(reader); lstLocal.Add(element); } reader.Close(); int index = 0; //依次对比服务器与本地信息,保证两者一致 for (int t = 0; t < lst_xnl.Count; t++) { XmlNodeList xnlTemp = lst_xnl[t]; for (int i = 0; i < xnlTemp.Count; i++) { try { //获得服务器记录信息 XmlElement xe = (XmlElement)xnlTemp[i]; String strLocation, strSize, strBgImage, strFontFamily, strContent, strFontSize, strFontColor, strSort; getTemplateProps(xe, out strLocation, out strSize, out strBgImage, out strFontFamily, out strContent, out strFontSize, out strFontColor, out strSort); //比对本地信息 Element localtemplate = lstLocal.ElementAt(Convert.ToInt16(strSort) - 1); //找到本地信息,先更新图片 bool bolImg = true; bolImg = createImg("template", strBgImage); //图片操作正常,删除原图片并更新数据库 if (bolImg) { comd.ExecuteNonQuery("update t_bz_templates set strLocation='" + strLocation + "',strSize='" + strSize + "',strFontFamily='" + strFontFamily + "',strContent='" + strContent + "',intFontSize=" + Convert.ToInt16(strFontSize) + ",strFontColor='" + strFontColor + "' where strName='"+localtemplate.strName+"'"); } index++; continue; } catch (Exception e) { ErrorLog.log(e); } } } } } catch (Exception e) { ErrorLog.log(e); } comd.Close(); //下载商家信息 try { request.OpenRequest(GlobalVariables.StrServerUrl + "/servlet/ShopDownload?strTerminalNo=" + GlobalVariables.StrTerminalNo, ""); XmlDocument doc = new XmlDocument(); string strXml = request.HtmlDocument; if (strXml.IndexOf("<shops>") > 0) { //加载服务器信息 doc.LoadXml(strXml); XmlNodeList xnlShop = doc.GetElementsByTagName("shop"); //加载本地信息 string strSql = "select strId,strSmallImg,strLargeImg from t_bz_shop"; OleDbDataReader reader = cmd.ExecuteReader(strSql); List<Shop> lstShop = new List<Shop>(); while (reader.Read()) { Shop shop = new Shop(reader); lstShop.Add(shop); } reader.Close(); //依次对比服务器与本地信息,保证两者一致 for (int i = 0; i < xnlShop.Count; i++) { try { //获得服务器记录信息 XmlElement xeShop = (XmlElement)xnlShop.Item(i); String strId, strBizName, strShopName, strTrade, strAddr, strIntro, strSmallImg, strLargeImg, intType, intSort; getShopProps(xeShop, out strId, out strBizName, out strShopName, out strTrade, out strAddr, out strIntro, out strSmallImg, out strLargeImg, out intType, out intSort); //比对本地信息 for (int j = 0; j < lstShop.Count; j++) { Shop localShop = lstShop.ElementAt(j); if (localShop.StrId.Equals(strId)) { //找到本地信息,先更新图片 bool bolImg = true; if (strSmallImg.Length > 0 && !strSmallImg.Equals(localShop.StrSmallImg)) { bolImg = createImg("shop", strSmallImg); } if (bolImg && strLargeImg.Length > 0 && !strLargeImg.Equals(localShop.StrLargeImg)) { bolImg = createImg("shop", strLargeImg); } //考虑数据库中有记录,但图片不存在的情况 if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\shop\\" + strSmallImg)) { bolImg = bolImg && createImg("shop", strSmallImg); } if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\shop\\" + strLargeImg)) { bolImg = bolImg && createImg("shop", strLargeImg); } //图片操作正常,删除原图片并更新数据库 if (bolImg) { cmd.ExecuteNonQuery("update t_bz_shop set strBizName='" + strBizName + "',strShopName='" + strShopName + "',strTrade='" + strTrade + "',strAddr='" + strAddr + "',strIntro='" + strIntro + "',strSmallImg='" + strSmallImg + "',strLargeImg='" + strLargeImg + "',intType=" + intType + ",intSort=" + intSort + " where strId='" + strId + "'"); if (!strSmallImg.Equals(localShop.StrSmallImg)) File.Delete(System.Windows.Forms.Application.StartupPath + "\\shop\\" + localShop.StrSmallImg); if (!strLargeImg.Equals(localShop.StrLargeImg)) File.Delete(System.Windows.Forms.Application.StartupPath + "\\shop\\" + localShop.StrLargeImg); } strId = ""; lstShop.Remove(localShop); break; } } if (strId.Length > 0) { //本地没有找到,先增加图片 bool bolImg = true; if (strSmallImg.Length > 0) { bolImg = createImg("shop", strSmallImg); } if (bolImg && strLargeImg.Length > 0) { bolImg = createImg("shop", strLargeImg); } //图片操作正常,更新数据库 if (bolImg) { cmd.ExecuteNonQuery("insert into t_bz_shop(strId,strBizName,strShopName,strTrade,strAddr,strIntro,strSmallImg,strLargeImg,intType,intSort) values('" + strId + "','" + strBizName + "','" + strShopName + "','" + strTrade + "','" + strAddr + "','" + strIntro + "','" + strSmallImg + "','" + strLargeImg + "'," + intType + "," + intSort + ")"); } } } catch (Exception e) { ErrorLog.log(e); } } //删除本地没有匹配的记录 for (int i = 0; i < lstShop.Count; i++) { Shop localShop = lstShop.ElementAt(i); cmd.ExecuteNonQuery("delete from t_bz_shop where strId='" + localShop.StrId + "'"); if (localShop.StrSmallImg.Length > 0) File.Delete(System.Windows.Forms.Application.StartupPath + "\\shop\\" + localShop.StrSmallImg); if (localShop.StrLargeImg.Length > 0) File.Delete(System.Windows.Forms.Application.StartupPath + "\\shop\\" + localShop.StrLargeImg); } } } catch (Exception e) { ErrorLog.log(e); } //下载优惠券信息 try { request.OpenRequest(GlobalVariables.StrServerUrl + "/servlet/CouponDownload?strTerminalNo=" + GlobalVariables.StrTerminalNo, ""); XmlDocument doc = new XmlDocument(); string strXml = request.HtmlDocument; if (strXml.IndexOf("<coupons>") > 0) { //加载服务器信息 doc.LoadXml(strXml); XmlNodeList xnlCoupon = doc.GetElementsByTagName("coupon"); //加载本地信息 string strSql = "select strId,strSmallImg,strLargeImg,strPrintImg from t_bz_coupon"; OleDbDataReader reader = cmd.ExecuteReader(strSql); List<Coupon> lstCoupon = new List<Coupon>(); while (reader.Read()) { Coupon coupon = new Coupon(reader); lstCoupon.Add(coupon); } reader.Close(); //依次对比服务器与本地信息,保证两者一致 for (int i = 0; i < xnlCoupon.Count; i++) { try { //获得服务器记录信息 XmlElement xeCoupon = (XmlElement)xnlCoupon.Item(i); String strId, strName, dtActiveTime, dtExpireTime, strShopId, strSmallImg, strLargeImg, strPrintImg, strIntro, strInstruction; int intVip, intRecommend, intSendBySM; float flaPrice; getCouponProps(xeCoupon, out strId, out strName, out dtActiveTime, out dtExpireTime, out strShopId, out intVip, out flaPrice, out intRecommend, out strSmallImg, out strLargeImg, out strPrintImg, out strIntro, out strInstruction,out intSendBySM); //比对本地信息 for (int j = 0; j < lstCoupon.Count; j++) { Coupon localCoupon = lstCoupon.ElementAt(j); if (localCoupon.StrId.Equals(strId)) { //找到本地信息,先更新图片 bool bolImg = true; if (strSmallImg.Length > 0 && !strSmallImg.Equals(localCoupon.StrSmallImg)) { bolImg = createImg("coupon", strSmallImg); } if (bolImg && strLargeImg.Length > 0 && !strLargeImg.Equals(localCoupon.StrLargeImg)) { bolImg = createImg("coupon", strLargeImg); } if (bolImg && strPrintImg.Length > 0 && !strPrintImg.Equals(localCoupon.StrPrintImg)) { bolImg = createImg("coupon", strPrintImg); } //考虑数据库中有记录,但图片不存在的情况 if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + strSmallImg)) { bolImg = bolImg && createImg("coupon", strSmallImg); } if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + strLargeImg)) { bolImg = bolImg && createImg("coupon", strLargeImg); } if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + strPrintImg)) { bolImg = bolImg && createImg("coupon", strPrintImg); } //图片操作正常,删除原图片并更新数据库 if (bolImg) { cmd.ExecuteNonQuery("update t_bz_coupon set strName='" + strName + "',dtActiveTime='" + dtActiveTime + "',dtExpireTime='" + dtExpireTime + "',strShopId='" + strShopId + "',intVip=" + intVip + ",intRecommend=" + intRecommend + ",flaPrice=" + flaPrice + ",strSmallImg='" + strSmallImg + "',strLargeImg='" + strLargeImg + "',strPrintImg='" + strPrintImg + "',strIntro='" + strIntro + "',strInstruction='" + strInstruction + "',intSendBySM=" + intSendBySM + " where strId='" + strId + "'"); if (!strSmallImg.Equals(localCoupon.StrSmallImg)) File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrSmallImg); if (!strLargeImg.Equals(localCoupon.StrLargeImg)) File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrLargeImg); if (!strPrintImg.Equals(localCoupon.StrPrintImg)) File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrPrintImg); } strId = ""; lstCoupon.Remove(localCoupon); break; } } if (strId.Length > 0) { //本地没有找到,先增加图片 bool bolImg = true; if (strSmallImg.Length > 0) { bolImg = createImg("coupon", strSmallImg); } if (bolImg && strLargeImg.Length > 0) { bolImg = createImg("coupon", strLargeImg); } if (bolImg && strPrintImg.Length > 0) { bolImg = createImg("coupon", strPrintImg); } //图片操作正常,更新数据库 if (bolImg) { cmd.ExecuteNonQuery("insert into t_bz_coupon(strId,strName,dtActiveTime,dtExpireTime,strShopId,intVip,intRecommend,flaPrice,strSmallImg,strLargeImg," + "strPrintImg,strIntro,strInstruction) values('" + strId + "','" + strName + "','" + dtActiveTime + "','" + dtExpireTime + "','" + strShopId + "'," + intVip + "," + intRecommend + "," + flaPrice + ",'" + strSmallImg + "','" + strLargeImg + "','" + strPrintImg + "','" + strIntro + "','" + strInstruction + "')"); } } } catch (Exception e) { ErrorLog.log(e); } } //删除本地没有匹配的记录 for (int i = 0; i < lstCoupon.Count; i++) { Coupon localCoupon = lstCoupon.ElementAt(i); cmd.ExecuteNonQuery("delete from t_bz_coupon where strId='" + localCoupon.StrId + "'"); if (localCoupon.StrSmallImg.Length > 0) File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrSmallImg); if (localCoupon.StrLargeImg.Length > 0) File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrLargeImg); if (localCoupon.StrPrintImg.Length > 0) File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrPrintImg); } } } catch (Exception e) { ErrorLog.log(e); } //下载广告信息 try { request.OpenRequest(GlobalVariables.StrServerUrl + "/servlet/AdDownload?strTerminalNo=" + GlobalVariables.StrTerminalNo, ""); XmlDocument doc = new XmlDocument(); string strXml = request.HtmlDocument; if (strXml.IndexOf("<ads>") > 0) { //加载服务器信息 doc.LoadXml(strXml); XmlNodeList xnlAd = doc.GetElementsByTagName("ad"); //加载本地信息 string strSql = "select strId,intType,strContent from t_bz_advertisement"; OleDbDataReader reader = cmd.ExecuteReader(strSql); List<Advertisement> lstAd = new List<Advertisement>(); while (reader.Read()) { Advertisement ad = new Advertisement(reader); lstAd.Add(ad); } reader.Close(); //依次对比服务器与本地信息,保证两者一致 for (int i = 0; i < xnlAd.Count; i++) { try { //获得服务器记录信息 XmlElement xeAd = (XmlElement)xnlAd.Item(i); String strId, strName, strContent, dtStartTime, dtEndTime; int intType; getAdProps(xeAd, out strId, out strName, out intType, out strContent, out dtStartTime, out dtEndTime); //比对本地信息 for (int j = 0; j < lstAd.Count; j++) { Advertisement localAd = lstAd.ElementAt(j); if (localAd.StrId.Equals(strId)) { //找到本地信息,先更新图片 bool bolImg = true; if (intType < 3 && strContent.Length > 0 && !strContent.Equals(localAd.StrContent)) { if (intType == 1) { bolImg = createImg("ad", strContent); } else if (intType == 2) { string[] aryFile = strContent.Split(new char[] { ',' }); for (int k = 0; k < aryFile.Length; k++) { bolImg = bolImg && createImg("ad", aryFile[k]); } } } //考虑数据库中有记录,但图片不存在的情况 if (intType == 1 && !File.Exists(System.Windows.Forms.Application.StartupPath + "\\ad\\" + strContent)) { bolImg = bolImg && createImg("ad", strContent); } else if (intType == 2) { string[] aryFile = strContent.Split(new char[] { ',' }); for (int k = 0; k < aryFile.Length; k++) { if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\ad\\" + aryFile[k])) { bolImg = bolImg && createImg("ad", aryFile[k]); } } } //图片操作正常,删除原图片并更新数据库 if (bolImg) { cmd.ExecuteNonQuery("update t_bz_advertisement set strName='" + strName + "',intType=" + intType + ",strContent='" + strContent + "',dtStartTime='" + dtStartTime + "',dtEndTime='" + dtEndTime + "' where strId='" + strId + "'"); if (localAd.IntType == 1 && !strContent.Equals(localAd.StrContent)) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\ad\\" + localAd.StrContent); } else if (localAd.IntType == 2 && !strContent.Equals(localAd.StrContent)) { string[] aryFile = localAd.StrContent.Split(new char[] { ',' }); for (int k = 0; k < aryFile.Length; k++) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\ad\\" + aryFile[k]); } } } strId = ""; lstAd.Remove(localAd); break; } } if (strId.Length > 0) { //本地没有找到,先增加图片 bool bolImg = true; if (intType < 3 && strContent.Length > 0) { if (intType == 1) { bolImg = createImg("ad", strContent); } else if (intType == 2) { string[] aryFile = strContent.Split(new char[] { ',' }); for (int k = 0; k < aryFile.Length; k++) { bolImg = bolImg && createImg("ad", aryFile[k]); } } } //图片操作正常,更新数据库 if (bolImg) { cmd.ExecuteNonQuery("insert into t_bz_advertisement(strId,strName,intType,strContent,dtStartTime,dtEndTime) values('" + strId + "','" + strName + "'," + intType + ",'" + strContent + "','" + dtStartTime + "','" + dtEndTime + "')"); } } } catch (Exception e) { ErrorLog.log(e); } } //删除本地没有匹配的记录 for (int i = 0; i < lstAd.Count; i++) { Advertisement localAd = lstAd.ElementAt(i); cmd.ExecuteNonQuery("delete from t_bz_advertisement where strId='" + localAd.StrId + "'"); if (localAd.StrContent.Length > 0) { if (localAd.IntType == 1) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\ad\\" + localAd.StrContent); } else if (localAd.IntType == 2) { string[] aryFile = localAd.StrContent.Split(new char[] { ',' }); for (int k = 0; k < aryFile.Length; k++) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\ad\\" + aryFile[k]); } } } } } } catch (Exception e) { ErrorLog.log(e); } cmd.Close(); }
private void Option_MouseUp(object sender, MouseEventArgs e) { Button btn = (Button)sender; switch (btn.Name) { case "Button_ModifyID": btn.BackgroundImage = Image.FromFile(path + "\\images\\切图\\Option\\修改参数.jpg"); if (this.Pwd.Text.Equals(GlobalVariables.StrExitPwd)) { if (this.ID.Text.Trim().Equals("")) { this.Label_Warning.Text = "请输入本机编码!"; } else if (this.URL.Text.Trim().Equals("")) { this.Label_Warning.Text = "请输入远程URL!"; } else { AccessCmd cmd = new AccessCmd(); cmd.ExecuteNonQuery("delete from t_bz_terminal_param where strParamName='strTerminalNo' or strParamName='strServerUrl'"); cmd.ExecuteNonQuery("insert into t_bz_terminal_param(strId,strParamName,strParamValue) values('" + 99 + "','strTerminalNo','" + this.ID.Text.Trim() + "')"); cmd.ExecuteNonQuery("insert into t_bz_terminal_param(strId,strParamName,strParamValue) values('" + 99 + "','strServerUrl','" + this.URL.Text.Trim() + "')"); cmd.Close(); GlobalVariables.StrTerminalNo = this.ID.Text.Trim(); GlobalVariables.StrServerUrl = this.URL.Text.Trim(); this.Label_Warning.Text = "操作成功!"; } } else { this.Label_Warning.Text = "密码错误,请重新输入!"; } return; case "Button_Exit": btn.BackgroundImage = Image.FromFile(path + "\\images\\切图\\Option\\退出系统.jpg"); if (this.Pwd.Text.Equals(GlobalVariables.StrExitPwd)) { Program.Exit(); } else { this.Label_Warning.Text = "密码错误,请重新输入!"; } return; case "Buttom_Close": btn.BackgroundImage = Image.FromFile(path + "\\images\\切图\\Option\\关闭.jpg"); this.Close(); return; case "Button_Paper": btn.BackgroundImage = Image.FromFile(path + "\\images\\切图\\Option\\换纸结束.jpg"); if (this.Pwd.Text.Equals(GlobalVariables.StrExitPwd)) { AccessCmd cmd = new AccessCmd(); cmd.ExecuteNonQuery("update t_bz_print_total set intPrintTotal=0"); cmd.Close(); this.Label_Warning.Text = "操作成功!"; } else { this.Label_Warning.Text = "密码错误,请重新输入!"; } return; } }
private void Btn_NewCouponList_Click(object sender, EventArgs e) { ChangeExternThreeButtonForeColor(sender as Button); MyMsgBox mb = new MyMsgBox(); try { String time = DateTime.Now.ToString("yyyy/M/d H:m:s"); string strSql = "select top 24 strId from t_bz_coupon where #" + time + "#>dtActiveTime and #" + time + "#< dtExpireTime order by dtActiveTime desc"; AccessCmd cmd = new AccessCmd(); OleDbDataReader reader = cmd.ExecuteReader(strSql); String strId = ""; while (reader.Read()) { if (!reader.IsDBNull(0)) { strId += reader.GetString(0) + ","; } } reader.Close(); cmd.Close(); if (strId != "") { LP_ctype[0] = FindCouponById(strId.Substring(0, strId.Length - 1).Split(',')); } else { LP_ctype[0] = new List<CouponPicInfo>(); } curPage = 1; curType = 0; theCouponNum = 0; ShowCoupon(); } catch (Exception e1) { mb.ShowMsg(e1.Message + "\n正在修复", 1); } }
private void Panel_Ad_VisibleChanged(object sender, EventArgs e) { if (Panel_Ad.Visible == false) { showContinue = false; Panel_Ad.Controls.Clear(); if (Ad_PB1 != null) { Ad_PB1.Dispose(); } if (Ad_PB2 != null) { Ad_PB2.Dispose(); } if (Ad_MediaPlayer1 != null) { try { Panel_Ad.Controls.Remove(Ad_MediaPlayer1); Ad_MediaPlayer1.Ctlcontrols.stop(); Ad_MediaPlayer1.close(); Ad_MediaPlayer1.Dispose(); } catch (Exception e1) { ErrorLog.log(e1); } } if (Ad_MediaPlayer2 != null) { try { Panel_Ad.Controls.Remove(Ad_MediaPlayer2); Ad_MediaPlayer2.Ctlcontrols.stop(); Ad_MediaPlayer2.close(); Ad_MediaPlayer2.Dispose(); } catch (Exception e2) { ErrorLog.log(e2); } } if (PicThread != null) { try { if (PicThread.IsAlive) { PicThread.Abort(); PicThread.Join(); } } catch (Exception e1) { ErrorLog.log(e1); } } } if (Panel_Ad.Visible == true) { string time = DateTime.Now.ToString("H:m:s"); string strSql = "select top 2 * from t_bz_advertisement where #" + time + "#>=dtStartTime And #" + time + "#<dtEndTime And (intType=1 or intType=2)"; AccessCmd cmd = new AccessCmd(); OleDbDataReader reader = cmd.ExecuteReader(strSql); Ad_type = new List<int>(); Ad_str = new List<string>(); while (reader.Read()) { Ad_type.Add(reader.GetInt32(2)); Ad_str.Add(reader.GetString(3)); } reader.Close(); cmd.Close(); Panel_Ad.Controls.Add(Label_AdClick); ShowAd(); } }
/// <summary> /// 加载界面元素 /// </summary> private void LoadTemplates() { string sql = "select * from t_bz_templates order by strId asc"; AccessCmd cmd = new AccessCmd(0); OleDbDataReader reader = cmd.ExecuteReader(sql); List<Element> lstlocal = new List<Element>(); while (reader.Read()) { Element element = new Element(reader); lstlocal.Add(element); } reader.Close(); cmd.Close(); for (int i = 0; i < lstlocal.Count; i++) { Element element = lstlocal.ElementAt(i); if (element.strCtlName == "PB_Shop_Type2_NextPage") { Console.WriteLine(""); } Control ctl = GetControl(element.strCtlName); if (ctl == null) continue; try { if (!element.strLocation.Equals("")) { Point old_P = ctl.Location; try { ctl.Location = new Point(Convert.ToInt32(element.strLocation.Split(',')[0]), Convert.ToInt32(element.strLocation.Split(',')[1])); } catch { ctl.Location = old_P; } Size old_S = ctl.Size; try { ctl.Size = new Size(Convert.ToInt32(element.strSize.Split(',')[0]), Convert.ToInt32(element.strSize.Split(',')[1])); } catch { ctl.Size = old_S; } if (!element.strBgImage.Equals("")) { if ((ctl is PictureBox) && (ctl as PictureBox).Image == null) continue; FileStream pFileStream; try { pFileStream = new FileStream(path + "\\template\\" + element.strBgImage, FileMode.Open, FileAccess.Read); if (ctl is Label) { Label lb = ctl as Label; lb.Image = new Bitmap(Image.FromStream(pFileStream), ctl.Size); } else { ctl.BackgroundImage = new Bitmap(Image.FromStream(pFileStream), ctl.Size); } pFileStream.Close(); pFileStream.Dispose(); } catch { pFileStream = new FileStream(path + "\\defalut\\" + element.strBgImage, FileMode.Open, FileAccess.Read); if (ctl is Label) (ctl as Label).Image = new Bitmap(Image.FromStream(pFileStream), ctl.Size); else ctl.BackgroundImage = new Bitmap(Image.FromStream(pFileStream), ctl.Size); pFileStream.Close(); pFileStream.Dispose(); } } if (!element.strFontFamily.Equals("")) { //if (ctl.Name == "Label_Countdown") // Console.WriteLine("get it"); if (ctl is Panel || ctl is PictureBox) continue; Font old_F = ctl.Font; Label lb = ctl as Label; if (element.strContent != "") lb.Text = element.strContent; if (element.strFontFamily != "" & element.intFontSize != 0) lb.Font = new Font(new FontFamily(element.strFontFamily), element.intFontSize, old_F.Style); if (element.strFontColor != "") { try { string[] color = element.strFontColor.Split(','); int[] intcolor = { Convert.ToInt32(color[0]), Convert.ToInt32(color[1]), Convert.ToInt32(color[2]) }; for (int t = 0; t < 3; t++) { if (intcolor[t] < 0) intcolor[t] = 0; if (intcolor[t] > 255) intcolor[t] = 255; } lb.ForeColor = Color.FromArgb(intcolor[0], intcolor[1], intcolor[2]); } catch { lb.ForeColor = Color.FromArgb(255, 255, 255); } } } } } catch (Exception e) { ErrorLog.log(e); } } }
/// <summary> /// 走马灯线程函数 /// </summary> private void LoadMarquee() { while (true) { String dtime = DateTime.Now.ToString("H:mm:ss"); string strSql = "select * from t_bz_advertisement where intType=3 and #" + dtime + "#>=dtStartTime and #" + dtime + "#<dtEndTime"; AccessCmd cmd = new AccessCmd(); OleDbDataReader reader = cmd.ExecuteReader(strSql); string strText = ""; if (reader != null) { if (reader.Read()) { if (!reader.IsDBNull(3)) { strText = reader.GetString(3); } } } reader.Close(); cmd.Close(); if (strText == "") { strText = "此处广告未招租,有意向请拨打" + GlobalVariables.StrPhone; } if (Label_ScrollText.InvokeRequired) { this.Label_ScrollText.Invoke((MethodInvoker)delegate { this.Label_ScrollText.Stop(); this.Label_ScrollText.strContent = strText; this.Label_ScrollText.Start(); }, null); } else { this.Label_ScrollText.Stop(); this.Label_ScrollText.strContent = strText; this.Label_ScrollText.Start(); } Thread.Sleep(1800 * 1000); } }
/// <summary> /// 加载商家详细页面的数据 /// </summary> private void InitShopInfoData(String shopid) { if (LP_ctype != null) { for (int i = 0; i < LP_ctype.Length; i++) { if (LP_ctype[i] != null && LP_ctype[i].Count > 0) { LP_ctype[i].Clear(); } } } string strSql = "select * from t_bz_shop where strId ='" + shopid + "'"; AccessCmd cmd = new AccessCmd(); OleDbDataReader reader = cmd.ExecuteReader(strSql); FileStream pFileStream; String lPath, name, address, info, id = null; LP_ctype = new List<CouponPicInfo>[1]; if (reader.Read()) { lPath = reader.GetString(9); if (lPath != "" && lPath != null) { if (!File.Exists(path + "\\shop\\" + lPath)) { pFileStream = new FileStream(path + "\\shop\\null.jpg", FileMode.Open, FileAccess.Read); } else { pFileStream = new FileStream(path + "\\shop\\" + lPath, FileMode.Open, FileAccess.Read); } } else { pFileStream = new FileStream(path + "\\shop\\null.jpg", FileMode.Open, FileAccess.Read); } PB_ShopInfo_Shop.Image = new Bitmap(Image.FromStream(pFileStream), 760, 397); pFileStream.Close(); pFileStream.Dispose(); if (!reader.IsDBNull(1)) { name = reader.GetString(1); if (name != "" && name != null) { Label_ShopInfo_Name.Text = "商家名称: " + name; } } id = reader.GetString(0); if (!reader.IsDBNull(4)) { address = reader.GetString(4); if (address != "" && address != null) { Label_ShopInfo_Address.Text = "地址: " + address; } else { Label_ShopInfo_Address.Text = "地址: "; } } if (!reader.IsDBNull(7)) { info = reader.GetString(7); if (info != "" && info != null) { Label_ShopInfo_Detail.Text = "简介: " + info; } else { Label_ShopInfo_Detail.Text = "简介: "; } } } if (this.PB_ShopInfo_Coupons.Image != null) { this.PB_ShopInfo_Coupons.Image.Dispose(); this.PB_ShopInfo_Coupons.Image = null; } LP_ctype[0] = FindCouponByShopId(id); if (LP_ctype[0] == null) { LP_ctype[0] = new List<CouponPicInfo>(); } reader.Close(); cmd.Close(); curPage = 1; curType = 0; theCouponNum = 0; }
/// <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(); }
/// <summary> /// 获取当前登录用户打印的次数 /// </summary> /// <returns>返回打印的次数</returns> private int GetUserPrintTimes() { string userId = GlobalVariables.LoginUserId; string strSql = "select count(*) from t_bz_coupon_print where strMemberCardNo='" + userId + "'"; AccessCmd cmd = new AccessCmd(); OleDbDataReader reader = cmd.ExecuteReader(strSql); if (reader.Read()) { int times = reader.GetInt32(0); reader.Close(); cmd.Close(); return times; } else { reader.Close(); cmd.Close(); return 0; } }
/// <summary> /// 获取商家种类的个数 /// </summary> /// <returns>返回商家种类的个数</returns> private string[] GetTradeName() { try { string strSql = "select strTrade from t_bz_shop group by strTrade order by count(strTrade) desc"; //select strTrade from t_bz_shop b group by strTrade order by count(strTrade) desc AccessCmd cmd = new AccessCmd(); OleDbDataReader reader = cmd.ExecuteReader(strSql); String tradeName = ""; while (reader.Read()) { tradeName += reader.GetString(0) + ","; count++; } reader.Close(); cmd.Close(); if (tradeName != "") { return tradeName.Substring(0, tradeName.Length - 1).Split(','); } else { return null; } } catch (Exception e) { ErrorLog.log(e); } return null; }
/// <summary> /// 查找推荐优惠劵 /// </summary> /// <returns>返回查找到的优惠劵List</returns> private List<CouponPicInfo> FindRecCoupon(int type) { List<CouponPicInfo> temp = null; try { String time = DateTime.Now.ToString("yyyy/M/d H:mm:ss"); string strSql; //0表示首页的推荐优惠劵,是所有的;其他的表示优惠卷页面的推荐优惠劵,是前24个 if (type == 0) strSql = "select strId from t_bz_coupon where intRecommend=1 order by dtActiveTime desc"; else strSql = "select top 24 strId from t_bz_coupon where intRecommend=1 order by dtActiveTime desc"; AccessCmd cmd = new AccessCmd(); OleDbDataReader reader = cmd.ExecuteReader(strSql); String strId = ""; while (reader.Read()) { if (!reader.IsDBNull(0)) { strId += reader.GetString(0) + ","; } } if (strId != "") temp = FindCouponById(strId.Substring(0, strId.Length - 1).Split(',')); else temp = new List<CouponPicInfo>(); reader.Close(); cmd.Close(); return temp; } catch (Exception e1) { ErrorLog.log(e1); return new List<CouponPicInfo>(); } }
/// <summary> /// 发送短信 /// </summary> private void SendMessage() { MyMsgBox mb = new MyMsgBox(); mb.ShowMsg("是否发送此优惠劵的信息到您的手机上?\n(信息不收取任何费用)", '1'); if (mb.DialogResult == DialogResult.Yes) { string strSql = "select strIntro from t_bz_coupon where strId='" + pi.id + "'"; AccessCmd cmd = new AccessCmd(); ; OleDbDataReader reader = cmd.ExecuteReader(strSql); if (reader.Read()) { if (!reader.IsDBNull(0)) { strMesContent = reader.GetString(0).Trim(); } else { strMesContent = ""; } } reader.Close(); cmd.Close(); if (strMesContent != "") { if (thSendMes != null) { if (thSendMes.IsAlive) { mb.ShowMsg("短信服务器忙,请稍后再试!", 1); thSendMes.Abort(); thSendMes.Join(); return; } } thSendMes = new Thread(new ThreadStart(SendMes)); thSendMes.Start(); mb.ShowMsg("短信已发送!", 1); } else { mb.ShowMsg("该优惠劵暂无优惠信息", 1); return; } } }
private void DoWork() { try { printQueue pq = new printQueue(); Dictionary<string, int> myprinter; string defaultPrinterName = Printer.GetDeaultPrinterName(); // MessageBox.Show(defaultPrinterName); if (pq.CanelAllPrintJob() == false) { MyMsgBox mb = new MyMsgBox(); mb.ShowMsg("打印纸已用尽!暂停服务!", 3); wait.CloseScrollBar(); return; } myprinter = pq.GetAllPrinterQueues(); if (0 == myprinter[defaultPrinterName]) { if (!pd.PrinterSettings.IsValid) { MyMsgBox mb = new MyMsgBox(); mb.ShowMsg("打印机不可用!暂停服务!", 3); wait.CloseScrollBar(); return; } pd.Print(); Application.DoEvents(); Thread.Sleep(500); myprinter = pq.GetAllPrinterQueues(); if (myprinter[defaultPrinterName] == 0) { MyMsgBox mb = new MyMsgBox(); mb.ShowMsg("打印纸已用尽!暂停服务!", 3); wait.CloseScrollBar(); return; } for (int i = 0; i <= 60; i += 1) { wait.SetProgressBarPositionP(i);//设置进度条当前位置 System.Threading.Thread.Sleep(100);//sleep一下减缓进度条进度,实际代码中,此处应该是实际的工作 } myprinter = pq.GetAllPrinterQueues(); if (myprinter[defaultPrinterName] == 0) { string tempId = DateTime.Now.ToString("yyyyMMddHHmmss"); // long tempId = DateTime.Now.Ticks; if (MD5code == "") { MD5code = "00000000"; } string strSql = "insert into t_bz_coupon_print values('" + tempId + "','" + GlobalVariables.LoginUserId + "','" + pi.id + "',#" + DateTime.Now.ToString("yyyy-M-d H:m:s") + "#,'" + MD5code + "')"; AccessCmd cmd = new AccessCmd(); // MessageBox.Show(strSql); cmd.ExecuteNonQuery(strSql); strSql = "update t_bz_print_total set intPrintTotal=intPrintTotal+1"; cmd.ExecuteNonQuery(strSql); strSql = "select * from t_bz_print_total"; OleDbDataReader reader = cmd.ExecuteReader(strSql); int printNum = 0; if (reader.Read()) { printNum = reader.GetInt32(0); } if (printNum >= GlobalVariables.IntCouponPrint) { UploadInfo ui = new UploadInfo(); ui.PrintAlert(printNum); } reader.Close(); cmd.Close(); for (int i = 60; i <= 100; i += 1) { wait.SetProgressBarPositionP(i);//设置进度条当前位置 System.Threading.Thread.Sleep(50);//sleep一下减缓进度条进度,实际代码中,此处应该是实际的工作 } } else { MyMsgBox mb = new MyMsgBox(); mb.ShowMsg("打印纸已用尽!暂停服务!", 3); wait.CloseScrollBar(); return; } } else { MyMsgBox mb = new MyMsgBox(); mb.ShowMsg("打印纸已用尽!暂停服务!", 3); wait.CloseScrollBar(); return; } } catch (Exception e) { ErrorLog.log(e); wait.CloseScrollBar(); return; } }
private void CouponPop_OnLoad(object sender, EventArgs e) { this.FormBorderStyle = FormBorderStyle.None; this.Height = 780; AccessCmd cmd = new AccessCmd(); ; OleDbDataReader reader; string strSql = ""; if (pi.pPath.CompareTo(path + "\\coupon\\null.jpg") == 0) { strSql = "select * from t_bz_shop where strId='" + pi.shopId + "'"; reader = cmd.ExecuteReader(strSql); try { FileStream pFileStream; if (reader.Read()) { if (!reader.IsDBNull(8)) { pFileStream = new FileStream(path + "\\shop\\" + reader.GetString(8), FileMode.Open, FileAccess.Read); } else { pFileStream = new FileStream(path + "\\shop\\null.jpg", FileMode.Open, FileAccess.Read); } } else { pFileStream = new FileStream(path + "\\shop\\null.jpg", FileMode.Open, FileAccess.Read); } this.PB_Couponpop.Image = new Bitmap(Image.FromStream(pFileStream), 150, 100); pFileStream.Close(); pFileStream.Dispose(); reader.Close(); } catch (Exception) { reader.Close(); } } else { FileStream pFileStream = new FileStream(pi.pPath, FileMode.Open, FileAccess.Read); this.PB_Couponpop.Image = new Bitmap(Image.FromStream(pFileStream), 150, 100); pFileStream.Close(); pFileStream.Dispose(); } strSql = "select * from t_bz_coupon where strId='" + pi.id + "'"; reader = cmd.ExecuteReader(strSql); try { if (reader.Read()) { if (!reader.IsDBNull(11)) { Intro = reader.GetString(11); } else { Intro = "暂无介绍"; } if (!reader.IsDBNull(12)) { Instruction = reader.GetString(12); } else { Instruction = "暂无说明"; } } reader.Close(); strSql = "select * from t_bz_terminal_param where strParamName='strPrintBottom'"; reader = cmd.ExecuteReader(strSql); if (reader.Read()) { if (!reader.IsDBNull(2)) { bottomText = reader.GetString(2); } else { bottomText = ""; } } reader.Close(); cmd.Close(); } catch (Exception) { reader.Close(); cmd.Close(); } Label_Into.Text = Intro; Label_Instruction.Text = Instruction; Label_phone.Text = bottomText + "\n" + GlobalVariables.StrPhone; if (pi.flaPrice != 0) { MD5code = this.ReturnCode(); this.Code.Text = "验证码:" + MD5code; } }