コード例 #1
0
        internal static AccountBankApproved[] GetAccountBanksApproved(Guid accountId, string language, out AccountBankReferenceData referenceData)
        {
            referenceData = null;
            using (SqlConnection sqlConnection = new SqlConnection(SettingManager.Default.ConnectionString))
            {
                using (SqlCommand sqlCommand = new SqlCommand("dbo.P_GetAccountBanksApproved", sqlConnection))
                {
                    sqlCommand.CommandType = CommandType.StoredProcedure;
                    sqlConnection.Open();
                    SqlCommandBuilder.DeriveParameters(sqlCommand);
                    sqlCommand.Parameters["@accountId"].Value = accountId;
                    sqlCommand.Parameters["@language"].Value = language;
                    SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);

                    DataSet dataSet = new DataSet();
                    sqlDataAdapter.Fill(dataSet);

                    referenceData = GetAccountBankReferenceData(dataSet, false);

                    AccountBankApproved[] bankAccounts = new AccountBankApproved[dataSet.Tables[3].Rows.Count];
                    int index = 0;
                    foreach (DataRow dataRow in dataSet.Tables[3].Rows)
                    {
                        AccountBankApproved bankAccount = new AccountBankApproved();

                        bankAccount.Id = (Guid)dataRow["Id"];
                        bankAccount.BankId = dataRow["BankId"] is DBNull ? null : (Guid?)dataRow["BankId"];
                        bankAccount.CountryId = dataRow["CountryId"] is DBNull ? null : (long?)dataRow["CountryId"];
                        bankAccount.BankName = dataRow["BankName"] is DBNull ? null : (string)dataRow["BankName"];
                        bankAccount.AccountBankNo = (string)dataRow["AccountBankNo"];
                        bankAccount.AccountBankType = (string)dataRow["AccountBankType"];
                        bankAccount.AccountOpener = (string)dataRow["AccountOpener"];
                        bankAccount.AccountBankProp = dataRow["AccountBankProp"] is DBNull ? null : (string)dataRow["AccountBankProp"];
                        bankAccount.AccountBankBCId = dataRow["AccountBankBCId"] is DBNull ? null : (Guid?)dataRow["AccountBankBCId"];
                        bankAccount.AccountBankBCName = dataRow["AccountBankBCName"] is DBNull ? null : (string)dataRow["AccountBankBCName"];
                        bankAccount.IdType = dataRow["IdType"] is DBNull ? null : (string)dataRow["IdType"];
                        bankAccount.IdNo = dataRow["IdNo"] is DBNull ? null : (string)dataRow["IdNo"];
                        bankAccount.BankProvinceId = dataRow["BankProvinceId"] is DBNull ? null : (long?)dataRow["BankProvinceId"];
                        bankAccount.BankCityId = dataRow["BankCityId"] is DBNull ? null : (long?)dataRow["BankCityId"];
                        bankAccount.BankAddress = dataRow["BankAddress"] is DBNull ? null : (string)dataRow["BankAddress"];
                        bankAccount.SwiftCode = dataRow["SwiftCode"] is DBNull ? null : (string)dataRow["SwiftCode"];

                        bankAccounts[index++] = bankAccount;
                    }
                    return bankAccounts;
                }
            }
        }
コード例 #2
0
        private static AccountBankReferenceData GetAccountBankReferenceData(DataSet dataSet, bool countryOnly)
        {
            AccountBankReferenceData referenceData = new AccountBankReferenceData();

            if (countryOnly)
            {
                referenceData.Countries = new Dictionary<long, string>();
                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    referenceData.Countries.Add((long)row["ID"], (string)row["Name"]);
                }
            }
            else
            {
                referenceData.Banks = new Dictionary<Guid, string>();
                referenceData.CountryBanks = new Dictionary<long, List<Guid>>();
                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    referenceData.Banks.Add((Guid)row["ID"], (string)row["Name"]);
                    long countryId2 = (long)row["CountryID"];
                    if (!referenceData.CountryBanks.ContainsKey(countryId2))
                    {
                        referenceData.CountryBanks.Add(countryId2, new List<Guid>());
                    }
                    referenceData.CountryBanks[countryId2].Add((Guid)row["ID"]);
                }

                referenceData.Provinces = new Dictionary<long, string>();
                referenceData.CountryProvinces = new Dictionary<long, List<long>>();
                foreach (DataRow row in dataSet.Tables[1].Rows)
                {
                    referenceData.Provinces.Add((long)row["ProvinceID"], (string)row["ProvinceName"]);
                    long countryId2 = (long)row["CountryID"];
                    if (!referenceData.CountryProvinces.ContainsKey(countryId2))
                    {
                        referenceData.CountryProvinces.Add(countryId2, new List<long>());
                    }
                    referenceData.CountryProvinces[countryId2].Add((long)row["ProvinceID"]);
                }

                referenceData.Cities = new Dictionary<long, string>();
                referenceData.ProvinceCities = new Dictionary<long, List<long>>();
                foreach (DataRow row in dataSet.Tables[2].Rows)
                {
                    referenceData.Cities.Add((long)row["CityID"], (string)row["CityName"]);
                    long provinceId = (long)row["ProvinceID"];
                    if (!referenceData.ProvinceCities.ContainsKey(provinceId))
                    {
                        referenceData.ProvinceCities.Add(provinceId, new List<long>());
                    }
                    referenceData.ProvinceCities[provinceId].Add((long)row["CityID"]);
                }
            }
            return referenceData;
        }