123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.Common;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Configuration;
- using MySql.Data.MySqlClient;
- using System.Runtime.InteropServices.ComTypes;
- using static DataManager.UIConstants;
- using System.ComponentModel.Design;
- using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
- using System.Xml.Linq;
- using System.Windows;
- using System.Security.Policy;
- namespace DataManager
- {
- public class DataAccess
- {
- private static String connectionString = ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString;
- public const sbyte DM_NULL = -99;
- public static DataTable Get_cm_user_by_cellphone(string cellphone)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_cm_user_by_cellphone", connection);
- MySqlParameter i_cellphone = new MySqlParameter("i_cellphone", cellphone);
- ad.SelectCommand.Parameters.Add(i_cellphone);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static DataTable Get_dm_user(int? userId, sbyte? role)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_user", connection);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- MySqlParameter i_role = new MySqlParameter("i_role", role);
- ad.SelectCommand.Parameters.Add(i_userid);
- ad.SelectCommand.Parameters.Add(i_role);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- /// <summary>
- /// 取数据采集任务列表
- /// </summary>
- /// <param name="userId"></param>
- /// <param name="taskId"></param>
- /// <param name="companyId"></param>
- /// <param name="taskDate"></param>
- /// <param name="taskType"></param>
- /// <param name="isValid"></param>
- /// <returns></returns>
- public static DataTable Get_dm_collection_task(int? userId, int? taskId, string providerId, string providerKeyword,
- DateTime? taskDate, short? taskType, string entityId, string entityKeyword, sbyte? isValid)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_collection_task", connection);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- MySqlParameter i_task_id = new MySqlParameter("i_task_id", taskId);
- MySqlParameter i_provider_id = new MySqlParameter("i_provider_id", providerId);
- MySqlParameter i_provider_keyword = new MySqlParameter("i_provider_keyword", providerKeyword);
- MySqlParameter i_task_date = new MySqlParameter("i_task_date", taskDate);
- MySqlParameter i_task_type = new MySqlParameter("i_task_type", taskType);
- MySqlParameter i_entity_id = new MySqlParameter("i_entity_id", entityId);
- MySqlParameter i_entity_keywordword = new MySqlParameter("i_entity_keyword", entityKeyword);
- MySqlParameter i_isvalid = new MySqlParameter("i_isvalid", isValid);
- ad.SelectCommand.Parameters.Add(i_userid);
- ad.SelectCommand.Parameters.Add(i_task_id);
- ad.SelectCommand.Parameters.Add(i_provider_id);
- ad.SelectCommand.Parameters.Add(i_provider_keyword);
- ad.SelectCommand.Parameters.Add(i_task_date);
- ad.SelectCommand.Parameters.Add(i_task_type);
- ad.SelectCommand.Parameters.Add(i_entity_id);
- ad.SelectCommand.Parameters.Add(i_entity_keywordword);
- ad.SelectCommand.Parameters.Add(i_isvalid);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static void Set_dm_collection_task(int? taskId, string providerId, DateTime taskDate, Int16 taskType,
- string entityId, string errMessage,
- sbyte isvalid, int userId, out int task_id)
- {
- task_id = 0;
- using (MySqlConnection connection = new MySqlConnection(connectionString))
- {
- connection.Open();
- MySqlCommand cmd = new MySqlCommand("sp_set_dm_collection_task", connection);
- MySqlParameter i_task_id = new MySqlParameter("i_task_id", taskId);
- MySqlParameter i_provider_id = new MySqlParameter("i_provider_id", providerId);
- MySqlParameter i_task_date = new MySqlParameter("i_task_date", taskDate);
- MySqlParameter i_task_type = new MySqlParameter("i_task_type", taskType);
- MySqlParameter i_entity_id = new MySqlParameter("i_entity_id", entityId);
- MySqlParameter i_err_message = new MySqlParameter("i_err_message", errMessage);
- MySqlParameter i_isvalid = new MySqlParameter("i_isvalid", isvalid);
- MySqlParameter i_user_id = new MySqlParameter("i_user_id", userId);
- MySqlParameter o_task_id = new MySqlParameter("o_task_id", DbType.Int32);
- o_task_id.Direction = ParameterDirection.Output;
- cmd.Parameters.Add(i_task_id);
- cmd.Parameters.Add(i_provider_id);
- cmd.Parameters.Add(i_task_date);
- cmd.Parameters.Add(i_task_type);
- cmd.Parameters.Add(i_isvalid);
- cmd.Parameters.Add(i_entity_id);
- cmd.Parameters.Add(i_err_message);
- cmd.Parameters.Add(i_user_id);
- cmd.Parameters.Add(o_task_id);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Connection = connection;
- cmd.ExecuteNonQuery();
- task_id = int.Parse(cmd.Parameters["o_task_id"].Value.ToString());
- }
- }
- /// <summary>
- /// 取公司联系任务列表
- /// </summary>
- /// <param name="userId"></param>
- /// <param name="taskId"></param>
- /// <param name="companyId"></param>
- /// <param name="taskDate"></param>
- /// <param name="taskType"></param>
- /// <param name="isValid"></param>
- /// <param name="priority"></param>
- /// <param name="followUpDate"></param>
- /// <param name="companyAsset"></param>
- /// <returns></returns>
- public static DataTable Get_dm_contact_task(int? userId, int? taskId, string companyId, string companyKeyword,
- DateTime? taskDate, short? taskType, sbyte? isValid, sbyte? priority,
- DateTime? followUpDate, sbyte? companyAsset)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_contact_task", connection);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- MySqlParameter i_task_id = new MySqlParameter("i_task_id", taskId);
- MySqlParameter i_company_id = new MySqlParameter("i_company_id", companyId);
- MySqlParameter i_company_keyword = new MySqlParameter("i_company_keyword", companyKeyword);
- MySqlParameter i_task_date = new MySqlParameter("i_task_date", taskDate);
- MySqlParameter i_task_type = new MySqlParameter("i_task_type", taskType);
- MySqlParameter i_isvalid = new MySqlParameter("i_isvalid", isValid);
- MySqlParameter i_priority = new MySqlParameter("i_priority", priority);
- MySqlParameter i_follow_up_date = new MySqlParameter("i_follow_up_date", followUpDate);
- MySqlParameter i_company_asset_size = new MySqlParameter("i_company_asset_size", companyAsset);
- ad.SelectCommand.Parameters.Add(i_userid);
- ad.SelectCommand.Parameters.Add(i_task_id);
- ad.SelectCommand.Parameters.Add(i_company_id);
- ad.SelectCommand.Parameters.Add(i_company_keyword);
- ad.SelectCommand.Parameters.Add(i_task_date);
- ad.SelectCommand.Parameters.Add(i_task_type);
- ad.SelectCommand.Parameters.Add(i_isvalid);
- ad.SelectCommand.Parameters.Add(i_priority);
- ad.SelectCommand.Parameters.Add(i_follow_up_date);
- ad.SelectCommand.Parameters.Add(i_company_asset_size);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- /// <summary>
- /// 更新联系任务表
- /// </summary>
- /// <param name="taskId"></param>
- /// <param name="companyId"></param>
- /// <param name="taskDate"></param>
- /// <param name="taskType"></param>
- /// <param name="isvalid"></param>
- /// <param name="priority"></param>
- /// <param name="followUpDate"></param>
- /// <param name="userId"></param>
- public static void Set_dm_contact_task(int? taskId, string companyId, DateTime taskDate, Int16 taskType, sbyte isvalid,
- sbyte priority, DateTime? followUpDate, int userId, out int task_id)
- {
- task_id = 0;
- using (MySqlConnection connection = new MySqlConnection(connectionString))
- {
- connection.Open();
- MySqlCommand cmd = new MySqlCommand("sp_set_dm_contact_task", connection);
- MySqlParameter i_task_id = new MySqlParameter("i_task_id", taskId);
- MySqlParameter i_company_id = new MySqlParameter("i_company_id", companyId);
- MySqlParameter i_task_date = new MySqlParameter("i_task_date", taskDate);
- MySqlParameter i_task_type = new MySqlParameter("i_task_type", taskType);
- MySqlParameter i_isvalid = new MySqlParameter("i_isvalid", isvalid);
- MySqlParameter i_priority = new MySqlParameter("i_priority", priority);
- MySqlParameter i_follow_up_date = new MySqlParameter("i_follow_up_date", followUpDate);
- MySqlParameter i_user_id = new MySqlParameter("i_user_id", userId);
- MySqlParameter o_task_id = new MySqlParameter("o_task_id", DbType.Int32);
- o_task_id.Direction = ParameterDirection.Output;
- cmd.Parameters.Add(i_task_id);
- cmd.Parameters.Add(i_company_id);
- cmd.Parameters.Add(i_task_date);
- cmd.Parameters.Add(i_task_type);
- cmd.Parameters.Add(i_isvalid);
- cmd.Parameters.Add(i_priority);
- cmd.Parameters.Add(i_follow_up_date);
- cmd.Parameters.Add(i_user_id);
- cmd.Parameters.Add(o_task_id);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Connection = connection;
- cmd.ExecuteNonQuery();
- task_id = int.Parse(cmd.Parameters["o_task_id"].Value.ToString());
- }
- }
- /// <summary>
- /// 取基金基本信息
- /// </summary>
- /// <param name="fundId"></param>
- /// <returns></returns>
- public static DataTable Get_dm_fund_information(string fundId, string companyId)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_fund_information", connection);
- MySqlParameter i_fundId = new MySqlParameter("i_fund_id", fundId);
- MySqlParameter i_company_id = new MySqlParameter("i_company_id", companyId);
- ad.SelectCommand.Parameters.Add(i_fundId);
- ad.SelectCommand.Parameters.Add(i_company_id);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static void Set_dm_fund_information(string fundId, string fundShortName, int? strategyId, int? substrategyId,
- string parentFundId, string navFrequency,
- sbyte isAuthorized, sbyte isRanking, sbyte isRating, int userId)
- {
- using (MySqlConnection connection = new MySqlConnection(connectionString))
- {
- connection.Open();
- MySqlCommand cmd = new MySqlCommand("sp_set_dm_fund_information", connection);
- MySqlParameter i_fund_id = new MySqlParameter("i_fund_id", fundId);
- MySqlParameter i_fund_short_name = new MySqlParameter("i_fund_short_name", fundShortName);
- MySqlParameter i_strategy_id = new MySqlParameter("i_strategy_id", strategyId);
- MySqlParameter i_substrategy_id = new MySqlParameter("i_substrategy_id", substrategyId);
- MySqlParameter i_p_fund_id = new MySqlParameter("i_p_fund_id", parentFundId);
- MySqlParameter i_nav_frequency = new MySqlParameter("i_nav_frequency", navFrequency);
- MySqlParameter i_is_authorized = new MySqlParameter("i_is_authorized", isAuthorized);
- MySqlParameter i_is_ranking = new MySqlParameter("i_is_ranking", isRanking);
- MySqlParameter i_is_rating = new MySqlParameter("i_is_rating", isRating);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- cmd.Parameters.Add(i_fund_id);
- cmd.Parameters.Add(i_fund_short_name);
- cmd.Parameters.Add(i_strategy_id);
- cmd.Parameters.Add(i_substrategy_id);
- cmd.Parameters.Add(i_p_fund_id);
- cmd.Parameters.Add(i_nav_frequency);
- cmd.Parameters.Add(i_is_authorized);
- cmd.Parameters.Add(i_is_ranking);
- cmd.Parameters.Add(i_is_rating);
- cmd.Parameters.Add(i_userid);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Connection = connection;
- cmd.ExecuteNonQuery();
- }
- }
- public static DataTable Get_dm_company_information(string companyId)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_company_information", connection);
- MySqlParameter i_company_id = new MySqlParameter("i_company_id", companyId);
- ad.SelectCommand.Parameters.Add(i_company_id);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static int Set_dm_company_information(string companyId, string shortName, int userId)
- {
- int ret = -1;
- using (MySqlConnection connection = new MySqlConnection(connectionString))
- {
- connection.Open();
- MySqlCommand cmd = new MySqlCommand("sp_set_dm_company_information", connection);
- MySqlParameter i_company_id = new MySqlParameter("i_company_id", companyId);
- MySqlParameter i_company_short_name = new MySqlParameter("i_company_short_name", shortName);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- cmd.Parameters.Add(i_company_id);
- cmd.Parameters.Add(i_company_short_name);
- cmd.Parameters.Add(i_userid);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Connection = connection;
- cmd.ExecuteNonQuery();
- ret = 1;
- }
- return ret;
- }
- /// <summary>
- /// 搜索公司(目前仅支持对 company_short_name 的搜索)
- /// </summary>
- /// <param name="companyType"></param> 私募证券:1
- /// <param name="keyWord"></param>
- /// <returns></returns>
- public static DataTable Search_dm_company(int? companyType, string keyWord)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_dm_search_company", connection);
- MySqlParameter i_companyType = new MySqlParameter("i_company_type", companyType);
- MySqlParameter i_keyWord = new MySqlParameter("i_key_word", keyWord);
- ad.SelectCommand.Parameters.Add(i_companyType);
- ad.SelectCommand.Parameters.Add(i_keyWord);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- /// <summary>
- /// 搜索基金(目前仅支持对 fund_short_name 的搜索)
- /// </summary>
- /// <param name="raiseType"></param> 私募:1、公募:2
- /// <param name="keyWord"></param>
- /// <returns></returns>
- public static DataTable Search_dm_fund(int? raiseType, string keyWord)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_dm_search_fund", connection);
- MySqlParameter i_raise_type = new MySqlParameter("i_raise_type", raiseType);
- MySqlParameter i_keyWord = new MySqlParameter("i_key_word", keyWord);
- ad.SelectCommand.Parameters.Add(i_raise_type);
- ad.SelectCommand.Parameters.Add(i_keyWord);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- /// <summary>
- /// 从 mfdb 里取NAV
- /// </summary>
- /// <param name="fundId"></param>
- /// <param name="startDate"></param>
- /// <param name="endDate"></param>
- /// <returns></returns>
- public static DataTable Get_Nav(string fundId, DateTime? startDate, DateTime? endDate)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_nav", connection);
- MySqlParameter i_fund_id = new MySqlParameter("i_fund_id", fundId);
- MySqlParameter i_start_date = new MySqlParameter("i_start_date", startDate);
- MySqlParameter i_end_date = new MySqlParameter("i_end_date", endDate);
- ad.SelectCommand.Parameters.Add(i_fund_id);
- ad.SelectCommand.Parameters.Add(i_start_date);
- ad.SelectCommand.Parameters.Add(i_end_date);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- /// <summary>
- /// 从 raw_db 里取原始NAV
- /// </summary>
- /// <param name="fundId"></param>
- /// <param name="startDate"></param>
- /// <param name="endDate"></param>
- /// <returns></returns>
- public static DataTable Get_dm_nav(string fundId, string providerId, string externalId, DateTime? startDate, DateTime? endDate)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_nav", connection);
- MySqlParameter i_fund_id = new MySqlParameter("i_fund_id", fundId);
- MySqlParameter i_provider_id = new MySqlParameter("i_provider_id", providerId);
- MySqlParameter i_external_id = new MySqlParameter("i_external_id", externalId);
- MySqlParameter i_start_date = new MySqlParameter("i_start_date", startDate);
- MySqlParameter i_end_date = new MySqlParameter("i_end_date", endDate);
- ad.SelectCommand.Parameters.Add(i_fund_id);
- ad.SelectCommand.Parameters.Add(i_provider_id);
- ad.SelectCommand.Parameters.Add(i_external_id);
- ad.SelectCommand.Parameters.Add(i_start_date);
- ad.SelectCommand.Parameters.Add(i_end_date);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static DataTable Get_dm_memo(sbyte jobType, int taskId)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_task_memo", connection);
- MySqlParameter i_job_type = new MySqlParameter("i_job_type", jobType);
- MySqlParameter i_task_id = new MySqlParameter("i_task_id", taskId);
- ad.SelectCommand.Parameters.Add(i_job_type);
- ad.SelectCommand.Parameters.Add(i_task_id);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static void Set_dm_memo(sbyte jobType, int taskId, string memo, int userId)
- {
- using (MySqlConnection connection = new MySqlConnection(connectionString))
- {
- connection.Open();
- MySqlCommand cmd = new MySqlCommand("sp_set_dm_task_memo", connection);
- MySqlParameter i_job_type = new MySqlParameter("i_job_type", jobType);
- MySqlParameter i_task_id = new MySqlParameter("i_task_id", taskId);
- MySqlParameter i_memo = new MySqlParameter("i_memo", memo);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- cmd.Parameters.Add(i_job_type);
- cmd.Parameters.Add(i_task_id);
- cmd.Parameters.Add(i_memo);
- cmd.Parameters.Add(i_userid);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Connection = connection;
- cmd.ExecuteNonQuery();
- }
- }
- public static DataTable Get_dm_contacts(string companyId)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_dm_get_contacts", connection);
- MySqlParameter i_company_id = new MySqlParameter("i_company_id", companyId);
- ad.SelectCommand.Parameters.Add(i_company_id);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static int Set_dm_contacts(DataTable dt, string companyId, int userId)
- {
- int ret = 0;
- if (dt == null || dt.Rows.Count <= 0) { return ret; }
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataRow dataRow = dt.Rows[i];
- int o_id;
- if (dataRow.RowState == DataRowState.Deleted)
- {
- Set_dm_contacts(int.Parse(dataRow["id", DataRowVersion.Original].ToString()), dataRow["company_id", DataRowVersion.Original].ToString(),
- dataRow["name", DataRowVersion.Original].ToString(), dataRow["role", DataRowVersion.Original].ToString(),
- dataRow["phone", DataRowVersion.Original].ToString(), dataRow["wechat", DataRowVersion.Original].ToString(),
- dataRow["email", DataRowVersion.Original].ToString(),
- 0, userId, out o_id);
- ret++;
- }
- else if (dataRow.RowState == DataRowState.Added || dataRow.RowState == DataRowState.Modified)
- {
- int? id = null;
- if (string.IsNullOrEmpty(dataRow["id"].ToString()) == false)
- id = int.Parse(dataRow["id"].ToString());
- Set_dm_contacts(id, companyId, dataRow["name"].ToString(), dataRow["role"].ToString(), dataRow["phone"].ToString(),
- dataRow["wechat"].ToString(), dataRow["email"].ToString(),
- 1, userId, out o_id);
- if (dataRow.RowState == DataRowState.Added)
- {
- dataRow["id"] = o_id;
- dataRow["company_id"] = companyId;
- }
- ret++;
- }
- }
- return ret;
- }
- public static void Set_dm_contacts(int? id, string companyId, string name, string role, string phone,
- string wechat, string email, sbyte isvalid, int userId, out int out_id)
- {
- using (MySqlConnection connection = new MySqlConnection(connectionString))
- {
- connection.Open();
- MySqlCommand cmd = new MySqlCommand("sp_dm_set_contacts", connection);
- MySqlParameter i_id = new MySqlParameter("i_id", id);
- MySqlParameter i_company_id = new MySqlParameter("i_company_id", companyId);
- MySqlParameter i_name = new MySqlParameter("i_name", name);
- MySqlParameter i_role = new MySqlParameter("i_role", role);
- MySqlParameter i_phone = new MySqlParameter("i_phone", phone);
- MySqlParameter i_wechat = new MySqlParameter("i_wechat", wechat);
- MySqlParameter i_email = new MySqlParameter("i_email", email);
- MySqlParameter i_isvalid = new MySqlParameter("i_isvalid", isvalid);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
-
- MySqlParameter o_id = new MySqlParameter("o_id", DbType.Int32);
- o_id.Direction = ParameterDirection.Output;
- cmd.Parameters.Add(i_id);
- cmd.Parameters.Add(i_company_id);
- cmd.Parameters.Add(i_name);
- cmd.Parameters.Add(i_role);
- cmd.Parameters.Add(i_phone);
- cmd.Parameters.Add(i_wechat);
- cmd.Parameters.Add(i_email);
- cmd.Parameters.Add(i_isvalid);
- cmd.Parameters.Add(i_userid);
- cmd.Parameters.Add(o_id);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Connection = connection;
- cmd.ExecuteNonQuery();
- out_id = int.Parse(cmd.Parameters["o_id"].Value.ToString());
- }
- }
- public static DataTable Get_dm_company_cover(string companyId, sbyte? coverType, int? userId)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_company_cover", connection);
- MySqlParameter i_company_id = new MySqlParameter("i_company_id", companyId);
- MySqlParameter i_cover_type = new MySqlParameter("i_cover_type", coverType);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- ad.SelectCommand.Parameters.Add(i_company_id);
- ad.SelectCommand.Parameters.Add(i_cover_type);
- ad.SelectCommand.Parameters.Add(i_userid);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- /// <summary>
- /// 批量更新公司-对接人员关系
- /// </summary>
- /// <param name="updateQuery">Json字符串</param>
- /// <param name="userId"></param>
- /// <returns></returns>
- public static int Set_dm_company_cover(string updateQuery, int userId)
- {
- int ret = -1;
- using (MySqlConnection connection = new MySqlConnection(connectionString))
- {
- connection.Open();
- MySqlCommand cmd = new MySqlCommand("sp_set_dm_company_cover", connection);
- MySqlParameter i_update_query = new MySqlParameter("i_update_query", updateQuery);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- cmd.Parameters.Add(i_update_query);
- cmd.Parameters.Add(i_userid);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Connection = connection;
- cmd.ExecuteNonQuery();
- ret = 1;
- }
- return ret;
- }
- /// <summary>
- /// 取基金指数,benchmark_type: 0-主基准、1-分类平均
- /// </summary>
- /// <param name="fundId"></param>
- /// <returns></returns>
- public static DataTable Get_dm_fund_benchmark(string fundId)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_fund_benchmark", connection);
- MySqlParameter i_fund_id = new MySqlParameter("i_fund_id", fundId);
- ad.SelectCommand.Parameters.Add(i_fund_id);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static DataTable Get_dm_external_fund_mapping(sbyte? isOrphan, int? userId)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_external_fund_mapping", connection);
- MySqlParameter i_is_orphan = new MySqlParameter("i_is_orphan", isOrphan);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- ad.SelectCommand.Parameters.Add(i_is_orphan);
- ad.SelectCommand.Parameters.Add(i_userid);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static void Set_dm_external_fund_mapping(string providerId, string externalId, string fundId, int userId)
- {
- using (MySqlConnection connection = new MySqlConnection(connectionString))
- {
- connection.Open();
- MySqlCommand cmd = new MySqlCommand("sp_set_dm_external_fund_mapping", connection);
- MySqlParameter i_provider_id = new MySqlParameter("i_provider_id", providerId);
- MySqlParameter i_external_id = new MySqlParameter("i_external_id", externalId);
- MySqlParameter i_fund_id = new MySqlParameter("i_fund_id", fundId);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- cmd.Parameters.Add(i_provider_id);
- cmd.Parameters.Add(i_external_id);
- cmd.Parameters.Add(i_fund_id);
- cmd.Parameters.Add(i_userid);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Connection = connection;
- cmd.ExecuteNonQuery();
- }
- }
- public static DataTable Report_company_coverage(int? userId)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_dm_report_company_coverage", connection);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- ad.SelectCommand.Parameters.Add(i_userid);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static DataTable Get_dm_company_authorization(string companyId, int? userId)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_company_authorization", connection);
- MySqlParameter i_company_id = new MySqlParameter("i_company_id", companyId);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- ad.SelectCommand.Parameters.Add(i_company_id);
- ad.SelectCommand.Parameters.Add(i_userid);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static DataTable Report_fund_coverage(int? userId)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_dm_report_fund_coverage", connection);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- ad.SelectCommand.Parameters.Add(i_userid);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static DataTable Get_dm_fund_authorization(int? userId)
- {
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_fund_authorization", connection);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- ad.SelectCommand.Parameters.Add(i_userid);
- ad.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dt = new DataTable();
- ad.Fill(dt);
- connection.Close();
- return dt;
- }
- public static int Set_dm_fund_authorization(string ids, int isValid, int userId)
- {
- int ret = -1;
- using (MySqlConnection connection = new MySqlConnection(connectionString))
- {
- connection.Open();
- MySqlCommand cmd = new MySqlCommand("sp_set_dm_fund_authorization", connection);
- MySqlParameter i_fund_ids = new MySqlParameter("i_fund_ids", ids);
- MySqlParameter i_isvalid = new MySqlParameter("i_isvalid", isValid);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- cmd.Parameters.Add(i_fund_ids);
- cmd.Parameters.Add(i_isvalid);
- cmd.Parameters.Add(i_userid);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Connection = connection;
- cmd.ExecuteNonQuery();
- ret = 1;
- }
- return ret;
- }
- public static int Set_dm_company_authorization(string companyId, int isAuthorized, int userId)
- {
- int ret = -1;
- using (MySqlConnection connection = new MySqlConnection(connectionString))
- {
- connection.Open();
- MySqlCommand cmd = new MySqlCommand("sp_set_dm_company_authorization", connection);
- MySqlParameter i_company_id = new MySqlParameter("i_company_id", companyId);
- MySqlParameter i_isvalid = new MySqlParameter("i_isvalid", isAuthorized);
- MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
- cmd.Parameters.Add(i_company_id);
- cmd.Parameters.Add(i_isvalid);
- cmd.Parameters.Add(i_userid);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Connection = connection;
- cmd.ExecuteNonQuery();
- ret = 1;
- }
- return ret;
- }
- }
- }
|