Пример #1
0
    protected void cmdDelete_Click(object sender, EventArgs e)
    {
        LinkButton cmd = sender as LinkButton;

        if (cmd == null)
        {
            return;
        }
        string area = cmd.Attributes["area"];

        if (string.IsNullOrEmpty(area) || area.Trim().Length <= 0)
        {
            return;
        }
        using (ISession session = new Session())
        {
            WHAreaCfg cfg = WHAreaCfg.Retrieve(session, this.TransTypeCode, area);
            if (cfg != null)
            {
                cfg.Delete(session);

                this.BindArea(session);
                this.QueryAndBindData(session);
            }
        }
    }
Пример #2
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Add")
        {
            if (!string.IsNullOrEmpty(this.drpArea.SelectedValue))
            {
                using (ISession session = new Session())
                {
                    WHAreaCfg cfg = new WHAreaCfg();
                    cfg.AreaCfgCode     = this.TransTypeCode;
                    cfg.AreaCode        = this.drpArea.SelectedValue;
                    cfg.RequireAllChild = false;
                    cfg.Create(session);

                    this.BindArea(session);
                    this.QueryAndBindData(session);
                }
            }
        }
    }
Пример #3
0
        private static WHTransLine BuildTransLine(ISession session, TransItemWrapper wrapper, IWHTransHead transHead, int commitDate, int commitTime, ref int lineNumber, OrderTransDef orderTransDef)
        {
            WHArea area = null;

            WHTransLine line = new WHTransLine();

            line.LineNumber          = lineNumber++;
            line.SKUID               = wrapper.SKUID;
            line.TransDate           = commitDate;
            line.TransTime           = commitTime;
            line.UnitID              = wrapper.UnitID;
            line.CurrencyCode        = wrapper.CurrencyCode;
            line.RefOrderType        = transHead.OrderTypeCode;
            line.RefOrderNumber      = transHead.OrderNumber;
            line.RefOrderLine        = wrapper.LineNumber;
            line.OriginalOrderType   = transHead.OriginalOrderType;
            line.OriginalOrderNumber = transHead.OrginalOrderNumber;
            line.OriginalOrderLine   = wrapper.OriginalOrderLine;
            line.TaxValue            = wrapper.TaxValue;
            line.StockDetailID       = wrapper.StockDetailID;
            ItemSpec itemSpec = ItemSpec.Retrieve(session, line.SKUID);

            line.AvgMoveCost = itemSpec.AvgMoveCost;

            //TODO: 目前只支持的配置实现方式有限

            //交易类型
            if (orderTransDef.StepType == TransStepType.Single)
            {
                if (orderTransDef.TransTypeFrom == TransTypeFrom.ConfigValue)
                {
                    line.TransTypeCode = orderTransDef.TransTypeCode;
                }
                else if (orderTransDef.TransTypeFrom == TransTypeFrom.InterfaceValue)
                {
                    line.TransTypeCode = wrapper.TransTypeCode;
                }
                else
                {
                    throw new Exception(string.Format("WHTransaction: TransTypeFrom {0} not supported", (int)orderTransDef.TransTypeFrom));
                }
            }
            else if (orderTransDef.StepType == TransStepType.MultiSelect)
            {
                if (orderTransDef.TransTypeFrom == TransTypeFrom.InterfaceValue)
                {
                    line.TransTypeCode = wrapper.TransTypeCode;
                }
                else
                {
                    throw new Exception(string.Format("WHTransaction: TransTypeFrom {0} not supported by TransStepType.MultiSelect", (int)orderTransDef.TransTypeFrom));
                }
            }
            //交易数量
            if (orderTransDef.TransQtyFrom == TransQtyFrom.QualifiedQty)
            {
                line.TransQty = wrapper.QualifiedQty;
            }
            else if (orderTransDef.TransQtyFrom == TransQtyFrom.UnQualifiedQty)
            {
                line.TransQty = wrapper.UnQualifiedQty;
            }
            else
            {
                throw new Exception(string.Format("WHTransaction: TransQtyFrom {0} not supported", (int)orderTransDef.TransQtyFrom));
            }
            //交易仓库信息。LocationCode, AreaCode必须有,SectionCode可以有可以没有
            if (orderTransDef.TransLocationFrom == TransLocationFrom.ConfigValue)
            {
                //从(交易-仓库配置)中取库房区域、货架信息
                //不会从(产品-默认存储位置)读取,因为出入库单据如果用到(产品-默认存储位置),需要在界面提供选择,因此仓库获取类型变为TransLocationFrom.InterfaceValue
                IList <WHAreaCfg> areaCfg = WHAreaCfg.Retrieve(session, line.TransTypeCode);
                if (areaCfg == null || areaCfg.Count <= 0)
                {
                    throw new Exception(string.Format("WHTransaction: area cfg does not exists for transaction type {0}", line.TransTypeCode));
                }
                area = WHArea.Retrieve(session, areaCfg[0].AreaCode);
                if (area == null)
                {
                    throw new Exception(string.Format("WHTransaction: area {0} does not exist", areaCfg[0].AreaCode));
                }
                line.LocationCode = area.LocationCode;
                line.AreaCode     = area.AreaCode;
            }
            else if (orderTransDef.TransLocationFrom == TransLocationFrom.InterfaceValue)
            {
                if (string.IsNullOrEmpty(wrapper.LocationCode) || wrapper.LocationCode.Trim().Length <= 0 ||
                    string.IsNullOrEmpty(wrapper.AreaCode) || wrapper.AreaCode.Trim().Length <= 0)
                {
                    throw new Exception(string.Format("WHTransaction: LocationCode or AreaCode is empty in transaction order line {0}", wrapper.LineNumber));
                }
                line.LocationCode = wrapper.LocationCode;
                line.AreaCode     = wrapper.AreaCode;
                line.SectionCode  = wrapper.SectionCode;
            }
            else
            {
                throw new Exception(string.Format("WHTransaction: TransLocationFrom {0} not supported", (int)orderTransDef.TransLocationFrom));
            }

            area = WHArea.Retrieve(session, line.AreaCode);
            if (area == null)
            {
                throw new Exception(string.Format("WHTransaction: invalidate AreaCode {0}", line.AreaCode));
            }
            //如果库位被锁定(例如正在进行盘点作业)则不允许交易
            if (area.IsLocked && orderTransDef.TransTypeCode != "301") //盘点的交易类型为301
            {
                throw new Exception("库位" + area.AreaCode + "-" + area.Name + "正在盘点,无法执行出入库操作");
            }
            line.IsScrap     = area.IsScrap;
            line.IsQC        = area.IsQC;
            line.IsNonFormal = area.IsNonFormal;

            TransTypeDef transTypeDef = TransTypeDef.Retrieve(session, orderTransDef.TransTypeCode);

            if (transTypeDef == null)
            {
                throw new Exception(string.Format("WHTransaction: invalidate transaction type code {0}", orderTransDef.TransTypeCode));
            }
            line.TransQty = line.TransQty * ((int)transTypeDef.TransProperty);
            //交易描述
            line.TransReason = transTypeDef.TransDefText;
            if (!string.IsNullOrEmpty(transTypeDef.TransDefDesc) && transTypeDef.TransDefDesc.Trim().Length > 0)
            {
                line.TransReason = line.TransReason + " - " + transTypeDef.TransDefDesc;
            }
            //交易价格
            if (transTypeDef.PriceSourceType == TransTypePriceSource.FromSourceOrder)
            {
                line.TransPrice = wrapper.Price;
            }
            else if (transTypeDef.PriceSourceType == TransTypePriceSource.FromMovAvgCost)
            {
                line.TransPrice = itemSpec.AvgMoveCost;
            }
            else if (transTypeDef.PriceSourceType == TransTypePriceSource.FromAreaCfg)
            {
                if (!area.UseFixCost || area.CostFixValue < 0M)
                {
                    throw new Exception(string.Format("WHTransaction: TransTypePriceSource is FromAreaCfg, but it does not exists in AreaCode {0}", area.AreaCode));
                }
                line.TransPrice = area.CostFixValue;
            }
            line.TransPrice = line.TransPrice * area.CostTransRate - area.FixedComsumeValue;
            if (line.TransPrice < 0M)
            {
                line.TransPrice = 0M;
            }

            //if ((line.TransTypeCode == "101" || line.TransTypeCode == "301") && itemSpec.EnableOS)
            //{
            //    itemSpec.EnableOS = false;
            //    itemSpec.Update(session, "EnableOS");
            //}

            log.DebugFormat("trans line built: trans type:{0}, qty={1}, area={2}, section={3}, price={4}", line.TransTypeCode, line.TransQty, line.AreaCode, line.SectionCode, line.TransPrice);
            return(line);
        }