예제 #1
0
        private object LoadBarcode()
        {
            if (ObjectUtility.LengthEqual(Barcode, 12))
            {
                IEnumerable enumerable = DepartmentPurchaseOrderLogic.ProcessBarcode(Barcode);
                IEnumerator enumerator = enumerable.GetEnumerator();
                enumerator.MoveNext();
                Product product = (Product)enumerator.Current;

                DepartmentPurchaseOrderDetail detail = new DepartmentPurchaseOrderDetail
                {
                    DelFlg = 0,
                    CreateDate = DateTime.Now,
                    CreateId = "admin",
                    UpdateDate = DateTime.Now,
                    UpdateId = "admin",
                    ExclusiveKey = 1,
                    Product = product,
                    ProductMaster = product.ProductMaster,
                    DepartmentPurchaseOrder = DepartmentPurchaseOrder,
                    Quantity = 1
                };

                if (product.AdhocCase > 0)
                    detail.AdhocCase = product.AdhocCase;
                long maxId = 0;
                if (PurchaseOrderDetails.Count > 0)
                {
                     maxId = PurchaseOrderDetails.OfType<DepartmentPurchaseOrderDetail>().Max(
                        det => det.DepartmentPurchaseOrderDetailPK.PurchaseOrderDetailId);
                }
                DepartmentPurchaseOrderDetailPK pk = new DepartmentPurchaseOrderDetailPK
                {
                    DepartmentId = 1,
                    PurchaseOrderDetailId = ++maxId,
                    PurchaseOrderId = DepartmentPurchaseOrder.DepartmentPurchaseOrderPK.PurchaseOrderId
                };
                detail.DepartmentPurchaseOrderDetailPK = pk;
                var detailList = new ArrayList(PurchaseOrderDetails);
                DepartmentPurchaseOrderDetail current =
                    detailList.OfType<DepartmentPurchaseOrderDetail>().FirstOrDefault(
                        det => det.Product.ProductId.Equals(detail.Product.ProductId));

                if (current != null)
                {
                    current.Quantity += 1;
                }
                else
                {
                    enumerator.MoveNext();
                    detail.Price = ((MainPrice)enumerator.Current).Price;
                    detailList.Add(detail);
                }

                PurchaseOrderDetails = detailList;
                CalculatePrice();
                Barcode = "";

            }
            return null;
        }
 public void Delete(DepartmentPurchaseOrderDetail data)
 {
     DepartmentPurchaseOrderDetailDao.Delete(data);
 }
 public void Update(DepartmentPurchaseOrderDetail data)
 {
     DepartmentPurchaseOrderDetailDao.Update(data);
 }
 public DepartmentPurchaseOrderDetail Add(DepartmentPurchaseOrderDetail data)
 {
     DepartmentPurchaseOrderDetailDao.Add(data);
     return data;
 }
        protected bool Equals(DepartmentPurchaseOrderDetail entity)
        {
            if (entity == null) return false;
            if (!base.Equals(entity)) return false;

            return true;
        }