UICompany.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  1. using Mysqlx.Crud;
  2. using MySqlX.Serialization;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Reflection;
  11. using System.Runtime.InteropServices.ComTypes;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. using System.Text.Json;
  16. using System.IO;
  17. using System.Diagnostics;
  18. using System.Text.RegularExpressions;
  19. namespace DataManager
  20. {
  21. public partial class UICompany : Form
  22. {
  23. private string companyId;
  24. private int userId;
  25. private DataTable companyInfo;
  26. private DataTable fundList;
  27. private DataTable contactList;
  28. private List<DataRowView> old_selected_contactor = new List<DataRowView>();
  29. private List<DataRowView> old_selected_collector = new List<DataRowView>();
  30. private string saveFilePath;
  31. private DataTable taskList;
  32. public UICompany(string companyId, int userId)
  33. {
  34. this.companyId = companyId.Trim().ToUpper();
  35. this.userId = userId;
  36. this.saveFilePath = ".\\Contracts\\" + companyId + "\\";
  37. InitializeComponent();
  38. InitializedData();
  39. }
  40. public string CompanyId { get { return companyId; } }
  41. public int UserId { get { return userId; } }
  42. private void InitializedData()
  43. {
  44. #region Basic Info Tab
  45. companyInfo = DataAccess.Get_dm_company_information(CompanyId);
  46. if(companyInfo == null || companyInfo.Rows.Count == 0 ) { return; }
  47. txtCompanyName.Text = companyInfo.Rows[0]["company_name"].ToString();
  48. txtRegisterCode.Text = companyInfo.Rows[0]["register_number"].ToString();
  49. txtCompanyId.Text = companyInfo.Rows[0]["company_id"].ToString();
  50. txtIncoporationDate.Text = DateTime.Parse(companyInfo.Rows[0]["establish_date"].ToString()).ToShortDateString();
  51. txtRegisterAddress.Text = companyInfo.Rows[0]["register_number_address"].ToString();
  52. txtOrgCode.Text = companyInfo.Rows[0]["credit_code"].ToString();
  53. txtBusinessAddress.Text = companyInfo.Rows[0]["company_address"].ToString();
  54. if (companyInfo.Rows[0]["nature_business_type"].ToString() != "")
  55. txtOrgType.Text = UIConstants.CompanyOwnerType[int.Parse(companyInfo.Rows[0]["nature_business_type"].ToString())];
  56. else
  57. txtOrgType.Text = "未知";
  58. if (companyInfo.Rows[0]["company_type"].ToString() != "")
  59. txtCompanyType.Text = UIConstants.CompanyType[int.Parse(companyInfo.Rows[0]["company_type"].ToString())];
  60. else
  61. txtCompanyType.Text = "未知";
  62. txtBusinessType.Text = companyInfo.Rows[0]["business_type"].ToString();
  63. if (companyInfo.Rows[0]["company_asset_size"].ToString() != "")
  64. txtAssetSize.Text = UIConstants.CompanyAssetSize[int.Parse(companyInfo.Rows[0]["company_asset_size"].ToString())];
  65. else
  66. txtAssetSize.Text = "未知";
  67. txtIsQualifiedAdvisor.Text = companyInfo.Rows[0]["has_consulting_qualification"].ToString() == "1" ? "是" : "否";
  68. //txtOwner.Text = companyInfo.Rows[0]["establish_date"].ToString();
  69. //txtAmacUpdateDate.Text = companyInfo.Rows[0]["zjx_last_info_update_time"].ToString();
  70. //lklAmacURL.Links.Add(Link )companyInfo.Rows[0]["amac_link"].ToString();
  71. txtCompanyShortName.Text = companyInfo.Rows[0]["company_short_name"].ToString();
  72. #endregion
  73. LoadContactsGrid();
  74. #region Fund List Tab
  75. Dictionary<int, string> d = new Dictionary<int, string>(UIConstants.HedgeFundStrategy);
  76. d.Add(DataAccess.DM_NULL, "全部");
  77. BindingSource bs = new BindingSource();
  78. bs.DataSource = d;
  79. cmbStrategy.DataSource = bs;
  80. cmbStrategy.DisplayMember = "Value";
  81. cmbStrategy.ValueMember = "Key";
  82. cmbStrategy.SelectedValue = (int)DataAccess.DM_NULL;
  83. LoadFundGrid();
  84. #endregion
  85. #region Contracts Tab
  86. sbyte jobType = Convert.ToSByte(UIConstants.JobType.联络);
  87. DataTable dt_dm_user_1 = DataAccess.Get_dm_user(null, jobType);
  88. clbContactor.DataSource = dt_dm_user_1;
  89. clbContactor.DisplayMember = "username";
  90. clbContactor.ValueMember = "userid";
  91. // 给覆盖此公司的user打上勾
  92. DataTable dt_company_cover_1 = DataAccess.Get_dm_company_cover(CompanyId, jobType, null);
  93. for(int i = 0; i < clbContactor.Items.Count; i++)
  94. {
  95. string itemUserId = ((DataRowView)clbContactor.Items[i]).Row["userid"].ToString();
  96. if (dt_company_cover_1.Select("userid = " + itemUserId).Length > 0)
  97. clbContactor.SetItemChecked(i, true);
  98. }
  99. // 记录一下初始的勾选
  100. foreach(DataRowView item in clbContactor.CheckedItems)
  101. {
  102. old_selected_contactor.Add(item);
  103. }
  104. jobType = Convert.ToSByte(UIConstants.JobType.采集);
  105. DataTable dt_dm_user_2 = DataAccess.Get_dm_user(null, jobType);
  106. clbCollector.DataSource = dt_dm_user_2;
  107. clbCollector.DisplayMember = "username";
  108. clbCollector.ValueMember = "userid";
  109. // 给覆盖此公司的user打上勾
  110. DataTable dt_company_cover_2 = DataAccess.Get_dm_company_cover(CompanyId, jobType, null);
  111. for (int i = 0; i < clbCollector.Items.Count; i++)
  112. {
  113. string itemUserId = ((DataRowView)clbCollector.Items[i]).Row["userid"].ToString();
  114. if (dt_company_cover_2.Select("userid = " + itemUserId).Length > 0)
  115. clbCollector.SetItemChecked(i, true);
  116. }
  117. // 记录一下初始的勾选
  118. foreach(DataRowView item in clbCollector.CheckedItems)
  119. {
  120. old_selected_collector.Add(item);
  121. }
  122. LoadContractFiles();
  123. #endregion
  124. #region Task Tab
  125. cmbTaskType.Items.Add(UIConstants.JobType.联络.ToString());
  126. cmbTaskType.Items.Add(UIConstants.JobType.采集.ToString());
  127. cmbTaskType.SelectedIndex = 0;
  128. LoadTaskList(UIConstants.JobType.联络);
  129. #endregion
  130. }
  131. #region Basic Info
  132. private void btnSaveBasicInfo_Click(object sender, EventArgs e)
  133. {
  134. MessageBox.Show("暂时不支持存数据");
  135. }
  136. #endregion
  137. #region Contact List
  138. private void LoadContactsGrid()
  139. {
  140. contactList = DataAccess.Get_dm_contacts(CompanyId);
  141. grdContacts.DataSource = contactList;
  142. grdContacts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  143. grdContacts.Columns["id"].Visible = false;
  144. grdContacts.Columns["company_id"].Visible = false;
  145. grdContacts.Columns["name"].HeaderText = "姓名";
  146. grdContacts.Columns["role"].HeaderText = "职务";
  147. grdContacts.Columns["phone"].HeaderText = "电话";
  148. grdContacts.Columns["wechat"].HeaderText = "微信";
  149. grdContacts.Columns["email"].HeaderText = "邮箱";
  150. grdContacts.Columns["isvalid"].Visible = false;
  151. grdContacts.Columns["creatorid"].Visible = false;
  152. grdContacts.Columns["createtime"].Visible = false;
  153. grdContacts.Columns["updaterid"].Visible = false;
  154. grdContacts.Columns["updatetime"].Visible = false;
  155. lblContactsCount.Text = contactList.Rows.Count.ToString();
  156. }
  157. private void btnSaveContact_Click(object sender, EventArgs e)
  158. {
  159. if(contactList == null ) return;
  160. int updatedCnt = DataAccess.Set_dm_contacts(contactList, CompanyId, UserId);
  161. contactList.AcceptChanges();
  162. MessageBox.Show("成功更新了" + updatedCnt.ToString() + "个联系人", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  163. }
  164. #endregion
  165. #region Fund List
  166. private void LoadFundGrid()
  167. {
  168. fundList = DataAccess.Get_dm_fund_information(null, CompanyId);
  169. BindingSource bs = new BindingSource();
  170. bs.DataSource = fundList;
  171. grdFund.DataSource = bs;
  172. grdFund.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  173. grdFund.Columns["fund_id"].Visible = false;
  174. grdFund.Columns["raise_type"].Visible = false;
  175. grdFund.Columns["fund_name"].Visible = false;
  176. grdFund.Columns["fund_short_name"].HeaderText = "基金简称";
  177. grdFund.Columns["fund_structure"].Visible = false;
  178. grdFund.Columns["fund_type"].Visible = false;
  179. grdFund.Columns["strategy"].Visible = false;
  180. grdFund.Columns["substrategy"].Visible = false;
  181. grdFund.Columns["fund_status"].Visible = false;
  182. grdFund.Columns["base_currency"].Visible = false;
  183. grdFund.Columns["inception_date"].HeaderText = "成立日";
  184. grdFund.Columns["initial_unit_value"].Visible = false;
  185. grdFund.Columns["p_fund_id"].Visible = false;
  186. grdFund.Columns["p_fund_name"].Visible = false;
  187. grdFund.Columns["advisor_id"].Visible = false;
  188. grdFund.Columns["company_name"].Visible = false;
  189. grdFund.Columns["custodian_id"].Visible = false;
  190. grdFund.Columns["custodian_name"].HeaderText = "托管";
  191. grdFund.Columns["trust_id"].Visible = false;
  192. grdFund.Columns["nav_frequency"].HeaderText = "净值频率";
  193. grdFund.Columns["manager_type"].Visible = false;
  194. grdFund.Columns["zjx_last_info_update_time"].Visible = false;
  195. grdFund.Columns["amac_url"].Visible = false;
  196. grdFund.Columns["register_number"].HeaderText = "备案编码";
  197. grdFund.Columns["register_date"].Visible = false;
  198. grdFund.Columns["main_code"].Visible = false;
  199. grdFund.Columns["isVisible"].Visible = false;
  200. grdFund.Columns["is_ranking"].HeaderText = "是否排名";
  201. grdFund.Columns["is_rating"].HeaderText = "是否评级";
  202. grdFund.Columns["is_authorized"].HeaderText = "是否授权";
  203. grdFund.Columns["trust_register_number"].Visible = false;
  204. grdFund.Columns["isvalid"].Visible = false;
  205. grdFund.Columns["creatorid"].Visible = false;
  206. grdFund.Columns["createtime"].Visible = false;
  207. grdFund.Columns["updaterid"].Visible = false;
  208. grdFund.Columns["updatetime"].Visible = false;
  209. grdFund.Columns["max_price_date"].HeaderText = "最新净值日";
  210. grdFund.Columns["fund_short_name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
  211. SetStatusStrip(fundList.Rows.Count);
  212. }
  213. private void grdFund_CellClick(object sender, DataGridViewCellEventArgs e)
  214. {
  215. int rowIndex = e.RowIndex;
  216. int columnIndex = e.ColumnIndex;
  217. if (columnIndex < 0 || rowIndex < 0) return;
  218. DataGridViewRow row = grdFund.Rows[rowIndex];
  219. string fundId = row.Cells["fund_id"].Value.ToString();
  220. UIFund frm = new UIFund(fundId, UserId);
  221. frm.ShowDialog();
  222. }
  223. private void cmbStrategy_SelectedIndexChanged(object sender, EventArgs e)
  224. {
  225. FilterFund();
  226. }
  227. private void dtpInceptionDate_ValueChanged(object sender, EventArgs e)
  228. {
  229. FilterFund();
  230. }
  231. private void FilterFund()
  232. {
  233. string strategy = cmbStrategy.SelectedValue.ToString();
  234. string inception = dtpInceptionDate.Value.ToString();
  235. string filter = null;
  236. int cnt = 0;
  237. if (strategy == DataAccess.DM_NULL.ToString())
  238. filter = string.Format("inception_date <= #{0}#", inception);
  239. else
  240. filter = string.Format("strategy = {0} and inception_date <= #{1}#", strategy, inception);
  241. if (fundList != null && fundList.Rows.Count > 0)
  242. {
  243. BindingSource bs = (BindingSource)grdFund.DataSource;
  244. bs.Filter = filter;
  245. cnt = bs.Count;
  246. }
  247. SetStatusStrip(cnt);
  248. }
  249. private void SetStatusStrip(int cnt)
  250. {
  251. ToolStripStatusLabel label = new ToolStripStatusLabel();
  252. label.Text = "记录条数:" + cnt.ToString();
  253. sstCompany.Items.Clear();
  254. sstCompany.Items.Add(label);
  255. }
  256. #endregion
  257. #region Contract
  258. private void btnSaveContactor_Click(object sender, EventArgs e)
  259. {
  260. List<CompanyCoverUser> coverage = new List<CompanyCoverUser>();
  261. List<DataRowView> new_selected_contactor = new List<DataRowView>();
  262. foreach(DataRowView item in clbContactor.CheckedItems)
  263. new_selected_contactor.Add(item);
  264. CompanyCoverUser cov1 = CompareCoverage(CompanyId, 1, old_selected_contactor, new_selected_contactor);
  265. if(cov1 != null )
  266. coverage.Add(cov1);
  267. List<DataRowView> new_selected_collector = new List<DataRowView>();
  268. foreach (DataRowView item in clbCollector.CheckedItems)
  269. new_selected_collector.Add(item);
  270. CompanyCoverUser cov2 = CompareCoverage(CompanyId, 2, old_selected_collector, new_selected_collector);
  271. if(cov2 != null )
  272. coverage.Add(cov2);
  273. string query = JsonSerializer.Serialize(coverage);
  274. int ret = DataAccess.Set_dm_company_cover(query, UserId);
  275. string message = ret < 0 ? "Oops... 变更存数据库时出了错" : "人员覆盖变更已经成功存盘~";
  276. MessageBox.Show(message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  277. }
  278. /// <summary>
  279. /// 前后人员覆盖对比
  280. /// </summary>
  281. /// <param name="companyId"></param>
  282. /// <param name="coverType"></param>
  283. /// <param name="oldList"></param>
  284. /// <param name="newList"></param>
  285. /// <returns></returns>
  286. private CompanyCoverUser CompareCoverage(string companyId, sbyte coverType, List<DataRowView> oldList, List<DataRowView> newList)
  287. {
  288. CompanyCoverUser companyCoverUser = new CompanyCoverUser();
  289. companyCoverUser.CompanyId = companyId;
  290. companyCoverUser.CoverType = coverType;
  291. if (oldList == null || newList == null) return companyCoverUser;
  292. // 在旧名单里,但不在新名单里的要删掉
  293. List<DataRowView> itemDeleted = oldList.Except(newList).ToList();
  294. // 在新名单里,但不在旧名单里的要增加
  295. List<DataRowView> itemAdded = newList.Except(oldList).ToList();
  296. int i = 0;
  297. CompanyCoverUser.Coverage[] covers = null;
  298. if (itemDeleted.Count > 0 || itemAdded.Count > 0)
  299. covers = new CompanyCoverUser.Coverage[itemDeleted.Count+itemAdded.Count];
  300. foreach (DataRowView item in itemDeleted)
  301. {
  302. CompanyCoverUser.Coverage cov = new CompanyCoverUser.Coverage();
  303. cov.IsValid = 0;
  304. cov.UserId = int.Parse(item.Row["userid"].ToString());
  305. covers[i] = cov;
  306. i++;
  307. }
  308. foreach (DataRowView item in itemAdded)
  309. {
  310. CompanyCoverUser.Coverage cov = new CompanyCoverUser.Coverage();
  311. cov.IsValid = 1;
  312. cov.UserId = int.Parse(item.Row["userid"].ToString());
  313. covers[i] = cov;
  314. i++;
  315. }
  316. companyCoverUser.Coverages = covers;
  317. //ret = JsonSerializer.Serialize(companyCoverUser);
  318. return companyCoverUser;
  319. }
  320. /// <summary>
  321. /// 上传文件 TODO: 文件先写到本地
  322. /// </summary>
  323. /// <param name="sender"></param>
  324. /// <param name="e"></param>
  325. private void btnUploadFile_Click(object sender, EventArgs e)
  326. {
  327. ofdUploadFile.Title = "文件上传 ... 还没做完呢";
  328. //ofdUploadFile.DefaultExt = "doc";
  329. //ofdUploadFile.Filter = "所有Word文件(*.doc)|所有pdf文件(*.pdf)|所有文件(*.*)|*.*";
  330. if(ofdUploadFile.ShowDialog() == DialogResult.OK)
  331. {
  332. // TODO: upload files to server. let's fake it for now
  333. string filePath = ofdUploadFile.FileName;
  334. string fileName = Path.GetFileName(filePath);
  335. string saveFileName = this.saveFilePath + fileName;
  336. try
  337. {
  338. if (!Directory.Exists(saveFilePath)) { Directory.CreateDirectory(saveFilePath); }
  339. File.Copy(filePath, saveFileName, true);
  340. CreateFileButton(Path.GetFileName(saveFileName));
  341. }
  342. catch (Exception ex)
  343. {
  344. MessageBox.Show("文件上传失败:" + ex.Message, "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
  345. }
  346. }
  347. }
  348. /// <summary>
  349. /// 显示已上传文件,每个文件一个按钮
  350. /// </summary>
  351. private void LoadContractFiles()
  352. {
  353. if (Directory.Exists(this.saveFilePath))
  354. {
  355. string[] fileNames = Directory.GetFiles(saveFilePath);
  356. if(fileNames.Length > 0)
  357. {
  358. foreach (string fileName in fileNames)
  359. {
  360. CreateFileButton(Path.GetFileName(fileName));
  361. }
  362. }
  363. }
  364. }
  365. /// <summary>
  366. /// 为每个上传的文件产生一个按钮来显示
  367. /// </summary>
  368. /// <param name="fileName"></param>
  369. private void CreateFileButton(string fileName)
  370. {
  371. Panel panFile = new Panel();
  372. panFile.BorderStyle = BorderStyle.FixedSingle;
  373. panFile.Size = btnUploadFile.Size;
  374. panFile.Text = fileName;
  375. panFile.Font = new Font("微软雅黑", 10F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134)));
  376. panFile.Click += PanFile_Click;
  377. panFile.MouseEnter += PanFile_Enter;
  378. panFile.MouseLeave += PanFile_MouseLeave;
  379. Label lblFileName = new Label();
  380. lblFileName.Text = fileName;
  381. lblFileName.ForeColor = Color.DodgerBlue;
  382. lblFileName.Size = new Size(panFile.Width, panFile.Height/2);
  383. lblFileName.Location = new Point(panFile.Location.X, panFile.Location.Y + panFile.Size.Height/2);
  384. lblFileName.TextAlign = ContentAlignment.MiddleCenter;
  385. lblFileName.Click += LblFileName_Click;
  386. panFile.Controls.Add(lblFileName);
  387. CircleDeleteControl delIcon = new CircleDeleteControl();
  388. delIcon.Size = new Size(panFile.Width/8, panFile.Height/8);
  389. delIcon.Location = new Point(panFile.Width * 3/4, panFile.Width * 1/8);
  390. delIcon.Visible = true;
  391. delIcon.Click += DelIcon_Click;
  392. panFile.Controls.Add(delIcon);
  393. flowLayoutPanel1.Controls.Add(panFile);
  394. }
  395. private void LblFileName_Click(object sender, EventArgs e)
  396. {
  397. Control pan = ((Control)sender).Parent;
  398. PanFile_Click(pan, e);
  399. }
  400. private void PanFile_Click(object sender, EventArgs e)
  401. {
  402. OpenFile(saveFilePath + ((Panel)sender).Text);
  403. }
  404. private void PanFile_Enter(object sender, EventArgs e)
  405. {
  406. ((Control)sender).BackColor = Color.LightGray;
  407. }
  408. private void PanFile_MouseLeave(object sender, EventArgs e)
  409. {
  410. ((Control)sender).BackColor = Color.White;
  411. }
  412. private void DelIcon_Click(object sender, EventArgs e)
  413. {
  414. DialogResult result = MessageBox.Show("确认要删除此文件么?", "删除文件确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  415. if (result == DialogResult.Yes)
  416. {
  417. Panel pan = (Panel)((Control)sender).Parent;
  418. File.Delete(saveFilePath + pan.Text);
  419. pan.Parent.Controls.Remove(pan);
  420. }
  421. }
  422. private void OpenFile(string fileName)
  423. {
  424. ProcessStartInfo startInfo = new ProcessStartInfo
  425. {
  426. FileName = fileName,
  427. UseShellExecute = true
  428. };
  429. Process.Start(startInfo);
  430. }
  431. #endregion
  432. #region Task List
  433. private void LoadTaskList(UIConstants.JobType jobType)
  434. {
  435. if (jobType == UIConstants.JobType.联络)
  436. {
  437. taskList = DataAccess.Get_dm_contact_task(null, null, CompanyId, null, null, null, null, null, null, null);
  438. grdTaskList.DataSource = taskList;
  439. grdTaskList.Columns["task_id"].HeaderText = "ID";
  440. grdTaskList.Columns["company_short_name"].HeaderText = "公司";
  441. grdTaskList.Columns["task_date"].HeaderText = "日期";
  442. grdTaskList.Columns["task_type_name"].HeaderText = "任务";
  443. grdTaskList.Columns["isvalid_name"].HeaderText = "状态";
  444. grdTaskList.Columns["priority_name"].HeaderText = "优先级";
  445. grdTaskList.Columns["follow_up_date"].HeaderText = "跟进日";
  446. grdTaskList.Columns["company_asset_size_name"].HeaderText = "规模";
  447. grdTaskList.Columns["creator_name"].HeaderText = "创建";
  448. grdTaskList.Columns["updater_name"].HeaderText = "更新";
  449. grdTaskList.Columns["updatetime"].HeaderText = "更新时间";
  450. grdTaskList.Columns["company_id"].Visible = false;
  451. grdTaskList.Columns["task_type"].Visible = false;
  452. grdTaskList.Columns["isvalid"].Visible = false;
  453. grdTaskList.Columns["priority"].Visible = false;
  454. grdTaskList.Columns["company_asset_size"].Visible = false;
  455. grdTaskList.Columns["creatorid"].Visible = false;
  456. grdTaskList.Columns["createtime"].Visible = false;
  457. grdTaskList.Columns["updaterid"].Visible = false;
  458. grdTaskList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  459. }
  460. else
  461. {
  462. taskList = DataAccess.Get_dm_collection_task(null, null, CompanyId, null, null, null, null, null, null);
  463. grdTaskList.DataSource = taskList;
  464. grdTaskList.Columns["task_id"].HeaderText = "ID";
  465. grdTaskList.Columns["provider_name"].HeaderText = "来源";
  466. grdTaskList.Columns["task_date"].HeaderText = "日期";
  467. grdTaskList.Columns["task_type_name"].HeaderText = "任务";
  468. grdTaskList.Columns["entity_name"].HeaderText = "主题";
  469. grdTaskList.Columns["err_message"].HeaderText = "详情";
  470. grdTaskList.Columns["isvalid_name"].HeaderText = "状态";
  471. grdTaskList.Columns["creator_name"].HeaderText = "创建";
  472. grdTaskList.Columns["updater_name"].HeaderText = "更新";
  473. grdTaskList.Columns["updatetime"].HeaderText = "更新时间";
  474. grdTaskList.Columns["provider_id"].Visible = false;
  475. grdTaskList.Columns["task_type"].Visible = false;
  476. grdTaskList.Columns["entity_id"].Visible = false;
  477. grdTaskList.Columns["isvalid"].Visible = false;
  478. grdTaskList.Columns["creatorid"].Visible = false;
  479. grdTaskList.Columns["createtime"].Visible = false;
  480. grdTaskList.Columns["updaterid"].Visible = false;
  481. grdTaskList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  482. }
  483. }
  484. private void btnAddtTask_Click(object sender, EventArgs e)
  485. {
  486. UIConstants.JobType jobType = (UIConstants.JobType)Enum.Parse(typeof(UIConstants.JobType), cmbTaskType.SelectedItem.ToString());
  487. if (jobType == UIConstants.JobType.联络)
  488. {
  489. frmContactTask ctk = new frmContactTask(UserId, CompanyId, companyInfo.Rows[0]["company_short_name"].ToString());
  490. ctk.ShowDialog();
  491. // 刷新 grid 数据
  492. if (ctk.DialogResult == DialogResult.OK)
  493. {
  494. LoadTaskList(jobType);
  495. }
  496. }
  497. else
  498. {
  499. UICollectionTask ctk = new UICollectionTask(UserId, CompanyId, companyInfo.Rows[0]["company_short_name"].ToString());
  500. ctk.ShowDialog();
  501. // 刷新 grid 数据
  502. if (ctk.DialogResult == DialogResult.OK)
  503. {
  504. LoadTaskList(jobType);
  505. }
  506. }
  507. }
  508. private void cmbTaskType_SelectedIndexChanged(object sender, EventArgs e)
  509. {
  510. if (cmbTaskType.Focus())
  511. {
  512. UIConstants.JobType jobType = (UIConstants.JobType)Enum.Parse(typeof(UIConstants.JobType), cmbTaskType.SelectedItem.ToString());
  513. LoadTaskList(jobType);
  514. }
  515. }
  516. #endregion
  517. private void grdTaskList_CellClick(object sender, DataGridViewCellEventArgs e)
  518. {
  519. int rowIndex = e.RowIndex;
  520. int columnIndex = e.ColumnIndex;
  521. if (columnIndex < 0 || rowIndex < 0) return;
  522. DataRow row = taskList.Rows[rowIndex];
  523. UIConstants.JobType jobType = (UIConstants.JobType)Enum.Parse(typeof(UIConstants.JobType), cmbTaskType.SelectedItem.ToString());
  524. if (jobType == UIConstants.JobType.联络)
  525. {
  526. ContactTask task = new ContactTask(UserId, row.Field<int>("task_id"), row.Field<string>("company_id"), row.Field<string>("company_short_name"),
  527. row.Field<DateTime>("task_date"), row.Field<short>("task_type"), row.Field<sbyte>("isvalid"), row.Field<sbyte>("priority"),
  528. row.Field<DateTime?>("follow_up_date"), row.Field<sbyte?>("company_asset_size"),
  529. row.Field<int?>("creatorid"), row.Field<string>("creator_name"), row.Field<DateTime?>("createtime"),
  530. row.Field<int?>("updaterid"), row.Field<string>("updater_name"), row.Field<DateTime?>("updatetime"));
  531. if (task != null)
  532. {
  533. frmContactTask ctk = new frmContactTask(task);
  534. ctk.ShowDialog();
  535. // 刷新 grid 数据
  536. if (ctk.DialogResult == DialogResult.OK)
  537. {
  538. LoadTaskList(jobType);
  539. }
  540. }
  541. }
  542. else
  543. {
  544. CollectionTask task = new CollectionTask(UserId, row.Field<int>("task_id"), row.Field<string>("provider_id"), row.Field<string>("provider_name"),
  545. row.Field<DateTime>("task_date"), row.Field<short>("task_type"),
  546. row.Field<string>("entity_id"), row.Field<string>("entity_name"),
  547. row.Field<string>("err_message"), row.Field<sbyte>("isvalid"),
  548. row.Field<int?>("creatorid"), row.Field<string>("creator_name"), row.Field<DateTime?>("createtime"),
  549. row.Field<int?>("updaterid"), row.Field<string>("updater_name"), row.Field<DateTime?>("updatetime"));
  550. if (task != null)
  551. {
  552. UICollectionTask ctk = new UICollectionTask(task);
  553. ctk.ShowDialog();
  554. // 刷新 grid 数据
  555. if (ctk.DialogResult == DialogResult.OK)
  556. {
  557. LoadTaskList(jobType);
  558. }
  559. }
  560. }
  561. }
  562. }
  563. public class CompanyCoverUser
  564. {
  565. public string CompanyId { get; set; }
  566. public sbyte CoverType { get; set; }
  567. public Coverage[] Coverages { get; set; }
  568. public class Coverage
  569. {
  570. public sbyte IsValid { get; set; }
  571. public int UserId { get; set; }
  572. }
  573. }
  574. public class CircleDeleteControl : Control
  575. {
  576. protected override void OnPaint(PaintEventArgs e)
  577. {
  578. //this.BackColor = Color.White;
  579. base.OnPaint(e);
  580. Graphics g = e.Graphics;
  581. g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  582. Point center = new Point(this.Width/2, this.Height/2);
  583. // 圆形删除符号的直径可以是控件的最小边长
  584. int diameter = Math.Min(this.Width, this.Height);
  585. // 圆形删除符号的内半径
  586. int innerRadius = diameter / 2;
  587. using (Pen deletePen = new Pen(Color.Red, 1))
  588. {
  589. // 绘制圆形删除符号的背景
  590. g.DrawEllipse(deletePen, center.X - innerRadius, center.Y - innerRadius, diameter, diameter);
  591. // 绘制两条相交的对角线
  592. int offset = (int)Math.Floor(innerRadius / 1.4);
  593. g.DrawLine(deletePen, center.X - innerRadius - offset, center.Y + innerRadius + offset, center.X + innerRadius + offset, center.Y - innerRadius - offset);
  594. g.DrawLine(deletePen, center.X - innerRadius - offset, center.Y - innerRadius - offset, center.X + innerRadius + offset, center.Y + innerRadius + offset);
  595. }
  596. }
  597. protected override void OnMouseEnter(EventArgs e)
  598. {
  599. base.OnMouseEnter(e);
  600. this.Cursor = Cursors.Hand;
  601. }
  602. protected override void OnMouseLeave(EventArgs e)
  603. {
  604. base.OnMouseLeave(e);
  605. this.Cursor = Cursors.Arrow;
  606. }
  607. }
  608. }