protected override void OnAddClick(object sender, RoutedEventArgs e)
        {
            List <Drugs.Drugs> drugsList = new List <Drugs.Drugs>();

            if (!drugsData.SelectAll(drugsList))
            {
                MessageBoxes.ShowError(MessageBoxes.LoadDataErrorMessage);
                return;
            }

            DrugsInfoDialog drugsInfoDialog = new DrugsInfoDialog(new DrugsInfo(), drugsList, DialogModes.Add, this);
            bool?           dialogResult    = drugsInfoDialog.ShowDialog();

            if (dialogResult == false)
            {
                return;
            }

            DrugsInfo drugsInfo = drugsInfoDialog.drugInfo;

            drugsInfo.DealerID = dealerID;

            ///////////
            if (!drugsInfoData.Insert(drugsInfo))
            {
                MessageBoxes.ShowError(MessageBoxes.AddErrorMessage);
                return;
            }
            DrugsItem drugItem = toDrugItem(drugsInfo, drugsList);

            itemsSource.Add(drugItem);
        }
        protected override void OnEditClick(object sender, RoutedEventArgs e)
        {
            DrugsInfo drugInfo = toDrugsInfo((DrugsItem)SelectedItem);

            if (!drugsInfoData.SelectWhereID(drugInfo.ID, out drugInfo))
            {
                MessageBoxes.ShowError(MessageBoxes.PreviewErrorMessage);
                return;
            }

            DrugsInfoDialog drugsInfoDialog = new DrugsInfoDialog(drugInfo, drugsList, DialogModes.Edit);
            bool?           dialogResult    = drugsInfoDialog.ShowDialog();

            if (dialogResult == false)
            {
                return;
            }

            if (!drugsInfoData.UpdateWhereID(drugInfo.ID, drugInfo))
            {
                MessageBoxes.ShowError(MessageBoxes.EditErrorMessage);
                return;
            }

            itemsSource[SelectedIndex] = toDrugItem(drugInfo, drugsList);
        }
        /// <summary>Метод при натискане на "Преглед" от контекстното меню</summary>
        protected override void OnPreviewClick(object sender, RoutedEventArgs e)
        {
            if (SelectedItems.Count != 1)
            {
                return;
            }

            DrugsInfo drugInfo = toDrugsInfo((DrugsItem)SelectedItem);

            if (!drugsInfoData.SelectWhereID(drugInfo.ID, out drugInfo))
            {
                MessageBoxes.ShowError(MessageBoxes.PreviewErrorMessage);
                return;
            }

            DrugsInfoDialog drugsInfoDialog = new DrugsInfoDialog(drugInfo, drugsList, DialogModes.Preview);

            drugsInfoDialog.ShowDialog();
        }