示例#1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (!validator1.Validate())
            {
                return;
            }
            string      hpzl       = combQueryPlateType.Text;
            LoadingForm frmLoading = new LoadingForm("正在打印...");

            frmLoading.BackgroundWorkAction = delegate()
            {
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    try
                    {
                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(10, "正在打印...");
                        byte[] buffer = null;
                        if (picQRCode.BackgroundImage != null)
                        {
                            picQRCode.BackgroundImage.Save(memoryStream, ImageFormat.Png);
                            buffer = new byte[memoryStream.Length];
                            memoryStream.Seek(0, SeekOrigin.Begin);
                            memoryStream.Read(buffer, 0, buffer.Length);
                        }
                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(40, "正在打印...");
                        X18J52 x18J52 = new X18J52();
                        carFiller.FillEntity(x18J52);
                        CreatePDF(x18J52, hpzl, buffer);
                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(100, "正在打印...");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            };
            frmLoading.ShowDialog();
        }
示例#2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //查询前清空之前的数据
            picQRCode.BackgroundImage = null;
            carFiller.DisplayEntity(null);

            string hphm      = combQueryAera.Text + txtQueryPlateNo.Text.Trim();
            string vin       = txtQueryVIN.Text.Trim();
            string hpzl      = AppHelper.GetCodeByName(combQueryPlateType.Text, "HPZL");
            string result    = "";
            string loginUser = "";


            LoadingForm frmLoading = new LoadingForm("正在查询...");

            frmLoading.BackgroundWorkAction = delegate()
            {
                try
                {
                    frmLoading.CurrentMsg = new KeyValuePair <int, string>(10, "正在查询...");
                    NetHelper netHelper = new NetHelper();
                    result = netHelper.QueryCar(hphm, hpzl, loginUser, vin);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("查询时出现错误:" + ex.Message);
                }
            };
            frmLoading.ShowDialog();

            if (string.IsNullOrEmpty(result))
            {
                MessageBox.Show("查询结果为空");
                return;
            }

            File.WriteAllText("18J52.txt", result);

            result = HttpUtility.HtmlDecode(result);
            string code = RegexXML.MatchField(result, "code", false);

            if ("1".Equals(code))
            {
                X18J52 x18J52 = RegexXML.XmlToModelByName <X18J52>(result);
                string js     = JsonConvert.SerializeObject(x18J52);
                Bitmap bitmap = Live0xUtils.QRCodeUtils.QRCodeHelper.CreateCode(js, -1, 3, true);
                picQRCode.BackgroundImage = bitmap;

                DateTime d;
                if (x18J52.ccrq != null && DateTime.TryParse(x18J52.ccrq, out d))
                {
                    x18J52.ccrq = d.ToString("yyyy年MM月dd日");
                }

                if (x18J52.ccdjrq != null && DateTime.TryParse(x18J52.ccdjrq, out d))
                {
                    x18J52.ccdjrq = d.ToString("yyyy年MM月dd日");
                }

                x18J52.cllx = AppHelper.GetNameByCode(x18J52.cllx, "CLZL");
                x18J52.hpzl = AppHelper.GetNameByCode(x18J52.hpzl, "HPZL");

                carFiller.DisplayEntity(x18J52);
            }
            else if (string.IsNullOrEmpty(code))
            {
                MessageBox.Show("查询信息为空" + result);
            }
            else
            {
                MessageBox.Show(RegexXML.MatchField(result, "message", false));
            }
        }