Exemplo n.º 1
0
 public ActionResult New(ItemKit itemKit)
 {
     itemKit.ChildItem = itemKit.ChildItemCode != null ? this.genericMgr.FindById<Item>(itemKit.ChildItemCode) : null;
     if (itemKit.ChildItem != null) ModelState.Remove("ChildItem");
     if (ModelState.IsValid)
     {
         itemKit.IsActive = true;
         if (this.genericMgr.FindAll<long>(isExistsStatement, new object[] { itemKit.KitItem, itemKit.ChildItem })[0] > 0)
         {
             SaveErrorMessage(Resources.EXT.ControllerLan.Con_TheKitAlreadyExists);
         }
         else if (string.IsNullOrEmpty(itemKit.KitItem) || itemKit.ChildItem == null || itemKit.Qty==null )
         {
             SaveErrorMessage(Resources.EXT.ControllerLan.Con_PleaseFillCanNotBeEmpty);
         }
         else
         {
             genericMgr.CreateWithTrim(itemKit);
             SaveSuccessMessage(Resources.EXT.ControllerLan.Con_KitCreatedSuccessfully);
             return RedirectToAction("Edit/" + itemKit.Id);
         }
     }
    // TempData["ItemDiscontinue"] = itemKit;
     return View(itemKit);
 }
Exemplo n.º 2
0
        public string Print(string cardNos)
        {
            IList<object> data = new List<object>();
            IList<KanbanCard> kanbanCardList = null;

            try
            {
                if (!string.IsNullOrEmpty(cardNos))
                {
                    string[] array = cardNos.Split(',');

                    string selectStatement = string.Empty;
                    IList<object> selectPartyPara = new List<object>();
                    foreach (var para in array)
                    {
                        if (selectStatement == string.Empty)
                        {
                            selectStatement = " from KanbanCard where CardNo in (?";
                        }
                        else
                        {
                            selectStatement += ",?";
                        }
                        selectPartyPara.Add(para);
                    }
                    selectStatement += ")";

                    kanbanCardList = genericMgr.FindAll<KanbanCard>(selectStatement, selectPartyPara.ToArray());
                }
                else
                {
                    throw new BusinessException("看板单号不能为空.");
                }

                foreach (var kanbanCard in kanbanCardList)
                {
                    if (string.IsNullOrEmpty(kanbanCard.LogisticCenterCode))
                    {
                        kanbanCard.LogisticCenterCode = kanbanCard.SupplierName;
                    }
                    Item item = genericMgr.FindById<Item>(kanbanCard.Item);
                    IList<ItemKit> itemKitList = null;

                    //如果是套件
                    if (item.IsKit)
                    {
                        itemKitList = genericMgr.FindAll<ItemKit>(" from ItemKit as i where i.KitItem=? ", kanbanCard.Item);
                        foreach (var itemKit in itemKitList)
                        {
                            itemKit.ChildItemDescription = genericMgr.FindById<Item>(itemKit.ChildItem).Description;
                        }
                        kanbanCard.ItemKitList = itemKitList;
                    }
                    else
                    {
                        IList<ItemKit> newsItemKit = new List<ItemKit>();
                        ItemKit itemKit = new ItemKit();
                        itemKit.ChildItemDescription = genericMgr.FindById<Item>(kanbanCard.Item).Description;
                        itemKit.ChildItem = genericMgr.FindById<Item>(kanbanCard.Item);
                        newsItemKit.Add(itemKit);
                        kanbanCard.ItemKitList = newsItemKit;
                    }


                }
                data.Add(kanbanCardList);
                var kanbanCardList1 = kanbanCardList.Where(p => p.ItemKitList.Count == 1).ToList();

                if (kanbanCardList[0].ItemKitList.Count() == 1)
                {
                    return reportGen.WriteToFile("BarCodeOneItemKitA4.xls", data);
                }
                else
                {
                    return reportGen.WriteToFile("BarCodesTwoItemkitA4.xls", data);
                }
            }
            catch (BusinessException ex)
            {
                SaveBusinessExceptionMessage(ex);


            }

            return string.Empty;
        }
Exemplo n.º 3
0
        public ActionResult _UpdateSave(ItemKit itemKit)
        {
            itemKit.ChildItem = itemKit.ChildItemCode != null ? this.genericMgr.FindById<Item>(itemKit.ChildItemCode) : null;

            if (ModelState.IsValid)
            {
                if (this.genericMgr.FindAll<long>(isExistsStatement, new object[] { itemKit.KitItem, itemKit.ChildItem })[0] > 0)
                {
                    SaveErrorMessage(Resources.EXT.ControllerLan.Con_TheKitAlreadyExists);
                }
                else
                {
                    this.genericMgr.UpdateWithTrim(itemKit);
                    SaveSuccessMessage(Resources.EXT.ControllerLan.Con_KitUpdatedSuccessfully);
                    return RedirectToAction("List");
                }
            }
            return RedirectToAction("Edit/" + itemKit.Id);

        }