Esempio n. 1
0
        public override bool Equals(object obj)
        {
            ItemPackage another = obj as ItemPackage;

            if (another == null)
            {
                return(false);
            }
            else
            {
                return(this.Id == another.Id);
            }
        }
Esempio n. 2
0
 public void UpdateFlowDetail(FlowDetail flowDetail)
 {
     IList<ItemPackage> itemPackageList = genericMgr.FindAll<ItemPackage>("from ItemPackage as i where i.Item = ? and i.UnitCount = ?", new object[] { flowDetail.Item, flowDetail.UnitCount });
     if (itemPackageList == null || itemPackageList.Count == 0)
     {
         ItemPackage itemPackage = new ItemPackage();
         itemPackage.Item = flowDetail.Item;
         itemPackage.UnitCount = flowDetail.UnitCount;
         itemPackage.Description = string.IsNullOrEmpty(flowDetail.UnitCountDescription) ? string.Empty : flowDetail.UnitCountDescription;
         genericMgr.CreateWithTrim(itemPackage);
     }
     genericMgr.UpdateWithTrim(flowDetail);
 }
Esempio n. 3
0
        public ActionResult _ItemPackageComboBox(string controlName, string controlId, string selectedValue, string item)
        {
            ViewBag.ControlName = controlName;
            ViewBag.ControlId = controlId;
            IList<ItemPackage> itemPackageList = new List<ItemPackage>();
            if (!string.IsNullOrEmpty(item))
            {
                itemPackageList = base.genericMgr.FindAll<ItemPackage>("select i from ItemPackage as i where i.Item=?", item, firstRow, maxRow);
            }
            else if (selectedValue != null && selectedValue.Trim() != string.Empty)
            {
                itemPackageList = base.genericMgr.FindAll<ItemPackage>(selectEqItemPackageStatement, selectedValue, firstRow, maxRow);
            }

            if (!string.IsNullOrEmpty(selectedValue))
            {
                if (itemPackageList.Count < 1)
                {
                    ItemPackage itemPackage = new ItemPackage();
                    itemPackage.Item = item;
                    itemPackage.IsDefault = false;
                    itemPackage.UnitCount = decimal.Parse(selectedValue);
                    itemPackage.Description = selectedValue;
                    itemPackageList.Add(itemPackage);
                }
            }

            return PartialView(new SelectList(itemPackageList, "UnitCount", "UnitCount", selectedValue));
        }
Esempio n. 4
0
        public ActionResult _ItemPackageDropDownList(string controlName, string controlId, string selectedValue, bool? includeBlankOption, string blankOptionDescription, string blankOptionValue, string itemCode)
        {
            ViewBag.ControlName = controlName;
            ViewBag.ControlId = controlId;
            //ViewBag.SelectedValue = selectedValue;
            IList<ItemPackage> itemPackageList = base.genericMgr.FindAll<ItemPackage>("from ItemPackage as i where  i.Item=?", itemCode);
            if (itemPackageList == null)
            {
                itemPackageList = new List<ItemPackage>();
            }

            if (includeBlankOption.HasValue && includeBlankOption.Value)
            {
                ItemPackage blankItemPackage = new ItemPackage();
                blankItemPackage.UnitCount = Convert.ToDecimal(blankOptionValue);
                blankItemPackage.UnitCount = Convert.ToDecimal(blankOptionDescription);

                itemPackageList.Insert(0, blankItemPackage);
            }
            return PartialView(new SelectList(itemPackageList, "UnitCount", "UnitCount", selectedValue));
        }
