예제 #1
0
        private void btnAddOrUpdateAccount_Click(object sender, EventArgs e)
        {
            string ebayAccount = this.textBoxEbayAccount.Text;

            if (ebayAccount.Trim() == "")
            {
                MessageBox.Show("请输入Ebay账号", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string ebayToken = this.textBoxEbayToken.Text;

            if (ebayToken.Trim() == "")
            {
                MessageBox.Show("请输入Ebay Token", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            AccountType account = new AccountType();

            account.ebayAccount     = ebayAccount;
            account.ebayToken       = ebayToken;
            account.paypalAccount   = this.textBoxPayPalAccount.Text.Trim();
            account.paypalUsername  = this.textBoxPayPalUsername.Text.Trim();
            account.paypalPassword  = this.textBoxPayPalPassword.Text.Trim();
            account.paypalSignature = this.textBoxPayPalSignature.Text.Trim();

            bool update = false;

            AccountType existedAccount = AccountUtil.GetAccountByEbayUsername(ebayAccount);

            if (existedAccount != null)
            {
                if (existedAccount.isEqual(account))
                {
                    MessageBox.Show("无任何信息需要更新!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                update = true;
            }

            if (update)
            {
                AccountUtil.UpdateOneAccount(account);
                MessageBox.Show("更新账号信息成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                AccountUtil.AddOneAccount(account);
                this.listBoxAllAccounts.Items.Add(account);

                MessageBox.Show("添加账号信息成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #2
0
        private void buttonFinish_Click(object sender, EventArgs e)
        {
            AccountType account = new AccountType();

            account.ebayAccount = UserName;
            account.ebayToken   = Token;

            AccountType existedAccount = AccountUtil.GetAccountByEbayUsername(UserName);

            if (existedAccount != null)
            {
                MessageBox.Show("已存在此账号token,需先删除已有账号!", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            AccountUtil.AddOneAccount(account);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }