public string GenerateRMHuId(FlowDetail flowDetail, string lotNo, decimal qty, string idMark)
        {
            #region 物料条码
            //if (flowDetail.BarCodeType == BusinessConstants.CODE_MASTER_RAW_MATERIAL_BAR_CODE_TYPE_VALUE_DEFAULT)
            //{

            //}
            //else
            //{

            //}
            //ItemCode+供应商标识(1位)+年 月 日4位 + 数量(4位,不足4位以0补齐)+生产序号(3位,不足3位以0补齐)
            string itemCode  = flowDetail.Item.Code;
            string supIdMark = idMark != null && idMark.Trim() != string.Empty ? idMark :
                               (flowDetail.IdMark != null && flowDetail.IdMark.Trim() != string.Empty
                ? flowDetail.IdMark.Trim() : BusinessConstants.DEFAULT_SUPPLIER_ID_MARK);
            if (lotNo != null && lotNo.Trim().Length != 0)
            {
                LotNoHelper.validateLotNo(lotNo);
            }
            else
            {
                lotNo = LotNoHelper.GenerateLotNo();
            }
            if (flowDetail.Item.Uom.Code != flowDetail.Uom.Code)
            {
                qty = qty * this.uomConversionMgr.ConvertUomQty(flowDetail.Item, flowDetail.Uom, 1, flowDetail.Item.Uom);   //单位用量
            }
            string qtyStr = qty.ToString().PadLeft(4, '0');

            string barCodePrefix = itemCode + supIdMark + lotNo + qtyStr;
            return(GenerateNumber(barCodePrefix, 3));

            #endregion
        }
        public string GenerateFGHuId(OrderDetail orderDetail, decimal qty, string idMark)
        {
            #region 成品条码
            //if (orderDetail.BarCodeType == BusinessConstants.CODE_MASTER_FINISH_GOODS_BAR_CODE_TYPE_VALUE_DEFAULT)
            //{

            //}
            //else
            //{

            //}
            //生产线识别码2位+产品识别码(1位) +生产日期4位 (规则同5.5.1.2中的供货日期编码) +班别号1位 (以大写字母表示) +3位顺序号
            string pl = orderDetail.OrderHead.Flow;
            if (pl.Length > 2)
            {
                //如果生产线代码长度大于2,取后两位
                pl = pl.Substring(pl.Length - 2);
            }

            string pIdMark = idMark != null && idMark.Trim() != string.Empty ? idMark :
                             (orderDetail.IdMark != null && orderDetail.IdMark.Trim() != string.Empty
                ? orderDetail.IdMark.Trim() : BusinessConstants.DEFAULT_FINISHI_GOODS_ID_MARK);
            string lotNo = LotNoHelper.GenerateLotNo();
            string shift = orderDetail.OrderHead.Shift.Code;

            string barCodePrefix = pl + pIdMark + lotNo + shift;
            return(GenerateNumber(barCodePrefix, 3));

            #endregion
        }
    public void InitPageParameter(OrderHead orderHead)
    {
        this.GV_List.DataSource = orderHead.OrderDetails;

        #region 设置默认LotNo
        string lotNo = LotNoHelper.GenerateLotNo();
        foreach (OrderDetail orderDetail in orderHead.OrderDetails)
        {
            orderDetail.HuLotNo = lotNo;
        }
        #endregion

        this.GV_List.DataBind();
    }