Esempio n. 5
0
        public void UpdateItem(Item item)
        {
            string hql = "from ItemPackage where Item = ? and UnitCount = ?";
            IList<ItemPackage> itemPackageList = genericMgr.FindAll<ItemPackage>(hql, new object[] { item.Code, item.UnitCount });
            if (itemPackageList != null && itemPackageList.Count > 0)
            {
                ItemPackage itemPackage = itemPackageList[0];
                if (!itemPackage.IsDefault)
                {
                    itemPackage.IsDefault = true;
                    genericMgr.Update(itemPackage);
                }
            }
            else
            {
                #region 原默认包装至False
                hql = "from ItemPackage as i where i.Item = ? and i.IsDefault= ?";
                IList<ItemPackage> defualtItemPackageList = genericMgr.FindAll<ItemPackage>(hql, new object[] { item.Code, true });
                for (int i = 0; i < defualtItemPackageList.Count; i++)
                {
                    defualtItemPackageList[i].IsDefault = false;
                    this.genericMgr.Update(defualtItemPackageList[i]);
                }
                #endregion

                #region 没有找到包装,新增包装
                ItemPackage itemPackage = new ItemPackage();
                itemPackage.Item = item.Code;
                itemPackage.IsDefault = true;
                itemPackage.UnitCount = item.UnitCount;
                itemPackage.Description = string.Empty;
                this.genericMgr.Create(itemPackage);
                #endregion
            }

            genericMgr.Update(item);
        }
Esempio n. 6
0
        public void CreateItem(Item item)
        {
            ItemPackage itemPackage = new ItemPackage();
            itemPackage.Item = item.Code;
            itemPackage.IsDefault = true;
            itemPackage.UnitCount = item.UnitCount;
            itemPackage.Description = string.Empty;

            genericMgr.Create(item);
            genericMgr.Create(itemPackage);
        }
Esempio n. 7
0
        public void UpdateFlowDetail(FlowDetail flowDetail)
        {
            #region 零件标准包装
            var dbFlowDetail = this.genericMgr.FindById<FlowDetail>(flowDetail.Id);
            this.genericMgr.CleanSession();

            var flow = genericMgr.FindById<FlowMaster>(flowDetail.Flow);
            var locFrom = string.IsNullOrWhiteSpace(flowDetail.LocationFrom) ? flow.LocationFrom : flowDetail.LocationFrom;
            var locTo = string.IsNullOrWhiteSpace(flowDetail.LocationTo) ? flow.LocationTo : flowDetail.LocationTo;
            if (dbFlowDetail.Item != flowDetail.Item || dbFlowDetail.UnitCount != flowDetail.UnitCount || dbFlowDetail.UnitCountDescription != flowDetail.UnitCountDescription)
            {
                if (!string.IsNullOrWhiteSpace(locFrom))
                {
                    UpdateItemStandardPackByType(flowDetail, locFrom, "O");
                }
                if (!string.IsNullOrWhiteSpace(locTo))
                {
                    UpdateItemStandardPackByType(flowDetail, locTo, "I");
                }
            }
            else if (dbFlowDetail.LocationFrom != flowDetail.LocationFrom)
            {
                if (!string.IsNullOrWhiteSpace(locFrom))
                {
                    UpdateItemStandardPackByType(flowDetail, locFrom, "O");
                }
            }
            else if (dbFlowDetail.LocationTo != flowDetail.LocationTo)
            {
                if (!string.IsNullOrWhiteSpace(locTo))
                {
                    UpdateItemStandardPackByType(flowDetail, locTo, "I");
                }
            }

            #endregion

            IList<ItemPackage> itemPackageList = genericMgr.FindAll<ItemPackage>("from ItemPackage as i where i.Item = ? and i.UnitCount = ?", new object[] { flowDetail.Item, flowDetail.UnitCount });
            if (itemPackageList == null || itemPackageList.Count == 0)
            {
                ItemPackage itemPackage = new ItemPackage();
                itemPackage.Item = flowDetail.Item;
                itemPackage.UnitCount = flowDetail.UnitCount;
                itemPackage.Description = string.IsNullOrEmpty(flowDetail.UnitCountDescription) ? string.Empty : flowDetail.UnitCountDescription;
                genericMgr.Create(itemPackage);
            }
            genericMgr.Update(flowDetail);
        }
