예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            string redirectUrl = string.Format("{0}WareHouse/StockInList.aspx", NFMT.Common.DefaultValue.NftmSiteName);

            if (!IsPostBack)
            {
                Utility.VerificationUtility ver = new Utility.VerificationUtility();
                ver.JudgeOperate(this.Page, 41, new List<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);

                this.curStockType = (int)NFMT.Data.StyleEnum.库存类型;
                this.curCustomType = (int)NFMT.Data.StyleEnum.报关状态;

                if (string.IsNullOrEmpty(Request.QueryString["id"]))
                    Response.Redirect(redirectUrl);

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

                NFMT.WareHouse.BLL.StockInBLL stockInBLL = new NFMT.WareHouse.BLL.StockInBLL();
                NFMT.Common.ResultModel result = stockInBLL.Get(user, stockInId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                NFMT.WareHouse.Model.StockIn stockIn = result.ReturnValue as NFMT.WareHouse.Model.StockIn;
                this.curStockIn = stockIn;

                if (stockIn != null)
                {
                    NFMT.Common.AuditModel model = new NFMT.Common.AuditModel()
                    {
                        AssName = stockIn.AssName,
                        DalName = stockIn.DalName,
                        DataBaseName = stockIn.DataBaseName,
                        Id = stockIn.Id,
                        Status = stockIn.Status,
                        TableName = stockIn.TableName
                    };
                    string json = serializer.Serialize(model);
                    this.hidmodel.Value = json;
                }

                //获取入库合约关联表
                NFMT.WareHouse.BLL.ContractStockIn_BLL contractStockInBLL = new NFMT.WareHouse.BLL.ContractStockIn_BLL();
                NFMT.Common.ResultModel res = contractStockInBLL.GetByStockInId(user, stockIn.StockInId, NFMT.Common.StatusEnum.已录入);
                if (res.ResultStatus == 0)
                {
                    NFMT.WareHouse.Model.ContractStockIn contractStockIn = res.ReturnValue as NFMT.WareHouse.Model.ContractStockIn;
                    if (contractStockIn != null && contractStockIn.RefId > 0)
                    {
                        this.curContractStockIn = contractStockIn;

                        //获取子合约
                        NFMT.Contract.BLL.ContractSubBLL contractSubBLL = new NFMT.Contract.BLL.ContractSubBLL();
                        res = contractSubBLL.Get(user, contractStockIn.ContractSubId);
                        if (res.ResultStatus != 0)
                            Response.Redirect(redirectUrl);

                        NFMT.Contract.Model.ContractSub contractSub = res.ReturnValue as NFMT.Contract.Model.ContractSub;
                        if (contractSub == null)
                            Response.Redirect(redirectUrl);

                        this.curSubId = contractSub.SubId;

                        res = stockInBLL.Load(user, contractSub.SubId, NFMT.Common.StatusEnum.已录入);
                        if (res.ResultStatus != 0)
                            Response.Redirect(redirectUrl);

                        List<NFMT.WareHouse.Model.StockIn> stockIns = res.ReturnValue as List<NFMT.WareHouse.Model.StockIn>;
                        if (stockIns == null)
                            Response.Redirect(redirectUrl);

                        decimal sumWeight = stockIns.Sum(temp => temp.GrossAmount);
                        int contractId = contractSub.ContractId;

                        //获取合约
                        NFMT.Contract.BLL.ContractBLL contractBLL = new NFMT.Contract.BLL.ContractBLL();
                        res = contractBLL.Get(user, contractId);
                        if (res.ResultStatus != 0)
                            Response.Redirect(redirectUrl);

                        NFMT.Contract.Model.Contract contract = res.ReturnValue as NFMT.Contract.Model.Contract;
                        if (contract == null)
                            Response.Redirect(redirectUrl);

                        this.contractExpander1.CurContract = contract;
                        this.contractExpander1.CurContractSub = contractSub;
                        this.contractExpander1.RedirectUrl = redirectUrl;
                    }
                }
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Utility.VerificationUtility ver = new Utility.VerificationUtility();
                ver.JudgeOperate(this.Page, 41, new List<NFMT.Common.OperateEnum>() { NFMT.Common.OperateEnum.提交审核, NFMT.Common.OperateEnum.作废, NFMT.Common.OperateEnum.撤返 });

                string redirectUrl = "StockInContractList.aspx";

                this.navigation1.Routes.Add("入库分配列表", "StockInContractList.aspx");
                this.navigation1.Routes.Add("入库分配明细", string.Empty);

                if (string.IsNullOrEmpty(Request.QueryString["id"]))
                    Response.Redirect(redirectUrl);

                int refId = 0;
                if (!int.TryParse(Request.QueryString["id"], out refId))
                    Response.Redirect(redirectUrl);

                NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
                NFMT.Common.ResultModel result = new NFMT.Common.ResultModel();
                //获取入库分配
                NFMT.WareHouse.BLL.ContractStockIn_BLL contractStockInBLL = new NFMT.WareHouse.BLL.ContractStockIn_BLL();
                result = contractStockInBLL.Get(user, refId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                NFMT.WareHouse.Model.ContractStockIn contractStockIn = result.ReturnValue as NFMT.WareHouse.Model.ContractStockIn;
                if (contractStockIn == null || contractStockIn.RefId <= 0)
                    Response.Redirect(redirectUrl);

                this.curContractStockIn = contractStockIn;

                //获取入库登记
                NFMT.WareHouse.BLL.StockInBLL stockInBLL = new NFMT.WareHouse.BLL.StockInBLL();
                result = stockInBLL.Get(user, contractStockIn.StockInId);

                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                NFMT.WareHouse.Model.StockIn stockIn = result.ReturnValue as NFMT.WareHouse.Model.StockIn;
                if (stockIn == null || stockIn.StockInId <= 0)
                    Response.Redirect(redirectUrl);

                this.curStockIn = stockIn;

                NFMT.WareHouse.CustomTypeEnum customsType = (NFMT.WareHouse.CustomTypeEnum)stockIn.CustomType;
                this.CustomTypeName = customsType.ToString("F");

                NFMT.User.Model.Corporation corp = NFMT.User.UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == stockIn.CorpId);
                if (corp != null)
                    this.CorpName = corp.CorpName;

                NFMT.Data.Model.Asset asset = NFMT.Data.BasicDataProvider.Assets.FirstOrDefault(temp => temp.AssetId == stockIn.AssetId);
                if (asset != null)
                    this.AssetName = asset.AssetName;

                NFMT.Data.Model.MeasureUnit unit = NFMT.Data.BasicDataProvider.MeasureUnits.FirstOrDefault(temp => temp.MUId == stockIn.UintId);
                if (unit != null)
                    this.MUName = unit.MUName;

                NFMT.WareHouse.BLL.ContractStockIn_BLL bll = new NFMT.WareHouse.BLL.ContractStockIn_BLL();
                NFMT.Common.SelectModel select = bll.GetContractSelect(1, 100, "si.StockInId desc", stockIn.StockInId);
                result = bll.Load(user, select);
                int totalRows = result.AffectCount;
                System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
                this.curContractJson = 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(contractStockIn);
                this.hidModel.Value = json;
            }
        }
