示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Utility.VerificationUtility ver = new Utility.VerificationUtility();
            ver.JudgeOperate(this.Page, 37, new List<NFMT.Common.OperateEnum>() { NFMT.Common.OperateEnum.修改 });

            user = Utility.UserUtility.CurrentUser;
            string redirectUrl = "ContractOutStockList.aspx";

            this.navigation1.Routes.Add("合约列表", "ContractList.aspx");
            this.navigation1.Routes.Add("库存列表", redirectUrl);
            this.navigation1.Routes.Add("合约明细", string.Empty);

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

            int contractId = 0;
            if (subId <= 0 && (string.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out contractId) || contractId <= 0))
                Utility.JsUtility.WarmAlert(this, "合约序号错误", redirectUrl);

            NFMT.Common.ResultModel result = new NFMT.Common.ResultModel();
            NFMT.Contract.BLL.ContractSubBLL subBLL = new NFMT.Contract.BLL.ContractSubBLL();
            NFMT.Contract.BLL.ContractDetailBLL detailBLL = new NFMT.Contract.BLL.ContractDetailBLL();
            NFMT.Contract.BLL.ContractPriceBLL priceBLL = new NFMT.Contract.BLL.ContractPriceBLL();
            NFMT.Contract.BLL.ContractCorporationDetailBLL corpBLL = new NFMT.Contract.BLL.ContractCorporationDetailBLL();
            NFMT.Contract.BLL.ContractDeptBLL deptBLL = new NFMT.Contract.BLL.ContractDeptBLL();

            //主合约进入
            if (contractId > 0)
            {
                result = contractBLL.Get(user, contractId);
                if (result.ResultStatus != 0)
                    Utility.JsUtility.WarmAlert(this, "合约不存在", redirectUrl);

                NFMT.Contract.Model.Contract contract = result.ReturnValue as NFMT.Contract.Model.Contract;
                if (contract == null || contract.ContractId <= 0)
                    Utility.JsUtility.WarmAlert(this, "合约不存在", redirectUrl);

                if (contract.CreateFrom != (int)NFMT.Common.CreateFromEnum.销售合约库存创建)
                    Utility.JsUtility.WarmAlert(this, "合约创建来源不正确", redirectUrl);

                this.curContract = contract;

                result = subBLL.GetSubByContractId(user, contract.ContractId);
                if (result.ResultStatus != 0)
                    Utility.JsUtility.WarmAlert(this, "子合约获取失败", redirectUrl);

                NFMT.Contract.Model.ContractSub sub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                if (sub == null || sub.SubId <= 0)
                    Utility.JsUtility.WarmAlert(this, "子合约获取失败", redirectUrl);

                this.curSub = sub;
            }
            else if (subId > 0)//子合约进入
            {
                result = subBLL.Get(user, subId);
                if (result.ResultStatus != 0)
                    Utility.JsUtility.WarmAlert(this, "子合约获取失败", redirectUrl);

                NFMT.Contract.Model.ContractSub sub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                if (sub == null || sub.SubId <= 0)
                    Utility.JsUtility.WarmAlert(this, "子合约获取失败", redirectUrl);

                this.curSub = sub;

                result = contractBLL.Get(user, sub.ContractId);
                if (result.ResultStatus != 0)
                    Utility.JsUtility.WarmAlert(this, "合约不存在", redirectUrl);

                NFMT.Contract.Model.Contract contract = result.ReturnValue as NFMT.Contract.Model.Contract;
                if (contract == null || contract.ContractId <= 0)
                    Utility.JsUtility.WarmAlert(this, "合约不存在", redirectUrl);

                if (contract.CreateFrom != (int)NFMT.Common.CreateFromEnum.销售合约库存创建)
                    Utility.JsUtility.WarmAlert(this, "合约创建来源不正确", redirectUrl);

                this.curContract = contract;
            }

            //获取合约品种
            NFMT.Data.Model.Asset asset = NFMT.Data.BasicDataProvider.Assets.FirstOrDefault(temp => temp.AssetId == this.curContract.AssetId);
            if (asset == null || asset.AssetId <= 0)
                Utility.JsUtility.WarmAlert(this, "合约品种获取失败", redirectUrl);

            this.curAsset = asset;

            //获取明细
            result = detailBLL.GetDetailByContractId(user, this.curContract.ContractId);
            if (result.ResultStatus != 0)
                Utility.JsUtility.WarmAlert(this, "合约明细获取失败", redirectUrl);
            curContraceDetail = result.ReturnValue as NFMT.Contract.Model.ContractDetail;
            if (curContraceDetail == null)
                Utility.JsUtility.WarmAlert(this, "合约明细获取失败", redirectUrl);

            //获取价格
            result = priceBLL.GetPriceByContractId(user, this.curContract.ContractId);
            if (result.ResultStatus != 0)
                Utility.JsUtility.WarmAlert(this, "合约价格获取失败", redirectUrl);
            curContractPrice = result.ReturnValue as NFMT.Contract.Model.ContractPrice;
            if (curContractPrice == null)
                Utility.JsUtility.WarmAlert(this, "合约价格获取失败", redirectUrl);

            //获取公司列表
            //我方公司
            result = corpBLL.LoadCorpListByContractId(user, this.curContract.ContractId, true);
            if (result.ResultStatus != 0)
                Utility.JsUtility.WarmAlert(this, "合约我方抬头获取失败", redirectUrl);
            List<NFMT.Contract.Model.ContractCorporationDetail> inCorps = result.ReturnValue as List<NFMT.Contract.Model.ContractCorporationDetail>;
            if (inCorps == null || inCorps.Count == 0)
                Utility.JsUtility.WarmAlert(this, "合约我方抬头获取失败", redirectUrl);

            //对方公司
            result = corpBLL.LoadCorpListByContractId(user, this.curContract.ContractId, false);
            if (result.ResultStatus != 0)
                Utility.JsUtility.WarmAlert(this, "合约对方抬头获取失败", redirectUrl);
            List<NFMT.Contract.Model.ContractCorporationDetail> outCorps = result.ReturnValue as List<NFMT.Contract.Model.ContractCorporationDetail>;
            if (outCorps == null || outCorps.Count == 0)
                Utility.JsUtility.WarmAlert(this, "合约对方抬头获取失败", redirectUrl);

            //执行部门
            result = deptBLL.LoadDeptByContractId(user, this.curContract.ContractId);
            if (result.ResultStatus != 0)
                Response.Redirect("ContractList.aspx");

            List<NFMT.Contract.Model.ContractDept> depts = result.ReturnValue as List<NFMT.Contract.Model.ContractDept>;

            foreach (var obj in outCorps)
            {
                if (outCorps.IndexOf(obj) > 0)
                    curOutCorpsString += ",";
                curOutCorpsString += obj.CorpId.ToString();
            }

            foreach (var obj in inCorps)
            {
                if (inCorps.IndexOf(obj) > 0)
                    this.curInCorpsString += ",";
                curInCorpsString += obj.CorpId.ToString();
            }

            foreach (var obj in depts)
            {
                if (depts.IndexOf(obj) > 0)
                    curDeptsString += ",";
                curDeptsString += obj.DeptId.ToString();
            }

            //合约类型
            NFMT.Contract.BLL.ContractTypeDetailBLL contractTypeBLL = new NFMT.Contract.BLL.ContractTypeDetailBLL();
            result = contractTypeBLL.LoadContractTypesById(user, this.curContract.ContractId);
            if (result.ResultStatus != 0)
                this.WarmAlert("合约类型获取失败", redirectUrl);
            List<NFMT.Contract.Model.ContractTypeDetail> contractTypes = result.ReturnValue as List<NFMT.Contract.Model.ContractTypeDetail>;
            if (contractTypes == null)
                this.WarmAlert("合约类型获取失败", redirectUrl);
            foreach (NFMT.Contract.Model.ContractTypeDetail contractType in contractTypes)
            {
                if (contractTypes.IndexOf(contractType) > 0)
                    this.curContractTypesString += ",";

                this.curContractTypesString += contractType.ContractType.ToString();
            }

            int pageIndex = 1;
            int pageSize = 100;
            string orderStr = string.Empty;
            NFMT.WareHouse.BLL.StockLogBLL stockLogBLL = new NFMT.WareHouse.BLL.StockLogBLL();
            NFMT.Common.SelectModel select = stockLogBLL.GetContractOutStockSelect(pageIndex, pageSize, orderStr, this.curSub.SubId);
            result = stockLogBLL.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());

            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            string json = serializer.Serialize(this.curContract);
            this.hidModel.Value = json;

            this.attach1.BusinessIdValue = this.curContract.ContractId;
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Utility.VerificationUtility ver = new Utility.VerificationUtility();
            ver.JudgeOperate(this.Page, 37, new List<NFMT.Common.OperateEnum>() { NFMT.Common.OperateEnum.录入 });

            user = Utility.UserUtility.CurrentUser;
            string redirectUrl = "ContractOutStockList.aspx";

            this.navigation1.Routes.Add("合约列表", "ContractList.aspx");
            this.navigation1.Routes.Add("库存列表", redirectUrl);
            this.navigation1.Routes.Add("合约添加", string.Empty);

            stockIds = Request.QueryString["ids"];
            //库存验证
            if (string.IsNullOrEmpty(stockIds))
                Utility.JsUtility.WarmAlert(this, "未选中任务库存", redirectUrl);

            string[] ids = stockIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (ids == null || ids.Length == 0)
                Utility.JsUtility.WarmAlert(this, "未选中任务库存", redirectUrl);

            int assetId = 0;
            int customsType = 0;

            NFMT.WareHouse.BLL.StockBLL stockBLL = new NFMT.WareHouse.BLL.StockBLL();
            NFMT.Common.ResultModel result = new NFMT.Common.ResultModel();
            NFMT.WareHouse.BLL.StockExclusiveBLL stockExclusiveBLL = new NFMT.WareHouse.BLL.StockExclusiveBLL();

            foreach (string id in ids)
            {
                int stockId = 0;
                if (!int.TryParse(id, out stockId) || stockId <= 0)
                    Utility.JsUtility.WarmAlert(this, "库存序号错误", redirectUrl);

                result = stockBLL.Get(user, stockId);
                if (result.ResultStatus != 0)
                    Utility.JsUtility.WarmAlert(this, result.Message, redirectUrl);

                NFMT.WareHouse.Model.Stock stock = result.ReturnValue as NFMT.WareHouse.Model.Stock;
                if (stock == null || stock.StockId <= 0)
                    Utility.JsUtility.WarmAlert(this, "库存不存在", redirectUrl);

                if (assetId == 0)
                    assetId = stock.AssetId;

                if (customsType == 0)
                {
                    customsType = stock.CustomsType;
                    if (customsType == (int)NFMT.WareHouse.CustomTypeEnum.关内)
                        curTradeBorder = (int)NFMT.Contract.TradeBorderEnum.内贸;
                    else
                        curTradeBorder = (int)NFMT.Contract.TradeBorderEnum.外贸;
                }

                //比较是否同一品种
                if (assetId != stock.AssetId)
                    Utility.JsUtility.WarmAlert(this, "选中库存非同一品种", redirectUrl);

                //比对关内外库存
                if (stock.CustomsType != customsType)
                    Utility.JsUtility.WarmAlert(this, "选中库存关境状态不相同", redirectUrl);

                result = stockExclusiveBLL.LoadByStockId(user, stock.StockId);
                if(result.ResultStatus!=0)
                    Utility.JsUtility.WarmAlert(this, result.Message, redirectUrl);

                List<NFMT.WareHouse.Model.StockExclusive> excs = result.ReturnValue as List<NFMT.WareHouse.Model.StockExclusive>;
                if (excs == null)
                    Utility.JsUtility.WarmAlert(this,"排他表获取失败", redirectUrl);

                decimal excAmount = excs.Sum(temp => temp.ExclusiveAmount);
                sumGrossAmount += (stock.CurNetAmount - excAmount);
            }

            NFMT.Data.Model.Asset asset = NFMT.Data.BasicDataProvider.Assets.FirstOrDefault(temp => temp.AssetId == assetId);
            this.curAsset = asset;

            //
            int pageIndex = 1;
            int pageSize = 100;
            string orderStr = string.Empty;
            NFMT.WareHouse.BLL.StockLogBLL stockLogBLL = new NFMT.WareHouse.BLL.StockLogBLL();
            NFMT.Common.SelectModel select = stockLogBLL.GetContractOutStockSelect(pageIndex, pageSize, orderStr, string.Empty, NFMT.Common.DefaultValue.DefaultTime, NFMT.Common.DefaultValue.DefaultTime, stockIds);
            result = stockLogBLL.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());
        }
        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 stockName = context.Request.QueryString["stockName"];
            DateTime fromDate = NFMT.Common.DefaultValue.DefaultTime;
            DateTime toDate = NFMT.Common.DefaultValue.DefaultTime;

            if (!string.IsNullOrEmpty(context.Request.QueryString["fromDate"]))
            {
                if (!DateTime.TryParse(context.Request.QueryString["fromDate"], out fromDate))
                    fromDate = NFMT.Common.DefaultValue.DefaultTime;
            }
            if (!string.IsNullOrEmpty(context.Request.QueryString["toDate"]))
            {
                if (!DateTime.TryParse(context.Request.QueryString["toDate"], 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 "CustomsTypeName":
                        sortDataField = "sto.CustomsType";
                        break;
                    default:
                        sortDataField = "sto.StockId";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            NFMT.WareHouse.BLL.StockLogBLL bll = new NFMT.WareHouse.BLL.StockLogBLL();
            NFMT.Common.SelectModel select = bll.GetContractOutStockSelect(pageIndex, pageSize, orderStr, stockName, 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);
        }