/// <summary> /// /// </summary> /// <param name="numberUnits"></param> private void UpdateStock(int numberUnits) { orderQuantityInfo.Text = Convert.ToString(numberUnits); var remainingUnits = _bookInformation.Stock - numberUnits; if (Information.Status == Status.Pending) { statusProcessing.Checked = true; remainingUnits = _bookInformation.Stock; } else if (remainingUnits < 0) { remainingUnits = 0; statusWaiting.Checked = true; Information.Status = Status.Waiting; } else { statusDispatched.Checked = true; Information.Status = Status.Dispatched; } var purchaseTotal = _bookInformation.Price * numberUnits; bookStock.Text = Convert.ToString(remainingUnits); statusWaiting.Enabled = Information.Status == Status.Waiting; statusProcessing.Enabled = Information.Status == Status.Pending; statusDispatched.Enabled = Information.Status == Status.Dispatched; orderTotal.Text = LibrettoCommon.FormatDecimal(purchaseTotal); Information.Quantity = numberUnits; Information.Total = purchaseTotal; }
/// <summary> /// /// </summary> /// <param name="customerInformation"></param> private void UpdateCustomer(Customer customerInformation) { Information.CustomerId = customerInformation.Id; Information.CustomerName = customerInformation.Name; customerEmail.Text = customerInformation.Email; customerLocation.Text = customerInformation.Location; customerGuid.Text = LibrettoCommon.FormatGuid(customerInformation.Id); }
/// <summary> /// /// </summary> /// <param name="stockQuantity"></param> private void UpdateQuantity(int stockQuantity) { Information.Quantity = stockQuantity; Information.Total = _bookInformation.Price * stockQuantity; purchaseQuantityInfo.Text = Convert.ToString(stockQuantity); bookStock.Text = Convert.ToString(_bookInformation.Stock - stockQuantity); purchaseTotal.Text = LibrettoCommon.FormatDecimal(_bookInformation.Price * stockQuantity); }
/// <summary> /// /// </summary> /// <returns></returns> private bool ValidateForm() { return(string.IsNullOrEmpty(nameField.Text) == false && string.IsNullOrEmpty(emailField.Text) == false && string.IsNullOrEmpty(locationField.Text) == false && nameField.Text.Trim().Split().Length > 1 && LibrettoCommon.VerifyEmail(emailField.Text)); }
/// <summary> /// /// </summary> public BookForm(Book bookInformation) { InitializeComponent(); Text = @"Update Book"; BookInformation = bookInformation; titleField.Text = bookInformation.Title; stockField.Text = Convert.ToString(bookInformation.Stock); priceField.Text = LibrettoCommon.FormatDecimal(bookInformation.Price); }
/// <summary> /// /// </summary> /// <param name="bookInformation"></param> private void UpdateBook(Book bookInformation) { _bookInformation = bookInformation; bookGuid.Text = LibrettoCommon.FormatGuid(bookInformation.Id); bookStock.Text = Convert.ToString(bookInformation.Stock); bookPrice.Text = LibrettoCommon.FormatDecimal(bookInformation.Price); Information.BookTitle = bookInformation.Title; Information.BookId = bookInformation.Id; UpdateStock(orderQuantity.Value); }
/// <summary> /// /// </summary> /// <param name="bookInformation"></param> private void UpdateBook(Book bookInformation) { _bookInformation = bookInformation; purchaseQuantity.Minimum = 1; purchaseQuantity.Maximum = bookInformation.Stock; Information.BookId = bookInformation.Id; Information.BookTitle = bookInformation.Title; bookStock.Text = Convert.ToString(bookInformation.Stock); bookGuid.Text = LibrettoCommon.FormatGuid(bookInformation.Id); bookPrice.Text = LibrettoCommon.FormatDecimal(bookInformation.Price); UpdateQuantity(purchaseQuantity.Value); }
/// <summary> /// /// </summary> /// <param name="bookInformation"></param> /// <returns></returns> private static ListViewItem ParseBook(Book bookInformation) { return(new ListViewItem(LibrettoCommon.FormatGuid(bookInformation.Id)) { Tag = bookInformation, SubItems = { bookInformation.Title, LibrettoCommon.FormatCurrency(bookInformation.Price), Convert.ToString(bookInformation.Stock) } }); }
/// <summary> /// /// </summary> /// <param name="transactionInformation"></param> /// <returns></returns> private static ListViewItem ParseTransaction(Transaction transactionInformation) { return(new ListViewItem(LibrettoCommon.FormatDate(transactionInformation.Timestamp)) { Tag = transactionInformation, SubItems = { transactionInformation.BookTitle, transactionInformation.CustomerName, Convert.ToString(transactionInformation.Quantity), LibrettoCommon.FormatCurrency(transactionInformation.Total), transactionInformation.Description } }); }
/// <summary> /// /// </summary> /// <param name="orderInformation"></param> /// <returns></returns> public Response NotifyInsert(Order orderInformation) { var customerInformation = LibrettoDatabase.CustomerIntegration.Lookup(orderInformation.CustomerId); if (customerInformation == null) { return(Response.NotFound); } return(Send(customerInformation, $"Order {orderInformation.Id:B}", $@" <b>{orderInformation.Description}</b> <br/><br/>Book: {orderInformation.BookTitle} <br/>Customer: {orderInformation.CustomerName} <br/>Quantity: {orderInformation.Quantity} <br/>Total: {LibrettoCommon.FormatCurrency(orderInformation.Total)} <br/>Timestamp: {LibrettoCommon.FormatDate(orderInformation.Timestamp)}") ? Response.Success : Response.EmailFailure); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void CustomerForm_Load(object sender, EventArgs args) { buttonConfirm.Enabled = ValidateForm(); guidField.Text = LibrettoCommon.FormatGuid(Information.Id); }