Ejemplo n.º 1
0
    protected void tbFlow_TextChanged(Object sender, EventArgs e)
    {
        try
        {
            if (this.CurrentFlowCode == null || this.CurrentFlowCode != this.tbFlow.Text)
            {
                Flow currentFlow = TheFlowMgr.LoadFlow(this.tbFlow.Text);
                if (currentFlow != null)
                {
                    this.CurrentFlowCode = currentFlow.Code;

                    if (currentFlow.IsListDetail)
                    {
                        currentFlow.FlowDetails = TheFlowDetailMgr.GetFlowDetail(currentFlow);
                    }
                    else
                    {
                        currentFlow.FlowDetails = new List <FlowDetail>();
                    }

                    this.ucList.InitPageParameter(currentFlow);
                    this.ucList.Visible = true;
                }
            }
        }
        catch (BusinessErrorException ex)
        {
            this.ShowErrorMessage(ex);
        }
    }
Ejemplo n.º 2
0
    protected void CheckAllItem(object source, ServerValidateEventArgs args)
    {
        Controls_TextBox tbLocFrom         = (Controls_TextBox)this.FV_Flow.FindControl("tbLocFrom");
        Controls_TextBox tbLocTo           = (Controls_TextBox)this.FV_Flow.FindControl("tbLocTo");
        Controls_TextBox tbRefFlow         = (Controls_TextBox)this.FV_Flow.FindControl("tbRefFlow");
        CustomValidator  cvCheckDetailItem = (CustomValidator)this.FV_Flow.FindControl("cvCheckDetailItem");

        if (tbRefFlow != null && tbRefFlow.Text.Trim() != string.Empty)
        {
            Flow flow = TheFlowMgr.LoadFlow(FlowCode);

            List <FlowDetail> flowDetailList    = (List <FlowDetail>)TheFlowDetailMgr.GetFlowDetail(flow);
            List <FlowDetail> refFlowDetailList = (List <FlowDetail>)TheFlowDetailMgr.GetFlowDetail(tbRefFlow.Text.Trim());
            if (!FlowHelper.CheckDetailSeqExists(flowDetailList, refFlowDetailList))
            {
                args.IsValid = false;
                ShowErrorMessage("MasterData.Flow.RefFlow.Sequence.Exists");
                return;
            }
            ;


            List <string[]> itemList = new List <string[]>();
            foreach (FlowDetail flowDetail in flowDetailList)
            {
                string[] item = new string[5];
                item[0] = flowDetail.Item.Code;
                item[1] = flowDetail.Uom.Code;
                item[2] = flowDetail.DefaultLocationFrom != null ? flowDetail.DefaultLocationFrom.Code : string.Empty;
                item[3] = flowDetail.DefaultLocationTo != null ? flowDetail.DefaultLocationTo.Code : string.Empty;
                item[4] = flowDetail.UnitCount.ToString();
                itemList.Add(item);
            }

            foreach (FlowDetail refFlowDetail in refFlowDetailList)
            {
                string[] item = new string[5];
                item[0] = refFlowDetail.Item.Code;
                item[1] = refFlowDetail.Uom.Code;
                item[2] = refFlowDetail.LocationFrom != null ? refFlowDetail.LocationFrom.Code : tbLocFrom.Text.Trim();
                item[3] = refFlowDetail.LocationTo != null ? refFlowDetail.LocationTo.Code : tbLocTo.Text.Trim();
                item[4] = refFlowDetail.UnitCount.ToString();
                if (!FlowHelper.CheckDetailItemExists(itemList, item))
                {
                    args.IsValid = false;
                    ShowErrorMessage("MasterData.Flow.FlowDetail.Item.Code.Exists", item[0]);
                }
                else
                {
                    itemList.Add(item);
                }
            }
        }
    }
