Exemplo n.º 1
0
        private void BackgroundWorkerMain_DoWork(object sender, DoWorkEventArgs e)
        {
            List <string> treatcodes = new List <string>();

            string[] mkbcodesArray = mkbcodes.Split(',');

            BackgroundWorker backgroundWorker = sender as BackgroundWorker;
            double           progressCurrent  = 0;
            double           progressStep     = 20.0 / (mkbcodesArray.Length + selectedFilials.Length);

            foreach (string mkbcode in mkbcodesArray)
            {
                foreach (string filial in selectedFilials)
                {
                    backgroundWorker.ReportProgress((int)progressCurrent, "Получение данных о лечениях для диагноза " + mkbcode + " для филиала " + filial);
                    filid = filials.First(i => i.SHORTNAME == filial).FILID;
                    treatcodes.AddRange(DataHandle.GetTreatcodes(bdate, fdate, treatcount, mkbcode, filid));
                    progressCurrent += progressStep;
                }
            }

            if (treatcodes.Count == 0)
            {
                MessageBox.Show("Не удалось найти лечения по заданным параметрам", "", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            List <ItemTreatmentDetails> details = DataHandle.GetDetails(treatcodes, backgroundWorker, 20);

            if (details.Count == 0)
            {
                MessageBox.Show("Не удалось получить информацию про лечения", "", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            string filePrefix = "Отчет по использованию направлений " + mkbcodes + " с " + bdate + " по " + fdate;
            string resultFile = NpoiExcel.WriteDataToExcel(details, filePrefix, backgroundWorker, 90);

            if (File.Exists(resultFile))
            {
                Process.Start(resultFile);
            }

            backgroundWorker.ReportProgress(100, "Завершено");
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            BackgroundWorker backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork             += BackgroundWorkerFilials_DoWork;
            backgroundWorker.RunWorkerCompleted += BackgroundWorkerFilials_RunWorkerCompleted;
            backgroundWorker.RunWorkerAsync();

            Closed += (s, e) => { DataHandle.CloseConnection(); };

            DatePickerBegin.SelectedDate  = DateTime.Now.AddDays(-30);
            DatePickerFinish.SelectedDate = DateTime.Now;
            TextBoxMkbCodes.Text          = "g90.9";
            TextBoxTreatCount.Text        = "30";
            ListBoxSelected.Items.Add("СУЩ");
            ListBoxSelected.Items.Add("МДМ");
            ListBoxSelected.Items.Add("М-СРЕТ");
        }
Exemplo n.º 3
0
 private void BackgroundWorkerFilials_DoWork(object sender, DoWorkEventArgs e)
 {
     filials = DataHandle.GetFilialList();
     filials = filials.OrderBy(p => p.SHORTNAME).ToList();
 }