示例#1
0
 private void onScanGiftLoadedExec(object _param)
 {
     if (!_isLoaded)
     {
         _isLoaded = true;
         if (!string.IsNullOrEmpty(ScanRef))
         {
             int    _found    = ScanRef.IndexOf(":");
             string _giftId_  = ScanRef.Remove(_found);
             string _giftVal_ = ScanRef.Remove(0, _found + 1);
             System.Diagnostics.Debug.WriteLine(_giftVal_);
             List <Int32> _lstGift_ = new List <int>();
             _lstGift_.Add(Convert.ToInt32(_giftId_));
             DataTable _gift_ = GiftCardModel.getGiftCardById(_lstGift_);
             if (_gift_.Rows.Count > 0)
             {
                 Barcode     = _gift_.Rows[0]["Barcode"].ToString();
                 GiftSerial  = _gift_.Rows[0]["Serial"].ToString();
                 GiftBalance = _gift_.Rows[0]["Balance"].ToString();
                 UseValue    = _giftVal_;
             }
             ScanGiftId = Convert.ToInt32(_giftId_);
         }
     }
     else
     {
         _isLoaded = false;
     }
 }
        private string MultiCreateHTML(List <Int32> _lstId)
        {
            StringBuilder htmlBuilder = new StringBuilder();

            htmlBuilder.Append("<html xmlns='http://www.w3.org/1999/xhtml'>");
            htmlBuilder.Append("<head>");
            htmlBuilder.Append("<meta http-equiv='Content - Type' content='text / html; charset = utf - 8' />");
            htmlBuilder.Append("<title>" + App.Current.FindResource("gift_card").ToString() + "</title>");
            htmlBuilder.Append("</head>");
            htmlBuilder.Append("<body>");
            htmlBuilder.Append("<div style='width:100%; margin: 0px'>");
            htmlBuilder.Append("<table style='width:100%' border=\"1\"> ");
            htmlBuilder.Append("<tr>");
            DataTable _dtGift   = GiftCardModel.getGiftCardById(_lstId);
            int       _totalRow = _dtGift.Rows.Count;

            if (_totalRow <= 0)
            {
                htmlBuilder.Append("<div>" + App.Current.FindResource("cannot_found_data").ToString() + " </div>");
            }
            else
            {
                int j = 1;
                foreach (DataRow dr in _dtGift.Rows)
                {
                    htmlBuilder.Append("<td width=\"50%\" style=\"padding:5px;\">");
                    Bitmap _giftBitmap = CombineBitmap(dr);
                    byte[] imgBytes    = turnImageToByteArray(_giftBitmap);
                    string imgString   = Convert.ToBase64String(imgBytes);
                    htmlBuilder.Append("<img src=\"" + String.Format("data:image/Png;base64,{0}", imgString) + "\" border=\"0\" style=\"margin-top:3px\" width=\"320\" Height=\"280\"/>");
                    _giftBitmap.Dispose();
                    if (j % 2 == 0 && j < _totalRow)
                    {
                        htmlBuilder.Append("</tr><tr>");
                    }
                    j++;
                }
            }
            htmlBuilder.Append("</tr>");
            htmlBuilder.Append("</table>");
            htmlBuilder.Append("</div>");
            htmlBuilder.Append("</body>");
            htmlBuilder.Append("</html>");
            return(htmlBuilder.ToString());
        }