Пример #1
0
        public OrderBinding CreateOrderBinding(OrderHead order, Flow bindedFlow, string bindingType)
        {
            OrderBinding orderBinding = new OrderBinding();

            orderBinding.OrderHead = order;
            orderBinding.BindedFlow = bindedFlow;
            orderBinding.BindingType = bindingType;

            this.CreateOrderBinding(orderBinding);

            return orderBinding;
        }
    public override void UpdateView()
    {
        OrderHead orderHead = TheOrderHeadMgr.LoadOrderHead(this.OrderNo);
        IList<OrderBinding> orderBindingList = TheOrderBindingMgr.GetOrderBinding(this.OrderNo);
        if (orderHead.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE)
        {
            OrderBinding orderBinding = new OrderBinding();
            orderBinding.IsBlank = true;
            orderBindingList.Add(orderBinding);
            this.GV_List.Columns[4].Visible = true;
        }
        else
        {
            this.GV_List.Columns[4].Visible = false;
        }

        this.Visible = orderBindingList.Count == 0 ? false : true;

        this.GV_List.DataSource = orderBindingList;
        this.GV_List.DataBind();
    }
 public virtual void DeleteOrderBinding(OrderBinding entity)
 {
     Delete(entity);
 }
 public virtual void UpdateOrderBinding(OrderBinding entity)
 {
     Update(entity);
 }
 public virtual void CreateOrderBinding(OrderBinding entity)
 {
     Create(entity);
 }
    protected void GV_List_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //添加
        if (e.CommandName.Equals("AddBinding"))
        {
            int index = int.Parse(e.CommandArgument.ToString());
            GridViewRow row = this.GV_List.Rows[index];

            string flowCode = ((Controls_TextBox)row.FindControl("tbFlow")).Text.Trim();
            if (flowCode == string.Empty)
            {
                ShowErrorMessage("MasterData.Order.Binding.Flow.Empty");
                return;
            }
            string bindingType = ((DropDownList)row.FindControl("ddlBindingType")).SelectedValue;
            string remark = ((TextBox)row.FindControl("tbRemark")).Text.Trim();

            #region 检查是否存在
            OrderHead orderHead = TheOrderHeadMgr.LoadOrderHead(this.OrderNo);
            if (orderHead.Flow == flowCode)
            {
                ShowErrorMessage("MasterData.Order.Binding.Self");
                return;
            }
            for (int i = 0; i < index; i++)
            {
                GridViewRow oneRow = this.GV_List.Rows[i];
                string oneFlowCode = ((Label)oneRow.FindControl("lbFlow")).Text.Trim();
                if (flowCode == oneFlowCode)
                {
                    ShowErrorMessage("MasterData.Order.Binding.Flow.Exists");
                    return;
                }
            }
            #endregion

            OrderBinding orderBinding = new OrderBinding();
            orderBinding.OrderHead = orderHead;
            orderBinding.BindedFlow = TheFlowMgr.LoadFlow(flowCode);
            orderBinding.BindingType = bindingType;
            orderBinding.Remark = remark;
            TheOrderBindingMgr.CreateOrderBinding(orderBinding);
            ShowSuccessMessage("MasterData.Order.Binding.Add.Successfully");
            UpdateView();
        }
        else if (e.CommandName.Equals("DeleteBinding"))
        {
            int id = int.Parse(e.CommandArgument.ToString());
            TheOrderBindingMgr.DeleteOrderBinding(id);
            ShowSuccessMessage("MasterData.Order.Binding.Delete.Successfully");
            UpdateView();
        }
    }
