Пример #1
0
        public override bool Save()
        {
            if (!Entity.HasFixedPrice && Entity.FixedPrices.Count > 0)
            {
                foreach (var v in Entity.FixedPrices.ToList())
                {
                    Entity.FixedPrices.Remove(v);
                    UoW.Delete(v);
                }
            }

            var valid = new QSValidator <WaterSalesAgreement>(UoWGeneric.Root);

            if (valid.RunDlgIfNotValid((Gtk.Window) this.Toplevel))
            {
                return(false);
            }

            logger.Info("Сохраняем доп. соглашение...");
            UoWGeneric.Save();
            logger.Info("Ok");
            if (AgreementSaved != null)
            {
                AgreementSaved(this, new AgreementSavedEventArgs(UoWGeneric.Root));
            }
            return(true);
        }
Пример #2
0
        protected void OnButtonDelClicked(object sender, EventArgs e)
        {
            var item = ytreeviewFixedPrices.GetSelectedObject <WaterSalesAgreementFixedPrice>();

            Entity.ObservableFixedPrices.Remove(item);
            UoW.Delete(item);
        }
Пример #3
0
        protected void OnButtonDelClicked(object sender, EventArgs e)
        {
            var item = ytreeviewEquipments.GetSelectedObject <SalesEquipment>();

            Entity.ObservableSalesEqipments.Remove(item);
            UoW.Delete(item);
        }
Пример #4
0
        protected void OnButtonDeleteFineClicked(object sender, EventArgs e)
        {
            var item = ytreeviewItems.GetSelectedObject <InventoryDocumentItem>();

            UoW.Delete(item.Fine);
            item.Fine = null;
            YtreeviewItems_Selection_Changed(null, EventArgs.Empty);
        }
Пример #5
0
        protected void OnButtonTransferClicked(object sender, EventArgs e)
        {
            var itemsFrom = ytreeviewFrom.ItemsDataSource as IList <CarUnloadDocumentNode>;
            var itemsTo   = ytreeviewTo.ItemsDataSource as IList <CarUnloadDocumentNode>;
            var fromDoc   = ylistcomboReceptionTicketFrom.SelectedItem as CarUnloadDocument;
            var toDoc     = ylistcomboReceptionTicketTo.SelectedItem as CarUnloadDocument;

            foreach (var from in itemsFrom.Where(i => i.TransferCount > 0))
            {
                int transfer = from.TransferCount;
                //Заполняем для краткости
                var nomenclature = from.DocumentItem.WarehouseMovementOperation.Nomenclature;
                var receiveType  = from.DocumentItem.ReciveType;

                var to = itemsTo
                         .FirstOrDefault(i => i.DocumentItem.WarehouseMovementOperation.Nomenclature.Id == nomenclature.Id);

                if (to == null)
                {
                    toDoc.AddItem(receiveType, nomenclature, null, transfer, null);

                    foreach (var item in toDoc.Items)
                    {
                        var exist = itemsTo.FirstOrDefault(i => i.DocumentItem.Id == item.Id);
                        if (exist == null)
                        {
                            itemsTo.Add(new CarUnloadDocumentNode {
                                DocumentItem = item
                            });
                        }
                    }
                }
                else
                {
                    to.DocumentItem.WarehouseMovementOperation.Amount += transfer;

                    UoW.Save(to.DocumentItem.WarehouseMovementOperation);
                }

                from.DocumentItem.WarehouseMovementOperation.Amount -= transfer;
                if (from.DocumentItem.WarehouseMovementOperation.Amount == 0)
                {
                    var item = fromDoc.Items.First(i => i.Id == from.DocumentItem.Id);
                    fromDoc.Items.Remove(item);

                    UoW.Delete(from.DocumentItem.WarehouseMovementOperation);
                }
                else
                {
                    UoW.Save(from.DocumentItem.WarehouseMovementOperation);
                }

                from.TransferCount = 0;
            }
            UoW.Save(fromDoc);
            UoW.Save(toDoc);
            CheckSensitivities();
        }
Пример #6
0
        protected void OnButtonRemoveClicked(object sender, EventArgs e)
        {
            var row = ytreeviewItems.GetSelectedObject <PremiumItem>();

            if (row.Id > 0)
            {
                UoW.Delete(row);
                if (row.WageOperation != null)
                {
                    UoW.Delete(row.WageOperation);
                }
            }
            Entity.ObservableItems.Remove(row);
        }
        public override bool Save()
        {
            var valid = new QSValidator <RouteList>(Entity, new Dictionary <object, object>()
            {
                { nameof(IRouteListItemRepository), new RouteListItemRepository() }
            });

            if (valid.RunDlgIfNotValid((Gtk.Window) this.Toplevel))
            {
                return(false);
            }

            if (Entity.AdditionalLoadingDocument != null && !Entity.AdditionalLoadingDocument.Items.Any())
            {
                UoW.Delete(Entity.AdditionalLoadingDocument);
                Entity.AdditionalLoadingDocument = null;
            }

            Entity.CalculateWages(_wageParameterService);

            if (_oldDriver != Entity.Driver)
            {
                if (_oldDriver != null)
                {
                    var selfDriverTerminalTransferDocument = _routeListRepository.GetSelfDriverTerminalTransferDocument(UoW, _oldDriver, Entity);

                    if (selfDriverTerminalTransferDocument != null)
                    {
                        UoW.Delete(selfDriverTerminalTransferDocument);
                    }
                }

                _oldDriver = Entity.Driver;
            }

            _logger.Info("Сохраняем маршрутный лист...");
            UoWGeneric.Save();
            _logger.Info("Ok");
            return(true);
        }
