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) { _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 = ""; } } }