public bool DeleteWhereID(int ID) { List <DrugsInfo.DrugsInfo> drugsInfoList = new List <DrugsInfo.DrugsInfo>(); if (!drugsInfoData.SelectAll(drugsInfoList, " WHERE DEALER_ID = " + ID)) { MessageBoxes.ShowError(MessageBoxes.LoadDataErrorMessage); return(false); } foreach (var drugsInfo in drugsInfoList) { if (!drugsInfoData.DeleteWhereID(drugsInfo.ID)) { MessageBoxes.ShowError(MessageBoxes.DeleteErrorMessage); return(false); } } if (!dealersTable.DeleteRecord(ID)) { MessageBoxes.ShowError(MessageBoxes.DeleteErrorMessage); return(false); } return(true); }
private void drugExpiryDate_Click(object sender, RoutedEventArgs e) { int numberNotWorthy = 0, numberDiscountedPrice = 0; List <DrugsInfo.DrugsInfo> drugsInfoListForSelect = new List <DrugsInfo.DrugsInfo>(); if (!drugsInfoData.SelectAll(drugsInfoListForSelect, " WHERE DEALER_ID = " + dealerInfo.dealer.ID)) { MessageBoxes.ShowError(MessageBoxes.EditErrorMessage); return; } dealerInfo.drugsInfoList = drugsInfoListForSelect; List <DrugsInfo.DrugsInfo> drugsInfoList = dealerInfo.ifDrugIsWorthy(out numberNotWorthy, out numberDiscountedPrice); string Message = ""; if (numberNotWorthy != 0) { Message += "Открити са " + numberNotWorthy + " негодни лекарства. Те ще бъдат премахнати.\n"; } if (numberDiscountedPrice != 0) { Message += "Открити са " + numberDiscountedPrice + " лекарства, годността на които изтича след по - малко от месец. Цената им ще бъде намалена с 50%."; } MessageBoxes.ShowWarning(Message); drugsInfoList.ForEach(delegate(DrugsInfo.DrugsInfo element) { if (element.Number == 0) { if (!drugsInfoData.DeleteWhereID(element.ID)) { MessageBoxes.ShowError(MessageBoxes.DeleteErrorMessage); return; } } else { if (!drugsInfoData.UpdateWhereID(element.ID, element)) { MessageBoxes.ShowError(MessageBoxes.EditErrorMessage); return; } } }); drugsInfoView.Update(); //ui_btndrugExpiryDate.IsEnabled = false; }