Exemplo n.º 1
0
        /// <summary>
        /// Adds a new user bank info.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="bankInfo"></param>
        /// <returns></returns>
        public bool AddUserBankInfo(SqlConnection conn, UserBankInfo bankInfo)
        {
            SqlParameter[] sqlParameters = new SqlParameter[]
            {
               new SqlParameter("@UserId", bankInfo.UserId),
               new SqlParameter("@BankName", bankInfo.BankName ?? string.Empty),
               new SqlParameter("@BankAccount", bankInfo.BankAccount ?? string.Empty),
               new SqlParameter("@BankUserName", bankInfo.BankUserName ?? string.Empty),
               new SqlParameter("@BankAddress", bankInfo.BankAddress ?? string.Empty),
               new SqlParameter("@IsDefault", bankInfo.IsDefault),
               new SqlParameter("@CreatedTime", bankInfo.CreatedTime),
               new SqlParameter("@LastUpdatedTime", bankInfo.LastUpdatedTime)
            };

            return DBHelper.RunScalarProcedure(conn,
                SP_AddUserBankInfo, sqlParameters) > 0;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a new user bank info.
        /// </summary>
        /// <param name="bankInfo"></param>
        /// <returns></returns>
        public bool AddUserBankInfo(UserBankInfo bankInfo)
        {
            var conn = DBHelper.GetSqlConnection();
            bool result = false;

            try
            {
                conn.Open();
                result = userDao.AddUserBankInfo(conn, bankInfo);
            }
            catch (Exception e)
            {
                LogService.Log("添加用户银行信息失败--" + e.Message, e.ToString());
            }
            finally
            {
                conn.Close();
            }

            return result;
        }
Exemplo n.º 3
0
        private UserBankInfo ConvertToBankInfoObject(SqlDataReader reader)
        {
            UserBankInfo bankInfo = new UserBankInfo();

            bankInfo.BankId = reader["BankId"].DBToInt32();
            bankInfo.UserId = reader["UserId"].DBToInt32();
            bankInfo.BankName = reader["BankName"].DBToString();
            bankInfo.BankAccount = reader["BankAccount"].DBToString();
            bankInfo.BankUserName = reader["BankUserName"].DBToString();
            bankInfo.BankAddress = reader["BankAddress"].DBToString();
            bankInfo.IsDefault = reader["IsDefault"].DBToBoolean();
            bankInfo.CreatedTime = reader["CreatedTime"].DBToDateTime().Value;
            bankInfo.LastUpdatedTime = reader["LastUpdatedTime"].DBToDateTime().Value;

            return bankInfo;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets user bank info by bank id.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="bankId"></param>
        /// <returns></returns>
        public UserBankInfo GetUserBankInfo(SqlConnection conn, int bankId)
        {
            UserBankInfo bankInfo = new UserBankInfo();

            SqlParameter[] sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@BankId", bankId)
            };

            SqlDataReader reader = DBHelper.RunProcedure(conn, SP_GetUserBankInfo, sqlParameters);
            while (reader.Read())
            {
                bankInfo = ConvertToBankInfoObject(reader);
            }
            if (reader != null)
            {
                reader.Close();
            }

            return bankInfo;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets user bank info by bank id.
        /// </summary>
        /// <param name="bankId"></param>
        /// <returns></returns>
        public UserBankInfo GetUserBankInfo(int bankId)
        {
            var conn = DBHelper.GetSqlConnection();
            UserBankInfo bankInfo = new UserBankInfo();

            try
            {
                conn.Open();
                bankInfo = userDao.GetUserBankInfo(conn, bankId);
            }
            catch (Exception e)
            {
                LogService.Log("获取用户银行信息失败--" + e.Message, e.ToString());
            }
            finally
            {
                conn.Close();
            }

            return bankInfo;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Validates bank info with get. We need to add a new bank record to database if user select new bank info.
        /// </summary>
        private UserBankInfo ValidateBankInfoWithGet(string bankid, string bankname, string bankaccount, string bankusername, string bankaddress, out bool isNewBankInfo)
        {
            UserBankInfo bankInfo = null;
            isNewBankInfo = false;

            if (bankid.Equals("-1") && UserInfo != null)
            {
                bankInfo = new UserBankInfo();

                bankInfo.UserId = UserInfo.UserId;
                bankInfo.BankName = bankname ?? "信息缺失";
                bankInfo.BankAccount = bankaccount ?? "信息缺失";
                bankInfo.BankUserName = bankusername ?? "信息缺失";
                bankInfo.BankAddress = bankaddress ?? "信息缺失";
                bankInfo.CreatedTime = DateTime.Now;
                bankInfo.LastUpdatedTime = DateTime.Now;
                bankInfo.IsDefault = false;

                if (!userService.AddUserBankInfo(bankInfo))
                {
                    throw new ArgumentException("新增银行信息失败");
                }
                else
                {
                    isNewBankInfo = true;
                }
            }
            else
            {
                bankInfo = userService.GetUserBankInfo(int.Parse(bankid));
            }

            bankInfo.CheckNullObject("银行信息");

            return bankInfo;
        }