Esempio n. 8
0
        public void CreateFlowDetail(FlowDetail flowDetail)
        {
            IList<ItemPackage> itemPackageList = genericMgr.FindAll<ItemPackage>("from ItemPackage as i where i.Item = ? and i.UnitCount = ?", new object[] { flowDetail.Item, flowDetail.UnitCount });
            if (itemPackageList == null || itemPackageList.Count == 0)
            {
                ItemPackage itemPackage = new ItemPackage();
                itemPackage.Item = flowDetail.Item;
                itemPackage.UnitCount = flowDetail.UnitCount;
                itemPackage.Description = string.IsNullOrEmpty(flowDetail.UnitCountDescription) ? string.Empty : flowDetail.UnitCountDescription;
                genericMgr.Create(itemPackage);
            }
            genericMgr.Create(flowDetail);

            #region 更新计划协议历史数据,按照路线更新
            FlowMaster flow = genericMgr.FindById<FlowMaster>(flowDetail.Flow);
            ////允许新建的明细肯定是唯一有效的
            //IList<FlowDetail> flowDetailList = this.genericMgr.FindAll<FlowDetail>("select fd from FlowDetail as fd where fd.Item='" + flowDetail.Item + "' and IsActive <> 0 and exists (select 1 from FlowMaster as fm where fm.Code=fd.Flow and fm.PartyFrom='" + flow.PartyFrom + "' and fm.IsActive = 1)");
            //if (flowDetailList.Count == 1)
            //{
            //    Location location = flowDetail.IsActive ? genericMgr.FindById<Location>(flow.LocationTo) : null;
            //    Party partyTo = flowDetail.IsActive ? genericMgr.FindById<Party>(flow.PartyTo) : null;
            //    Address address = flowDetail.IsActive ? genericMgr.FindById<Address>(flow.ShipTo) : null;

            //    string updateMstr = "Update Ord_OrderMstr_8 set Flow = ?,FlowDesc = ?,PartyTo = ?,PartyToNm = ?,ShipTo = ?,ShipToAddr = ?,LocTo = ?,LocToNm = ? where  PartyFrom = ? and exists (select 1 from Ord_OrderDet_8 as d where d.Item = ? and Ord_OrderMstr_8.OrderNo=d.OrderNo)";
            //    genericMgr.FindAllWithNativeSql(updateMstr, new object[] { flow.Code, flow.Description, flow.PartyTo, partyTo.Name, flow.ShipTo, address.AddressContent, flow.LocationTo, location.Name, flow.PartyFrom, flowDetail.Item });
            //    string updateStr = "Update Ord_OrderDet_8 set LocTo = ?,LocToNm = ?,UC = ? where Item = ? and exists (select 1 from Ord_OrderMstr_8 as o where o.PartyFrom = ? and Ord_OrderDet_8.OrderNo=o.OrderNo)";
            //    genericMgr.FindAllWithNativeSql(updateStr, new object[] { flow.LocationTo, location.Name, flowDetail.UnitCount, flowDetail.Item, flow.PartyFrom });
            //}
            #endregion

            #region 将数据插入零件标准包装中间表
            //采购路线只有入库包装,移库路线才有出库/入库包装
            if (flow.Type == CodeMaster.OrderType.Transfer
                || flow.Type == CodeMaster.OrderType.Distribution
                || flow.Type == CodeMaster.OrderType.SubContractTransfer)
            {
                string locationFrom = string.IsNullOrWhiteSpace(flowDetail.LocationFrom) ? flow.LocationFrom : flowDetail.LocationFrom;
                if (string.IsNullOrWhiteSpace(locationFrom))
                {
                    var locTo = this.genericMgr.FindById<Location>(locationFrom);
                    CreateItemStandardPackByType(flowDetail, locTo, "I");
                }
            }

            if (flow.Type == CodeMaster.OrderType.Transfer
                || flow.Type == CodeMaster.OrderType.SubContractTransfer
                || flow.Type == CodeMaster.OrderType.SubContract
                || flow.Type == CodeMaster.OrderType.CustomerGoods
                || flow.Type == CodeMaster.OrderType.Procurement)
            {
                string locationTo = string.IsNullOrWhiteSpace(flowDetail.LocationTo) ? flow.LocationTo : flowDetail.LocationTo;
                if (string.IsNullOrWhiteSpace(locationTo))
                {
                    var locTo = this.genericMgr.FindById<Location>(locationTo);
                    CreateItemStandardPackByType(flowDetail, locTo, "I");
                }
            }
            #endregion
        }
