Exemplo n.º 1
0
        public int BuyBook(string title, string name, string email, string address, int quantity)
        {
            iRemBook = (IRemBook)Activator.GetObject(typeof(IRemBook), "http://localhost:9000/StoreServer/RemBook.rem");
            Book   book   = iRemBook.getBookByTitle(title);
            Client client = new Client();

            client.Name    = name;
            client.email   = email;
            client.address = address;
            return(iRemBook.sellBook(book, client, quantity));
        }
Exemplo n.º 2
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();
                        }
                    }
                }
            }
        }