Beispiel #4
0
    public void InitPageParameter(Flow flow)
    {
        this.PartyFromCode = flow.PartyFrom.Code;
        this.PartyToCode   = flow.PartyTo.Code;
        this.FlowType      = flow.Type;
        this.FlowCode      = flow.Code;

        int seqInterval = int.Parse(TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL).Value);

        if (flow.AllowCreateDetail && false) //新增的Detail打印有问题,暂时不支持
        {
            FlowDetail blankFlowDetail = new FlowDetail();
            if (flow.FlowDetails == null || flow.FlowDetails.Count == 0)
            {
                blankFlowDetail.Sequence = seqInterval;
            }
            else
            {
                int CurrentSeq = flow.FlowDetails.Last <FlowDetail>().Sequence + seqInterval;
                blankFlowDetail.Sequence = CurrentSeq;
            }
            blankFlowDetail.IsBlankDetail = true;
            flow.AddFlowDetail(blankFlowDetail);
        }

        #region 设置默认LotNo
        string lotNo = LotNoHelper.GenerateLotNo();
        foreach (FlowDetail flowDetail in flow.FlowDetails)
        {
            flowDetail.HuLotNo = lotNo;
        }
        #endregion

        this.GV_List.DataSource = flow.FlowDetails;
        this.GV_List.DataBind();

        BindShift();

        if (flow.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
        {
            this.TabProd.Visible            = false;
            this.GV_List.Columns[8].Visible = true;
        }
        else
        {
            this.TabProd.Visible            = true;
            this.GV_List.Columns[8].Visible = false;
        }
    }
Beispiel #5
0
 public ActionResult _AjaxIpDetailList(GridCommand command, IpDetailSearchModel searchModel)
 {
     if (string.IsNullOrEmpty(searchModel.IpNo))
     {
         return(PartialView(new GridModel(new List <IpDetail>())));
     }
     else
     {
         SearchStatementModel searchStatementModel = PrepareIpDetailSearchStatement(command, searchModel);
         GridModel <IpDetail> List = GetAjaxPageData <IpDetail>(searchStatementModel, command);
         foreach (IpDetail flow in List.Data)
         {
             IpMaster item = base.genericMgr.FindById <IpMaster>(flow.IpNo);
             flow.ManufactureParty = item.PartyFrom;
             flow.LotNo            = LotNoHelper.GenerateLotNo();
             flow.HuQty            = flow.Qty;
         }
         return(PartialView(List));
     }
 }
        private Hu ResolveAndCreateHu(string barCode, OrderDetail orderDetail, decimal qty)
        {
            string[] splitedBarcode  = BarcodeHelper.SplitFGBarcode(barCode);
            Item     item            = orderDetail.Item;
            string   lotNo           = splitedBarcode[2];
            DateTime manufactureDate = LotNoHelper.ResolveLotNo(lotNo);


            Hu hu = new Hu();

            hu.HuId = barCode;
            hu.Item = item;
            hu.Uom  = orderDetail.Uom;  //用Flow单位
            #region 单位用量
            if (item.Uom.Code != orderDetail.Uom.Code)
            {
                hu.UnitQty = this.uomConversionMgr.ConvertUomQty(item, orderDetail.Uom, 1, item.Uom);   //单位用量
            }
            else
            {
                hu.UnitQty = 1;
            }
            #endregion
            hu.QualityLevel     = BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_1;
            hu.Qty              = qty;
            hu.UnitCount        = orderDetail.UnitCount;
            hu.LotNo            = lotNo;
            hu.LotSize          = qty;
            hu.ManufactureDate  = manufactureDate;
            hu.ManufactureParty = orderDetail.OrderHead.PartyFrom;
            hu.CreateUser       = this.userMgr.GetMonitorUser();
            hu.CreateDate       = DateTime.Now;
            hu.Status           = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CREATE;

            this.huMgr.CreateHu(hu);
            this.numberControlMgr.ReverseUpdateHuId(barCode);

            return(hu);
        }
        public string GenerateRMHuId(OrderDetail orderDetail, string lotNo, decimal qty, string idMark)
        {
            #region 物料条码
            //if (orderDetail.BarCodeType == BusinessConstants.CODE_MASTER_RAW_MATERIAL_BAR_CODE_TYPE_VALUE_DEFAULT)
            //{

            //}
            //else
            //{

            //}
            //ItemCode+供应商标识(1位)+年 月 日4位 + 数量(4位,不足4位以0补齐)+生产序号(3位,不足3位以0补齐)
            string itemCode  = orderDetail.Item.Code;
            string supIdMark = idMark != null && idMark.Trim() != string.Empty ? idMark :
                               (orderDetail.IdMark != null && orderDetail.IdMark.Trim() != string.Empty
                ? orderDetail.IdMark.Trim() : BusinessConstants.DEFAULT_SUPPLIER_ID_MARK);
            if (lotNo != null && lotNo.Trim().Length != 0)
            {
                LotNoHelper.validateLotNo(lotNo);
            }
            else
            {
                lotNo = LotNoHelper.GenerateLotNo();
            }

            //单位换算,转换为基本单位
            //理论上应该qty * inOrderLocationTransaction.UnitQty,现在暂时直接用单位换算
            if (orderDetail.Item.Uom.Code != orderDetail.Uom.Code)
            {
                qty = qty * uomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Uom, qty, orderDetail.Item.Uom);
            }

            string qtyStr = qty.ToString("0.########").PadLeft(4, '0');

            string barCodePrefix = itemCode + supIdMark + lotNo + qtyStr;
            return(GenerateNumber(barCodePrefix, 3));

            #endregion
        }
