protected void OnButtonBottleAddEditFineClicked(object sender, EventArgs e)
        {
            string fineReason       = "Недосдача";
            var    bottleDifference = bottlesReturnedTotal - bottlesReturnedToWarehouse;
            var    summ             = DefaultBottle.SumOfDamage * (bottleDifference > 0 ? bottleDifference : (decimal)0);

            summ += routelistdiscrepancyview.Items.Where(x => x.UseFine).Sum(x => x.SumOfDamage);
            var nomenclatures = routelistdiscrepancyview.Items.Where(x => x.UseFine)
                                .ToDictionary(x => x.Nomenclature, x => - x.Remainder);

            if (checkUseBottleFine.Active)
            {
                nomenclatures.Add(DefaultBottle, bottleDifference);
            }

            FineDlg fineDlg;

            if (Entity.BottleFine != null)
            {
                fineDlg = new FineDlg(Entity.BottleFine);

                Entity.BottleFine.UpdateNomenclature(nomenclatures);
                fineDlg.Entity.TotalMoney = summ;
                fineDlg.EntitySaved      += FineDlgExist_EntitySaved;
            }
            else
            {
                fineDlg = new FineDlg(summ, Entity, fineReason, Entity.Date, Entity.Driver);
                fineDlg.Entity.AddNomenclature(nomenclatures);
                fineDlg.EntitySaved += FineDlgNew_EntitySaved;
            }
            TabParent.AddSlaveTab(this, fineDlg);
        }
        private void ButtonAcceptFineOnClicked(object sender, EventArgs e)
        {
            string fineReason = "Перерасход топлива";

            var fineDlg = new FineDlg(0, Entity, fineReason, Entity.Date, Entity.Driver);

            fineDlg.Entity.FineType = FineTypes.FuelOverspending;
            fineDlg.EntitySaved    += OnFinesAdded;

            TabParent.AddSlaveTab(this, fineDlg);
        }
        protected void OnButtonFineClicked(object sender, EventArgs e)
        {
            var     selected = ytreeviewItems.GetSelectedObject <InventoryDocumentItem>();
            FineDlg fineDlg;

            if (selected.Fine != null)
            {
                fineDlg              = new FineDlg(selected.Fine);
                fineDlg.EntitySaved += FineDlgExist_EntitySaved;
            }
            else
            {
                fineDlg              = new FineDlg("Недостача");
                fineDlg.EntitySaved += FineDlgNew_EntitySaved;
            }
            fineDlg.Entity.TotalMoney = selected.SumOfDamage;
            FineEditItem = selected;
            MyTab.TabParent.AddSlaveTab(MyTab, fineDlg);
        }
 protected void OnButtonFineClicked(object sender, EventArgs e)
 {
     var selected = treeItemsList.GetSelectedObject<WriteoffDocumentItem>();
     FineDlg fineDlg;
     if (selected.Fine != null)
     {
         fineDlg = new FineDlg(selected.Fine);
         fineDlg.EntitySaved += FineDlgExist_EntitySaved;
     }
     else
     {
         fineDlg = new FineDlg();
         fineDlg.EntitySaved += FineDlgNew_EntitySaved;
     }
     fineDlg.Entity.TotalMoney = selected.SumOfDamage;
     FineEditItem = selected;
     MyTab.TabParent.AddSlaveTab(MyTab, fineDlg);
 }