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

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

            string CorpCode = context.Request["Code"];//公司代码
            string CorpName = context.Request["Name"];//公司名称

            if (!string.IsNullOrEmpty(context.Request["blocId"]))
                int.TryParse(context.Request["blocId"], out blocId);//归属集团查询条件

            //jqwidgets jqxGrid
            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 "AllotBala":
                        sortDataField = "allot.SumAllotBala";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            NFMT.Funds.BLL.ReceivableAllotBLL bll = new NFMT.Funds.BLL.ReceivableAllotBLL();
            NFMT.Common.SelectModel select = bll.GetReceCorpReadyListSelect(pageIndex, pageSize, orderStr, CorpCode, CorpName, blocId);
            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();
            }

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

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

            string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(dic, new Newtonsoft.Json.Converters.DataTableConverter());
            context.Response.Write(jsonStr);
        }
        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 status = 0;
            if (!string.IsNullOrEmpty(context.Request.QueryString["s"]))
            {
                if (!int.TryParse(context.Request.QueryString["s"], out status))
                    status = 0;
            }

            int empId = 0;
            if (!string.IsNullOrEmpty(context.Request.QueryString["e"]))
            {
                if (!int.TryParse(context.Request.QueryString["e"], out empId))
                    empId = 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.Funds.BLL.ReceivableAllotBLL bll = new NFMT.Funds.BLL.ReceivableAllotBLL();
            NFMT.Common.SelectModel select = bll.GetReceCorpSelectModel(pageIndex, pageSize, orderStr, empId, status);
            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);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            string redirectUrl = string.Format("{0}Funds/ContractReceivableList.aspx", NFMT.Common.DefaultValue.NftmSiteName);
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

            if (!IsPostBack)
            {
                Utility.VerificationUtility ver = new Utility.VerificationUtility();
                ver.JudgeOperate(this.Page, 57, new List<NFMT.Common.OperateEnum>() { NFMT.Common.OperateEnum.提交审核, NFMT.Common.OperateEnum.作废, NFMT.Common.OperateEnum.撤返, NFMT.Common.OperateEnum.执行完成, NFMT.Common.OperateEnum.执行完成撤销 });

                this.navigation1.Routes.Add("合约收款分配", redirectUrl);
                this.navigation1.Routes.Add("合约收款分配明细", string.Empty);

                int receivableAllotId = 0;
                if (string.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out receivableAllotId) || receivableAllotId <= 0)
                    Response.Redirect(redirectUrl);

                this.hidid.Value = receivableAllotId.ToString();

                NFMT.Funds.BLL.ReceivableAllotBLL receivableAllotBLL = new NFMT.Funds.BLL.ReceivableAllotBLL();
                NFMT.Common.ResultModel result = receivableAllotBLL.Get(user, receivableAllotId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                NFMT.Funds.Model.ReceivableAllot receivableAllot = result.ReturnValue as NFMT.Funds.Model.ReceivableAllot;
                if (receivableAllot != null)
                {
                    NFMT.Data.Model.Currency currency = NFMT.Data.BasicDataProvider.Currencies.SingleOrDefault(a => a.CurrencyId == receivableAllot.CurrencyId);
                    if (currency != null)
                        this.spanAllotBala.InnerText = receivableAllot.AllotBala.ToString() + currency.CurrencyName;

                    this.spanAllotDesc.InnerText = receivableAllot.AllotDesc;

                    NFMT.User.Model.Employee employee = NFMT.User.UserProvider.Employees.SingleOrDefault(a => a.EmpId == receivableAllot.EmpId);
                    if (employee != null)
                        this.spanEmpId.InnerText = employee.Name;

                    this.spanAllotTime.InnerText = receivableAllot.AllotTime.ToString();

                    string json = serializer.Serialize(receivableAllot);
                    this.hidModel.Value = json;
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

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

            int allotId = 0;
            if (!string.IsNullOrEmpty(context.Request.Form["id"]))
            {
                if (!int.TryParse(context.Request.Form["id"], out allotId))
                {
                    context.Response.Write("参数错误");
                    context.Response.End();
                }
            }

            NFMT.Funds.BLL.ReceivableAllotBLL bll = new NFMT.Funds.BLL.ReceivableAllotBLL();
            result = bll.ReceCorpComplete(user, allotId);
            context.Response.Write(result.Message);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            string redirectUrl = string.Format("{0}Funds/ReceivableStockList.aspx", NFMT.Common.DefaultValue.NftmSiteName);
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

            if (!IsPostBack)
            {
                this.navigation1.Routes.Add("库存收款分配", redirectUrl);
                this.navigation1.Routes.Add("库存收款分配修改", string.Empty);

                int receivableAllotId = 0;
                if (string.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out receivableAllotId) || receivableAllotId <= 0)
                    Response.Redirect(redirectUrl);

                this.hidid.Value = receivableAllotId.ToString();

                NFMT.Funds.BLL.StcokReceivableBLL stcokReceivableBLL = new NFMT.Funds.BLL.StcokReceivableBLL();
                NFMT.Funds.BLL.ContractReceivableBLL contractReceivableBLL = new NFMT.Funds.BLL.ContractReceivableBLL();
                NFMT.Common.ResultModel result = stcokReceivableBLL.GetStockId(user, receivableAllotId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                int stockId = (int)result.ReturnValue;
                this.hidStockId.Value = stockId.ToString();

                //库存信息
                NFMT.WareHouse.BLL.StockBLL stockBLL = new NFMT.WareHouse.BLL.StockBLL();
                result = stockBLL.GetStockContractOutCorp(user, stockId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                this.hidCorps.Value = Newtonsoft.Json.JsonConvert.SerializeObject(result.ReturnValue);

                result = stockBLL.Get(user, stockId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                NFMT.WareHouse.Model.Stock stock = result.ReturnValue as NFMT.WareHouse.Model.Stock;
                if (stock != null)
                {
                    this.hidStockNameId.Value = stock.StockNameId.ToString();

                    NFMT.WareHouse.BLL.StockNameBLL stockNameBLL = new NFMT.WareHouse.BLL.StockNameBLL();
                    result = stockNameBLL.Get(user, stock.StockNameId);
                    if (result.ResultStatus != 0)
                        Response.Redirect(redirectUrl);
                    NFMT.WareHouse.Model.StockName stockName = result.ReturnValue as NFMT.WareHouse.Model.StockName;

                    if (stockName != null)
                        this.spanRefNo.InnerText = stockName.RefNo;
                    this.spanStockDate.InnerText = stock.StockDate.ToShortDateString();

                    NFMT.User.Model.Corporation corp = NFMT.User.UserProvider.Corporations.SingleOrDefault(a => a.CorpId == stock.CorpId);
                    if (corp != null)
                        this.spanCorpId.InnerText = corp.CorpName;

                    NFMT.Data.Model.MeasureUnit measureUnit = NFMT.Data.BasicDataProvider.MeasureUnits.SingleOrDefault(a => a.MUId == stock.UintId);
                    if (measureUnit != null)
                        this.spanGrossAmout.InnerText = stock.GrossAmount + measureUnit.MUName;

                    NFMT.Data.Model.Asset asset = NFMT.Data.BasicDataProvider.Assets.SingleOrDefault(a => a.AssetId == stock.AssetId);
                    if (asset != null)
                        this.spanAssetId.InnerText = asset.AssetName;

                    NFMT.Data.Model.Brand brand = NFMT.Data.BasicDataProvider.Brands.SingleOrDefault(a => a.BrandId == stock.BrandId);
                    if (brand != null)
                        this.spanBrandId.InnerText = brand.BrandName;

                    NFMT.Funds.BLL.ReceivableAllotBLL receivableAllotBLL = new NFMT.Funds.BLL.ReceivableAllotBLL();
                    result = receivableAllotBLL.GetStockAllotAmount(user, stockId);
                    if (result.ResultStatus != 0)
                        Response.Redirect(redirectUrl);

                    this.spanAllotAmount.InnerText = result.ReturnValue == null ? "" : result.ReturnValue.ToString();

                    //分配信息
                    result = receivableAllotBLL.Get(user, receivableAllotId);
                    if (result.ResultStatus != 0)
                        Response.Redirect(redirectUrl);

                    NFMT.Funds.Model.ReceivableAllot receivableAllot = result.ReturnValue as NFMT.Funds.Model.ReceivableAllot;
                    if (receivableAllot != null)
                    {
                        this.txbMemo.Value = receivableAllot.AllotDesc;
                        this.hidcurrencyId.Value = receivableAllot.CurrencyId.ToString();
                        this.hidAllotFrom.Value = receivableAllot.AllotFrom.ToString();

                        if (receivableAllot.AllotFrom == NFMT.Data.DetailProvider.Details(NFMT.Data.StyleEnum.分配来源)["Receivable"].StyleDetailId)
                        {
                            //获取收款登记相关
                            result = stcokReceivableBLL.GetReceIds(user, receivableAllotId);
                            if (result.ResultStatus != 0)
                                Response.Redirect(redirectUrl);

                            this.hidReceIds.Value = result.ReturnValue.ToString();

                            result = stcokReceivableBLL.GetRowsDetail(user, receivableAllotId);
                            if (result.ResultStatus != 0)
                                Response.Redirect(redirectUrl);

                            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

                            this.hidRowDetail.Value = Newtonsoft.Json.JsonConvert.SerializeObject(dt);
                        }
                        else if (receivableAllot.AllotFrom == NFMT.Data.DetailProvider.Details(NFMT.Data.StyleEnum.分配来源)["CorpReceivable"].StyleDetailId)
                        {
                            //获取公司收款相关
                            result = contractReceivableBLL.GetCorpRefIds(user, receivableAllotId);
                            if (result.ResultStatus != 0)
                                Response.Redirect(redirectUrl);

                            this.hidCorpRefIds.Value = result.ReturnValue.ToString();

                            result = contractReceivableBLL.GetRowsDetailByCorp(user, receivableAllotId);
                            if (result.ResultStatus != 0)
                                Response.Redirect(redirectUrl);

                            System.Data.DataTable dtCorp = result.ReturnValue as System.Data.DataTable;

                            this.hidRowDetailCorp.Value = Newtonsoft.Json.JsonConvert.SerializeObject(dtCorp);
                        }
                        else if (receivableAllot.AllotFrom == NFMT.Data.DetailProvider.Details(NFMT.Data.StyleEnum.分配来源)["ContractReceivable"].StyleDetailId)
                        {
                            //获取合约收款相关
                            result = stcokReceivableBLL.GetReceIdsForContract(user, receivableAllotId);
                            if (result.ResultStatus != 0)
                                Response.Redirect(redirectUrl);

                            this.hidReceIdsForContract.Value = result.ReturnValue.ToString();

                            result = stcokReceivableBLL.GetRowsDetailForContract(user, receivableAllotId);
                            if (result.ResultStatus != 0)
                                Response.Redirect(redirectUrl);

                            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

                            this.hidRowDetailForContract.Value = Newtonsoft.Json.JsonConvert.SerializeObject(dt);
                        }
                    }
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string r = context.Request.Form["Allot"];
            if (string.IsNullOrEmpty(r))
            {
                context.Response.Write("分配信息不能为空");
                context.Response.End();
            }
            string memo = context.Request.Form["memo"];

            int corpId = 0;
            if (string.IsNullOrEmpty(context.Request.Form["cid"]) || !int.TryParse(context.Request.Form["cid"], out corpId) || corpId <= 0)
            {
                context.Response.Write("公司信息错误");
                context.Response.End();
            }

            int blocId = 0;
            if (string.IsNullOrEmpty(context.Request.Form["blocId"]) || !int.TryParse(context.Request.Form["blocId"], out blocId) || blocId <= 0)
            {
                context.Response.Write("集团信息错误");
                context.Response.End();
            }

            int curId = 0;
            if (string.IsNullOrEmpty(context.Request.Form["curId"]) || !int.TryParse(context.Request.Form["curId"], out curId) || curId <= 0)
            {
                context.Response.Write("币种信息错误");
                context.Response.End();
            }

            bool isShare = false;
            if (string.IsNullOrEmpty(context.Request.Form["isShare"]) || !bool.TryParse(context.Request.Form["isShare"], out isShare))
            {
                context.Response.Write("是否共享信息错误");
                context.Response.End();
            }

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

            try
            {
                System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                List<AllotInfo> allotInfos = serializer.Deserialize<List<AllotInfo>>(r);
                if (allotInfos == null)
                {
                    context.Response.Write("分配信息错误");
                    context.Response.End();
                }

                NFMT.Funds.Model.ReceivableAllot allot = new NFMT.Funds.Model.ReceivableAllot();
                allot.AllotDesc = memo;
                allot.AllotStatus = NFMT.Common.StatusEnum.已录入;
                allot.AllotTime = DateTime.Now;
                allot.CurrencyId = curId;
                allot.EmpId = user.EmpId;

                NFMT.Funds.Model.CorpReceivable corpRec = new NFMT.Funds.Model.CorpReceivable();
                corpRec.BlocId = blocId;
                corpRec.CorpId = corpId;
                corpRec.IsShare = isShare;

                List<NFMT.Funds.Model.RecAllotDetail> details = new List<NFMT.Funds.Model.RecAllotDetail>();
                foreach (AllotInfo info in allotInfos)
                {
                    NFMT.Funds.Model.RecAllotDetail detail = new NFMT.Funds.Model.RecAllotDetail();

                    detail.AllotBala = info.CanAllotBala;
                    detail.DetailStatus = NFMT.Common.StatusEnum.已生效;
                    detail.RecId = info.ReceivableId;

                    details.Add(detail);
                }

                NFMT.Funds.BLL.ReceivableAllotBLL bll = new NFMT.Funds.BLL.ReceivableAllotBLL();
                result = bll.CreateCorp(user, allot, details, corpRec);
            }
            catch (Exception e)
            {
                result.Message = e.Message;
            }

            if (result.ResultStatus == 0)
                result.Message = "分配成功";

            context.Response.Write(result.Message);
            context.Response.End();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            string redirectUrl = string.Format("{0}Funds/ReceivableCorpList.aspx", NFMT.Common.DefaultValue.NftmSiteName);
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

            if (!IsPostBack)
            {
                this.navigation1.Routes.Add("公司收款分配", redirectUrl);
                this.navigation1.Routes.Add("公司收款分配修改", string.Empty);

                int receivableAllotId = 0;
                if (string.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out receivableAllotId) || receivableAllotId <= 0)
                    Response.Redirect(redirectUrl);

                NFMT.Common.ResultModel result = new NFMT.Common.ResultModel();

                //获取分配
                NFMT.Funds.BLL.ReceivableAllotBLL allotBLL = new NFMT.Funds.BLL.ReceivableAllotBLL();
                result = allotBLL.Get(user, receivableAllotId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                NFMT.Funds.Model.ReceivableAllot recAllot = result.ReturnValue as NFMT.Funds.Model.ReceivableAllot;
                if (recAllot == null || recAllot.ReceivableAllotId <= 0)
                    Response.Redirect(redirectUrl);

                this.curRecAllot = recAllot;
                this.currencyId = recAllot.CurrencyId;

                //获取分配明细列表
                NFMT.Funds.BLL.RecAllotDetailBLL recAllotDetailBLL = new NFMT.Funds.BLL.RecAllotDetailBLL();
                result = recAllotDetailBLL.Load(user, recAllot.ReceivableAllotId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                List<NFMT.Funds.Model.RecAllotDetail> details = result.ReturnValue as List<NFMT.Funds.Model.RecAllotDetail>;
                if (details == null)
                    Response.Redirect(redirectUrl);

                foreach (NFMT.Funds.Model.RecAllotDetail d in details)
                {
                    if (details.IndexOf(d) != 0)
                    {
                        this.curRids += ",";
                        this.curDids += ",";
                    }

                    this.curRids += d.RecId.ToString();
                    this.curDids += d.DetailId.ToString();
                }

                //获取分配公司明细列表
                NFMT.Funds.BLL.CorpReceivableBLL corpReceivalbleBLL = new NFMT.Funds.BLL.CorpReceivableBLL();
                result = corpReceivalbleBLL.Load(user, recAllot.ReceivableAllotId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                List<NFMT.Funds.Model.CorpReceivable> corpDetails = result.ReturnValue as List<NFMT.Funds.Model.CorpReceivable>;
                if (corpDetails == null)
                    Response.Redirect(redirectUrl);

                //公司信息
                if (corpDetails.Count == 0)
                    Response.Redirect(redirectUrl);

                NFMT.Funds.Model.CorpReceivable corpDetail = corpDetails[0];
                NFMT.User.Model.Corporation corp = NFMT.User.UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == corpDetail.CorpId);
                if (corp != null && corp.CorpId > 0)
                {
                    this.spanBlocId.InnerHtml = corp.BlocName;
                    this.spanCorpCode.InnerHtml = corp.CorpCode;
                    this.spanCorpName.InnerHtml = corp.CorpName;
                    this.spanTaxPlayer.InnerHtml = corp.TaxPayerId;
                    this.spanCorpAddress.InnerHtml = corp.CorpAddress;
                    this.spanCorpTel.InnerHtml = corp.CorpTel;
                    this.spanCorpFax.InnerHtml = corp.CorpFax;
                    this.spanCorpZip.InnerHtml = corp.CorpZip;

                    this.curCorp = corp;
                }
                this.isShare = corpDetail.IsShare;

                result = corpReceivalbleBLL.GetRowsDetail(user, receivableAllotId,NFMT.Common.StatusEnum.已作废);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
                this.curJsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(dt);

                string json = serializer.Serialize(recAllot);
                this.hidModel.Value = json;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string r = context.Request.Form["Allot"];
            if (string.IsNullOrEmpty(r))
            {
                context.Response.Write("分配信息不能为空");
                context.Response.End();
            }
            string memo = context.Request.Form["memo"];

            int sid = 0;
            if (string.IsNullOrEmpty(context.Request.Form["sid"]) || !int.TryParse(context.Request.Form["sid"], out sid) || sid <= 0)
            {
                context.Response.Write("库存信息错误");
                context.Response.End();
            }

            int stockNameId = 0;
            if (string.IsNullOrEmpty(context.Request.Form["stockNameId"]) || !int.TryParse(context.Request.Form["stockNameId"], out stockNameId) || stockNameId <= 0)
            {
                context.Response.Write("业务单号错误");
                context.Response.End();
            }

            int curId = 0;
            if (string.IsNullOrEmpty(context.Request.Form["curId"]) || !int.TryParse(context.Request.Form["curId"], out curId) || curId <= 0)
            {
                context.Response.Write("币种信息错误");
                context.Response.End();
            }

            int allotId = 0;
            if (string.IsNullOrEmpty(context.Request.Form["id"]) || !int.TryParse(context.Request.Form["id"], out allotId) || allotId <= 0)
            {
                context.Response.Write("序号信息错误");
                context.Response.End();
            }

            int allotFrom = 0;
            if (string.IsNullOrEmpty(context.Request.Form["allotFrom"]) || !int.TryParse(context.Request.Form["allotFrom"], out allotFrom) || allotFrom <= 0)
            {
                context.Response.Write("来源信息错误");
                context.Response.End();
            }

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

            try
            {
                System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                List<AllotInfo> allotInfos = serializer.Deserialize<List<AllotInfo>>(r);
                if (allotInfos == null)
                {
                    context.Response.Write("分配信息错误");
                    context.Response.End();
                }

                List<NFMT.Funds.Model.ContractReceivable> contractReceivables = new List<NFMT.Funds.Model.ContractReceivable>();
                foreach (var item in allotInfos)
                {
                    int refId =0;
                    decimal bala = 0;
                    if (!string.IsNullOrEmpty(item.CanAllotBala)
                        && !string.IsNullOrEmpty(item.RefId)
                        && int.TryParse(item.RefId, out refId)
                        && decimal.TryParse(item.CanAllotBala, out bala))
                    {
                        NFMT.Funds.Model.ContractReceivable contractReceivable = new NFMT.Funds.Model.ContractReceivable()
                        {
                            CorpRefId = refId,
                            AllotId = allotId,
                            //RecId
                            //ContractId
                            //SubContractId
                            //AllotBala = bala
                        };
                        contractReceivables.Add(contractReceivable);
                    }
                }

                NFMT.Funds.BLL.ReceivableAllotBLL bll = new NFMT.Funds.BLL.ReceivableAllotBLL();
                result = bll.ReceivableStockUpdateForCorpHandle(user, contractReceivables, curId, memo, allotId, sid, stockNameId, allotFrom);
                if (result.ResultStatus == 0)
                    result.Message = "修改成功";

            }
            catch (Exception e)
            {
                result.Message = e.Message;
            }

            context.Response.Write(result.Message);
            context.Response.End();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            string redirectUrl = string.Format("{0}Funds/ContractReceivableList.aspx", NFMT.Common.DefaultValue.NftmSiteName);
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

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

                this.navigation1.Routes.Add("合约收款分配", redirectUrl);
                this.navigation1.Routes.Add("合约收款分配修改", string.Empty);

                int receivableAllotId = 0;
                if (string.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out receivableAllotId) || receivableAllotId <= 0)
                    Response.Redirect(redirectUrl);

                this.hidid.Value = receivableAllotId.ToString();

                NFMT.Funds.BLL.ContractReceivableBLL contractReceivableBLL = new NFMT.Funds.BLL.ContractReceivableBLL();
                NFMT.Common.ResultModel result = contractReceivableBLL.GetSubId(user, receivableAllotId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                int subId = (int)result.ReturnValue;
                this.hidsubId.Value = subId.ToString();

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

                this.hidCorps.Value = Newtonsoft.Json.JsonConvert.SerializeObject(result.ReturnValue);

                result = contractReceivableBLL.GetReceIds(user, receivableAllotId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                this.hidReceIds.Value = result.ReturnValue.ToString();

                result = contractReceivableBLL.GetCorpRefIds(user, receivableAllotId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                this.hidCorpRefIds.Value = result.ReturnValue.ToString();

                result = contractReceivableBLL.GetRowsDetail(user, receivableAllotId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

                this.hidRowDetail.Value = Newtonsoft.Json.JsonConvert.SerializeObject(dt);

                result = contractReceivableBLL.GetRowsDetailByCorp(user, receivableAllotId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                System.Data.DataTable dtCorp = result.ReturnValue as System.Data.DataTable;

                this.hidRowDetailCorp.Value = Newtonsoft.Json.JsonConvert.SerializeObject(dtCorp);

                result = contractSubBLL.Get(user, subId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                //子合约信息
                NFMT.Contract.Model.ContractSub contractSub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                if (contractSub != null)
                {
                    this.hidCurrucyId.Value = contractSub.SettleCurrency.ToString();
                    this.hidcontractId.Value = contractSub.ContractId.ToString();
                    this.spnSubNo.InnerText = contractSub.SubNo;
                    NFMT.Data.Model.MeasureUnit measureUnit = NFMT.Data.BasicDataProvider.MeasureUnits.SingleOrDefault(a => a.MUId == contractSub.UnitId);
                    if (measureUnit != null)
                        this.spnSubSignAmount.InnerText = contractSub.SignAmount.ToString() + measureUnit.MUName;
                    this.spnPeriodE.InnerText = contractSub.ContractPeriodE.ToShortDateString();

                    NFMT.Funds.BLL.ReceivableAllotBLL receivableAllotBLL = new NFMT.Funds.BLL.ReceivableAllotBLL();
                    result = receivableAllotBLL.GetSubContractAllotAmount(user, subId);
                    if (result.ResultStatus != 0)
                        Response.Redirect(redirectUrl);

                    this.spanAllotAmount.InnerText = result.ReturnValue == null ? "" : result.ReturnValue.ToString();

                    //分配信息
                    result = receivableAllotBLL.Get(user, receivableAllotId);
                    if (result.ResultStatus != 0)
                        Response.Redirect(redirectUrl);

                    NFMT.Funds.Model.ReceivableAllot receivableAllot = result.ReturnValue as NFMT.Funds.Model.ReceivableAllot;
                    if (receivableAllot != null)
                    {
                        this.txbMemo.Value = receivableAllot.AllotDesc;
                        this.hidAllotFrom.Value = receivableAllot.AllotFrom.ToString();
                    }
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            int corpId = -1;
            int pageIndex = 1, pageSize = 10;
            string orderStr = string.Empty, whereStr = string.Empty;

            DateTime stockDateBegin = NFMT.Common.DefaultValue.DefaultTime;//context.Request["stockDateBegin"];//入库日期开始查询条件
            DateTime stockDateEnd = NFMT.Common.DefaultValue.DefaultTime;// context.Request["stockDateEnd"];//入库日期结束查询条件

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

            if (!string.IsNullOrEmpty(context.Request["sde"]))
            {
                if (!DateTime.TryParse(context.Request["sde"], out stockDateEnd))
                    stockDateEnd = NFMT.Common.DefaultValue.DefaultTime;
                else
                    stockDateEnd.AddDays(1);
            }

            string stockName = context.Request["sn"];//业务单号模糊查询

            if (!string.IsNullOrEmpty(context.Request["ci"]))
                int.TryParse(context.Request["ci"], out corpId);//所属公司查询条件

            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 "StockDate":
                        sortDataField = string.Format("sto.{0}", sortDataField);
                        break;
                    case "RefNo":
                        sortDataField = string.Format("sn.{0}", sortDataField);
                        break;
                    case "CorpName":
                        sortDataField = "cor.CorpName";
                        break;
                    case "AssetName":
                        sortDataField = "ass.AssetName";
                        break;
                    case "StockWeight":
                        sortDataField = "sto.GrossAmount";
                        break;
                    case "BrandName":
                        sortDataField = "bra.BrandName";
                        break;
                    case "CustomsTypeName":
                        sortDataField = "sto.CustomsType";
                        break;
                    case "StatusName":
                        sortDataField = "sd.StatusName";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            NFMT.Funds.BLL.ReceivableAllotBLL bll = new NFMT.Funds.BLL.ReceivableAllotBLL();
            NFMT.Common.SelectModel select = bll.GetReceStockReadyListSelect(pageIndex, pageSize, orderStr, stockName, stockDateBegin, stockDateEnd, corpId);
            NFMT.Common.ResultModel result = bll.Load(new NFMT.Common.UserModel(), 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)
        {
            context.Response.ContentType = "text/plain";

            string r = context.Request.Form["Allot"];
            if (string.IsNullOrEmpty(r))
            {
                context.Response.Write("分配信息不能为空");
                context.Response.End();
            }
            string memo = context.Request.Form["memo"];

            int subId = 0;
            if (string.IsNullOrEmpty(context.Request.Form["subId"]) || !int.TryParse(context.Request.Form["subId"], out subId) || subId <= 0)
            {
                context.Response.Write("子合约信息错误");
                context.Response.End();
            }

            int contractId = 0;
            if (string.IsNullOrEmpty(context.Request.Form["contractId"]) || !int.TryParse(context.Request.Form["contractId"], out contractId) || contractId <= 0)
            {
                context.Response.Write("合约信息错误");
                context.Response.End();
            }

            int curId = 0;
            if (string.IsNullOrEmpty(context.Request.Form["curId"]) || !int.TryParse(context.Request.Form["curId"], out curId) || curId <= 0)
            {
                context.Response.Write("币种信息错误");
                context.Response.End();
            }

            int allotFrom = 0;
            if (string.IsNullOrEmpty(context.Request.Form["allotFrom"]) || !int.TryParse(context.Request.Form["allotFrom"], out allotFrom) || allotFrom <= 0)
            {
                context.Response.Write("分配来源错误");
                context.Response.End();
            }

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

            try
            {
                System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                List<AllotInfo> allotInfos = serializer.Deserialize<List<AllotInfo>>(r);
                if (allotInfos == null)
                {
                    context.Response.Write("分配信息错误");
                    context.Response.End();
                }

                List<NFMT.Funds.Model.CorpReceivable> corpReceivables = new List<NFMT.Funds.Model.CorpReceivable>();
                foreach (var item in allotInfos)
                {
                    int rId = 0, corpId = 0;
                    decimal bala = 0;
                    if (!string.IsNullOrEmpty(item.CanAllotBala)
                        && !string.IsNullOrEmpty(item.ReceivableId)
                        && !string.IsNullOrEmpty(item.CorpCode)
                        && int.TryParse(item.ReceivableId, out rId)
                        && decimal.TryParse(item.CanAllotBala, out bala)
                        && int.TryParse(item.CorpCode, out corpId))
                    {
                        NFMT.Funds.Model.CorpReceivable corpReceivable = new NFMT.Funds.Model.CorpReceivable()
                        {
                            //AllotId
                            //BlocId
                            CorpId = corpId,
                            RecId = rId,
                            //AllotBala = bala,
                        };
                        corpReceivables.Add(corpReceivable);
                    }
                }

                NFMT.Funds.BLL.ReceivableAllotBLL bll = new NFMT.Funds.BLL.ReceivableAllotBLL();
                result = bll.ReceivableAllotCreateHandle(user, corpReceivables, contractId, subId, curId, memo, allotFrom);
            }
            catch (Exception e)
            {
                result.Message = e.Message;
            }

            context.Response.Write(result.Message);
            context.Response.End();
        }