Exemplo n.º 1
0
        public void SelectJson(NFMT.Invoice.Model.BusinessInvoice businessInvoice, 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();

            if(sub.PriceMode == (int)NFMT.Contract.PriceModeEnum.定价)
                select = bll.GetDirectFinalStocksSelect(pageIndex, pageSize, orderStr, businessInvoice.SubContractId, businessInvoice.BusinessInvoiceId, false, false);
            else
                select = bll.GetDirectStocksModel(pageIndex, pageSize, orderStr, sub.SubId, false, businessInvoice.BusinessInvoiceId);

            NFMT.Common.ResultModel result = bll.Load(user, select, NFMT.Common.DefaultValue.ClearAuth);
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
            this.SubJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());

            if (sub.PriceMode == (int)NFMT.Contract.PriceModeEnum.定价)
                select = bll.GetDirectFinalStocksSelect(pageIndex, pageSize, orderStr, businessInvoice.SubContractId, businessInvoice.BusinessInvoiceId, false, true);
            else
                select = bll.GetDirectStocksModel(pageIndex, pageSize, orderStr, sub.SubId, true, businessInvoice.BusinessInvoiceId);
            result = bll.Load(user, select, NFMT.Common.DefaultValue.ClearAuth);
            dt = result.ReturnValue as System.Data.DataTable;
            this.InvJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());
        }
        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());
        }
Exemplo n.º 3
0
        public void SelectJson(int finalInvoiceId,int suppleInvoiceId)
        {
            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.GetSuppleFinalByFinalStockListSelect(pageIndex, pageSize, orderStr, finalInvoiceId, suppleInvoiceId);
            NFMT.Common.ResultModel result = bll.Load(user, select);
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
            this.ReceiptJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());

            select = bll.GetSuppleFinalByFinalStockListSelect(pageIndex, pageSize, orderStr, finalInvoiceId, suppleInvoiceId,true);
            result = bll.Load(user, select);
            dt = result.ReturnValue as System.Data.DataTable;
            this.SuppleJson = 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.GetReplaceFinalByProvisionalStockListSelect(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.GetReplaceFinalByProvisionalStockListSelect(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());
        }
