示例#1
0
 /// <summary>
 /// 转账按钮事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         string  FromCapital        = this.cmbFromCaption.SelectedItem.ToString();
         int     FromCapitalAccount = Caption(FromCapital);
         string  ToCapital          = this.cmbToCaption.SelectedItem.ToString();
         int     ToCapitalAccount   = Caption(ToCapital);
         decimal TransferAmount     = 0;
         if (decimal.TryParse(this.txtCaptionNum.Text.ToString(), out TransferAmount))
         {
             if (!string.IsNullOrEmpty(this.txtCaptionNum.Text.ToString()))
             {
                 FreeTransferEntity freeTransferEntity = new FreeTransferEntity();
                 freeTransferEntity.TraderID = ServerConfig.TraderID.ToString();
                 freeTransferEntity.FromCapitalAccountType = FromCapitalAccount;
                 freeTransferEntity.ToCapitalAccountType   = ToCapitalAccount;
                 freeTransferEntity.TransferAmount         = TransferAmount;
                 string             Currency     = this.cmbCurrencyType.SelectedItem.ToString();
                 Types.CurrencyType currencyType = new Types.CurrencyType();
                 if (Currency.Equals("人民币"))
                 {
                     currencyType = Types.CurrencyType.RMB;
                 }
                 else if (Currency.Equals("港币"))
                 {
                     currencyType = Types.CurrencyType.HK;
                 }
                 else if (Currency.Equals("美元"))
                 {
                     currencyType = Types.CurrencyType.US;
                 }
                 if (TransferAmount > 0)
                 {
                     string errMsg = "";
                     bool   x      = wcfLogic.TwoAccountsFreeTransferFunds(freeTransferEntity, currencyType, out errMsg);
                     if (x == true)
                     {
                         MessageBox.Show("转账成功", "系统提示");
                         this.txtCaptionNum.Text = "";
                         if (this.cmbToCaption.SelectedItem.Equals("银行帐号") ||
                             this.cmbFromCaption.SelectedItem.Equals("银行帐号"))
                         {
                             QueryUA_BankAccountByUserID();
                         }
                     }
                     else
                     {
                         error.SetError(txtCaptionNum, "转账失败!" + errMsg);
                     }
                 }
                 else
                 {
                     error.SetError(txtCaptionNum, "转账金额必须大于零!");
                 }
             }
             else
             {
                 error.SetError(txtCaptionNum, "转账金额不能为空!");
             }
         }
         else
         {
             error.SetError(txtCaptionNum, "转账金额输入错误!");
         }
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(ex.Message, ex);
     }
 }