internal static AccountBankApplication[] GetAccountBankApplicationsNotApproved(Guid accountId) { using (SqlConnection sqlConnection = new SqlConnection(SettingManager.Default.ConnectionString)) { using (SqlCommand sqlCommand = new SqlCommand("dbo.P_GetAccountBankApplicationsNotApproved", sqlConnection)) { sqlCommand.CommandType = CommandType.StoredProcedure; sqlConnection.Open(); SqlCommandBuilder.DeriveParameters(sqlCommand); sqlCommand.Parameters["@accountId"].Value = accountId; List<AccountBankApplication> resultList = new List<AccountBankApplication>(); using (SqlDataReader reader = sqlCommand.ExecuteReader()) { while (reader.Read()) { AccountBankApplication dailyVwap = new AccountBankApplication { Id = (Guid)reader["Id"], BankId = reader["BankId"] is DBNull ? null : (Guid?)reader["BankId"], BankName = reader["BankName"] is DBNull ? null : (string)reader["BankName"], AccountBankNo = (string)reader["AccountBankNo"], AccountBankType = (string)reader["AccountBankType"], AccountOpener = (string)reader["AccountOpener"], AccountBankProp = reader["AccountBankProp"] is DBNull ? null : (string)reader["AccountBankProp"], AccountBankBCId = reader["AccountBankBCId"] is DBNull ? null : (Guid?)reader["AccountBankBCId"], AccountBankBCName = reader["AccountBankBCName"] is DBNull ? null : (string)reader["AccountBankBCName"], IdType = reader["IdType"] is DBNull ? null : (string)reader["IdType"], IdNo = reader["IdNo"] is DBNull ? null : (string)reader["IdNo"], BankProvinceId = reader["BankProvinceId"] is DBNull ? null : (long?)reader["BankProvinceId"], BankCityId = reader["BankCityId"] is DBNull ? null : (long?)reader["BankCityId"], BankAddress = reader["BankAddress"] is DBNull ? null : (string)reader["BankAddress"], SwiftCode = reader["SwiftCode"] is DBNull ? null : (string)reader["SwiftCode"] }; resultList.Add(dailyVwap); } } return resultList.ToArray(); } } }
internal static AccountBankApplyResult Apply(AccountBankApplication application, Guid userId) { using (SqlConnection sqlConnection = new SqlConnection(SettingManager.Default.ConnectionString)) { using (SqlCommand sqlCommand = new SqlCommand("dbo.P_ApplyAccountBank", sqlConnection)) { sqlCommand.CommandType = CommandType.StoredProcedure; sqlConnection.Open(); SqlCommandBuilder.DeriveParameters(sqlCommand); sqlCommand.Parameters["@id"].Value = application.Id; sqlCommand.Parameters["@accountId"].Value = application.AccountId; if (application.CountryId != null) { sqlCommand.Parameters["@countryId"].Value = application.CountryId.Value; } if (application.AccountBankApprovedId != null) { sqlCommand.Parameters["@accountBankApprovedId"].Value = application.AccountBankApprovedId.Value; } if (application.BankId != null) { sqlCommand.Parameters["@bankId"].Value = application.BankId.Value; } sqlCommand.Parameters["@bankName"].Value = application.BankName; sqlCommand.Parameters["@accountBankNo"].Value = application.AccountBankNo; sqlCommand.Parameters["@accountBankType"].Value = application.AccountBankType; sqlCommand.Parameters["@accountOpener"].Value = application.AccountOpener; sqlCommand.Parameters["@accountBankProp"].Value = application.AccountBankProp; sqlCommand.Parameters["@accountBankBCId"].Value = application.AccountBankBCId; sqlCommand.Parameters["@accountBankBCName"].Value = application.AccountBankBCName; sqlCommand.Parameters["@idType"].Value = application.IdType; sqlCommand.Parameters["@bankProvinceId"].Value = application.BankProvinceId; sqlCommand.Parameters["@idNo"].Value = application.IdNo; sqlCommand.Parameters["@bankCityId"].Value = application.BankCityId; sqlCommand.Parameters["@bankAddress"].Value = application.BankAddress; sqlCommand.Parameters["@swiftCode"].Value = application.SwiftCode; sqlCommand.Parameters["@applicationType"].Value = application.ApplicationType; sqlCommand.Parameters["@updatePersonId"].Value = userId; sqlCommand.ExecuteNonQuery(); int result = (int)sqlCommand.Parameters["@RETURN_VALUE"].Value; if (result != 0) return AccountBankApplyResult.Failed; bool approved = (bool)sqlCommand.Parameters["@approved"].Value; return approved ? AccountBankApplyResult.SuccessAndApproved : AccountBankApplyResult.Success; } } }