Пример #1
0
        public override void Edit(IDBCommon entity)
        {
            InventoryItem_CU_ID = ((InventoryItemPrice_cu)ActiveDBItem).InventoryItem_CU_ID;
            InventoryItem_UnitMeasurment_cu bridge =
                InventoryItem_UnitMeasurment_cu.ItemsList.Find(
                    item =>
                    Convert.ToInt32(item.ID)
                    .Equals(Convert.ToInt32(((InventoryItemPrice_cu)ActiveDBItem).InventoryItem_UnitMeasurment_CU_ID)));

            if (bridge != null)
            {
                UnitMeasurment_cu unitMeasurment =
                    UnitMeasurment_cu.ItemsList.Find(
                        item => Convert.ToInt32(item.ID).Equals(Convert.ToInt32(bridge.UnitMeasurment_CU_ID)));
                if (unitMeasurment != null)
                {
                    UnitMeasurment_CU_ID = unitMeasurment.ID;
                }
            }
            Date           = ((InventoryItemPrice_cu)ActiveDBItem).Date;
            Price          = ((InventoryItemPrice_cu)ActiveDBItem).Price;
            Customer_CU_ID = ((InventoryItemPrice_cu)ActiveDBItem).Customer_CU_ID;
            PriceType_P_ID = ((InventoryItemPrice_cu)ActiveDBItem).PriceType_P_ID;
            Supplier_CU_ID = ((InventoryItemPrice_cu)ActiveDBItem).Supplier_CU_ID;

            ((IInventoryItemPriceViewer)ActiveCollector.ActiveViewer).ID = ((InventoryItemPrice_cu)ActiveDBItem).ID;
            ActiveCollector.ActiveDBItem.ID = ((InventoryItemPrice_cu)ActiveDBItem).ID;

            base.Edit(ActiveCollector.ActiveDBItem);
        }
Пример #2
0
        public override bool Collect(AbstractDataCollector <TEntity> collector)
        {
            if (collector == null)
            {
                return(false);
            }

            ActiveCollector = collector;

            ID = ((IInventoryItemPriceViewer)ActiveCollector.ActiveViewer).ID;

            if (ActiveDBItem == null)
            {
                return(false);
            }

            if (InventoryItem_CU_ID != null)
            {
                ((InventoryItemPrice_cu)ActiveDBItem).InventoryItem_CU_ID = Convert.ToInt32(InventoryItem_CU_ID);
            }

            if (UnitMeasurment_CU_ID != null)
            {
                InventoryItem_UnitMeasurment_cu bridge =
                    InventoryItem_UnitMeasurment_cu.ItemsList.Find(
                        item =>
                        Convert.ToInt32(item.UnitMeasurment_CU_ID).Equals(Convert.ToInt32(UnitMeasurment_CU_ID)) &&
                        Convert.ToInt32(item.InventoryItem_CU_ID).Equals(Convert.ToInt32(InventoryItem_CU_ID)));

                if (bridge != null)
                {
                    ((InventoryItemPrice_cu)ActiveDBItem).InventoryItem_UnitMeasurment_CU_ID = Convert.ToInt32(bridge.ID);
                }
            }

            if (Date != null)
            {
                ((InventoryItemPrice_cu)ActiveDBItem).Date = Convert.ToDateTime(Date);
            }

            if (Price != null)
            {
                ((InventoryItemPrice_cu)ActiveDBItem).Price = Convert.ToDouble(Price);
            }

            if (PriceType_P_ID != null)
            {
                ((InventoryItemPrice_cu)ActiveDBItem).PriceType_P_ID = Convert.ToInt32(PriceType_P_ID);
            }

            if (Customer_CU_ID != null)
            {
                ((InventoryItemPrice_cu)ActiveDBItem).Customer_CU_ID = Convert.ToInt32(Customer_CU_ID);
            }

            if (Supplier_CU_ID != null)
            {
                ((InventoryItemPrice_cu)ActiveDBItem).Supplier_CU_ID = Convert.ToInt32(Supplier_CU_ID);
            }

            if (UserID != null)
            {
                ((InventoryItemPrice_cu)ActiveDBItem).InsertedBy = Convert.ToInt32(UserID);
            }

            ((InventoryItemPrice_cu)ActiveDBItem).IsOnDuty = true;
            switch (((IInventoryItemPriceViewer)ActiveCollector.ActiveViewer).CommonTransactionType)
            {
            case DB_CommonTransactionType.DeleteExisting:
                ((InventoryItemPrice_cu)ActiveDBItem).IsOnDuty = false;
                break;
            }

            RelatedViewers = ((IInventoryItemPriceViewer)ActiveCollector.ActiveViewer).RelatedViewers;

            return(true);
        }
