Beispiel #1
0
        public void processDicom(DicomInfo dicom, String filePath)
        {
            verifyDicom verify     = new verifyDicom();
            Boolean     validDicom = verify.verify(filePath);

            if (validDicom == true)
            {
                dicom.fileReadable = true;
                readDicom reader = new readDicom();
                reader.read(dicom);

                if (dicom.fileReadable == true)
                {
                    CheckIfPatientExist(dicom);
                    InsertToDatabase database = new InsertToDatabase();
                    database.insert(dicom, filePath);
                }
            }
            else
            {
                Console.WriteLine("Not a Valid DICOM file");
            }
        }
Beispiel #2
0
        private void exec_btn_Click(object sender, RoutedEventArgs e)
        {
            if (mode.Equals("Add"))
            {
                // Если мы оставили все поля пустыми:
                if (name_txt.Text == "" && birth_txt.Text == "")
                {
                    MessageBox.Show("Вы оставили все поля пустыми", "Все поля пустые...", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                // Если мы оставили все поля пустыми:
                else if (name_txt.Text == "" || birth_txt.Text == "")
                {
                    MessageBox.Show("Какое то пеле оставили пустым", "Пустое к-ето поле...", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    try
                    {
                        Author author = new Author
                        {
                            Id            = autoIncrement,
                            Name          = name_txt.Text,
                            Date_of_Birth = int.Parse(birth_txt.Text),
                        };

                        // Add to Books table of databese:
                        string msg = InsertToDatabase.InsertAuthor(author);
                        MessageBox.Show(msg, "Added");

                        (this.Owner as MainWindow).listBox1.Items.Add(author);
                        (this.Owner as MainWindow).listBox1.Items.Clear();

                        authors = ReadFromDatabase.ReadAllAuthors().ToArray();

                        // Ubdate listbox to curent datas from a table Books:
                        foreach (Author b in authors)
                        {
                            (this.Owner as MainWindow).listBox1.Items.Add(b);
                        }
                        ClearFields();
                        this.Close();
                    }
                    catch { MessageBox.Show("Вы ввели символи, или строку вместо целого числа", "Не правильный формат", MessageBoxButton.OK, MessageBoxImage.Warning); }
                }
            }
            else if (mode.Equals("Update"))
            {
                // Если мы оставили все поля пустыми:
                if (name_txt.Text == "" && birth_txt.Text == "")
                {
                    MessageBox.Show("Вы оставили все поля пустыми", "Все поля пустые...", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                // Если мы оставили все поля пустыми:
                else if (name_txt.Text == "" || birth_txt.Text == "")
                {
                    MessageBox.Show("Какое то пеле оставили пустым", "Пустое к-ето поле...", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    try
                    {
                        My_Context db    = new My_Context();
                        int        index = (this.Owner as MainWindow).listBox1.Items.IndexOf(this.author);

                        // Get Id entity from the Table:
                        int id = author.Id;

                        // Get entity from DbSet to Id and edit it:
                        List <Author> all     = ReadFromDatabase.ReadAllAuthors();
                        Author        updated = all.Where(u => u.Id == id).FirstOrDefault();
                        //updated.Id = index + 1;
                        updated.Name          = name_txt.Text;
                        updated.Date_of_Birth = int.Parse(birth_txt.Text);

                        // Update to Database:
                        db.Entry(updated).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        //MessageBox.Show(msg, "Updated");

                        (this.Owner as MainWindow).listBox1.Items.RemoveAt(index);
                        (this.Owner as MainWindow).listBox1.Items.Insert(index, updated);
                        (this.Owner as MainWindow).listBox1.Items.Clear();

                        authors = ReadFromDatabase.ReadAllAuthors().ToArray();
                        foreach (Author b in authors)
                        {
                            (this.Owner as MainWindow).listBox1.Items.Add(b);
                        }
                        this.Close();
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message, "System Exception..Failed..", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("Incorrect sting parameter 'mode'..", "Something went wrong...", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Beispiel #3
0
        private void add_btn_Click(object sender, EventArgs e)
        {
            if (mode.Equals("Add")) // mode == "Add"
            {
                // Если мы оставили все поля пустыми:
                if (title_txt.Text == "" && age_txt.Text == "" && author_txt.Text == "" && genre_txt.Text == "")
                {
                    MessageBox.Show("Вы оставили все поля пустыми", "Все поля пустые...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                // Если мы оставили все поля пустыми:
                else if (title_txt.Text == "" || age_txt.Text == "" || author_txt.Text == "" || genre_txt.Text == "")
                {
                    MessageBox.Show("Какое то пеле оставили пустым", "Пустое к-ето поле...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    try
                    {
                        Book book = new Book
                        {
                            Id           = autoIncrement,
                            Title        = title_txt.Text,
                            Age_Release  = int.Parse(age_txt.Text),
                            Id_Author    = int.Parse(author_txt.Text),
                            Id_Genre     = int.Parse(genre_txt.Text),
                            Date_Updated = DateTime.Now
                        };

                        // Add to Books table of databese:
                        string msg = InsertToDatabase.InsertBook(book);
                        MessageBox.Show(msg, "Added");

                        (this.Owner as Main_Form).listBox1.Items.Add(book);
                        (this.Owner as Main_Form).listBox1.Items.Clear();
                        (this.Owner as Main_Form).listBox1.Items.AddRange(ReadFromDatabase.ReadAllBooks().ToArray());
                        ClearFields();
                        this.Close();
                    }
                    catch { MessageBox.Show("Вы ввели символи, или строку вместо целого числа", "Не правильный формат", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
                }
            }
            else if (mode.Equals("Edit"))
            {
                // Если мы оставили все поля пустыми:
                if (title_txt.Text == "" && age_txt.Text == "" && author_txt.Text == "" && genre_txt.Text == "")
                {
                    MessageBox.Show("Вы оставили все поля пустыми", "Все поля пустые...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                // Если мы оставили все поля пустыми:
                else if (title_txt.Text == "" || age_txt.Text == "" || author_txt.Text == "" || genre_txt.Text == "")
                {
                    MessageBox.Show("Какое то пеле оставили пустым", "Пустое к-ето поле...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    int  index   = (this.Owner as Main_Form).listBox1.Items.IndexOf(this.book);
                    Book updated = new Book();
                    updated.Id           = index + 1;
                    updated.Title        = title_txt.Text;
                    updated.Age_Release  = int.Parse(age_txt.Text);
                    updated.Id_Author    = int.Parse(author_txt.Text);
                    updated.Id_Genre     = int.Parse(genre_txt.Text);
                    updated.Date_Updated = DateTime.Now;

                    string msg = UpdateFromDatrabase.EditBook(updated);
                    MessageBox.Show(msg, "Updated");

                    (this.Owner as Main_Form).listBox1.Items.RemoveAt(index);
                    (this.Owner as Main_Form).listBox1.Items.Insert(index, updated);
                    (this.Owner as Main_Form).listBox1.Items.Clear();
                    (this.Owner as Main_Form).listBox1.Items.AddRange(ReadFromDatabase.ReadAllBooks().ToArray());
                    this.Close();
                }
            }
            else if (mode.Equals("ServiceWCF"))
            {
                // Если мы оставили все поля пустыми:
                if (title_txt.Text == "" && age_txt.Text == "" && author_txt.Text == "" && genre_txt.Text == "")
                {
                    MessageBox.Show("Вы оставили все поля пустыми", "Все поля пустые...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                // Если мы оставили все поля пустыми:
                else if (title_txt.Text == "" || age_txt.Text == "" || author_txt.Text == "" || genre_txt.Text == "")
                {
                    MessageBox.Show("Какое то пеле оставили пустым", "Пустое к-ето поле...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    try
                    {
                        BookService service = new BookService();
                        service.Title        = title_txt.Text;
                        service.Age_Release  = int.Parse(age_txt.Text);
                        service.Id_Author    = int.Parse(author_txt.Text);
                        service.Id_Genre     = int.Parse(genre_txt.Text);
                        service.Date_Updated = DateTime.Now;

                        client.Insert_Book(service);

                        ClearFields();
                        Close();
                    }
                    catch (DataException dex)
                    {
                        MessageBox.Show(dex.Message, "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Beispiel #4
0
        private void add_btn_Click(object sender, EventArgs e)
        {
            if (mode.Equals("Add"))
            {
                if (name_txt.Text == "" && date_of_birth_txt.Text == "")
                {
                    MessageBox.Show("Вы оставили все поля пустыми", "Все поля пустые...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (name_txt.Text == "" || date_of_birth_txt.Text == "")
                {
                    MessageBox.Show("Какое то пеле оставили пустым", "Пустое к-ето поле...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    try
                    {
                        Author author = new Author
                        {
                            Id            = autoIncrement,
                            Name          = name_txt.Text,
                            Date_of_Birth = int.Parse(date_of_birth_txt.Text)
                        };

                        string msg = InsertToDatabase.InsertAuthor(author);
                        MessageBox.Show(msg, "Added");
                        (this.Owner as Main_Form).listBox1.Items.Add(author);
                        (this.Owner as Main_Form).listBox1.Items.Clear();
                        (this.Owner as Main_Form).listBox1.Items.AddRange(ReadFromDatabase.ReadAllAuthors().ToArray());
                        name_txt.Text          = "";
                        date_of_birth_txt.Text = "";
                        this.Close();
                    }
                    catch { MessageBox.Show("Вы ввели символи, или строку вместо целого числа", "Не правильный формат", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
                }
            }
            else if (mode.Equals("Edit"))
            {
                if (name_txt.Text == "" && date_of_birth_txt.Text == "")
                {
                    MessageBox.Show("Вы оставили все поля пустыми", "Все поля пустые...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (name_txt.Text == "" || date_of_birth_txt.Text == "")
                {
                    MessageBox.Show("Какое то пеле оставили пустым", "Пустое к-ето поле...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    int    index   = (this.Owner as Main_Form).listBox1.Items.IndexOf(this.author);
                    Author updated = new Author();
                    updated.Id            = index + 1;
                    updated.Name          = name_txt.Text;
                    updated.Date_of_Birth = int.Parse(date_of_birth_txt.Text);

                    string msg = UpdateFromDatrabase.EditAuthor(updated);
                    MessageBox.Show(msg, "Updated");

                    (this.Owner as Main_Form).listBox1.Items.RemoveAt(index);
                    (this.Owner as Main_Form).listBox1.Items.Insert(index, updated);
                    (this.Owner as Main_Form).listBox1.Items.Clear();
                    (this.Owner as Main_Form).listBox1.Items.AddRange(ReadFromDatabase.ReadAllAuthors().ToArray());
                    this.Close();
                }
            }
        }