示例#1
0
        private void SellButton_Click(object sender, EventArgs e)
        {
            this.book = userInteract.getBook(titleBox.Text, authorBox.Text, user);

            if (userInteract.existsBook(this.book))
            {
                if (!quantityBox.Text.Equals(""))
                {
                    if (Int32.Parse(quantityBox.Text) <= book.quantity)
                    {
                        book.addObserver(user);
                        userInteract.sellBook(book, Int32.Parse(quantityBox.Text));

                        if (Int32.Parse(quantityBox.Text) == book.quantity)
                        {
                            GeneratePDF generatePDF = new GeneratePDF();
                            GenerateCSV generateCSV = new GenerateCSV();

                            String text = "Title: " + book.title + "\n" +
                                          "Author: " + book.author + "\n" +
                                          "Genre: " + book.genre;
                            String filename = book.author + "-" + book.title;
                            generatePDF.createPDF(filename, text);

                            generateCSV.addNeededBook(book.title, book.author);


                            MessageBox.Show("There are no more books with: \n" +
                                            "Title: " + book.title + "\n" +
                                            "Author: " + book.author);
                        }


                        MessageBox.Show("Selled " + quantityBox.Text + " books: \n" +
                                        "Title: " + titleBox.Text + "\n" +
                                        "Author: " + authorBox.Text + "\n" +
                                        "Total price: " + totalLabel.Text);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Insufficient stock!");
                    }
                }
                else
                {
                    MessageBox.Show("Please fill the Quantity field!");
                }
            }
            else
            {
                MessageBox.Show("This book doesn't exist!");
            }
        }
示例#2
0
        public void Write2File(long iterations = 10, int progLength = 20)
        {
            MyWatch     t           = new MyWatch();
            GenerateCSV generateCSV = new GenerateCSV();

            t.Start();

            using (StreamWriter sw = new StreamWriter(myFn))
            {
                string    line;
                MyProgBar progressBar = new MyProgBar(iterations, progLength);
                progressBar.Init();

                for (int i = 1; i <= iterations; i++)
                {
                    progressBar.Step(i);
                    line = generateCSV.GenerateLine();
                    sw.WriteLine(line);
                }
            }
            t.StopAndPrint();
        }