예제 #1
0
        private void btnManageFunds_Click(object sender, EventArgs e)
        {
            OrderDataAccess       ordersDA  = new OrderDataAccess();
            OrderDetailDataAccess detailsDA = new OrderDetailDataAccess();

            mlvOrders.Items.Clear();
            decimal loss = 0, profit = 0;

            foreach (var order in ordersDA.GetList())
            {
                ListViewItem item = new ListViewItem(order.OrderID.ToString());
                item.SubItems.Add(order.CustomerID.ToString());
                item.SubItems.Add(order.OrderDate.ToLongTimeString());
                item.SubItems.Add(order.OrderState.ToString());
                if (detailsDA.GetList().Where(d => d.OrderID == order.OrderID).ToList().Count > 0)
                {
                    foreach (var orderDetails in detailsDA.GetList().Where(d => d.OrderID == order.OrderID).ToList())
                    {
                        item.SubItems.Add(orderDetails.Loss + "$");
                        loss += orderDetails.Loss;
                        item.SubItems.Add(orderDetails.Profit + "$");
                        profit += orderDetails.Profit;
                    }
                }
                else
                {
                    item.SubItems.Add("---- $");
                    item.SubItems.Add("---- $");
                }
                mlvOrders.Items.Add(item);
            }
            lblLoss.Text   = loss.ToString() + "$";
            lblProfit.Text = profit.ToString() + "$";

            if ((profit - loss) > 0)
            {
                lblBalance.ForeColor = Color.SeaGreen;
                lblBalance.Text      = (profit - loss).ToString() + "$";
            }
            else
            {
                lblBalance.ForeColor = Color.Red;
                lblBalance.Text      = (loss - profit).ToString() + "$";
            }
            pnlManageFunds.Visible = true;
            pnlManageFunds.BringToFront();
        }