Ejemplo n.º 3
0
    protected void checkSeqExists(object source, ServerValidateEventArgs args)
    {
        String seq = ((TextBox)(this.FV_FlowDetail.FindControl("tbSeq"))).Text.Trim();

        IList <FlowDetail> flowDetailList = TheFlowDetailMgr.GetFlowDetail(this.FlowCode, true);

        if (flowDetailList != null && flowDetailList.Count > 0)
        {
            foreach (FlowDetail flowDetail in flowDetailList)
            {
                if (flowDetail.Sequence == int.Parse(seq) && flowDetail.Id != this.FlowDetailId)
                {
                    args.IsValid = false;
                    break;
                }
            }
        }
    }
Ejemplo n.º 4
0
    public FlowDetailProxy GenerateFlowDetailProxy(string flowCode, string itemCode, string moduleType, string partyFromCode, string partyToCode, bool changeRef, DateTime startTime)
    {
        IList <FlowDetail> flowDetailList = TheFlowDetailMgr.GetFlowDetail(flowCode, true);

        if (flowDetailList != null && flowDetailList.Count > 0)
        {
            foreach (FlowDetail fd in flowDetailList)
            {
                if (fd.Item.Code == itemCode)
                {
                    FlowDetailProxy flowDetailProxy = new FlowDetailProxy();
                    flowDetailProxy.ItemCode        = fd.Item.Code;
                    flowDetailProxy.ItemDescription = fd.Item.Description;
                    if (changeRef)
                    {
                        flowDetailProxy.ItemReferenceCode = fd.ReferenceItemCode;
                    }
                    flowDetailProxy.UomCode   = fd.Uom.Code;
                    flowDetailProxy.UnitCount = fd.UnitCount;
                    flowDetailProxy.HuLotSize = fd.HuLotSize == null?Convert.ToInt32(fd.UnitCount) : fd.HuLotSize;

                    if (moduleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
                    {
                        if (fd.DefaultPriceListFrom != null)
                        {
                            flowDetailProxy.PriceListCode = fd.DefaultPriceListFrom.Code;
                            PriceListDetail priceListDetailFrom = ThePriceListDetailMgr.GetLastestPriceListDetail(fd.DefaultPriceListFrom, fd.Item, startTime, fd.Flow.Currency, fd.Uom);
                            if (priceListDetailFrom != null)
                            {
                                flowDetailProxy.UnitPrice         = priceListDetailFrom.UnitPrice;
                                flowDetailProxy.PriceListDetailId = priceListDetailFrom.Id;
                            }
                        }
                    }
                    else if (moduleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
                    {
                        if (fd.DefaultPriceListTo != null)
                        {
                            flowDetailProxy.PriceListCode = fd.DefaultPriceListTo.Code;
                            PriceListDetail priceListDetailTo = ThePriceListDetailMgr.GetLastestPriceListDetail(fd.DefaultPriceListTo, fd.Item, startTime, fd.Flow.Currency, fd.Uom);
                            if (priceListDetailTo != null)
                            {
                                flowDetailProxy.UnitPrice         = priceListDetailTo.UnitPrice;
                                flowDetailProxy.PriceListDetailId = priceListDetailTo.Id;
                            }
                        }
                        flowDetailProxy.PackageVolumn = fd.PackageVolumn;
                    }

                    if (changeRef)
                    {
                        if (fd.ReferenceItemCode != null && fd.ReferenceItemCode != string.Empty)
                        {
                            flowDetailProxy.ItemReferenceCode = fd.ReferenceItemCode;
                        }
                        else
                        {
                            flowDetailProxy.ItemReferenceCode = TheItemReferenceMgr.GetItemReferenceByItem(itemCode, partyToCode, partyFromCode);
                        }
                    }
                    return(flowDetailProxy);
                }
            }
        }

        Item item = TheItemMgr.LoadItem(itemCode);

        if (item != null)
        {
            Flow            flow            = TheFlowMgr.LoadFlow(flowCode);
            FlowDetailProxy flowDetailProxy = new FlowDetailProxy();
            flowDetailProxy.ItemCode        = item.Code;
            flowDetailProxy.ItemDescription = item.Description;
            flowDetailProxy.UomCode         = item.Uom.Code;

            if (moduleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
            {
                if (flow.PriceListFrom != null)
                {
                    flowDetailProxy.PriceListCode = flow.PriceListFrom.Code;
                    PriceListDetail priceListDetailFrom = ThePriceListDetailMgr.GetLastestPriceListDetail(flow.PriceListFrom, item, startTime, flow.Currency, item.Uom);
                    if (priceListDetailFrom != null)
                    {
                        flowDetailProxy.UnitPrice         = priceListDetailFrom.UnitPrice;
                        flowDetailProxy.PriceListDetailId = priceListDetailFrom.Id;
                    }
                }
            }
            else if (moduleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
            {
                if (flow.PriceListTo != null)
                {
                    flowDetailProxy.PriceListCode = flow.PriceListTo.Code;
                    PriceListDetail priceListDetailTo = ThePriceListDetailMgr.GetLastestPriceListDetail(flow.PriceListTo, item, startTime, flow.Currency, item.Uom);
                    if (priceListDetailTo != null)
                    {
                        flowDetailProxy.UnitPrice         = priceListDetailTo.UnitPrice;
                        flowDetailProxy.PriceListDetailId = priceListDetailTo.Id;
                    }
                }
            }

            if (changeRef)
            {
                flowDetailProxy.ItemReferenceCode = TheItemReferenceMgr.GetItemReferenceByItem(itemCode, partyToCode, partyFromCode);
            }
            flowDetailProxy.UnitCount = item.UnitCount;
            flowDetailProxy.HuLotSize = Convert.ToInt32(item.UnitCount);
            return(flowDetailProxy);
        }

        return(null);
    }
Ejemplo n.º 5
0
 public FlowDetail[] LoadFlowDetail(string flowCode)
 {
     return(TheFlowDetailMgr.GetFlowDetail(flowCode).ToArray());
 }
Ejemplo n.º 6
0
    protected void checkItemExists(object source, ServerValidateEventArgs args)
    {
        Flow    flow      = TheFlowMgr.LoadFlow(this.FlowCode, true);
        string  itemCode  = ((Controls_TextBox)(this.FV_FlowDetail.FindControl("tbItemCode"))).Text;
        string  uomCode   = ((Controls_TextBox)(this.FV_FlowDetail.FindControl("tbUom"))).Text;
        decimal unitCount = decimal.Parse(((TextBox)(this.FV_FlowDetail.FindControl("tbUC"))).Text);
        string  locFrom   = string.Empty;
        string  locTo     = string.Empty;

        if (this.ModuleType == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PROCUREMENT ||
            this.ModuleType == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_CUSTOMERGOODS ||
            this.ModuleType == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_SUBCONCTRACTING)
        {
            Controls_TextBox tbLocTo = (Controls_TextBox)this.FV_FlowDetail.FindControl("tbProcurementLocTo");
            if (tbLocTo != null && tbLocTo.Text.Trim() != string.Empty)
            {
                locTo = tbLocTo.Text.Trim();
            }
            else
            {
                locTo = flow.LocationTo != null ? flow.LocationTo.Code : string.Empty;
            }
            locFrom = string.Empty;
        }
        else if (this.ModuleType == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_DISTRIBUTION)
        {
            Controls_TextBox tbLocFrom = (Controls_TextBox)this.FV_FlowDetail.FindControl("tbDistributionLocFrom");
            if (tbLocFrom != null && tbLocFrom.Text.Trim() != string.Empty)
            {
                locFrom = tbLocFrom.Text.Trim();
            }
            else
            {
                locFrom = flow.LocationFrom != null ? flow.LocationFrom.Code : string.Empty;
            }
            locTo = string.Empty;
        }
        else if (this.ModuleType == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PRODUCTION)
        {
            Controls_TextBox tbLocFrom = (Controls_TextBox)this.FV_FlowDetail.FindControl("tbProductionLocFrom");
            if (tbLocFrom != null && tbLocFrom.Text.Trim() != string.Empty)
            {
                locFrom = tbLocFrom.Text.Trim();
            }
            else
            {
                locFrom = flow.LocationFrom != null ? flow.LocationFrom.Code : string.Empty;
            }
            Controls_TextBox tbLocTo = (Controls_TextBox)this.FV_FlowDetail.FindControl("tbProductionLocTo");
            if (tbLocTo != null && tbLocTo.Text.Trim() != string.Empty)
            {
                locTo = tbLocTo.Text.Trim();
            }
            else
            {
                locTo = flow.LocationTo != null ? flow.LocationTo.Code : string.Empty;
            }
        }
        else if (this.ModuleType == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_TRANSFER)
        {
            Controls_TextBox tbLocFrom = (Controls_TextBox)this.FV_FlowDetail.FindControl("tbTransferLocFrom");
            if (tbLocFrom != null && tbLocFrom.Text.Trim() != string.Empty)
            {
                locFrom = tbLocFrom.Text.Trim();
            }
            else
            {
                locFrom = flow.LocationFrom != null ? flow.LocationFrom.Code : string.Empty;
            }
            Controls_TextBox tbLocTo = (Controls_TextBox)this.FV_FlowDetail.FindControl("tbTransferLocTo");
            if (tbLocTo != null && tbLocTo.Text.Trim() != string.Empty)
            {
                locTo = tbLocTo.Text.Trim();
            }
            else
            {
                locTo = flow.LocationTo != null ? flow.LocationTo.Code : string.Empty;
            }
        }

        IList <FlowDetail> flowDetailList = flow.FlowDetails;

        if (flowDetailList != null && flowDetailList.Count > 0)
        {
            foreach (FlowDetail flowDetail in flowDetailList)
            {
                string defaultLocFrom = flowDetail.DefaultLocationFrom == null ? string.Empty : flowDetail.DefaultLocationFrom.Code;
                string defaultLocTo   = flowDetail.DefaultLocationTo == null ? string.Empty : flowDetail.DefaultLocationTo.Code;
                if (flowDetail.Item.Code == itemCode && flowDetail.Uom.Code == uomCode && defaultLocFrom == locFrom && defaultLocTo == locTo && flowDetail.Id != this.FlowDetailId && flowDetail.UnitCount == unitCount)
                {
                    args.IsValid = false;
                    ((CustomValidator)(this.FV_FlowDetail.FindControl("cvItemCheck"))).ErrorMessage = "${MasterData.Flow.FlowDetail.ItemCode.Exists}";
                    break;
                }
            }
        }
        if (flow.ReferenceFlow != null && flow.ReferenceFlow.Trim() != string.Empty && args.IsValid)
        {
            IList <FlowDetail> refFlowDetailList = TheFlowDetailMgr.GetFlowDetail(flow.ReferenceFlow);
            if (refFlowDetailList != null && refFlowDetailList.Count > 0)
            {
                foreach (FlowDetail flowDetail in refFlowDetailList)
                {
                    string defaultLocFrom = flowDetail.DefaultLocationFrom == null ? string.Empty : flowDetail.DefaultLocationFrom.Code;
                    string defaultLocTo   = flowDetail.DefaultLocationTo == null ? string.Empty : flowDetail.DefaultLocationTo.Code;
                    if (flowDetail.Item.Code == itemCode && flowDetail.Uom.Code == uomCode && defaultLocFrom == locFrom && defaultLocTo == locTo && flowDetail.UnitCount == unitCount)
                    {
                        args.IsValid = false;
                        ((CustomValidator)(this.FV_FlowDetail.FindControl("cvItemCheck"))).ErrorMessage = "${MasterData.Flow.FlowDetail.ItemCode.Exists}";
                        break;
                    }
                }
            }
        }
    }