示例#1
0
 private void AddSerumBtn_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(SerumTextBox.Text))
     {
         if (!SerumReferences.Any(a => a.ReferenceNumber == SerumTextBox.Text.Trim()))
         {
             SerumReferences.Add(new SerumReference {
                 ReferenceNumber = SerumTextBox.Text.Trim()
             });
             SerumRefGrid.ItemsSource = SerumReferences;
             SerumRefGrid.Items.Refresh();
         }
         else
         {
             MessageBox.Show("This reference number is already added");
         }
         SerumTextBox.Text = string.Empty;
     }
 }
示例#2
0
        private bool ValidatePage(bool skipPrintCountLbl = false)
        {
            RemoveErrorBorders();

            bool          isValid       = true;
            List <string> errorMessages = new List <string>();

            if (ArrayListbx.SelectedIndex == -1)
            {
                ArrayLabel.BorderBrush     = Brushes.Red;
                ArrayLabel.BorderThickness = new Thickness(2);
                isValid = false;
            }
            if (GroupListbx.SelectedIndex == -1)
            {
                GroupLabel.BorderBrush     = Brushes.Red;
                GroupLabel.BorderThickness = new Thickness(2);
                isValid = false;
            }
            if (App.ccPageType != CCType.N && AntigenListbx.SelectedIndex == -1)
            {
                AntigenLabel.BorderBrush     = Brushes.Red;
                AntigenLabel.BorderThickness = new Thickness(2);
                isValid = false;
            }
            if (!SerumReferences.Any())
            {
                SerumRefLabel.BorderBrush     = Brushes.Red;
                SerumRefLabel.BorderThickness = new Thickness(2);
                isValid = false;
            }
            if (string.IsNullOrWhiteSpace(DilutionFactorTextBox.Text))
            {
                DilutionLabel.BorderBrush     = Brushes.Red;
                DilutionLabel.BorderThickness = new Thickness(2);
                isValid = false;
            }
            if (!DilutionDatePicker.SelectedDate.HasValue)
            {
                DateLabel.BorderBrush     = Brushes.Red;
                DateLabel.BorderThickness = new Thickness(2);
                isValid = false;
            }
            if (string.IsNullOrWhiteSpace(ExpirationDateTextBox.Text))
            {
                ExpirationLabel.BorderBrush     = Brushes.Red;
                ExpirationLabel.BorderThickness = new Thickness(2);
                isValid = false;
            }
            if (!skipPrintCountLbl && string.IsNullOrWhiteSpace(QuantityLabelTextBox.Text))
            {
                QtyLabel.BorderBrush     = Brushes.Red;
                QtyLabel.BorderThickness = new Thickness(2);
                isValid = false;
            }

            if (AntigensGrid.ItemsSource == null)
            {
                AntigensGrid.BorderBrush     = Brushes.Red;
                AntigensGrid.BorderThickness = new Thickness(2);
                isValid = false;
            }

            if (!isValid)
            {
                errorMessages.Add("Please complete missing fields");
            }

            if (!ValidateGetMinMax(errorMessages))
            {
                isValid = false;
            }

            if (!isValid)
            {
                ErrorMessages.Text = " * " + string.Join("\r\n * ", errorMessages);
            }
            else
            {
                ErrorMessages.Text = string.Empty;
            }

            return(isValid);
        }
示例#3
0
        private bool SaveCCs()
        {
            try
            {
                var antigenRanges = AntigensGrid.ItemsSource as List <AntigenRange>;

                var activeCCs = App.CCProvider.GetExistingCC(
                    ArrayListbx.SelectedValue.ToString(),
                    null,
                    App.ccPageType.ToString());

                if (activeCCs != null && activeCCs.Any())
                {
                    var antigensIds        = activeCCs.Where(a => a.DilutionDate == DilutionDatePicker.SelectedDate.Value.Date).Select(a => a.AntigenId).ToList();
                    var duplicatedAntigens = antigenRanges.Where(a => antigensIds.Contains(a.AntigenId)).ToList();

                    if (duplicatedAntigens != null && duplicatedAntigens.Count > 1)
                    {
                        MessageBox.Show($"Following antigens already have records that are not expired: {string.Join(",", duplicatedAntigens.Select(a => a.AntigenName))}", "Error");
                        return(false);
                    }
                    else if (duplicatedAntigens != null && duplicatedAntigens.Count == 1)
                    {
                        MessageBox.Show($"Selected antigen already has record that is not expired: {duplicatedAntigens.First().AntigenName}", "Error");
                        return(false);
                    }
                }

                var lotNumber     = SetLotNumber();
                var CalibControls = new List <CalibControl>();

                var dilutionFactor = double.Parse(DilutionFactorTextBox.Text);
                var barcodes       = new List <Barcode>();

                foreach (var antigenRange in antigenRanges)
                {
                    CalibControls.Add(new CalibControl
                    {
                        AntigenGroup   = GroupListbx.Text,
                        ArrayId        = ArrayListbx.SelectedValue.ToString(),
                        AntigenId      = antigenRange.AntigenId,
                        DilutionDate   = DilutionDatePicker.SelectedDate.Value.Date,
                        DilutionFactor = dilutionFactor.ToString(),
                        ExpirationDate = Convert.ToDateTime(ExpirationDateTextBox.Text),
                        LotNumber      = lotNumber,
                        Min            = Convert.ToDouble(antigenRange.Min),
                        Max            = Convert.ToDouble(antigenRange.Max),
                        Serum          = string.Join(",", SerumReferences.Select(a => a.ReferenceNumber)),
                        Type           = App.ccPageType.ToString()
                    });

                    barcodes.Add(new Barcode
                    {
                        AntigenName    = antigenRange.AntigenName,
                        ExpirationDate = ExpirationDateTextBox.Text,
                        LotNumber      = lotNumber
                    });
                }


                App.CCProvider.CreateCalibControl(CalibControls);
                MessageBox.Show("Successfully Saved. Click OK to start printing labels");

                PrintDialog printDialog = null;
                foreach (var antigenRange in antigenRanges)
                {
                    var printPage = new CCLabel();
                    if (printDialog != null)
                    {
                        printPage.printDlg = printDialog;
                    }

                    printPage.Barcode = new Barcode
                    {
                        AntigenName    = antigenRange.AntigenName,
                        ExpirationDate = ExpirationDateTextBox.Text,
                        LotNumber      = lotNumber
                    };
                    printPage.NumberOfLabels = Convert.ToInt32(QuantityLabelTextBox.Text);
                    printPage.ShowDialog();

                    printDialog = printPage.printDlg;
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ Messages.Exception} - log: {ex.Data["logNumber"]}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
        }
示例#4
0
 private void RemoveSerum_Click(object sender, RoutedEventArgs e)
 {
     SerumReferences.Remove(SerumRefGrid.SelectedItem as SerumReference);
     SerumRefGrid.ItemsSource = SerumReferences;
     SerumRefGrid.Items.Refresh();
 }