public void SelectJson(int provisionalInvoiceId, NFMT.Contract.Model.ContractSub sub)
        {
            int pageIndex = 1, pageSize = 100;
            string orderStr = string.Empty, whereStr = string.Empty;

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Common.SelectModel select = new NFMT.Common.SelectModel();
            NFMT.Invoice.BLL.BusinessInvoiceBLL bll = new NFMT.Invoice.BLL.BusinessInvoiceBLL();

            select = bll.GetReplaceFinalStocksSelect(pageIndex, pageSize, orderStr, provisionalInvoiceId);
            NFMT.Common.ResultModel result = bll.Load(user, select, NFMT.Common.DefaultValue.ClearAuth);
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            decimal sumBala = dt.Select().Sum(temp => Convert.ToDecimal(temp["Bala"]));
            decimal sumNetAmount = dt.Select().Sum(temp => Convert.ToDecimal(temp["NetAmount"]));

            if (sumNetAmount == 0)
                this.WarmAlert("未确认价格,禁止开终票", "InvoiceReplaceFinalList.aspx");

            this.netAmount = sumNetAmount;
            this.invoiceBala = Math.Round(sumBala, 2, MidpointRounding.AwayFromZero);
            this.AvgPrice = Math.Round(this.invoiceBala / sumNetAmount, 4, MidpointRounding.AwayFromZero);

            this.SelectedJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());
        }
        public void SelectJson(NFMT.Invoice.Model.BusinessInvoice replaceInvoice, NFMT.Invoice.InvoiceDirectionEnum direction)
        {
            int pageIndex = 1, pageSize = 100;
            string orderStr = string.Empty, whereStr = string.Empty;

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Common.SelectModel select = new NFMT.Common.SelectModel();
            NFMT.Invoice.BLL.BusinessInvoiceBLL bll = new NFMT.Invoice.BLL.BusinessInvoiceBLL();
            NFMT.Common.ResultModel result = new NFMT.Common.ResultModel();

            select = bll.GetReplaceFinalStocksSelect(pageIndex, pageSize, orderStr, replaceInvoice.RefInvoiceId, replaceInvoice.BusinessInvoiceId, false);
            result = bll.Load(user, select, NFMT.Common.DefaultValue.ClearAuth);
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
            this.ProJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());

            select = bll.GetReplaceFinalStocksSelect(pageIndex, pageSize, orderStr, replaceInvoice.RefInvoiceId, replaceInvoice.BusinessInvoiceId, true);
            result = bll.Load(user, select, NFMT.Common.DefaultValue.ClearAuth);
            dt = result.ReturnValue as System.Data.DataTable;
            this.RepJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());
        }