private void UpdatePostionList() { try { DayPositionList.BeginUpdate(); DayPositionList.Items.Clear(); DayPositionList.Columns[4].Text = refresh_pl_count++.ToString(); foreach (var jp in DataSet.gPositionList) { var ja = jp.Value; int quantity = ja.inventory_quantitiy - ja.stock_quantity; if (quantity != 0) { ListViewItem item = new ListViewItem(); item.SubItems[0].Text = ja.stock_code; item.SubItems.Add(ja.stock_name); string direction = (quantity > 0) ? "买入" : "卖出"; item.SubItems.Add(direction); item.SubItems.Add(quantity.ToString()); if (direction.Equals("买入")) { item.ForeColor = Color.Red; } else if (direction.Equals("卖出")) { item.ForeColor = QuoteForm.RGB(0x65E339);; } DayPositionList.Items.Add(item); } } DayPositionList.EndUpdate(); } catch (Exception e) { MessageBox.Show(e.ToString()); } }
private void UpdateOrderList() { try { OrderList.Columns[8].Text = refresh_ol_count++.ToString(); var data_item = mOrderListDataSet.getItems(); if (data_item != null) { int top_index = (OrderList.TopItem != null) ? OrderList.TopItem.Index : -1; OrderList.BeginUpdate(); OrderList.Items.Clear(); for (int i = 0; i < data_item.Length; i++) { ListViewItem view_item = new ListViewItem(); view_item.SubItems[0].Text = data_item[i].mOrderTime.ToString(); view_item.SubItems.Add(data_item[i].mStockCode); view_item.SubItems.Add(data_item[i].mStockName); view_item.SubItems.Add(data_item[i].mOrderPrice.ToString()); view_item.SubItems.Add(data_item[i].mOrderSize.ToString()); view_item.SubItems.Add(data_item[i].mOrderDirect); if (data_item[i].mOrderDirect.Equals("买入担保品")) { view_item.ForeColor = Color.Red; } else if (data_item[i].mOrderDirect.Equals("卖出担保品") || data_item[i].mOrderDirect.Equals("融券卖出")) { view_item.ForeColor = QuoteForm.RGB(0x65E339); } view_item.SubItems.Add(data_item[i].mOrderId); view_item.SubItems.Add(data_item[i].mOrderStatus); if (data_item[i].mOrderId.Equals(mOrderListDataSet.selected_id)) { view_item.Selected = true; } if (mOrderListDataSet.checked_ids.Contains(data_item[i].mOrderId)) { view_item.Checked = true; } OrderList.Items.Add(view_item); } OrderList.EndUpdate(); if (top_index > 0 && OrderList.Items.Count > top_index) { int H = OrderList.Height; int h = OrderList.TopItem.GetBounds(ItemBoundsPortion.Entire).Height; int n = H / h - 1; if (n + top_index >= OrderList.Items.Count - 1) { OrderList.TopItem = OrderList.Items[top_index + 1]; } else { OrderList.TopItem = OrderList.Items[top_index]; } } } } catch (Exception e) { MessageBox.Show(e.ToString()); } }