private void OnBarcodeClick(object sender, RoutedEventArgs e) { try { var str = BluetoothHandler.GetStrFromBluetooth().Trim('\0').Split(','); long medicineCode = long.Parse(str[0]); string medicineName = str[1]; int month = int.Parse(str[2].Substring(0, 2)); int year = int.Parse(str[2].Substring(2, 4)); var medicine = new Medicine(medicineName, new DateTime(year, month, 1), medicineCode); List <Medicine> medicines = Dict; Predicate <Medicine> medicineFinder = m => { return(m.Code == medicineCode); }; if (medicines.Exists(medicineFinder)) { UpdateCounter(medicine, this); return; } medicines.Add(medicine); RowAdder.AddRow(medicine, this, medicines.Count, OnClickCheckBox); } catch (Exception exception) { bluetoothIndicator.Fill = new SolidColorBrush(Colors.Red); Console.WriteLine(exception); BluetoothHandler.Close(); } }
private void PutMedicinesInTable() { if (_medicineList == null) { return; } var medicines = _medicineList.MedicineVal; for (var index = 0; index < medicines.Count; index++) { var medicine = medicines[index]; var checkBox = DrugsGrid.FindName($"check_{medicine.Code}"); var isChecked = ((CheckBox)checkBox)?.IsChecked; if (isChecked != null && isChecked.Value) { index += 1; //Go to the next medicine medicines.Remove(medicine); continue; } RowAdder.AddRow(medicine, this, index + 1, OnClickCheckBox); } PrepareTable(medicines.Count); }
private void OnOk(object sender, RoutedEventArgs e) { var medicineName = MedicineName.Text; var medicineCode = string.IsNullOrEmpty(MedicineCode.Text) ? 0 : long.Parse(MedicineCode.Text); var medicineDate = MedicineDate.SelectedDate ?? MedicineDate.DisplayDate; Medicine medicine = new Medicine(medicineName, medicineDate, medicineCode); medicine.ImagePath = txtEditor.Text; medicine.UserDesc = new TextRange(UsagesByUser.Document.ContentStart, UsagesByUser.Document.ContentEnd).Text; medicine.DangersDesc = new TextRange(DangersByUser.Document.ContentStart, DangersByUser.Document.ContentEnd).Text; List <Medicine> medicines = MainWindow.Dict; Predicate <Medicine> medicineFinder = (Medicine m) => { return(m.Code == medicineCode); }; if (medicines.Exists(medicineFinder)) { MainWindow.UpdateCounter(medicine, _mainWindow); return; } medicines.Add(medicine); RowAdder.AddRow(medicine, _mainWindow, medicines.Count, MainWindow.OnClickCheckBox); }
private void PutTableHeader() { RowAdder.AddTextBlockExternal(0, 0, "Item", DrugsGrid, HorizontalAlignment.Center, VerticalAlignment.Center); RowAdder.AddTextBlockExternal(1, 0, "Name", DrugsGrid, HorizontalAlignment.Center, VerticalAlignment.Center); RowAdder.AddTextBlockExternal(2, 0, "Date", DrugsGrid, HorizontalAlignment.Center, VerticalAlignment.Center); RowAdder.AddTextBlockExternal(3, 0, "Amount", DrugsGrid, HorizontalAlignment.Center, VerticalAlignment.Center); RowAdder.AddTextBlockExternal(4, 0, "Price", DrugsGrid, HorizontalAlignment.Center, VerticalAlignment.Center); RowAdder.AddTextBlockExternal(5, 0, "Picture", DrugsGrid, HorizontalAlignment.Center, VerticalAlignment.Center); RowAdder.AddTextBlockExternal(6, 0, "Item_Code", DrugsGrid, HorizontalAlignment.Center, VerticalAlignment.Center); RowAdder.AddTextBlockExternal(7, 0, "", DrugsGrid, HorizontalAlignment.Center, VerticalAlignment.Center); }
public void Start(DatabaseDialog databaseDialog, int whichDatabase, TableDialog tableDialog, int whichTable) { //Start the Control() method, and set returned value as option int option = Control(); switch (option) { case 0: //If --Print Table-- is selected print the table TablePrinter.Print(ConnectionString, ServerType, databaseDialog, whichDatabase, tableDialog, whichTable, this); break; case 1: //If --Search in table-- is selected, print table only with content matching the search TableSearcher.Search(ConnectionString, ServerType, databaseDialog, whichDatabase, tableDialog, whichTable, this); break; case 2: //If --Edit table-- is selected let user select the cell to edit TableEditor.SelectCell(ConnectionString, ServerType, databaseDialog, whichDatabase, tableDialog, whichTable, this); break; case 3: //If --Add new row-- is selected start adding new row RowAdder.Add(ConnectionString, ServerType, databaseDialog, whichDatabase, tableDialog, whichTable, this); break; case 4: //If --Add new column-- is selected start adding new column ColumnAdder.Add(ConnectionString, ServerType, databaseDialog, whichDatabase, tableDialog, whichTable, this); break; case 5: //If --Delete column-- is selected let user select the column to delete ColumnDeleter.SelectColumn(ConnectionString, ServerType, databaseDialog, whichDatabase, tableDialog, whichTable, this); break; case 6: //If --Delete row-- is selected let user select the row to delete RowDeleter.SelectRow(ConnectionString, ServerType, databaseDialog, whichDatabase, tableDialog, whichTable, this); break; case 7: //If --Delete table-- is selected start deleting currently selected table TableDeleter.Delete(ConnectionString, ServerType, databaseDialog, whichDatabase, tableDialog, whichTable, this); break; case 8: //If --Return-- is selected return to the tableDialog tableDialog.Start(databaseDialog, whichDatabase, this); break; } }