private void AddTraderAccountRelation(string userName) { string account = listBoxAccounts.SelectedItem.ToString(); Task.Run(() => { try { var result = Program.AASServiceClient.AddTraderAccount(userName, account); var arrResult = result.Split('|'); if (arrResult[0] == "0") { this.Invoke(new Action(() => { MessageBox.Show(arrResult[1]); })); } else { Program.logger.LogInfo("交易员分配券商账户成功:" + result); dt = Program.AASServiceClient.QueryAllTraderAccounts(); this.Invoke(new Action(RefreshDataGridView)); } } catch (Exception ex) { this.BeginInvoke(new Action(() => { MessageBox.Show("交易员分配券商账户异常: " + ex.Message); })); } }); }
private void UcUserAccountSet_Load(object sender, EventArgs e) { labelLoading.Visible = true; dataGridViewNotSelected.AutoGenerateColumns = false; dataGridViewSelected.AutoGenerateColumns = false; Task.Run(() => { dt = Program.AASServiceClient.QueryAllTraderAccounts(); userNames = Program.AASServiceClient.QueryTraderNameList(); var accountList = Program.AASServiceClient.QueryQSNameList(); listBoxAccounts.BeginInvoke(new Action(() => { for (int i = 0; i < accountList.Length; i++) { if (listBoxAccounts.Items.Count > i) { listBoxAccounts.Items[i] = accountList[i]; } else { listBoxAccounts.Items.Add(accountList[i]); } } if (listBoxAccounts.Items.Count > accountList.Length) { for (int i = listBoxAccounts.Items.Count - 1; i > accountList.Length; i--) { listBoxAccounts.Items.RemoveAt(i); } } labelLoading.Visible = false; })); }); }
private void DeleteTraderAccountRelation(string userName) { string account = listBoxAccounts.SelectedItem.ToString(); Task.Run(() => { try { Program.AASServiceClient.DeleteTraderAccountRelation(account, userName); dt = Program.AASServiceClient.QueryAllTraderAccounts(); this.Invoke(new Action(RefreshDataGridView)); } catch (Exception ex) { this.BeginInvoke(new Action(() => { MessageBox.Show("交易员分配券商账户异常:" + ex.Message); })); } }); }