Пример #3
0
        public override bool CheckIfActiveDBItemExists()
        {
            List <InventoryItemPrice_cu> list = InventoryItemPrice_cu.ItemsList;

            if (list.Count == 0)
            {
                return(false);
            }

            InventoryItem_UnitMeasurment_cu bridge = null;

            if (UnitMeasurment_CU_ID != null)
            {
                bridge =
                    InventoryItem_UnitMeasurment_cu.ItemsList.Find(
                        item =>
                        Convert.ToInt32(item.UnitMeasurment_CU_ID).Equals(Convert.ToInt32(UnitMeasurment_CU_ID)) &&
                        Convert.ToInt32(item.InventoryItem_CU_ID).Equals(Convert.ToInt32(InventoryItem_CU_ID)));
            }
            else
            {
                return(false);
            }

            if (bridge == null)
            {
                return(false);
            }

            List <InventoryItemPrice_cu> inventoryItemPricesList =
                list.FindAll(
                    item =>
                    Convert.ToInt32(item.InventoryItem_CU_ID).Equals(Convert.ToInt32(InventoryItem_CU_ID)) &&
                    Convert.ToInt32(item.InventoryItem_UnitMeasurment_CU_ID).Equals(Convert.ToInt32(bridge.ID)));

            if (inventoryItemPricesList.Count == 0)
            {
                return(false);
            }

            InventoryItemPrice_cu inventoryItemPrice = null;

            if (PriceType_P_ID != null && Convert.ToInt32(PriceType_P_ID).Equals((int)DB_PriceType.SellingPrice) &&
                Customer_CU_ID != null)
            {
                inventoryItemPrice =
                    inventoryItemPricesList.Find(
                        item =>
                        Convert.ToInt32(item.Customer_CU_ID).Equals(Convert.ToInt32(Customer_CU_ID)) &&
                        Convert.ToDateTime(item.Date)
                        .Date.StartOfDayDateTime()
                        .Equals(Convert.ToDateTime(Date).Date.StartOfDayDateTime()) &&
                        Convert.ToInt32(item.PriceType_P_ID).Equals(PriceType_P_ID));
            }
            else if (PriceType_P_ID != null && Convert.ToInt32(PriceType_P_ID).Equals((int)DB_PriceType.PurchasingPrice) &&
                     Supplier_CU_ID != null)
            {
                inventoryItemPrice =
                    inventoryItemPricesList.Find(
                        item =>
                        Convert.ToInt32(item.Supplier_CU_ID).Equals(Convert.ToInt32(Supplier_CU_ID)) &&
                        Convert.ToDateTime(item.Date)
                        .Date.StartOfDayDateTime()
                        .Equals(Convert.ToDateTime(Date).Date.StartOfDayDateTime()) &&
                        Convert.ToInt32(item.PriceType_P_ID).Equals(PriceType_P_ID));
            }
            else if (PriceType_P_ID != null)
            {
                inventoryItemPrice =
                    inventoryItemPricesList.Find(
                        item =>
                        Convert.ToDateTime(item.Date)
                        .Date.StartOfDayDateTime()
                        .Equals(Convert.ToDateTime(Date).Date.StartOfDayDateTime()) &&
                        Convert.ToInt32(item.PriceType_P_ID).Equals(PriceType_P_ID));
            }
            if (inventoryItemPrice != null)
            {
                return(true);
            }

            return(false);
        }