Пример #8
0
        bool UpdateReceivedItemsOnEntity()
        {
            //Собираем список всего на возврат из разных виджетов.
            var tempItemList = new List <InternalItem>();

            foreach (var node in bottlereceptionview1.Items)
            {
                if (node.Amount == 0)
                {
                    continue;
                }

                var item = new InternalItem {
                    ReciveType     = ReciveTypes.Bottle,
                    NomenclatureId = node.NomenclatureId,
                    Amount         = node.Amount
                };
                tempItemList.Add(item);
            }

            var defectiveItemsList = new List <InternalItem>();

            foreach (var node in defectiveitemsreceptionview1.Items)
            {
                if (node.Amount == 0)
                {
                    continue;
                }

                var item = new InternalItem {
                    ReciveType          = ReciveTypes.Defective,
                    NomenclatureId      = node.NomenclatureId,
                    Amount              = node.Amount,
                    MovementOperationId = node.MovementOperation != null ? node.MovementOperation.Id : 0,
                    TypeOfDefect        = node.TypeOfDefect,
                    Source              = node.Source
                };

                if (!defectiveItemsList.Any(i => i.EqualsToAnotherInternalItem(item)))
                {
                    defectiveItemsList.Add(item);
                }
            }

            foreach (var node in returnsreceptionview1.Items)
            {
                if (node.Amount == 0)
                {
                    continue;
                }

                var item = new InternalItem {
                    ReciveType     = ReciveTypes.Returnes,
                    NomenclatureId = node.NomenclatureId,
                    Amount         = node.Amount,
                    Redhead        = node.Redhead
                };
                tempItemList.Add(item);
            }

            foreach (var node in nonserialequipmentreceptionview1.Items)
            {
                if (node.Amount == 0)
                {
                    continue;
                }

                var item = new InternalItem {
                    ReciveType     = ReciveTypes.Equipment,
                    NomenclatureId = node.NomenclatureId,
                    Amount         = node.Amount
                };
                tempItemList.Add(item);
            }

            //Обновляем Entity
            foreach (var tempItem in defectiveItemsList)
            {
                //валидация брака
                if (tempItem.TypeOfDefect == null)
                {
                    MessageDialogWorks.RunWarningDialog("Для брака необходимо указать его вид");
                    return(false);
                }

                //проверка на дубли. если несколько одинаковых, то устанавливаем кол-во в 0 для последующего удаления из коллекции
                if (tempItem.Amount > 0 && defectiveItemsList.Count(i => i.EqualsToAnotherInternalItem(tempItem)) > 1)
                {
                    tempItem.Amount = 0;
                }
            }

            foreach (var tempItem in defectiveItemsList)
            {
                var item = Entity.Items.FirstOrDefault(x => x.MovementOperation.Id > 0 && x.MovementOperation.Id == tempItem.MovementOperationId);
                if (item == null)
                {
                    Entity.AddItem(
                        tempItem.ReciveType,
                        UoW.GetById <Nomenclature>(tempItem.NomenclatureId),
                        null,
                        tempItem.Amount,
                        null,
                        null,
                        tempItem.Source,
                        tempItem.TypeOfDefect
                        );
                }
                else
                {
                    if (item.MovementOperation.Amount != tempItem.Amount)
                    {
                        item.MovementOperation.Amount = tempItem.Amount;
                    }
                    if (item.TypeOfDefect != tempItem.TypeOfDefect)
                    {
                        item.TypeOfDefect = tempItem.TypeOfDefect;
                    }
                    if (item.Source != tempItem.Source)
                    {
                        item.Source = tempItem.Source;
                    }
                }
            }

            var nomenclatures = UoW.GetById <Nomenclature>(tempItemList.Select(x => x.NomenclatureId).ToArray());

            foreach (var tempItem in tempItemList)
            {
                var item = Entity.Items.FirstOrDefault(x => x.MovementOperation.Nomenclature.Id == tempItem.NomenclatureId);
                if (item == null)
                {
                    var nomenclature = nomenclatures.First(x => x.Id == tempItem.NomenclatureId);
                    Entity.AddItem(
                        tempItem.ReciveType,
                        nomenclature,
                        null,
                        tempItem.Amount,
                        null,
                        tempItem.Redhead
                        );
                }
                else
                {
                    if (item.MovementOperation.Amount != tempItem.Amount)
                    {
                        item.MovementOperation.Amount = tempItem.Amount;
                    }
                    if (item.Redhead != tempItem.Redhead)
                    {
                        item.Redhead = tempItem.Redhead;
                    }
                }
            }

            foreach (var item in Entity.Items.ToList())
            {
                bool exist = true;
                if (item.ReciveType != ReciveTypes.Defective)
                {
                    exist = tempItemList.Any(x => x.NomenclatureId == item.MovementOperation.Nomenclature?.Id);
                }
                else
                {
                    exist = defectiveItemsList.Any(x => x.MovementOperationId == item.MovementOperation.Id && x.Amount > 0);
                }

                if (!exist)
                {
                    UoW.Delete(item.MovementOperation);
                    Entity.ObservableItems.Remove(item);
                }
            }

            return(true);
        }
Пример #9
0
 public static void Remove(Post post)
 {
     UoW
     .Delete(post);
 }
 private void OnButtonRemoveAdditionalLoadClicked(object sender, EventArgs e)
 {
     UoW.Delete(Entity.AdditionalLoadingDocument);
     Entity.AdditionalLoadingDocument = null;
     createroutelistitemsview1.UpdateInfo();
 }
Пример #11
0
 public static void Remove(Comment comment)
 {
     UoW.Delete(comment);
 }
Пример #12
0
 public static void Remove(Category category)
 {
     UoW.Delete(category);
 }