Esempio n. 9
0
        public void CreateItem(Item item)
        {
            ItemPackage itemPackage = new ItemPackage();
            itemPackage.Item = item.Code;
            itemPackage.IsDefault = true;
            itemPackage.UnitCount = item.UnitCount;
            itemPackage.Description = string.Empty;

            genericMgr.Create(item);
            genericMgr.Create(itemPackage);
            this.ResetItemCache();
            GetCacheAllItem();
            //if (!cachedAllItem.ContainsKey(item.Code))
            //{
            //    cachedAllItem.Add(item.Code, item);
            //}
        }
Esempio n. 10
0
        public ActionResult ItemPackageNew(ItemPackage itemPackage)
        {
            if (ModelState.IsValid)
            {
                if (this.genericMgr.FindAll<long>(itemPackageDuiplicateVerifyStatement, new object[] { itemPackage.Id })[0] > 0)
                {
                    SaveErrorMessage(Resources.SYS.ErrorMessage.Errors_Existing_Code, itemPackage.Id.ToString());
                }
                else if (this.genericMgr.FindAll<long>(itemAndUnitCountIsExistStatement, new object[] { itemPackage.Item, itemPackage.UnitCount })[0] > 0)
                {
                    SaveErrorMessage(Resources.MD.ItemPackage.ItemPackageErrors_Existing_ItemAndUnitCount);
                }
                else if (itemPackage.UnitCount <= 0)
                {
                    SaveErrorMessage(Resources.EXT.ControllerLan.Con_UnitcountQuantityMustGreater);
                }
                else
                {
                    if (itemPackage.Description == null)
                    {
                        itemPackage.Description = string.Empty;
                    }
                    this.genericMgr.CreateWithTrim(itemPackage);

                    SaveSuccessMessage(Resources.MD.ItemPackage.ItemPackage_Added);
                    return RedirectToAction("ItemPackage/" + itemPackage.Item);
                }
            }

            return PartialView(itemPackage);
        }
Esempio n. 11
0
 public ActionResult ItemPackageNew(string id)
 {
     ItemPackage itemPackage = new ItemPackage();
     itemPackage.Item = id;
     return PartialView(itemPackage);
 }
Esempio n. 12
0
        public ActionResult ItemPackageNew(ItemPackage itemPackage)
        {
            if (ModelState.IsValid)
            {
                if (base.genericMgr.FindAll<long>(itemPackageDuiplicateVerifyStatement, new object[] { itemPackage.Id })[0] > 0)
                {
                    SaveErrorMessage(Resources.ErrorMessage.Errors_Existing_Code, itemPackage.Id.ToString());
                }
                else if (base.genericMgr.FindAll<long>(itemAndUnitCountIsExistStatement, new object[] { itemPackage.Item, itemPackage.UnitCount })[0] > 0)
                {
                    SaveErrorMessage(Resources.MD.ItemPackage.ItemPackageErrors_Existing_ItemAndUnitCount);
                }
                else if (itemPackage.UnitCount <= 0)
                {
                    SaveErrorMessage("包装数必须大于0");
                }
                else
                {
                    if (itemPackage.Description == null)
                    {
                        itemPackage.Description = string.Empty;
                    }
                    base.genericMgr.Create(itemPackage);

                    SaveSuccessMessage(Resources.MD.ItemPackage.ItemPackage_Added);
                    return RedirectToAction("ItemPackage/" + itemPackage.Item);
                }
            }

            return PartialView(itemPackage);
        }