Пример #1
0
 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();
     }
 }
Пример #2
0
 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();
     }
 }
Пример #3
0
        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();
        }
Пример #4
0
        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;
            }
        }
Пример #5
0
        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;
            }
        }