public void ProcessRequest(HttpContext context)
        {
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;

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

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

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

            DateTime toDate = NFMT.Common.DefaultValue.DefaultTime;
            if (!string.IsNullOrEmpty(context.Request.QueryString["t"]))
            {
                if (!DateTime.TryParse(context.Request.QueryString["t"], 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"]))
                orderStr = string.Format("{0} {1}", context.Request.QueryString["sortdatafield"].Trim(), context.Request.QueryString["sortorder"].Trim());

            NFMT.DoPrice.BLL.PricingBLL bll = new NFMT.DoPrice.BLL.PricingBLL();
            NFMT.Common.SelectModel select = bll.GetCanDelayApplySelectModel(pageIndex, pageSize, orderStr, applyDept, fromDate, toDate);
            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)
        {
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;

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

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

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

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

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

            int status = 0;
            if (!string.IsNullOrEmpty(context.Request.QueryString["s"]))
            {
                if (!int.TryParse(context.Request.QueryString["s"], out status))
                    status = 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"]))
                orderStr = string.Format("{0} {1}", context.Request.QueryString["sortdatafield"].Trim(), context.Request.QueryString["sortorder"].Trim());

            NFMT.DoPrice.BLL.PricingBLL bll = new NFMT.DoPrice.BLL.PricingBLL();
            NFMT.Common.SelectModel select = bll.GetCanStopLossApplySelectModel(pageIndex, pageSize, orderStr, person, assetId, exchangeId, status, subNo);
            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);
        }
Exemplo n.º 3
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, 62, 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.收取;

                //获取子合约价格明细
                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);

                if (sub.PriceMode == (int)NFMT.Contract.PriceModeEnum.Pricing)
                {
                    //定价合约
                    this.AvgPrice = subPrice.FixedPrice.ToString("0.0000");
                }
                else if ((subPrice.WhoDoPrice == (int)NFMT.Contract.WhoDoPriceEnum.我方 && contract.TradeDirection == (int)NFMT.Contract.TradeDirectionEnum.采购) || contract.TradeDirection == (int)NFMT.Contract.TradeDirectionEnum.销售)
                {
                    //点价合约
                    //获取当前子合约下点价列表
                    NFMT.DoPrice.BLL.PricingBLL pricingBLL = new NFMT.DoPrice.BLL.PricingBLL();
                    result = pricingBLL.Load(user, sub.SubId);
                    if (result.ResultStatus != 0)
                    {
                        Response.Write("<script>");
                        Response.Write("alert(\"该合约未进行任何点价,不能开具或收取直接终票\");");
                        Response.Write(string.Format("document.local.href={0};",redirectUrl));
                        Response.Write("</script>");
                        Response.End();
                    }

                    List<NFMT.DoPrice.Model.Pricing> pricings = result.ReturnValue as List<NFMT.DoPrice.Model.Pricing>;
                    if (pricings == null || pricings.Count <= 0)
                    {
                        Response.Write("<script>");
                        Response.Write("alert(\"该合约未进行任何点价,不能开具或收取直接终票\");");
                        Response.Write(string.Format("document.location.href =\"{0}\";", redirectUrl));
                        Response.Write("</script>");
                        Response.End();
                    }
                    decimal sumBala = pricings.Sum(temp => temp.FinalPrice * temp.PricingWeight);
                    decimal sumAmount = pricings.Sum(temp => temp.PricingWeight);

                    decimal avgPrice = sumBala / sumAmount;
                    this.AvgPrice = avgPrice.ToString("0.0000");
                }

                this.SelectJson(sub.SubId, invoiceDirection);

                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.º 4
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);

            string contractNo = context.Request["c"];

            int assetId = 0;
            if (string.IsNullOrEmpty(context.Request.QueryString["a"]) || !int.TryParse(context.Request.QueryString["a"], 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 "PricingId":
                        sortDataField = "p.PricingId";
                        break;
                    case "ContractNo":
                        sortDataField = "con.ContractNo";
                        break;
                    case "OutContractNo":
                        sortDataField = "con.OutContractNo";
                        break;
                    case "CorpName":
                        sortDataField = "CustCorp.CorpName";
                        break;
                    case "AssetName":
                        sortDataField = "asset.AssetName";
                        break;
                    case "TradeCode":
                        sortDataField = "fc.TradeCode";
                        break;
                    case "ExchangeCode":
                        sortDataField = "ex.ExchangeCode";
                        break;
                    case "CurrencyName":
                        sortDataField = "cur.CurrencyName";
                        break;
                    case "TurnoverHand":
                        sortDataField = "p.PricingWeight";
                        break;
                    case "Turnover":
                        sortDataField = "p.PricingWeight";
                        break;
                    case "PricingStyle":
                        sortDataField = "bdPricingStyle.DetailName";
                        break;
                    case "SpotQP":
                        sortDataField = "p.SpotQP";
                        break;
                    case "Spread":
                        sortDataField = "p.Spread";
                        break;
                    case "Premium":
                        sortDataField = "con.Premium";
                        break;
                    case "DelayFee":
                        sortDataField = "p.DelayFee";
                        break;
                    case "OtherFee":
                        sortDataField = "p.OtherFee";
                        break;
                    case "FinalPrice":
                        sortDataField = "p.FinalPrice";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            NFMT.DoPrice.BLL.PricingBLL bll = new NFMT.DoPrice.BLL.PricingBLL();
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Common.SelectModel select = bll.GetDoPriceReportSelect(pageIndex, pageSize, orderStr, contractNo, 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);
        }