Beispiel #8
0
        public ActionResult _AjaxFlowDetailList(GridCommand command, FlowDetailSearchModel searchModel)
        {
            SearchStatementModel   searchStatementModel = PrepareDetailFlowSearchStatement(command, searchModel);
            GridModel <FlowDetail> List = GetAjaxPageData <FlowDetail>(searchStatementModel, command);

            if (!string.IsNullOrEmpty(searchModel.Flow))
            {
                FlowMaster flowMaster = base.genericMgr.FindById <FlowMaster>(searchModel.Flow);

                foreach (FlowDetail flowDetail in List.Data)
                {
                    flowDetail.ManufactureParty = flowMaster.PartyFrom;
                    flowDetail.LotNo            = LotNoHelper.GenerateLotNo();
                }

                foreach (FlowDetail flowDetail in List.Data)
                {
                    Item item = base.genericMgr.FindById <Item>(flowDetail.Item);
                    flowDetail.ItemDescription = item.Description;
                }
            }
            return(PartialView(List));
        }
Beispiel #9
0
        public ActionResult _AjaxOrderDetailList(GridCommand command, OrderMasterSearchModel searchModel)
        {
            com.Sconit.Entity.ACC.User user            = SecurityContextHolder.Get();
            IList <OrderMaster>        orderMasterList = null;

            if (user.Code.Trim().ToLower() != "su")
            {
                orderMasterList = base.genericMgr.FindAll <OrderMaster>("from OrderMaster as o where o.OrderNo=?  and exists (select 1 from UserPermissionView as up where up.UserId =" + user.Id + " and up.PermissionCategoryType = " + (int)com.Sconit.CodeMaster.PermissionCategoryType.Supplier + " and up.PermissionCode = o.PartyFrom)", searchModel.OrderNo);
                if (orderMasterList.Count <= 0)
                {
                    return(PartialView(new GridModel(new List <OrderDetail>())));
                }
            }
            SearchStatementModel    searchStatementModel = PrepareOrderDetailSearchStatement(command, searchModel);
            GridModel <OrderDetail> List = GetAjaxPageData <OrderDetail>(searchStatementModel, command);

            try
            {
                foreach (OrderDetail orderDetail in List.Data)
                {
                    orderDetail.LotNo = LotNoHelper.GenerateLotNo();
                }
                OrderMaster order = base.genericMgr.FindById <OrderMaster>(searchModel.OrderNo);
                foreach (OrderDetail orderDetail in List.Data)
                {
                    orderDetail.ManufactureParty = order.PartyFrom;
                    orderDetail.HuQty            = orderDetail.OrderedQty;
                }

                return(View(List));
            }
            catch (Exception)
            {
                return(PartialView(new GridModel(new List <IpLocationDetail>())));
            }
        }
Beispiel #10
0
        private IList <Hu> CreateHu(Item item, decimal qty, string lotNo, Uom uom, decimal unitCount, int?huLotSize,
                                    string orderNo, string recNo, DateTime?manufactureDate, Party manufactureParty, string qualityLevel, User user, Object obj, string shiftCode, string itemVersion, string idMark, string customerItemCode)
        {
            IList <Hu> huList = new List <Hu>();

            #region 根据Hu批量创建Hu
            decimal  remainHuQty  = qty;                                      //剩余量
            decimal  currentHuQty = GetNextHuQty(ref remainHuQty, huLotSize); //本次量
            DateTime dateTimeNow  = DateTime.Now;

            while (currentHuQty > 0)
            {
                #region 创建Hu
                Hu hu = new Hu();
                #region HuId生成
                if (obj.GetType() == typeof(FlowDetail))
                {
                    FlowDetail flowDetail = (FlowDetail)obj;
                    if (flowDetail.Flow.Type != BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PRODUCTION)
                    {
                        lotNo   = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo();
                        hu.HuId = this.numberControlMgr.GenerateRMHuId(flowDetail, lotNo, currentHuQty, idMark);
                    }
                    else
                    {
                        if (shiftCode != null && shiftCode.Trim().Length != 0)
                        {
                            lotNo   = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo();
                            hu.HuId = this.numberControlMgr.GenerateFGHuId(flowDetail, shiftCode, currentHuQty, idMark);
                        }
                        else
                        {
                            throw new TechnicalException("ShiftCode can't be null when create fg huId by flowdetail");
                        }
                    }
                }
                else if (obj.GetType() == typeof(OrderDetail))
                {
                    OrderDetail orderDetail = (OrderDetail)obj;
                    if (orderDetail.OrderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                    {
                        lotNo   = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo(orderDetail.OrderHead.WindowTime);
                        hu.HuId = this.numberControlMgr.GenerateRMHuId(orderDetail, lotNo, currentHuQty, idMark);
                    }
                    else
                    {
                        lotNo   = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo(orderDetail.OrderHead.WindowTime);
                        hu.HuId = this.numberControlMgr.GenerateFGHuId(orderDetail, currentHuQty, idMark);
                    }
                }
                else if (obj.GetType() == typeof(InProcessLocationDetail))
                {
                    InProcessLocationDetail inProcessLocationDetail = (InProcessLocationDetail)obj;
                    if (inProcessLocationDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type
                        != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                    {
                        lotNo   = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo();
                        hu.HuId = this.numberControlMgr.GenerateRMHuId(inProcessLocationDetail, lotNo, currentHuQty);
                    }
                    else
                    {
                        throw new TechnicalException("Can't create fg huid by InProcessLocationDetail");
                    }
                }
                else if (obj.GetType() == typeof(ReceiptDetail))
                {
                    ReceiptDetail receiptDetail = (ReceiptDetail)obj;
                    if (receiptDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type
                        != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                    {
                        lotNo   = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo();
                        hu.HuId = this.numberControlMgr.GenerateRMHuId(receiptDetail, lotNo, currentHuQty);
                    }
                    else
                    {
                        lotNo   = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo();
                        hu.HuId = this.numberControlMgr.GenerateFGHuId(receiptDetail, currentHuQty);
                    }
                }
                else
                {
                    throw new TechnicalException("Parameter obj only accept type: FlowDetail, OrderDetail, InProcessLocationDetail, ReceiptDetail");
                }
                #endregion
                hu.Item      = item;
                hu.OrderNo   = orderNo;
                hu.ReceiptNo = recNo;
                hu.Uom       = uom; //用订单单位
                hu.UnitCount = unitCount;
                #region 单位用量
                //如果是OrderDetail,应该等于inOrderLocationTransaction.UnitQty,现在暂时直接用单位换算
                if (item.Uom.Code != uom.Code)
                {
                    hu.UnitQty = this.uomConversionMgr.ConvertUomQty(item, uom, 1, item.Uom);   //单位用量
                }
                else
                {
                    hu.UnitQty = 1;
                }
                #endregion
                hu.QualityLevel     = qualityLevel;
                hu.Qty              = currentHuQty;
                hu.LotNo            = lotNo;
                hu.ManufactureDate  = manufactureDate.HasValue ? manufactureDate.Value : LotNoHelper.ResolveLotNo(hu.LotNo);
                hu.ManufactureParty = manufactureParty;
                hu.CreateUser       = user;
                hu.CreateDate       = dateTimeNow;
                hu.LotSize          = huLotSize.HasValue ? huLotSize.Value : currentHuQty;
                hu.Version          = itemVersion;
                hu.Status           = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CREATE;
                hu.CustomerItemCode = customerItemCode;

                this.CreateHu(hu);
                #endregion

                huList.Add(hu);
                currentHuQty = GetNextHuQty(ref remainHuQty, huLotSize);
            }
            #endregion

            return(huList);
        }
Beispiel #11
0
        public IList <Hu> CreateHu(IList <OrderDetail> orderDetailList, User user, string idMark, string packageType)
        {
            if (orderDetailList != null && orderDetailList.Count > 0)
            {
                IList <Hu> huList    = new List <Hu>();
                int?       huLotSize = null;
                foreach (OrderDetail orderDetail in orderDetailList)
                {
                    if (packageType == BusinessConstants.CODE_MASTER_PACKAGETYPE_INNER)
                    {
                        huLotSize = Convert.ToInt32(orderDetail.UnitCount);
                    }
                    else
                    {
                        huLotSize = orderDetail.HuLotSize;
                    }
                    string lotNo = orderDetail.HuLotNo != null && orderDetail.HuLotNo.Trim().Length != 0 ? orderDetail.HuLotNo.Trim() : LotNoHelper.GenerateLotNo(orderDetail.OrderHead.WindowTime);
                    IListHelper.AddRange <Hu>(huList,
                                              CreateHu(orderDetail.Item, orderDetail.OrderedQty, lotNo, orderDetail.Uom, orderDetail.UnitCount, huLotSize,
                                                       null, null, null, orderDetail.OrderHead.PartyFrom, BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_1, user, orderDetail, null, orderDetail.ItemVersion, idMark, orderDetail.CustomerItemCode));
                }

                return(huList);
            }

            return(null);
        }
Beispiel #12
0
        public JsonResult CreateHuByOrderDetail(string OrderDetailidStr, string OrderDetailucStr, string OrderDetailsupplierLotNoStr, string OrderDetailqtyStr, bool OrderDetailisExport)
        {
            try
            {
                IList <OrderDetail> nonZeroOrderDetailList = new List <OrderDetail>();
                if (!string.IsNullOrEmpty(OrderDetailidStr))
                {
                    string[]    idArray            = OrderDetailidStr.Split(',');
                    string[]    ucArray            = OrderDetailucStr.Split(',');
                    string[]    supplierLotNoArray = OrderDetailsupplierLotNoStr.Split(',');
                    string[]    qtyArray           = OrderDetailqtyStr.Split(',');
                    OrderMaster orderMaster        = null;

                    if (idArray != null && idArray.Count() > 0)
                    {
                        for (int i = 0; i < idArray.Count(); i++)
                        {
                            OrderDetail orderDetail = base.genericMgr.FindById <OrderDetail>(Convert.ToInt32(idArray[i]));
                            if (orderMaster == null)
                            {
                                orderMaster            = base.genericMgr.FindById <OrderMaster>(orderDetail.OrderNo);
                                orderMaster.HuTemplate = orderMaster.HuTemplate.Trim();
                            }

                            orderDetail.UnitCount        = Convert.ToDecimal(ucArray[i]);
                            orderDetail.SupplierLotNo    = supplierLotNoArray[i];
                            orderDetail.LotNo            = LotNoHelper.GenerateLotNo();
                            orderDetail.ManufactureParty = orderMaster.PartyFrom;
                            orderDetail.HuQty            = Convert.ToDecimal(qtyArray[i]);
                            nonZeroOrderDetailList.Add(orderDetail);
                        }
                    }
                    base.genericMgr.CleanSession();
                    if (string.IsNullOrEmpty(orderMaster.HuTemplate))
                    {
                        orderMaster.HuTemplate = this.systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.DefaultBarCodeTemplate);
                    }

                    if (orderMaster != null)
                    {
                        IList <Hu> huList = huMgr.CreateHu(orderMaster, nonZeroOrderDetailList);
                        foreach (var hu in huList)
                        {
                            hu.ManufacturePartyDescription = base.genericMgr.FindById <Party>(hu.ManufactureParty).Name;
                        }

                        if (OrderDetailisExport)
                        {
                            IList <PrintHu> printHuList = Mapper.Map <IList <Hu>, IList <PrintHu> >(huList);

                            IList <object> data = new List <object>();
                            data.Add(printHuList);
                            data.Add(CurrentUser.FullName);
                            reportGen.WriteToClient(orderMaster.HuTemplate, data, orderMaster.HuTemplate);
                            return(Json(null));
                        }
                        else
                        {
                            //CreateBarCode(huList, null);
                            string printUrl = PrintHuList(huList, orderMaster.HuTemplate);

                            SaveSuccessMessage("条码打印成功,共打印了{0}张条码", huList.Count.ToString());
                            return(Json(new { PrintUrl = printUrl }));
                        }
                    }
                }
                return(Json(null));
            }
            catch (BusinessException ex)
            {
                SaveBusinessExceptionMessage(ex);
            }
            catch (Exception ex)
            {
                SaveErrorMessage(ex);
            }
            return(Json(null));
        }
Beispiel #13
0
        public JsonResult CreateHuByFlow(string FlowidStr, string FlowucStr, string FlowsupplierLotNoStr, string FlowqtyStr, bool FlowisExport)
        {
            try
            {
                IList <FlowDetail> nonZeroFlowDetailList = new List <FlowDetail>();
                if (!string.IsNullOrEmpty(FlowidStr))
                {
                    string[]   idArray            = FlowidStr.Split(',');
                    string[]   ucArray            = FlowucStr.Split(',');
                    string[]   supplierLotNoArray = FlowsupplierLotNoStr.Split(',');
                    string[]   qtyArray           = FlowqtyStr.Split(',');
                    FlowMaster flowMaster         = null;

                    if (idArray != null && idArray.Count() > 0)
                    {
                        for (int i = 0; i < idArray.Count(); i++)
                        {
                            FlowDetail flowDetail = base.genericMgr.FindById <FlowDetail>(Convert.ToInt32(idArray[i]));
                            if (flowMaster == null)
                            {
                                flowMaster = base.genericMgr.FindById <FlowMaster>(flowDetail.Flow);
                            }

                            flowDetail.UnitCount        = Convert.ToDecimal(ucArray[i]);
                            flowDetail.SupplierLotNo    = supplierLotNoArray[i];
                            flowDetail.LotNo            = LotNoHelper.GenerateLotNo();
                            flowDetail.ManufactureParty = flowMaster.PartyFrom;
                            flowDetail.HuQty            = Convert.ToDecimal(qtyArray[i]);
                            nonZeroFlowDetailList.Add(flowDetail);
                        }
                    }

                    base.genericMgr.CleanSession();
                    if (flowMaster != null)
                    {
                        IList <Hu> huList = huMgr.CreateHu(flowMaster, nonZeroFlowDetailList);
                        foreach (var hu in huList)
                        {
                            hu.ManufacturePartyDescription = base.genericMgr.FindById <Party>(hu.ManufactureParty).Name;
                        }

                        if (FlowisExport)
                        {
                            IList <PrintHu> printHuList = Mapper.Map <IList <Hu>, IList <PrintHu> >(huList);

                            IList <object> data = new List <object>();
                            data.Add(printHuList);
                            data.Add(CurrentUser.FullName);
                            reportGen.WriteToClient(flowMaster.HuTemplate, data, flowMaster.HuTemplate);
                            return(Json(null));
                        }
                        else
                        {
                            //CreateBarCode(huList, null);
                            string printUrl = PrintHuList(huList, flowMaster.HuTemplate);
                            SaveSuccessMessage("条码打印成功,共打印了{0}张条码", huList.Count.ToString());
                            return(Json(new { PrintUrl = printUrl }));
                        }
                    }
                }
                return(Json(null));
            }
            catch (BusinessException ex)
            {
                SaveBusinessExceptionMessage(ex);
            }
            catch (Exception ex)
            {
                SaveErrorMessage(ex);
            }
            return(Json(null));
        }
Beispiel #14
0
    //返回订单明细
    private IList <FlowDetail> PopulateFlowDetailList(bool includeBlank)
    {
        if (this.GV_List.Rows != null && this.GV_List.Rows.Count > 0)
        {
            Flow               flow           = null;
            DateTime?          winTime        = null;
            IList <FlowDetail> flowDetailList = new List <FlowDetail>();
            if (this.tbWinTime.Text.Trim() != string.Empty)
            {
                winTime = DateTime.Parse(this.tbWinTime.Text.Trim());
            }

            int seqInterval = int.Parse(TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL).Value);
            int lastSeq     = 0;

            foreach (GridViewRow row in this.GV_List.Rows)
            {
                HiddenField hfId       = (HiddenField)row.FindControl("hfId");
                TextBox     tbLotNo    = (TextBox)row.FindControl("tbLotNo");
                TextBox     tbOrderQty = (TextBox)row.FindControl("tbOrderQty");

                if (hfId.Value != string.Empty && hfId.Value != "0")
                {
                    FlowDetail flowDetail = TheFlowDetailMgr.LoadFlowDetail(int.Parse(hfId.Value));
                    flowDetail.HuLotNo    = tbLotNo.Text.Trim() != string.Empty ? tbLotNo.Text.Trim() : null;
                    flowDetail.OrderedQty = tbOrderQty.Text != string.Empty ? decimal.Parse(tbOrderQty.Text) : decimal.Zero;
                    flowDetailList.Add(flowDetail);
                    lastSeq = flowDetail.Sequence;
                    if (flow == null)
                    {
                        flow = flowDetail.Flow;
                    }

                    if (flow.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                    {
                        flowDetail.HuLotNo = tbLotNo.Text.Trim() != string.Empty ? tbLotNo.Text.Trim() : null;
                    }
                    else
                    {
                        flowDetail.HuLotNo     = LotNoHelper.GenerateLotNo(winTime.Value);
                        flowDetail.HuShiftCode = this.ucShift.ShiftCode;
                    }
                }
                else
                {
                    if (!includeBlank)
                    {
                        continue;
                    }

                    if (flow == null)
                    {
                        flow = this.TheFlowMgr.LoadFlow(this.FlowCode);
                    }

                    TextBox          tbNewSeq      = (TextBox)row.FindControl("tbSeq");
                    Controls_TextBox tbNewItemCode = (Controls_TextBox)row.FindControl("tbItemCode");
                    Controls_TextBox tbNewUom      = (Controls_TextBox)row.FindControl("tbUom");
                    com.Sconit.Control.CodeMstrDropDownList ddlPackageType = (com.Sconit.Control.CodeMstrDropDownList)row.FindControl("ddlPackageType");
                    TextBox tbNewUnitCount = (TextBox)row.FindControl("tbUnitCount");
                    TextBox tbNewOrderQty  = (TextBox)row.FindControl("tbOrderQty");

                    FlowDetail newFlowDetail = new FlowDetail();
                    newFlowDetail.Sequence      = tbNewSeq.Text != string.Empty ? int.Parse(tbNewSeq.Text) : (lastSeq + seqInterval);
                    newFlowDetail.Item          = this.TheItemMgr.LoadItem(tbNewItemCode.Text.Trim());
                    newFlowDetail.Uom           = this.TheUomMgr.LoadUom(tbNewUom.Text.Trim());
                    newFlowDetail.PackageType   = ddlPackageType.SelectedValue;
                    newFlowDetail.UnitCount     = tbNewUnitCount.Text.Trim() != string.Empty ? decimal.Parse(tbNewUnitCount.Text) : 1;
                    newFlowDetail.OrderedQty    = tbNewOrderQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(tbNewOrderQty.Text.Trim());
                    newFlowDetail.Flow          = flow;
                    newFlowDetail.IsBlankDetail = true;

                    if (flow.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                    {
                        newFlowDetail.HuLotNo = tbLotNo.Text.Trim() != string.Empty ? tbLotNo.Text.Trim() : null;
                    }
                    else
                    {
                        newFlowDetail.HuLotNo     = LotNoHelper.GenerateLotNo(winTime.Value);
                        newFlowDetail.HuShiftCode = this.ucShift.ShiftCode;
                    }

                    flowDetailList.Add(newFlowDetail);
                }
            }

            return(flowDetailList);
        }

        return(null);
    }
Beispiel #15
0
    protected void lbtnAdd_Click(object sender, EventArgs e)
    {
        IList <FlowDetail> flowDetailList = PopulateFlowDetailList(true);

        if (CheckItemExists(flowDetailList))
        {
            return;
        }

        int                    newRowId    = flowDetailList != null ? flowDetailList.Count - 1 : 0;
        GridViewRow            newRow      = this.GV_List.Rows[newRowId];
        RequiredFieldValidator rfvItemCode = (RequiredFieldValidator)newRow.FindControl("rfvItemCode");
        RequiredFieldValidator rfvUom      = (RequiredFieldValidator)newRow.FindControl("rfvUom");
        int                    seqInterval = int.Parse(TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_SEQ_INTERVAL).Value);

        if (rfvItemCode.IsValid && rfvUom.IsValid)
        {
            if (flowDetailList != null)
            {
                Flow       flow       = flowDetailList[0].Flow;
                FlowDetail flowDetail = flowDetailList.Last <FlowDetail>();
                flowDetailList.RemoveAt(newRowId);

                if (flowDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
                {
                    IList <ItemKit> itemKitList = this.TheItemKitMgr.GetChildItemKit(flowDetail.Item);
                    decimal?        convertRate = null;

                    foreach (ItemKit itemKit in itemKitList)
                    {
                        if (!convertRate.HasValue)
                        {
                            if (itemKit.ParentItem.Uom.Code != flowDetail.Uom.Code)
                            {
                                convertRate = this.TheUomConversionMgr.ConvertUomQty(flowDetail.Item, flowDetail.Uom, 1, itemKit.ParentItem.Uom);
                            }
                            else
                            {
                                convertRate = 1;
                            }
                        }

                        FlowDetail newKitFlowDetail = new FlowDetail();

                        newKitFlowDetail.Sequence      = flowDetailList.Last <FlowDetail>().Sequence + seqInterval;
                        newKitFlowDetail.Item          = itemKit.ChildItem;
                        newKitFlowDetail.Uom           = itemKit.ChildItem.Uom;
                        newKitFlowDetail.UnitCount     = flowDetail.UnitCount * itemKit.Qty * convertRate.Value;
                        newKitFlowDetail.OrderedQty    = flowDetail.OrderedQty * itemKit.Qty * convertRate.Value;
                        newKitFlowDetail.PackageType   = flowDetail.PackageType;
                        newKitFlowDetail.IsBlankDetail = false;
                        newKitFlowDetail.Flow          = flow;

                        flowDetailList.Add(newKitFlowDetail);
                    }
                }
                else
                {
                    flowDetail.IsBlankDetail = false;
                    flowDetailList.Add(flowDetail);
                }

                FlowDetail blankFlowDetail = new FlowDetail();
                blankFlowDetail.Sequence      = flowDetailList.Last <FlowDetail>().Sequence + seqInterval;
                blankFlowDetail.IsBlankDetail = true;
                blankFlowDetail.HuLotNo       = LotNoHelper.GenerateLotNo();
                flowDetailList.Add(blankFlowDetail);

                this.GV_List.DataSource = flowDetailList;
                this.GV_List.DataBind();
            }
        }
    }