Ejemplo n.º 1
0
        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();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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)
        {
            int outerCorp = -1;
            int pageIndex = 1, pageSize = 10;
            string orderStr = string.Empty;

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

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

            if (!string.IsNullOrEmpty(context.Request["fd"]))
            {
                if (!DateTime.TryParse(context.Request["fd"], out beginDate))
                    beginDate = NFMT.Common.DefaultValue.DefaultTime;
            }
            if (!string.IsNullOrEmpty(context.Request["td"]))
            {
                if (!DateTime.TryParse(context.Request["td"], out endDate))
                    endDate = NFMT.Common.DefaultValue.DefaultTime;
                else
                    endDate.AddDays(1);
            }
            if (!string.IsNullOrEmpty(context.Request["ci"]))
                int.TryParse(context.Request["ci"], out outerCorp);

            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 "ContractId":
                        sortDataField = "c.ContractId";
                        break;
                    case "ContractDate":
                        sortDataField = "cs.ContractDate";
                        break;
                    case "ContractNo":
                        sortDataField = "cs.SubNo";
                        break;
                    case "OutContractNo":
                        sortDataField = "cs.OutContractNo";
                        break;
                    case "TradeDirectionName":
                        sortDataField = "c.TradeDirection";
                        break;
                    case "InCorpName":
                        sortDataField = "inCorp.CorpName";
                        break;
                    case "OutCorpName":
                        sortDataField = "outCorp.CorpName";
                        break;
                    case "AssetName":
                        sortDataField = "c.AssetId";
                        break;
                    case "ContractWeight":
                        sortDataField = "cs.SignAmount";
                        break;
                    case "PriceModeName":
                        sortDataField = "cs.PriceMode";
                        break;
                    case "StatusName":
                        sortDataField = "cs.SubStatus";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Funds.BLL.ContractReceivableBLL bll = new NFMT.Funds.BLL.ContractReceivableBLL();
            NFMT.Common.SelectModel select = bll.GetCanAllotListSelect(pageIndex, pageSize, orderStr, contractNo, outerCorp, beginDate, 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();
            }

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

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

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

            context.Response.Write(postData);
        }