Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text))
            {
                MessageBox.Show("Client CPF field cannot be empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                this.label6.Text = (bk.price * Double.Parse(numericUpDown1.Value.ToString())).ToString();

                Client clt = remClient.getClient(long.Parse(textBox1.Text));

                if (clt == null)
                {
                    MessageBox.Show("Client not found!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (numericUpDown1.Value > remBook.getBookStock(bk))
                    {
                        DialogResult proceed = MessageBox.Show("Number of copies requested is not available in stock.\nAn order will be created. Proceed?", "Atention", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                        if (proceed.Equals(DialogResult.Yes))
                        {
                            Thread.Sleep(1000);

                            DialogResult result = MessageBox.Show("Corfirm order?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                            if (result.Equals(DialogResult.Yes))
                            {
                                int id = remBook.orderBook(bk, 10 + int.Parse(numericUpDown1.Value.ToString()));
                                MessageBox.Show("Successfully created order!\nOrder ID: " + id);
                            }
                        }
                    }
                    else
                    {
                        Thread.Sleep(1000);
                        DialogResult proceed = MessageBox.Show("Confirm sale?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                        if (proceed.Equals(DialogResult.Yes))
                        {
                            Sale sl = remBook.sellBook(bk, clt, int.Parse(numericUpDown1.Value.ToString()));

                            this.Enabled = false;
                            (new Receipt(this, sl)).Show();
                        }
                    }
                }
            }
        }
Exemple #2
0
        public BookWindow(Book book)
        {
            remBook = (IRemBook)GetRemote.New(typeof(IRemBook));
            bk      = book;

            InitializeComponent();
            this.label10.Text = bk.id.ToString();
            this.label11.Text = bk.title;
            this.label12.Text = bk.author;
            this.label13.Text = bk.publisher;
            this.label14.Text = bk.pubDate;
            this.label15.Text = bk.genre;
            this.label16.Text = bk.volume.ToString();
            this.label17.Text = bk.edition.ToString();
            this.label18.Text = (remBook.getBookStock(bk)).ToString();
            this.label20.Text = bk.price.ToString();
        }