private void _btn扫描品种_Click(object sender, RoutedEventArgs e) { using (StatementContext statement = new StatementContext(typeof(Commodity), typeof(CommoditySummarization))) { List <Commodity> commodityList = new List <Commodity>(); var commoditys = statement.Commoditys; var css = statement.CommoditySummarizations; int count = 0; foreach (var cs in css) { if (commoditys.FirstOrDefault(m => m.Code.Equals(cs.Commodity)) == null && commodityList.FirstOrDefault(m => m.Code.Equals(cs.Commodity)) == null) { Commodity cd = new Commodity(); cd.Code = cs.Commodity; cd.Name = cs.Commodity; commodityList.Add(cd); count++; } } statement.AddCommoditys(commodityList); statement.SaveChanged(); _listBox品种列表.ItemsSource = null; _listBox品种列表.ItemsSource = new StatementContext(typeof(Commodity)).Commoditys.ToList(); MessageBox.Show(string.Concat("扫描完成!新增", count, "个品种。")); } }
private void _button修改_Click(object sender, RoutedEventArgs e) { bool changed = false; using (StatementContext statement = new StatementContext(typeof(User))) { // if (string.IsNullOrEmpty(_textBox用户名.Text) || _textBox用户名.Text.Length > 20) { MessageBox.Show("用户名必须1-20个字符!"); return; } if (statement.Users.FirstOrDefault(model => model.Id != user.Id && model.UserName.Equals(_textBox用户名.Text)) != null) { MessageBox.Show("用户名已被占用!"); return; } if (string.IsNullOrEmpty(_textBox用户密码.Password) || _textBox用户密码.Password.Length < 6 || _textBox用户密码.Password.Length > 20) { MessageBox.Show("密码必须6-20个字符!"); return; } if (!_textBox用户密码.Password.Equals(_textBox用户密码2.Password)) { MessageBox.Show("两次密码不一致!"); return; } var oldUser = statement.Users.FirstOrDefault(model => model.Id == user.Id); if (!_textBox用户名.Text.Trim().Equals(user.UserName)) { changed = true; oldUser.UserName = _textBox用户名.Text.Trim(); } if (!_textBox用户密码.Password.Trim().Equals(user.UserPassword._RSADecrypt())) { changed = true; oldUser.UserPassword = _textBox用户密码.Password._RSAEcrypt(); } if (!_textBox邮箱.Text.Trim().Equals(user.Email)) { changed = true; oldUser.Email = _textBox邮箱.Text.Trim(); } if (changed) { statement.EditUser(oldUser); statement.SaveChanged(); MessageBox.Show("信息修改成功!"); } Close(); } }
private void DeleteData(DateTime date) { try { mainWindow.ProgressInfoVisible(3); using (StatementContext statement = new StatementContext()) { mainWindow.SetProgressText("(1/3)正在删除数据..."); statement.Delete(date, _Session.SelectedAccountId, typeof(ClosedTradeDetail), typeof(CommoditySummarization), typeof(FundStatus), typeof(PositionDetail), typeof(Position), typeof(Remittance), typeof(Stock), typeof(TradeDetail), typeof(Trade)); mainWindow.AddProgressValue(1); mainWindow.SetProgressText("(2/3)正在校准权益..."); var stocks = statement.Stocks.Where(m => m.AccountId == _Session.SelectedAccountId).OrderBy(m => m.Date); var fundStatus = statement.FundStatus.Where(m => m.AccountId == _Session.SelectedAccountId).OrderBy(m => m.Date); if (stocks.Count() > 0 && fundStatus.Count() > 0) { var lastStock = stocks.ToList().LastOrDefault(); var lastFundStatus = fundStatus.ToList().LastOrDefault(); var diff = lastFundStatus.CustomerRights - lastStock.Close; if (diff != 0) { foreach (var stc in stocks) { stc.Open += diff; stc.High += diff; stc.Low += diff; stc.Close += diff; } mainWindow.AddProgressValue(1); statement.UpdateStocks(stocks); } } mainWindow.SetProgressText("(3/3)正在保存数据..."); statement.SaveChanged(); mainWindow.AddProgressValue(1); MessageBox.Show(string.Concat("账号【", statement.Accounts.FirstOrDefault(m => m.Id == _Session.SelectedAccountId).AccountNumber, "】 ", date.ToString("yyyy年MM月dd日"), " 以及之后的数据已全部删除。")); } mainWindow.InitializeUserControlsThreadStart(); } catch (Exception ex) { OverStatusAndProgressBar(); MessageBoxSync(ex.Message + "\n" + ex.StackTrace); } finally { mainWindow.ProgressInfoHidden(); } }
private void _button确认_Click(object sender, RoutedEventArgs e) { using (StatementContext statement = new StatementContext(typeof(Account))) { account.CustomerName = _textBox客户姓名.Text; account.FuturesCompanyName = _textBox配资公司.Text; account.AccountNumber = _textBox配资账号.Text; account.Password = _textBox交易密码.Text.Trim()._RSAEcrypt(); statement.EditAccount(account); statement.SaveChanged(); } Close(); MessageBox.Show("修改账户成功!"); }
private void _btnOK_Click(object sender, RoutedEventArgs e) { using (StatementContext statement = new StatementContext()) { var comm = statement.Commoditys.FirstOrDefault(m => m.Code.ToLower().Equals(_tb品种代码.Text.Trim().ToLower())); if (comm == null) { MessageBox.Show("数据库中不存在此品种"); return; } comm.Name = _tb品种名称.Text; statement.EditCommodity(comm); statement.SaveChanged(); } Close(); }
private void _menuItem列表隐藏_Click(object sender, RoutedEventArgs e) { if (selectedAccountItem == null) { return; } using (StatementContext statement = new StatementContext(typeof(Account))) { var account = statement.Accounts.FirstOrDefault(m => m.Id == selectedAccountItem.Id); if (account == null) { throw new ArgumentNullException("要修改的对象不存在!"); } account.Type = account.Type * 10; statement.EditAccount(account); statement.SaveChanged(); InitializeAccountList(); } }
private void _button确认_Click(object sender, RoutedEventArgs e) { // using (StatementContext statement = new StatementContext(typeof(Account))) { if (statement.Accounts.Where(a => a.AccountNumber.Equals(_textBox配资账号.Text.Trim()) && a.FuturesCompanyName.Equals(_textBox配资公司.Text.Trim())).Count() != 0) { MessageBox.Show("此配资账户已经存在于当前数据库中!"); Close(); } else { try { Account account = new Account(); // account.Id = Guid.NewGuid(); account.Type = 2; account.FuturesCompanyName = _textBox配资公司.Text.Trim(); account.AccountNumber = _textBox配资账号.Text.Trim(); account.CustomerName = _textBox客户姓名.Text.Trim(); account.Password = _textBox交易密码.Text.Trim()._RSAEcrypt();; account.UserId = _Session.LoginedUserId; statement.AddAccount(account); statement.SaveChanged(); // DialogResult = true; MessageBox.Show("添加配资账户成功!"); // Close(); } catch (Exception ex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + ex.Message); } } } }
private void _button添加_Click(object sender, RoutedEventArgs e) { try { using (StatementContext statement = new StatementContext(typeof(User))) { // if (string.IsNullOrEmpty(_textBox用户名.Text) || _textBox用户名.Text.Length > 20) { MessageBox.Show("用户名必须1-20个字符!"); return; } if (statement.Users.FirstOrDefault(user => user.UserName.Equals(_textBox用户名.Text)) != null) { MessageBox.Show("用户名已被占用!"); return; } if (string.IsNullOrEmpty(_textBox用户密码.Password) || _textBox用户密码.Password.Length < 6 || _textBox用户密码.Password.Length > 20) { MessageBox.Show("密码必须6-20个字符!"); return; } if (!_textBox用户密码.Password.Equals(_textBox用户密码2.Password)) { MessageBox.Show("两次密码不一致!"); return; } // statement.AddUser(new User { Id = Guid.NewGuid(), UserName = _textBox用户名.Text, UserPassword = _textBox用户密码.Password._RSAEcrypt(), Email = _textBox邮箱.Text }); statement.SaveChanged(); DialogResult = true; } } catch (Exception) { throw; } }
private void _menuItem禁止下载_Click(object sender, RoutedEventArgs e) { if (selectedAccountItem == null) { return; } if (selectedAccountItem.Type != 1 && selectedAccountItem.Type != 10) { return; } using (StatementContext context = new StatementContext(typeof(Account))) { Account acc = context.Accounts.FirstOrDefault(m => m.Id == selectedAccountItem.Id); acc.IsAllowLoad = !acc.IsAllowLoad; context.EditAccount(acc); context.SaveChanged(); if (!acc.IsAllowLoad) { MessageBox.Show("此账户将在超过60天未更新时,下载一次。"); } InitializeAccountList(); } }
private void _linkLabel忘记密码_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { try { using (StatementContext statement = new StatementContext(typeof(User))) { var user = statement.Users.FirstOrDefault(model => model.UserName.Equals(_comboBox用户列表.Text.Trim())); // if (MessageBox.Show(string.Format("是否向用户<{0}>的密保邮箱发送新密码?", user.UserName), "发送新密码确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { //确定smtp服务器地址。实例化一个Smtp客户端 SmtpClient client = new SmtpClient("smtp.163.com"); //构造一个发件人地址对象 MailAddress from = new MailAddress("*****@*****.**", "期货助手", Encoding.UTF8); //构造一个收件人地址对象 MailAddress to = new MailAddress(user.Email, _comboBox用户列表.Text.Trim(), Encoding.UTF8); //构造一个Email的Message对 MailMessage message = new MailMessage(from, to); Random random = new Random(); string newPassword = string.Format("{0}{1}{2}{3}{4}{5}", random.Next(10), random.Next(10), random.Next(10), random.Next(10), random.Next(10), random.Next(10)); //添加邮件主题和内容 message.Subject = "期货助手 - 新密码"; message.SubjectEncoding = Encoding.UTF8; message.Body = string.Format("您的新密码是:{0}", newPassword); message.BodyEncoding = Encoding.UTF8; //设置邮件的信息 client.DeliveryMethod = SmtpDeliveryMethod.Network; message.BodyEncoding = System.Text.Encoding.UTF8; message.IsBodyHtml = false; //设置用户名和密码。 client.UseDefaultCredentials = false; string username = "******"; string passwd = "mail351489"; //用户登陆信息 NetworkCredential myCredentials = new NetworkCredential(username, passwd); client.Credentials = myCredentials; //发送邮件 client.Send(message); // user.UserPassword = newPassword._RSAEcrypt(); statement.EditUser(user); statement.SaveChanged(); //提示发送成功 MessageBox.Show("新密码已经发送到您的邮箱中,请及时查收!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
private void _button确认_Click(object sender, RoutedEventArgs e) { _gridLoading.Visibility = System.Windows.Visibility.Visible; // using (StatementContext statement = new StatementContext(typeof(Account))) { if (statement.Accounts.Where(a => a.AccountNumber.Equals(_textBox资金账号.Text.Trim())).Count() != 0) { _gridLoading.Visibility = System.Windows.Visibility.Hidden; MessageBox.Show("此资金账户已经存在于当前数据库中!"); Close(); } else { try { string htmlStatement = _Helper.LoginWithVerify(Cookie, _textBox资金账号.Text.Trim(), _textBox资金密码.Password.Trim(), _textBox验证码.Text.Trim()); //= _Helper.RequestElementrayInformationPage(Cookie); Account account = new Account(); //基本资料 int startIndex = htmlStatement.IndexOf("基本资料"); int endIndex = htmlStatement.IndexOf("资金状况"); string strAccount = htmlStatement.Substring(startIndex, endIndex - startIndex); endIndex = strAccount.IndexOf("</table>", StringComparison.CurrentCultureIgnoreCase); strAccount = strAccount.Substring(0, endIndex); //客户名称 startIndex = strAccount.IndexOf("客户名称"); strAccount = strAccount.Substring(startIndex); startIndex = strAccount.IndexOf(@"<TD", StringComparison.CurrentCultureIgnoreCase); strAccount = strAccount.Substring(startIndex); startIndex = strAccount.IndexOf(">") + 1; strAccount = strAccount.Substring(startIndex); endIndex = strAccount.IndexOf(@"</TD>", StringComparison.CurrentCultureIgnoreCase); // account.CustomerName = strAccount.Substring(0, endIndex).Replace(" ", "").Trim(); //期货公司名称 startIndex = strAccount.IndexOf("期货公司名称"); strAccount = strAccount.Substring(startIndex); startIndex = strAccount.IndexOf(@"<TD", StringComparison.CurrentCultureIgnoreCase); strAccount = strAccount.Substring(startIndex); startIndex = strAccount.IndexOf(">") + 1; strAccount = strAccount.Substring(startIndex); endIndex = strAccount.IndexOf(@"</TD>", StringComparison.CurrentCultureIgnoreCase); // account.FuturesCompanyName = strAccount.Substring(0, endIndex).Replace(" ", "").Trim(); account.IsAllowLoad = true; account.AccountNumber = _textBox资金账号.Text.Trim(); account.Password = _textBox资金密码.Password.Trim()._RSAEcrypt(); account.UserId = _Session.LoginedUserId; account.Type = 1; statement.AddAccount(account); statement.SaveChanged(); // _gridLoading.Visibility = System.Windows.Visibility.Hidden; MessageBox.Show("添加资金账户成功!"); DialogResult = true; // Close(); } catch (IdentifyingCodeMismatchException ecwex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + ecwex.Message); } catch (UsernameOrPasswordWrongException uopwex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + uopwex.Message); } catch (InputNullException inex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + inex.Message); } catch (TryTooMoreException ttmex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + ttmex.Message); Close(); return; } catch (IllegalCustomerNameException iex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + iex.Message); } catch (Exception ex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + ex.Message); } // _pictureBox验证码.Image = _Helper.GetValidateCode(Cookie); _gridLoading.Visibility = System.Windows.Visibility.Hidden; _textBox验证码.Text = ""; } } }
private void _button确认_Click(object sender, RoutedEventArgs e) { try { _gridLoading.Visibility = System.Windows.Visibility.Visible; _gridLoading._Refresh(); _Helper.LoginWithVerify(Cookie, _textBox资金账号.Text.Trim(), _textBox资金密码.Password.Trim(), _textBox验证码.Text.Trim()); if (_textBox资金密码.IsEnabled == true) { using (StatementContext statement = new StatementContext(typeof(Account))) { Account account = statement.Accounts.FirstOrDefault(a => a.AccountNumber.Equals(_textBox资金账号.Text.Trim())); if (account != null) { account.Password = _textBox资金密码.Password.Trim()._RSAEcrypt(); statement.EditAccount(account); statement.SaveChanged(); } else { _gridLoading.Visibility = System.Windows.Visibility.Hidden; MessageBox.Show(string.Format("数据库错误:本地数据库中不存在资金账户“{0}”,请联系管理员!", _textBox资金账号.Text.Trim())); } } } DialogResult = true; _gridLoading.Visibility = System.Windows.Visibility.Hidden; Close(); } catch (IdentifyingCodeMismatchException ecwex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + ecwex.Message); } catch (UsernameOrPasswordWrongException uopwex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + uopwex.Message); _textBox资金密码.Password = ""; _textBox资金密码.IsEnabled = true; _textBox资金密码.Focus(); } catch (InputNullException inex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + inex.Message); } catch (TryTooMoreException ttmex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + ttmex.Message); Close(); return; } catch (IllegalCustomerNameException iex) { MessageBox.Show(DateTime.Now.ToLongTimeString() + iex.Message); } catch (Exception ex) { MessageBox.Show(string.Format("账号<{1}>登录保证金监控中心时失败,错误信息:\n{0}", ex.Message, requestAccount.AccountNumber)); } // _pictureBox验证码.Image = _Helper.GetValidateCode(Cookie); _gridLoading.Visibility = System.Windows.Visibility.Hidden; _textBox验证码.Text = ""; }
private void LoadStatementFromCFMMC(CookieContainer cookie, Guid accountId) { StatementParseWay parseWay = StatementParseWay.html; lock (locker) { // StatementContext statement = new StatementContext(); Account account = statement.Accounts.FirstOrDefault(model => model.Id == accountId); //try //{ DateTime startDate = DateTime.Now.AddDays(-186).Date; DateTime endDate = DateTime.Now.Date; decimal close = 0; decimal? yesterdayBalance, todayBalance, remittance, amount; int dataCount = 0; FundStatus lastFundStatus; Stock lastStock; // TransactionOptions transactionOptions = new TransactionOptions(); transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; transactionOptions.Timeout = new TimeSpan(0, 30, 0); //using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, transactionOptions)) //{ lastStock = statement.Stocks.Where(s => s.AccountId == account.Id).OrderByDescending(s => s.Date).FirstOrDefault(); if (lastStock == null) { ProgressInfoVisible((endDate - startDate).Days + 1); // bool firstLine = true; // while (startDate <= endDate) { SetProgressText(string.Concat("【", account.AccountNumber, "】 ", startDate.ToString("yyyy年MM月dd日"))); if (parseWay == StatementParseWay.html) { _Helper.GetStatementByRequestHtml(cookie, startDate, SettlementType.date, statement, out yesterdayBalance, out todayBalance, out remittance, out amount, account.Id); } else { _Helper.GetStatementByLoadExcel(cookie, startDate, SettlementType.date, statement, out yesterdayBalance, out todayBalance, out remittance, out amount, account.Id); } if (yesterdayBalance.HasValue && todayBalance.HasValue && remittance.HasValue && amount.HasValue) { Stock stock = new Stock(); stock.Id = Guid.NewGuid(); if (firstLine) { stock.Date = startDate.Date; stock.Open = yesterdayBalance.Value + remittance.Value; stock.Close = close = todayBalance.Value; if (stock.Close > stock.Open) { stock.High = stock.Close; stock.Low = stock.Open; } else { stock.High = stock.Open; stock.Low = stock.Close; } stock.Volume = amount.Value; stock.AccountId = account.Id; firstLine = false; } else { stock.Date = startDate.Date; stock.Open = close; stock.Close = close += todayBalance.Value - yesterdayBalance.Value - remittance.Value; if (stock.Close > stock.Open) { stock.High = stock.Close; stock.Low = stock.Open; } else { stock.High = stock.Open; stock.Low = stock.Close; } stock.Volume = amount.Value; stock.AccountId = account.Id; } statement.AddStock(stock); dataCount++; } // startDate = startDate.AddDays(1); AddProgressValue(1); } } else { startDate = lastStock.Date.AddDays(1).Date; ProgressInfoVisible((endDate - startDate).Days + 1); // close = lastStock.Close; while (startDate <= endDate) { SetProgressText(string.Concat("【", account.AccountNumber, "】 ", startDate.ToString("yyyy年MM月dd日"))); if (parseWay == StatementParseWay.html) { _Helper.GetStatementByRequestHtml(cookie, startDate, SettlementType.date, statement, out yesterdayBalance, out todayBalance, out remittance, out amount, account.Id); } else { _Helper.GetStatementByLoadExcel(cookie, startDate, SettlementType.date, statement, out yesterdayBalance, out todayBalance, out remittance, out amount, account.Id); } if (yesterdayBalance.HasValue && todayBalance.HasValue && remittance.HasValue && amount.HasValue) { Stock stock = new Stock(); stock.Id = Guid.NewGuid(); stock.Date = startDate.Date; stock.Open = close; stock.Close = close += todayBalance.Value - yesterdayBalance.Value - remittance.Value; if (stock.Close > stock.Open) { stock.High = stock.Close; stock.Low = stock.Open; } else { stock.High = stock.Open; stock.Low = stock.Close; } stock.Volume = amount.Value; stock.AccountId = account.Id; statement.AddStock(stock); dataCount++; } // startDate = startDate.AddDays(1); AddProgressValue(1); } } // 复权处理 var stocks = statement.Stocks.Where(s => s.AccountId == account.Id).OrderBy(s => s.Date); lastStock = stocks.LastOrDefault(); lastFundStatus = statement.FundStatus.Where(fs => fs.AccountId == account.Id).OrderBy(fs => fs.Date).LastOrDefault(); if (lastStock != null && lastFundStatus != null) { decimal tmp = lastStock.Close - lastFundStatus.TodayBalance; if (tmp != 0) { SetProgressText(string.Format("<{0}>图表复权...", account.AccountNumber)); foreach (var stock in stocks) { stock.Open -= tmp; stock.High -= tmp; stock.Low -= tmp; stock.Close -= tmp; } statement.UpdateStocks(stocks); } } // SetProgressText(string.Format("<{0}>保存数据...", account.AccountNumber)); statement.SaveChanged(); if (dataCount > 0) { InitializeUserControlsThreadStart(); } _settingUserControl.AddLog(string.Format("账户<{0}>下载数据完毕,新增 {1} 天数据。", account.AccountNumber, dataCount)); ProgressInfoHidden(); //} //catch (Exception) //{ // throw; //} //finally //{ // this.ProgressInfoHidden(); //} // 备份数据至邮箱。 //MailYunBackup(true); } }
private void _button确认_Click(object sender, RoutedEventArgs e) { decimal profit = 0, commission = 0, remittance = 0, volume = 0; int bing = 0; try { profit = Decimal.Parse(_textBox盈利.Text.Trim()); bing = 1; commission = Decimal.Parse(_textBox手续费.Text.Trim()); bing = 2; remittance = Decimal.Parse(_textBox出入金.Text.Trim()); bing = 3; volume = Decimal.Parse(_textBox成交额.Text.Trim()); } catch (FormatException) { switch (bing) { case 0: MessageBox.Show("盈利必须为数字!"); break; case 1: MessageBox.Show("手续费必须为数字!"); break; case 2: MessageBox.Show("出入金必须为数字!"); break; case 3: MessageBox.Show("成交额必须为数字!"); break; } } catch (OverflowException) { switch (bing) { case 0: MessageBox.Show("盈利超出数字范围!"); break; case 1: MessageBox.Show("手续费超出数字范围!"); break; case 2: MessageBox.Show("出入金超出数字范围!"); break; case 3: MessageBox.Show("成交额超出数字范围!"); break; } } using (StatementContext statement = new StatementContext(typeof(FundStatus), typeof(Account), typeof(Stock))) { var cooperate = statement.Accounts.FirstOrDefault(m => m.Id == accountId); if (cooperate == null) { throw new Exception(string.Concat("不存在ID为:", accountId, "的配资账户!")); } var sto = statement.Stocks.FirstOrDefault(m => m.AccountId == accountId && m.Date == _datePicker日期.SelectedDate.Value); if (sto != null) { MessageBox.Show(string.Concat("此账户【", _datePicker日期.SelectedDate.Value, "】数据已经存在!")); return; } var allStocks = statement.Stocks.Where(m => m.AccountId == accountId).OrderBy(m => m.Date); var beforeStocks = allStocks.Where(m => m.Date < _datePicker日期.SelectedDate.Value); var afterStocks = allStocks.Where(m => m.Date > _datePicker日期.SelectedDate.Value); var lastStock = beforeStocks.LastOrDefault(); Stock stock = new Stock(); if (lastStock != null) { stock.Open = lastStock.Close; } else { stock.Open = remittance; } stock.Close = stock.Open + profit - commission; stock.High = stock.Open < stock.Close ? stock.Close : stock.Open; stock.Low = stock.Open > stock.Close ? stock.Close : stock.Open; stock.Date = _datePicker日期.SelectedDate.Value; stock.Volume = volume; stock.AccountId = accountId; // statement.AddStock(stock); // if (afterStocks.Count() != 0 && stock.Close != stock.Open) { foreach (var st in afterStocks) { st.Open += stock.Close - stock.Open; st.Close += stock.Close - stock.Open; st.High += stock.Close - stock.Open; st.Low += stock.Close - stock.Open; } statement.UpdateStocks(afterStocks); } if (remittance != 0) { var stocks = statement.Stocks.Where(m => m.AccountId == accountId); foreach (var st in stocks) { st.Open += remittance; st.Close += remittance; st.High += remittance; st.Low += remittance; } statement.UpdateStocks(stocks); } statement.SaveChanged(); } DialogResult = true; MessageBox.Show("添加成功!"); }