//关闭前执行 private void Application_Exit(object sender, EventArgs e) { //关闭金税盘 if (GoldTax != null) { GoldTax.CloseCard(); MessageBox.Show("金税盘已退出"); } }
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { busy.IsBusy = false; // 没有出错 if (e.Error == null) { //把数据转换成JSON JsonObject item = JsonValue.Parse(e.Result) as JsonObject; if (item.ContainsKey("error")) { string error = item["error"]; MessageBox.Show("交费失败:" + error); return; } // 把交易编号、交易日期写入打印界面 SeriaNumber Seriabx = (SeriaNumber)FrameworkElementExtension.FindResource(this, "Seriabx"); if (Seriabx == null) { MessageBox.Show("无法获取编号产生器信息,请重新登陆后操作!"); return; } //ui_sellid.Text = Seriabx.Key.ToString() + item["id"].ToString(); //把收费id放到收费对象 GeneralObject retsell = (GeneralObject)(from r in loader.Res where r.Name.Equals("retsell") select r).First(); retsell.FromJson(item); GeneralObject printobj = aofengprint.DataContext as GeneralObject; printobj.FromJson(item); //string date = (string)item["f_deliverydate"]; //ui_day.Text = date; //保存发票信息 GeneralObject fpinfosobj = (GeneralObject)(from r in loader.Res where r.Name.Equals("fpinfosobj") select r).First(); fpinfosobj.SetPropertyValue("f_fapiaostatue", "已用", true); fpinfosobj.Save(); // 调用打印 GoldTax tax = (GoldTax)(from r in loader.Res where r.Name.Equals("tax") select r).First(); //气费大于0,打印税票 if (tax.IsInit && tax.ListNumber != null && Int32.Parse(tax.ListNumber.Split(new char[] { '|' })[0]) > 0) { tax.Invoice(); } else { print.TipPrint(); } } else { // 提示出错 MessageBox.Show("交易失败,链接错误!如果继续失败,请联系系统管理员。"); // 清除界面数据 Clear(); } }
// 提交数据到后台服务器 private void SaveClick(object sender, RoutedEventArgs e) { //如果数据有错,提示不能保存 GeneralObject kbfee = kbfee1.DataContext as GeneralObject; if (kbfee.HasErrors) { MessageBox.Show("输入数据有错,请检查!"); return; } GeneralObject loginUser = (GeneralObject)FrameworkElementExtension.FindResource(this, "LoginUser"); if (loginUser == null) { MessageBox.Show("无法获取当前登陆用户信息,请重新登陆后操作!"); return; } //查询金税盘发票信息 GoldTax tax = (GoldTax)(from r in loader.Res where r.Name.Equals("tax") select r).First(); if (!tax.GetInfo()) { return; } string loginid = (string)loginUser.GetPropertyValue("id"); string orgpathstr = (string)loginUser.GetPropertyValue("orgpathstr"); //显示正在工作 busy.IsBusy = true; string handids = ""; //获得当前交费的欠费id foreach (GeneralObject item in dataGrid1.ItemsSource) { bool ischeck = (bool)item.IsChecked; if (ischeck) { string id = item.GetPropertyValue("id") + ""; handids = id + "," + handids; } } if (handids == "") { handids = "0"; } else { handids = handids.Substring(0, handids.Length - 1); } //发票号 string f_invoicenum = kbfee.GetPropertyValue("f_invoicenum") + ""; if (string.IsNullOrEmpty(f_invoicenum)) { f_invoicenum = "0"; } //获取基础地址 WebClientInfo wci = (WebClientInfo)Application.Current.Resources["server"]; // 提交 string str = wci.BaseAddress + "/sell/" + ui_userid.Text + "/" + shoukuan.Text + "/" + ui_zhinajin.Text + "/" + f_payment.SelectedValue + "/" + loginid + "/" + orgpathstr + "/" + handids + "/" + f_invoicenum + "?uuid=" + System.Guid.NewGuid().ToString(); Uri uri = new Uri(str); WebClient client = new WebClient(); client.DownloadStringCompleted += client_DownloadStringCompleted; client.DownloadStringAsync(uri); }