コード例 #1
0
        private void buttonSave_Click(object sender, RoutedEventArgs e)
        {
            Stream FileStream = null;

            grid1.IsEnabled = false;
            if (save())
            {
                labelError.Foreground = Brushes.CadetBlue;
                labelError.Content = "Report saved....";
                labelError.Visibility = System.Windows.Visibility.Visible;
                timer1.Start();

                if (draftWorkingOn != null)
                {
                    ((List<Record>)dataGridDraftsList.DataContext).Remove(draftWorkingOn);
                    draftWorkingOn = null;
                    DraftList list = new DraftList();
                    list.list = (List<Record>)dataGridDraftsList.DataContext;
                    FileStream = File.Create(draftsPath);
                    BinaryFormatter serializer = new BinaryFormatter();
                    serializer.Serialize(FileStream, list);
                    FileStream.Close();
                }

            }
            grid1.IsEnabled = true;
        }
コード例 #2
0
        private void buttonPrint_Click(object sender, RoutedEventArgs e)
        {
            Stream FileStream = null;
            if (grid3.Visibility == System.Windows.Visibility.Visible)
            {
                if ((Record)dataGrid1.SelectedItem == null)
                {
                    MessageBox.Show("Please select a report first.", "", MessageBoxButton.OK, MessageBoxImage.Stop);
                    return;
                }
            }

            if (grid3.Visibility == System.Windows.Visibility.Hidden)
            {
                labelError.Foreground = Brushes.CadetBlue;
                labelError.Content = "Saving report in the database....";
                labelError.Visibility = System.Windows.Visibility.Visible;
                if (!save())
                {
                    return;
                }
            }

            if (draftWorkingOn != null)
            {
                ((List<Record>)dataGridDraftsList.DataContext).Remove(draftWorkingOn);
                draftWorkingOn = null;
                DraftList list = new DraftList();
                list.list = (List<Record>)dataGridDraftsList.DataContext;
                FileStream = File.Create(draftsPath);
                BinaryFormatter serializer = new BinaryFormatter();
                serializer.Serialize(FileStream, list);
                FileStream.Close();
            }

            if (grid3.Visibility == System.Windows.Visibility.Hidden)
            {
                labelError.Foreground = Brushes.CadetBlue;
                labelError.Visibility = System.Windows.Visibility.Visible;
                labelError.Content = "Report Saved...";
            }

            Window1 printC = new Window1();
            printC.Owner = this;
            printC.Left = this.Left;
            printC.Top = this.Top;
            printC.ShowDialog();

            if (!canceled)
            {
                labelError.Foreground = Brushes.CadetBlue;
                labelError.Visibility = System.Windows.Visibility.Visible;
                labelError.Content = "Transferring report to the printer....";

                print();

                labelError.Content = "Report has been transferred to the printer....";
            }

            timer1.Start();
        }
コード例 #3
0
        private void buttonSaveDraft_Click(object sender, RoutedEventArgs e)
        {
            if (textPatientName.Text != "")
            {
                DraftList list;
                Stream FileStream = null;
                BinaryFormatter deserializer;
                if (dataGridDraftsList.DataContext == null)
                {
                    try
                    {
                        FileStream = File.OpenRead(draftsPath);
                        deserializer = new BinaryFormatter();
                        list = (DraftList)deserializer.Deserialize(FileStream);
                        FileStream.Close();
                    }
                    catch
                    {
                        if (FileStream != null)
                        {
                            FileStream.Close();
                        }
                        list = new DraftList();
                    }
                }
                else
                {
                    list = new DraftList();
                    list.list = (List<Record>)dataGridDraftsList.DataContext;
                }

                int months = 0;
                if (comboBoxTitle.Text == "Baby")
                    Int32.TryParse(textMonth.Text, out months);
                int years = 0;
                Int32.TryParse(textAge.Text, out years);

                list.list.Add(new Record(textReportNo.Text, textWardNo.Text, textBhtNo.Text, comboBoxTitle.Text, textPatientName.Text, years, months, comboBoxGender.Text, textBoxListToStringArray(speciTexts), textMacroscopy.Text, textMicroscopy.Text, textConclusion.Text, dateToString(datePicker2.SelectedDate.Value), dateToString(datePicker1.SelectedDate.Value), comboBoxSeverity.Text, textClinicalDetails.Text));
                if (draftWorkingOn != null)
                {
                    list.list.Remove(draftWorkingOn);
                    draftWorkingOn = null;
                }
                FileStream = File.Create(draftsPath);
                BinaryFormatter serializer = new BinaryFormatter();
                serializer.Serialize(FileStream, list);
                FileStream.Close();

                labelError.Foreground = Brushes.CadetBlue;
                labelError.Content = "Draft Saved successfully";
                labelError.Visibility = System.Windows.Visibility.Visible;
                timer1.Start();
            }
            else
                MessageBox.Show("Can't save a draft without a name.", "Draft Not Saved", MessageBoxButton.OK);
        }
コード例 #4
0
 private void buttonDeleteDraft_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Are you sure that you want to delete the selected draft?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         Stream FileStream;
         ((List<Record>)dataGridDraftsList.DataContext).Remove((Record)dataGridDraftsList.SelectedItem);
         DraftList list = new DraftList();
         list.list = (List<Record>)dataGridDraftsList.DataContext;
         FileStream = File.Create(draftsPath);
         BinaryFormatter serializer = new BinaryFormatter();
         serializer.Serialize(FileStream, list);
         FileStream.Close();
         dataGridDraftsList.Items.Refresh();
     }
 }