コード例 #1
0
ファイル: BlueViewModel.cs プロジェクト: leoualy/InvcSys
        public void UpdateData(int id, int window)
        {
            DataTable resDt = SqlHelper.ExecDQLForDataTable(resSql, new List <IDataParameter>()
            {
                SqlHelper.CreateDataParameter("@resv_name_id", id)
            });

            if (resDt == null || resDt.Rows.Count <= 0)
            {
                clearUIData();
                return;
            }
            List <IDataParameter> billParams = new List <IDataParameter>()
            {
                SqlHelper.CreateDataParameter("@resv_name_id", id),
                SqlHelper.CreateDataParameter("@Window", window)
            };

            DataTable dt = SqlHelper.ExecDQLForDataTable(billSql, billParams);

            if (dt == null || dt.Rows.Count <= 0)
            {
                clearUIData();
                return;
            }
            List <BlueGoods> goods = new List <BlueGoods>();

            foreach (DataRow dr in dt.Rows)
            {
                BlueGoods goodes = SqlHelper.Row2Model <BlueGoods>(dr);
                goodes.TaxRateAmount = TaxHelper.GetTaxAmount(goodes.Quantity, goodes.Price, goodes.TaxRate);
                goods.Add(goodes);
            }

            BlueGoodses  = goods;
            BuyerName    = resDt.Rows[0]["company"].ToString();
            BuyerAddress = resDt.Rows[0]["address"].ToString();
            BuyerTel     = resDt.Rows[0]["phone"].ToString();
            BuyerEmail   = resDt.Rows[0]["email"].ToString();

            // 待修改
            TaxPayerNum = "110101201702071";
        }
コード例 #2
0
ファイル: PiaotongHelper.cs プロジェクト: leoualy/InvcSys
        static void postBlueJson(BlueViewModel viewModel, string url, string type)
        {
            InvoiceBlue invoice = new InvoiceBlue();

            // 纳税人识别号
            invoice.taxpayerNum = viewModel.TaxPayerNum;
            // 发票请求流水号
            invoice.invoiceReqSerialNo = SerialNoHelper.GetInvoiceReqSerialNo(mcPrefix);

            invoice.buyerName        = viewModel.BuyerName;
            invoice.buyerAddress     = viewModel.BuyerAddress;
            invoice.buyerTel         = viewModel.BuyerTel;
            invoice.buyerBankName    = viewModel.BuyerBankName;
            invoice.buyerBankAccount = viewModel.BuyerBankAccount;
            invoice.buyerTaxpayerNum = viewModel.TaxPayerNum;

            invoice.sellerAddress     = viewModel.SellerAddress;
            invoice.sellerBankAccount = viewModel.SellerBankAccount;
            invoice.sellerBankName    = viewModel.SellerBankName;
            invoice.sellerTel         = viewModel.SellerTel;

            // 纸质蓝票的分机号时必填项
            if (type == "纸质")
            {
                invoice.extensionNum = "1";
            }

            List <Goods> goodsList = new List <Goods>();

            foreach (BlueGoods item in viewModel.BlueGoodses)
            {
                // 只添加被选中的项目
                if (!item.IsSelected)
                {
                    continue;
                }
                goodsList.Add(new Goods()
                {
                    goodsName = item.Description,
                    quantity  = item.Quantity.ToString(),
                    //quantity ="1.00",
                    unitPrice = item.Price.ToString(),
                    //unitPrice ="56.64",
                    invoiceAmount = item.TransactionAmount.ToString(),
                    // invoiceAmount ="56.64",
                    includeTaxFlag = item.IsIncludeTax?"1":"0",
                    taxRateValue   = item.TaxRate.ToString(),
                    // 0税率处理
                    zeroTaxFlag = item.TaxRate == 0?"1":null,
                    // 税额的计算
                    taxRateAmount = Convert.ToDouble((item.TaxRateAmount == 0?
                                                      TaxHelper.GetTaxAmount(item.Quantity, item.Price, item.TaxRate):item.TaxRateAmount)).ToString(),

                    taxClassificationCode = item.TaxClassificationCode,
                });
            }
            // 项目列表
            invoice.itemList = JsonHelper.Object2String <List <Goods> >(goodsList);
            // 过滤业务内容串
            string content = JsonHelper.Object2String <InvoiceBlue>(invoice).
                             Replace("\\", "").Replace("\"[", "[").Replace("]\"", "]");

            // 记录业务报文json串到日志中
            mLogger.Info("蓝票业务内容JSON串:" + content);

            Task.Factory.StartNew(() =>
            {
                MsgResponse rsp = mApi.PostJson(url, content);
                if (OnHttpPost != null)
                {
                    OnHttpPost(type + "蓝票开票" + rsp.msg);
                }
            });
        }