예제 #1
0
        private void LoadCustomerInformation(int customerId, int addressId, int orderId)
        {
            lblCustomerId.Text = customerId.ToString();
            lblAddressId.Text  = addressId.ToString();
            lblOrderId.Text    = orderId.ToString();

            if (customerId > -1)
            {
                Customer customer = BalObj.GetCustomerInformation(customerId, addressId);

                if (customer != null)
                {
                    rdoUpdateCustomer.Checked = true;
                    txtFirstName.Text         = customer.FirstName;
                    txtLastName.Text          = customer.LastName;
                    txtPhoneNumber.Text       = customer.PhoneNumber1;

                    if (customer.AddressDetails != null && addressId > -1)
                    {
                        rdoUpdateAddress.Checked = true;
                        txtAddressLine1.Text     = customer.AddressDetails.AddressLine1;
                        txtAddressLine2.Text     = customer.AddressDetails.AddressLine2;
                        txtCity.Text             = customer.AddressDetails.City;
                        txtPinCode.Text          = customer.AddressDetails.PinCode;
                    }
                    else
                    {
                        rdoCreateAddress.Checked = true;
                    }
                }
            }
            else
            {
                rdoCreateAddress.Checked  = true;
                rdoCreateCustomer.Checked = true;
            }

            if (orderId > 0)
            {
                Order order = BalObj.GetOrder(orderId);

                if (order != null && order.OrderItems.Count > 0)
                {
                    foreach (DataGridViewRow row in dgMenuView.Rows)
                    {
                        int itemId = Convert.ToInt32(row.Cells["dcItemId"].Value);

                        OrderItem orderItem = order.OrderItems.FirstOrDefault(x => x.ItemId == itemId);
                        if (orderItem != null)
                        {
                            row.Cells["dcItemTotal"].Value    = orderItem.TotalPrice.ToString(CultureInfo.InvariantCulture);
                            row.Cells["dcItemQuantity"].Value = orderItem.Quantity.ToString();
                        }
                    }

                    txtDiscount.Text   = order.Discount.ToString();
                    lblTotalPrice.Text = order.Total.ToString();
                }
            }
        }
예제 #2
0
        private void DisplayData(int orderId)
        {
            Order order = BalObj.GetOrder(orderId);

            if (order != null && order.CustomerDetails != null)
            {
                lblCustomerId.Text = order.CustomerDetails.CustomerId.ToString();
                lblName.Text       = string.Format("{0} {1}", order.CustomerDetails.FirstName, order.CustomerDetails.LastName);
                lblPhone.Text      = order.CustomerDetails.PhoneNumber1;
            }

            if (order != null && order.AddressDetails != null)
            {
                lblAddressId.Text = order.AddressDetails.AddressId.ToString();
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(order.AddressDetails.AddressLine1);
                sb.AppendLine(order.AddressDetails.AddressLine2);
                sb.AppendLine(order.AddressDetails.City);
                sb.AppendLine(order.AddressDetails.PinCode);
                lblAddress.Text = sb.ToString();
            }

            if (order != null)
            {
                lblOrderID.Text         = order.OrderId.ToString();
                lblOrderStatus.Text     = order.Status.ToString();
                lblTotalWithoutTax.Text = order.TotalWithoutTax.ToString(CultureInfo.InvariantCulture);
                lblTotal.Text           = order.Total.ToString();
                lblDiscount.Text        = order.Discount.ToString();
                lblPlacedOn.Text        = order.PlacedOn.ToString();
            }

            if (order != null && order.OrderItems != null && order.OrderItems.Count > 0)
            {
                dgOrderItems.AutoGenerateColumns = false;
                dgOrderItems.DataSource          = order.OrderItems;
            }
        }