public void Save()
 {
     if (CheckData())
     {
         PathologyService service = new PathologyService();
         if ((this.DataContext as PathologyEntity).Id == -1 && !CheckDoppione())
         {
             if (service.Add(this.DataContext as PathologyEntity) == 0)
             {
                 MessageBox.Show("Salvato!");
                 this.DataContext = new PathologyEntity();
             }
             else
             {
                 MessageBox.Show("Errore durante il salvataggio!");
             }
         }
         else
         {
             if (service.Update(this.DataContext as PathologyEntity) == 0)
             {
                 MessageBox.Show("Salvato!");
             }
             else
             {
                 MessageBox.Show("Errore durante il salvataggio!");
             }
         }
     }
 }
        public void RefreshData()
        {
            PathologyService service = new PathologyService();

            pathologies = new ObservableCollection <PathologyEntity>(service.GetAllPathologies());
            this.lvPathology.ItemsSource = pathologies;
        }
        private void DeleteUserButton_Click(object sender, RoutedEventArgs e)
        {
            var selectedItem = this.lvPathology.SelectedItem;

            if (selectedItem != null)
            {
                PathologyEntity pathology = selectedItem as PathologyEntity;

                PathologyService service = new PathologyService();
                if (MessageBox.Show("Sei sicuro di voler eliminare \"" + pathology.PathologyName + " \" ?", "Elimina patologia", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    if (service.Delete(pathology) == 0)
                    {
                        MessageBox.Show("cancellato!");
                        this.RefreshData();
                    }
                    else
                    {
                        MessageBox.Show("NON cancellato!");
                    }
                }
                else
                {
                    MessageBox.Show("NON cancellato!");
                }
            }
        }
        private bool CheckDoppione()
        {
            string pathologyName = (this.DataContext as PathologyEntity).PathologyName.ToLower();

            PathologyService       service     = new PathologyService();
            List <PathologyEntity> pathologies = service.GetAllPathologies();

            if (pathologies.Any(x => x.PathologyName.ToLower().Equals(pathologyName)))
            {
                return(true);
            }

            return(false);
        }
예제 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab.Text == "同期费用比")
            {
                var    flag = rb_all.Checked ? "all" : (rb_in.Checked ? "in" : (rb_out.Checked ? "out" : null));
                Stream ms   = new MemoryStream(Properties.Resources.CurrentPeriod);
                reportViewer2.LocalReport.LoadReportDefinition(ms);
                ReportDataSource reportDataSource = new ReportDataSource();
                reportDataSource.Name = "DataSet1";


                Task <DataTable> t = new SameReriodIncomeReportService(
                    flag
                    , dtp_current_start.Value.Date.ToShortDateString()
                    , dtp_current_end.Value.Date.ToShortDateString()
                    , dtp_period_start.Value.Date.ToShortDateString()
                    , dtp_period_end.Value.Date.ToShortDateString()).DoTable();

                t.Wait();
                reportDataSource.Value = t.Result;
                reportViewer2.LocalReport.DataSources.Clear();
                reportViewer2.LocalReport.DataSources.Add(reportDataSource);
                reportViewer2.LocalReport.Refresh();

                reportViewer2.Tag = t.Result;
                reportViewer2.RefreshReport();
            }

            if (tabControl1.SelectedTab.Text == "38项费用")
            {
                var    flag = radioButton2.Checked ? "all" : (radioButton3.Checked ? "out" : (radioButton1.Checked ? "in" : null));
                Stream ms   = new MemoryStream(Properties.Resources.ThirtyEight);
                reportViewer1.LocalReport.LoadReportDefinition(ms);
                ReportDataSource reportDataSource = new ReportDataSource();
                reportDataSource.Name = "ThirtyEight2";


                Task <DataTable> t = new ThirtyEightFeeReportService(flag
                                                                     , dateTimePicker2.Value.Date.ToShortDateString()
                                                                     , dateTimePicker1.Value.Date.ToShortDateString()
                                                                     , dateTimePicker4.Value.Date.ToShortDateString()
                                                                     , dateTimePicker3.Value.Date.ToShortDateString()).DoTable();

                t.Wait();
                reportDataSource.Value = t.Result;
                reportViewer1.LocalReport.DataSources.Clear();
                reportViewer1.LocalReport.DataSources.Add(reportDataSource);
                reportViewer1.LocalReport.Refresh();

                reportViewer1.Tag = t.Result;
                reportViewer1.RefreshReport();
            }
            if (tabControl1.SelectedTab.Text == "检验项目比")
            {
                var flag = radioButton5.Checked ? "all"
               : (radioButton6.Checked ? "out"
               : (radioButton4.Checked ? "in" : null));
                Stream ms = new MemoryStream(Properties.Resources.WorkloadChangeandWeight);
                reportViewer3.LocalReport.LoadReportDefinition(ms);
                ReportDataSource reportDataSource = new ReportDataSource();
                reportDataSource.Name = "DataSet1";


                Task <DataTable> t = new WorkloadWeightReportService(flag
                                                                     , dateTimePicker6.Value.Date.ToShortDateString()
                                                                     , dateTimePicker5.Value.Date.ToShortDateString()
                                                                     , dateTimePicker8.Value.Date.ToShortDateString()
                                                                     , dateTimePicker7.Value.Date.ToShortDateString()).DoTable();

                t.Wait();
                reportDataSource.Value = t.Result;
                reportViewer3.LocalReport.DataSources.Clear();
                reportViewer3.LocalReport.DataSources.Add(reportDataSource);
                reportViewer3.LocalReport.Refresh();

                reportViewer3.Tag = t.Result;
                reportViewer3.RefreshReport();
            }
            if (tabControl1.SelectedTab.Text == "病理项目比")
            {
                var flag = radioButton8.Checked ? "all"
                : (radioButton9.Checked ? "out"
                : (radioButton7.Checked ? "in" : null));
                Stream ms = new MemoryStream(Properties.Resources.WorkloadChangeandWeight);
                reportViewer4.LocalReport.LoadReportDefinition(ms);
                ReportDataSource reportDataSource = new ReportDataSource();
                reportDataSource.Name = "DataSet1";


                Task <DataTable> t = new PathologyService(flag
                                                          , dateTimePicker10.Value.Date.ToShortDateString()
                                                          , dateTimePicker9.Value.Date.ToShortDateString()
                                                          , dateTimePicker12.Value.Date.ToShortDateString()
                                                          , dateTimePicker11.Value.Date.ToShortDateString()).DoTable();

                t.Wait();
                reportDataSource.Value = t.Result;
                reportViewer4.LocalReport.DataSources.Clear();
                reportViewer4.LocalReport.DataSources.Add(reportDataSource);
                reportViewer4.LocalReport.Refresh();

                reportViewer4.Tag = t.Result;
                reportViewer4.RefreshReport();
            }
        }