Exemplo n.º 1
0
        /* Context menu override */
        protected override void OnEditClick(object sender, RoutedEventArgs e)
        {
            if (SelectedItems.Count != 1)
            {
                return;
            }

            Drugs drug = (Drugs)SelectedItem;

            if (!drugsData.SelectWhereID(drug.ID, out drug))
            {
                MessageBoxes.ShowError(MessageBoxes.EditErrorMessage);
                return;
            }

            DrugsDialog drugsDialog  = new DrugsDialog(drug, DialogModes.Edit, this);
            bool?       dialogResult = drugsDialog.ShowDialog();

            if (dialogResult == false)
            {
                return;
            }

            drug = drugsDialog.drug;
            if (!drugsData.UpdateWhereID(drug.ID, drug))
            {
                MessageBoxes.ShowError(MessageBoxes.EditErrorMessage);
                return;
            }

            itemsSource[SelectedIndex] = drug;
        }
Exemplo n.º 2
0
        /* Context menu override */
        protected override void OnPreviewClick(object sender, RoutedEventArgs e)
        {
            if (SelectedItems.Count != 1)
            {
                return;
            }

            Drugs drug = (Drugs)SelectedItem;

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

            DrugsDialog drugsDialog = new DrugsDialog(drug, DialogModes.Preview, this);

            drugsDialog.ShowDialog();
        }
Exemplo n.º 3
0
        /* Context menu override */
        protected override void OnAddClick(object sender, RoutedEventArgs e)
        {
            DrugsDialog drugsDialog  = new DrugsDialog(new Drugs(), DialogModes.Add, this);
            bool?       dialogResult = drugsDialog.ShowDialog();

            if (dialogResult == false)
            {
                return;
            }

            Drugs drug = drugsDialog.drug;

            if (!drugsData.Insert(drug))
            {
                MessageBoxes.ShowError(MessageBoxes.AddErrorMessage);
                return;
            }

            itemsSource.Add(drug);
        }
Exemplo n.º 4
0
        /* Context menu override */
        protected override void OnDeleteClick(object sender, RoutedEventArgs e)
        {
            if (SelectedItems.Count != 1)
            {
                return;
            }

            MessageBoxResult result = MessageBoxes.MessageBoxShowDeleteMessage();

            if (result == MessageBoxResult.No)
            {
                return;
            }


            List <DrugsInfo.DrugsInfo> drugsInfoList = new List <DrugsInfo.DrugsInfo>();
            Drugs drug = (Drugs)SelectedItem;

            if (!drugsInfoData.SelectAll(drugsInfoList, " WHERE DRUG_ID = " + drug.ID))
            {
                MessageBoxes.ShowError(MessageBoxes.DeleteErrorMessage);
                return;
            }

            foreach (DrugsInfo.DrugsInfo drugInfo in drugsInfoList)
            {
                if (!drugsInfoData.DeleteWhereID(drugInfo.ID))
                {
                    MessageBoxes.ShowError(MessageBoxes.DeleteErrorMessage);
                    return;
                }
            }

            if (!drugsData.DeleteWhereID(drug.ID))
            {
                MessageBoxes.ShowError(MessageBoxes.DeleteErrorMessage);
                return;
            }

            itemsSource.RemoveAt(SelectedIndex);
        }
Exemplo n.º 5
0
        public DrugsDialog(Drugs _drug, DialogModes _dialogMode, DependencyObject parent = null) : base(_dialogMode, parent)
        {
            InitializeComponent();

            drug = _drug;
        }
Exemplo n.º 6
0
 public bool Insert(Drugs drug)
 {
     return(drugsTable.InsertRecord(drug));
 }
Exemplo n.º 7
0
 public bool UpdateWhereID(int ID, Drugs drug)
 {
     return(drugsTable.EditRecord(ID, drug));
 }
Exemplo n.º 8
0
 public bool SelectWhereID(int ID, out Drugs drug)
 {
     return(drugsTable.SelectRecord(ID, out drug));
 }