Exemplo n.º 5
0
        public void SelectJson(int subId, 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();
            select = bll.GetProvisionalContractStockListSelect(pageIndex, pageSize, orderStr, subId);
            NFMT.Common.ResultModel result = bll.Load(user, select,NFMT.Common.DefaultValue.ClearAuth);

            int totalRows = result.AffectCount;
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            this.SelectedJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());
        }
        public void ProcessRequest(HttpContext context)
        {
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;

            int pageIndex = 1, pageSize = 10;
            string orderStr = string.Empty, whereStr = string.Empty;

            string iids = context.Request.QueryString["iids"];

            if (!string.IsNullOrEmpty(context.Request.QueryString["pagenum"]))
                int.TryParse(context.Request.QueryString["pagenum"], out pageIndex);
            pageIndex++;
            if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
                int.TryParse(context.Request.QueryString["pagesize"], out pageSize);

            if (!string.IsNullOrEmpty(context.Request.QueryString["sortdatafield"]) && !string.IsNullOrEmpty(context.Request.QueryString["sortorder"]))
                orderStr = string.Format("{0} {1}", context.Request.QueryString["sortdatafield"].Trim(), context.Request.QueryString["sortorder"].Trim());

            NFMT.Invoice.BLL.BusinessInvoiceBLL bll = new NFMT.Invoice.BLL.BusinessInvoiceBLL();
            NFMT.Common.SelectModel select = bll.GetBISelectModel(pageIndex, pageSize, orderStr, iids);
            NFMT.Common.ResultModel result = bll.Load(user, select);

            context.Response.ContentType = "application/json; charset=utf-8";
            if (result.ResultStatus != 0)
            {
                context.Response.Write(result.Message);
                context.Response.End();
            }

            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
            System.Collections.Generic.Dictionary<string, object> dic = new System.Collections.Generic.Dictionary<string, object>();

            dic.Add("count", result.AffectCount);
            dic.Add("data", dt);

            string postData = Newtonsoft.Json.JsonConvert.SerializeObject(dic);

            context.Response.Write(postData);
        }
        public void ProcessRequest(HttpContext context)
        {
            int pageIndex = 1, pageSize = 10;
            string orderStr = string.Empty, whereStr = string.Empty;

            DateTime fromDate = NFMT.Common.DefaultValue.DefaultTime;
            DateTime toDate = NFMT.Common.DefaultValue.DefaultTime;

            if (!string.IsNullOrEmpty(context.Request.QueryString["fd"]))
            {
                if (!DateTime.TryParse(context.Request.QueryString["fd"], out fromDate))
                    fromDate = NFMT.Common.DefaultValue.DefaultTime;
            }
            if (!string.IsNullOrEmpty(context.Request.QueryString["td"]))
            {
                if (!DateTime.TryParse(context.Request.QueryString["td"], out toDate))
                    toDate = NFMT.Common.DefaultValue.DefaultTime;
                else
                    toDate.AddDays(1);
            }

            int inCorpId = 0;
            int outCorpId = 0;
            if (string.IsNullOrEmpty(context.Request.QueryString["ic"]) || !int.TryParse(context.Request.QueryString["ic"].Trim(), out inCorpId))
                inCorpId = 0;

            if (string.IsNullOrEmpty(context.Request.QueryString["oc"]) || !int.TryParse(context.Request.QueryString["oc"].Trim(), out outCorpId))
                outCorpId = 0;

            if (!string.IsNullOrEmpty(context.Request.QueryString["pagenum"]))
                int.TryParse(context.Request.QueryString["pagenum"], out pageIndex);
            pageIndex++;
            if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
                int.TryParse(context.Request.QueryString["pagesize"], out pageSize);

            if (!string.IsNullOrEmpty(context.Request.QueryString["sortdatafield"]) && !string.IsNullOrEmpty(context.Request.QueryString["sortorder"]))
            {
                string sortDataField = context.Request.QueryString["sortdatafield"].Trim();
                string sortOrder = context.Request.QueryString["sortorder"].Trim();

                switch (sortDataField)
                {
                    case "InvoiceDate":
                        sortDataField = "inv.InvoiceDate";
                        break;
                    case "InvoiceNo":
                        sortDataField = "inv.InvoiceNo";
                        break;
                    case "InvoiceName":
                        sortDataField = "inv.InvoiceName";
                        break;
                    case "InvoiceBala":
                        sortDataField = "inv.InvoiceBala";
                        break;
                    case "CurrencyName":
                        sortDataField = "cur.CurrencyName ";
                        break;
                    case "OutCorpName":
                        sortDataField = "inv.OutCorpName";
                        break;
                    case "InCorpName":
                        sortDataField = "inv.InCorpName";
                        break;
                    case "VATRatio":
                        sortDataField = "bi.VATRatio";
                        break;
                    case "VATBala":
                        sortDataField = "bi.VATBala";
                        break;
                    case "StatusName":
                        sortDataField = "inv.InvoiceStatus";
                        break;
                    case "DirectionName":
                        sortDataField = "inv.InvoiceDirection";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;

            NFMT.Invoice.BLL.BusinessInvoiceBLL bll = new NFMT.Invoice.BLL.BusinessInvoiceBLL();
            NFMT.Common.SelectModel select = bll.GetReadyFinalSelect(pageIndex, pageSize, orderStr);
            NFMT.Common.ResultModel result = bll.Load(user, select);

            context.Response.ContentType = "text/plain";
            if (result.ResultStatus != 0)
            {
                context.Response.Write(result.Message);
                context.Response.End();
            }

            int totalRows = result.AffectCount;
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("count", totalRows);
            dic.Add("data", dt);

            string postData = Newtonsoft.Json.JsonConvert.SerializeObject(dic, new Newtonsoft.Json.Converters.DataTableConverter());

            context.Response.Write(postData);
        }
        public void ProcessRequest(HttpContext context)
        {
            int pageIndex = 1, pageSize = 10;
            string orderStr = string.Empty, whereStr = string.Empty;

            string subNo = context.Request.QueryString["sn"];
            DateTime fromDate = NFMT.Common.DefaultValue.DefaultTime;
            DateTime toDate = NFMT.Common.DefaultValue.DefaultTime;
            int outCorpId = 0;

            if (!string.IsNullOrEmpty(context.Request.QueryString["oci"]))
            {
                if (!int.TryParse(context.Request.QueryString["oci"], out outCorpId))
                    outCorpId = 0;
            }

            int tradeDir = 0;
            if (!string.IsNullOrEmpty(context.Request.QueryString["tradeDir"]))
                int.TryParse(context.Request.QueryString["tradeDir"], out tradeDir);

            if (!string.IsNullOrEmpty(context.Request.QueryString["fd"]))
            {
                if (!DateTime.TryParse(context.Request.QueryString["fd"], out fromDate))
                    fromDate = NFMT.Common.DefaultValue.DefaultTime;
            }
            if (!string.IsNullOrEmpty(context.Request.QueryString["td"]))
            {
                if (!DateTime.TryParse(context.Request.QueryString["td"], out toDate))
                    toDate = NFMT.Common.DefaultValue.DefaultTime;
            }

            if (!string.IsNullOrEmpty(context.Request.QueryString["pagenum"]))
                int.TryParse(context.Request.QueryString["pagenum"], out pageIndex);
            pageIndex++;
            if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
                int.TryParse(context.Request.QueryString["pagesize"], out pageSize);

            if (!string.IsNullOrEmpty(context.Request.QueryString["sortdatafield"]) && !string.IsNullOrEmpty(context.Request.QueryString["sortorder"]))
            {
                string sortDataField = context.Request.QueryString["sortdatafield"].Trim();
                string sortOrder = context.Request.QueryString["sortorder"].Trim();

                switch (sortDataField)
                {
                    case "ContractDate":
                        sortDataField = string.Format("cs.{0}", sortDataField);
                        break;
                    case "ContractNo":
                        sortDataField = string.Format("c.{0}", sortDataField);
                        break;
                    case "SubNo":
                        sortDataField = "cs.SubNo";
                        break;
                    case "TradeDirectionName":
                        sortDataField = "c.TradeDirection";
                        break;
                    case "InCorpName":
                        sortDataField = "inccd.CorpName";
                        break;
                    case "OutCorpName":
                        sortDataField = "outccd.CorpName";
                        break;
                    case "AssetName":
                        sortDataField = "a.AssetName";
                        break;
                    case "SignWeight":
                        sortDataField = "cs.SignAmount";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Invoice.BLL.BusinessInvoiceBLL bll = new NFMT.Invoice.BLL.BusinessInvoiceBLL();
            NFMT.Common.SelectModel select = bll.GetDirectFinalContractListSelect(pageIndex, pageSize, orderStr, subNo, outCorpId, fromDate, toDate, tradeDir);

            NFMT.Authority.ContractAuth auth = new NFMT.Authority.ContractAuth();
            NFMT.Common.ResultModel result = bll.Load(user, select, auth);

            context.Response.ContentType = "text/plain";
            if (result.ResultStatus != 0)
            {
                context.Response.Write(result.Message);
                context.Response.End();
            }

            int totalRows = result.AffectCount;
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("count", totalRows);
            dic.Add("data", dt);

            string postData = Newtonsoft.Json.JsonConvert.SerializeObject(dic, new Newtonsoft.Json.Converters.DataTableConverter());

            context.Response.Write(postData);
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string redirectUrl = "InvoiceDirectFinalList.aspx";

            if (!IsPostBack)
            {
                Utility.VerificationUtility ver = new Utility.VerificationUtility();
                ver.JudgeOperate(this.Page, 116, new List<NFMT.Common.OperateEnum>() { NFMT.Common.OperateEnum.录入 });

                NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
                NFMT.Common.ResultModel result = new NFMT.Common.ResultModel();

                //获取合约与子合约
                int subId = 0;
                if (string.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out subId))
                    Response.Redirect(redirectUrl);

                NFMT.Contract.BLL.ContractSubBLL subBLL = new NFMT.Contract.BLL.ContractSubBLL();
                result = subBLL.Get(user, subId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                NFMT.Contract.Model.ContractSub sub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                if (sub == null || sub.SubId <= 0)
                    Response.Redirect(redirectUrl);

                this.curContractSub = sub;

                NFMT.Data.Model.Currency currency = NFMT.Data.BasicDataProvider.Currencies.FirstOrDefault(temp => temp.CurrencyId == sub.SettleCurrency);
                if (currency != null && currency.CurrencyId > 0)
                    this.currencyName = currency.CurrencyName;

                NFMT.Contract.BLL.ContractBLL conBLL = new NFMT.Contract.BLL.ContractBLL();
                result = conBLL.Get(user, sub.ContractId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                NFMT.Contract.Model.Contract contract = result.ReturnValue as NFMT.Contract.Model.Contract;
                if (contract == null || contract.ContractId <= 0)
                    Response.Redirect(redirectUrl);

                this.curContract = contract;

                if (contract.TradeDirection == (int)NFMT.Contract.TradeDirectionEnum.Buy)
                    invoiceDirection = NFMT.Invoice.InvoiceDirectionEnum.收取;

                int pageIndex = 1, pageSize = 100;
                string orderStr = string.Empty, whereStr = string.Empty;
                NFMT.Common.SelectModel select = new NFMT.Common.SelectModel();
                NFMT.Invoice.BLL.BusinessInvoiceBLL bll = new NFMT.Invoice.BLL.BusinessInvoiceBLL();

                if (sub.PriceMode == (int)NFMT.Contract.PriceModeEnum.定价)
                {
                    //定价合约

                    //获取子合约价格明细
                    NFMT.Contract.BLL.SubPriceBLL subPriceBLL = new NFMT.Contract.BLL.SubPriceBLL();
                    result = subPriceBLL.GetPriceBySubId(user, sub.SubId);
                    if (result.ResultStatus != 0)
                        Response.Redirect(redirectUrl);

                    NFMT.Contract.Model.SubPrice subPrice = result.ReturnValue as NFMT.Contract.Model.SubPrice;
                    if (subPrice == null || subPrice.SubPriceId <= 0)
                        Response.Redirect(redirectUrl);
                    this.AvgPrice = subPrice.FixedPrice;
                    select = bll.GetDirectFinalStocksSelect(pageIndex, pageSize, orderStr, subId, 0, false, false);
                }
                else
                {
                    select = bll.GetDirectStocksModel(pageIndex, pageSize, orderStr, subId, false, 0);
                }

                result = bll.Load(user, select, NFMT.Common.DefaultValue.ClearAuth);
                System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
                this.SelectedJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());

                //if (sub.PriceMode == (int)NFMT.Contract.PriceModeEnum.点价)
                //{
                    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("未确认价格,禁止开终票", redirectUrl);
                if (sumNetAmount > 0)
                {
                    this.netAmount = sumNetAmount;
                    this.invoiceBala = Math.Round(sumBala, 2, MidpointRounding.AwayFromZero);
                    this.AvgPrice = Math.Round(this.invoiceBala/sumNetAmount, 4, MidpointRounding.AwayFromZero);
                }
                //}

                NFMT.Data.Model.MeasureUnit muContract = NFMT.Data.BasicDataProvider.MeasureUnits.Single(temp => temp.MUId == contract.UnitId);
                NFMT.Data.Model.MeasureUnit muSub = NFMT.Data.BasicDataProvider.MeasureUnits.Single(temp => temp.MUId == sub.UnitId);

                this.navigation1.Routes.Add("直接终票列表", redirectUrl);
                this.navigation1.Routes.Add(string.Format("直接终票新增", invoiceDirection), string.Empty);

                this.contractExpander1.CurContract = this.curContract;
                this.contractExpander1.CurContractSub = this.curContractSub;
                this.contractExpander1.RedirectUrl = redirectUrl;
            }
        }
Exemplo n.º 10
0
        public void ProcessRequest(HttpContext context)
        {
            int pageIndex = 1, pageSize = 10;
            string orderStr = string.Empty, whereStr = string.Empty;

            DateTime startDate = NFMT.Common.DefaultValue.DefaultTime;
            DateTime endDate = NFMT.Common.DefaultValue.DefaultTime;

            if (string.IsNullOrEmpty(context.Request["s"]) || !DateTime.TryParse(context.Request["s"], out startDate))
                startDate = NFMT.Common.DefaultValue.DefaultTime;

            if (string.IsNullOrEmpty(context.Request["e"]) || !DateTime.TryParse(context.Request["e"], out endDate))
                endDate = NFMT.Common.DefaultValue.DefaultTime;
            else
                endDate = endDate.AddDays(1);

            int innerCorpId = 0;
            if (string.IsNullOrEmpty(context.Request.QueryString["inner"]) || !int.TryParse(context.Request.QueryString["inner"], out innerCorpId))
                innerCorpId = 0;

            int outerCorpId = 0;
            if (string.IsNullOrEmpty(context.Request.QueryString["outer"]) || !int.TryParse(context.Request.QueryString["outer"], out outerCorpId))
                outerCorpId = 0;

            int invType = 0;
            if (string.IsNullOrEmpty(context.Request.QueryString["invType"]) || !int.TryParse(context.Request.QueryString["invType"], out invType))
                invType = 0;

            int assetId = 0;
            if (string.IsNullOrEmpty(context.Request.QueryString["ass"]) || !int.TryParse(context.Request.QueryString["ass"], out assetId))
                assetId = 0;

            if (!string.IsNullOrEmpty(context.Request.QueryString["pagenum"]))
                int.TryParse(context.Request.QueryString["pagenum"], out pageIndex);
            pageIndex++;
            if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
                int.TryParse(context.Request.QueryString["pagesize"], out pageSize);

            if (!string.IsNullOrEmpty(context.Request.QueryString["sortdatafield"]) && !string.IsNullOrEmpty(context.Request.QueryString["sortorder"]))
            {
                string sortDataField = context.Request.QueryString["sortdatafield"].Trim();
                string sortOrder = context.Request.QueryString["sortorder"].Trim();

                switch (sortDataField)
                {
                    case "InvoiceId":
                        sortDataField = "inv.InvoiceId";
                        break;
                    case "InvoiceDate":
                        sortDataField = "inv.InvoiceDate";
                        break;
                    case "InvoiceNo":
                        sortDataField = "inv.InvoiceNo";
                        break;
                    case "InvoiceName":
                        sortDataField = "inv.InvoiceName";
                        break;
                    case "innerCorp":
                        sortDataField = "outCorp.CorpName";
                        break;
                    case "outerCorp":
                        sortDataField = "inCorp.CorpName";
                        break;
                    case "InvoiceDirection":
                        sortDataField = "bdInvoiceDirection.DetailName";
                        break;
                    case "InvoiceType":
                        sortDataField = "bdInvoiceType.DetailName";
                        break;
                    case "AssetName":
                        sortDataField = "ass.AssetName";
                        break;
                    case "NetAmount":
                        sortDataField = "biDetail.NetAmount";
                        break;
                    case "MUName":
                        sortDataField = "mu.MUName";
                        break;
                    case "Bala":
                        sortDataField = "biDetail.Bala";
                        break;
                    case "CurrencyName":
                        sortDataField = "cur.CurrencyName";
                        break;
                    case "RefNo":
                        sortDataField = "sn.RefNo";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            NFMT.Invoice.BLL.BusinessInvoiceBLL bll = new NFMT.Invoice.BLL.BusinessInvoiceBLL();
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Common.SelectModel select = bll.GetBusInvReportSelect(pageIndex, pageSize, orderStr, innerCorpId, outerCorpId, invType, assetId, startDate, endDate);
            NFMT.Common.ResultModel result = bll.Load(user, select);

            context.Response.ContentType = "text/plain";
            if (result.ResultStatus != 0)
            {
                context.Response.Write(result.Message);
                context.Response.End();
            }

            int totalRows = result.AffectCount;
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
            Dictionary<string, object> dic = new Dictionary<string, object>();

            dic.Add("count", totalRows);
            dic.Add("data", dt);

            string postData = Newtonsoft.Json.JsonConvert.SerializeObject(dic, new Newtonsoft.Json.Converters.DataTableConverter());

            context.Response.Write(postData);
        }