示例#1
0
        private void buttonFindOrder_Click(object sender, EventArgs e)
        {
            listViewItems.Items.Clear();
            listViewOrder.Items.Clear();

            OrderDTO order = new OrderDTO();

            try
            {
                order = _ordersManager.GetOrderById(Convert.ToInt64(textBox1.Text));
            }
            catch
            {
                MessageBox.Show("Incorrect data inputted!!!");
                textBox1.Text = "";
                return;
            }

            if (order is null)
            {
                return;
            }

            string[] row1 = { "Full Name: ", _ordersManager.GetUsersFullNameById(order.CustomerID) };
            string[] row2 = { "Date: ", order.Date.ToString() };
            string[] row3 = { "Comments: ", order.Comments };

            string[] row1_ = { "Last Update: ", order.LastUpdate.ToString() };
            string[] row2_ = { "Last Update By", _ordersManager.GetUsersFullNameById(order.LastStaffUpdated != null ? order.LastStaffUpdated.Value : 0) };
            string[] row3_ = { "Status: ", _ordersManager.GetStatusName(order.StatusID) };

            listViewOrder.Items.Add(new ListViewItem(row1));
            listViewOrder.Items.Add(new ListViewItem(row2));
            listViewOrder.Items.Add(new ListViewItem(row3));

            listViewOrder.Items.Add(new ListViewItem(row3_));
            listViewOrder.Items.Add(new ListViewItem(row1_));
            listViewOrder.Items.Add(new ListViewItem(row2_));

            List <OrdersRefDTO> refs = _ordersManager.GetItemsInOrder(Convert.ToInt64(textBox1.Text));

            foreach (var i in refs)
            {
                string[] row = { _ordersManager.GetItemNameById(i.refItemID),
                                 i.refItemID.ToString(),
                                 _ordersManager.GetItemById(i.refItemID).Price.ToString(),
                                 i.amount.ToString() };

                listViewItems.Items.Add(new ListViewItem(row));
            }
        }