예제 #3
0
        public ResultModel InsertStockInContract(UserModel user,int contractId,int subId,List<int> stockLogIds)
        {
            ResultModel result = new ResultModel();

            int assetId = 0;
            int logDirection = 0;
            int customsType = 0;

            StockLogDAL stockLogDAL = new StockLogDAL();
            StockInDAL stockInDAL = new StockInDAL();
            ContractStockInDAL contractStockInDAL = new ContractStockInDAL();
            StockInStockDAL stockInStockDAL = new StockInStockDAL();

            foreach (int stockLogId in stockLogIds)
            {
                result = stockLogDAL.Get(user, stockLogId);
                if (result.ResultStatus != 0)
                    return result;

                NFMT.WareHouse.Model.StockLog stockLog = result.ReturnValue as NFMT.WareHouse.Model.StockLog;
                if (stockLog == null || stockLog.StockLogId <= 0)
                {
                    result.ResultStatus = -1;
                    result.Message = "库存流水不存在";
                    return result;
                }

                if(stockLog.LogStatus != StatusEnum.已生效)
                {
                    result.ResultStatus = -1;
                    result.Message = "库存流水状态不正确";
                    return result;
                }

                if (assetId == 0)
                    assetId = stockLog.AssetId;
                if (logDirection == 0)
                    logDirection = stockLog.LogDirection;
                if (customsType == 0)
                    customsType = stockLog.CustomsType;

                if (assetId != stockLog.AssetId)
                {
                    result.ResultStatus = -1;
                    result.Message = "选中库存存在品种不一致";
                    return result;
                }

                if (logDirection != stockLog.LogDirection)
                {
                    result.ResultStatus = -1;
                    result.Message = "选中库存存在流水方向不一致";
                    return result;
                }

                if (customsType != stockLog.CustomsType)
                {
                    result.ResultStatus = -1;
                    result.Message = "选中库存存在关境不一致";
                    return result;
                }

                result = stockInStockDAL.GetByStockLogId(user, stockLog.StockLogId);
                if (result.ResultStatus != 0)
                    return result;

                NFMT.WareHouse.Model.StockInStock stockInStock = result.ReturnValue as NFMT.WareHouse.Model.StockInStock;
                if (stockInStock == null || stockInStock.RefId <= 0)
                {
                    result.ResultStatus = -1;
                    result.Message = "库存流水与入库登记关系获取失败";
                    return result;
                }

                NFMT.WareHouse.Model.ContractStockIn contractStockIn = new NFMT.WareHouse.Model.ContractStockIn();
                contractStockIn.ContractId = contractId;
                contractStockIn.ContractSubId = subId;
                contractStockIn.RefStatus = StatusEnum.已生效;
                contractStockIn.StockInId = stockInStock.StockInId;

                result = contractStockInDAL.Insert(user, contractStockIn);
                if (result.ResultStatus != 0)
                    return result;
            }

            return result;
        }