Пример #7
0
        private OrderHead CreateBindingOrder(OrderBinding orderBinding, OrderHead refenceOrderhead, User user)
        {
            OrderHead bindedOrderHead = this.TransferFlow2Order(orderBinding.BindedFlow);
            bindedOrderHead.OrderDetails = new List<OrderDetail>();

            foreach (OrderDetail orderDetail in refenceOrderhead.OrderDetails)
            {
                IList<FlowDetail> bindedFlowDetailList = this.flowBindingMgr.GetBindedFlowDetail(
                    orderDetail, orderBinding.BindedFlow.Code);

                if (bindedFlowDetailList != null && bindedFlowDetailList.Count > 0)
                {
                    foreach (FlowDetail bindedFlowDetail in bindedFlowDetailList)
                    {
                        OrderDetail binedOrderDetail = (from od in bindedOrderHead.OrderDetails where od.Item.Code == bindedFlowDetail.Item.Code select od).SingleOrDefault();
                        if (binedOrderDetail != null)
                        {
                            #region 合并相同的零件
                            //对于生产,相同的零件可以出现在不同的工序里,绑定的时候需要合并
                            if (binedOrderDetail.Uom.Code != bindedFlowDetail.Uom.Code)
                            {
                                decimal qty = this.uomConversionMgr.ConvertUomQty(binedOrderDetail.Item, bindedFlowDetail.Uom, bindedFlowDetail.OrderedQty, binedOrderDetail.Uom);
                                binedOrderDetail.OrderedQty += qty;
                                binedOrderDetail.RequiredQty += qty;
                            }
                            else
                            {
                                binedOrderDetail.OrderedQty += bindedFlowDetail.OrderedQty;
                                binedOrderDetail.RequiredQty += bindedFlowDetail.OrderedQty;
                            }
                            #endregion
                        }
                        else
                        {
                            bool isReferenceFlow = (bindedFlowDetail.Flow.Code != orderBinding.BindedFlow.Code);
                            IList<OrderDetail> newOrderDetailList = this.orderDetailMgr.GenerateOrderDetail(bindedOrderHead, bindedFlowDetail, isReferenceFlow);
                            if (newOrderDetailList.Count == 1)
                            {
                                newOrderDetailList[0].OrderedQty = bindedFlowDetail.OrderedQty;
                                newOrderDetailList[0].RequiredQty = bindedFlowDetail.OrderedQty;
                            }
                            else if (newOrderDetailList.Count > 1)
                            {
                                #region 处理套件的RequiredQty、OrderedQty
                                IList<ItemKit> itemKitList = this.itemKitMgr.GetChildItemKit(bindedFlowDetail.Item.Code);

                                decimal? convertRate = null;
                                foreach (ItemKit itemKit in itemKitList)
                                {
                                    if (!convertRate.HasValue)
                                    {
                                        if (itemKit.ParentItem.Uom.Code != bindedFlowDetail.Uom.Code)
                                        {
                                            convertRate = this.uomConversionMgr.ConvertUomQty(orderDetail.Item, bindedFlowDetail.Uom, bindedFlowDetail.OrderedQty, itemKit.ParentItem.Uom);
                                        }
                                        else
                                        {
                                            convertRate = 1;
                                        }
                                    }

                                    foreach (OrderDetail newOrderDetail in newOrderDetailList)
                                    {
                                        if (newOrderDetail.Item.Code == itemKit.ChildItem.Code)
                                        {
                                            newOrderDetail.RequiredQty = bindedFlowDetail.OrderedQty * itemKit.Qty * convertRate.Value;
                                            newOrderDetail.OrderedQty = bindedFlowDetail.OrderedQty * itemKit.Qty * convertRate.Value;
                                        }
                                    }
                                }
                                #endregion
                            }
                        }
                    }
                }
            }

            if (bindedOrderHead.OrderDetails.Count > 0)
            {
                Decimal leadTime = orderBinding.BindedFlow.LeadTime.HasValue ? orderBinding.BindedFlow.LeadTime.Value : 0;
                bindedOrderHead.ReferenceOrderNo = refenceOrderhead.OrderNo;
                bindedOrderHead.StartTime = DateTime.Now;
                bindedOrderHead.WindowTime = refenceOrderhead.StartTime.AddHours(double.Parse(leadTime.ToString()));
                bindedOrderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL;
                if (orderBinding.BindingType == BusinessConstants.CODE_MASTER_BINDING_TYPE_VALUE_RECEIVE_SYN)
                {
                    bindedOrderHead.IsAutoRelease = true;
                    bindedOrderHead.IsAutoStart = true;
                    bindedOrderHead.IsAutoShip = false;
                    bindedOrderHead.IsAutoReceive = false;
                    bindedOrderHead.StartLatency = 0;
                    bindedOrderHead.CompleteLatency = 0;
                }
                else if (orderBinding.BindingType == BusinessConstants.CODE_MASTER_BINDING_TYPE_VALUE_RECEIVE_ASYN)
                {
                    bindedOrderHead.IsAutoRelease = true;
                    bindedOrderHead.StartLatency = 0;
                }
                this.CreateOrder(bindedOrderHead, user);

                orderBinding.BindedOrderNo = bindedOrderHead.OrderNo;
                this.orderBindingMgr.UpdateOrderBinding(orderBinding);
            }

            return bindedOrderHead;
        }
 public virtual void DeleteOrderBinding(OrderBinding entity)
 {
     entityDao.DeleteOrderBinding(entity);
 }
 public virtual void UpdateOrderBinding(OrderBinding entity)
 {
     entityDao.UpdateOrderBinding(entity);
 }
 public virtual void CreateOrderBinding(OrderBinding entity)
 {
     entityDao.CreateOrderBinding(entity);
 }