123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 |
- using Mysqlx.Crud;
- using MySqlX.Serialization;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SqlClient;
- using System.Drawing;
- using System.Linq;
- using System.Reflection;
- using System.Runtime.InteropServices.ComTypes;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Text.Json;
- using System.IO;
- using System.Diagnostics;
- using System.Text.RegularExpressions;
- namespace DataManager
- {
- public partial class UICompany : Form
- {
- private string companyId;
- private int userId;
- private DataTable companyInfo;
- private DataTable fundList;
- private DataTable contactList;
- private List<DataRowView> old_selected_contactor = new List<DataRowView>();
- private List<DataRowView> old_selected_collector = new List<DataRowView>();
- private string saveFilePath;
- private DataTable taskList;
- public UICompany(string companyId, int userId)
- {
- this.companyId = companyId.Trim().ToUpper();
- this.userId = userId;
- this.saveFilePath = ".\\Contracts\\" + companyId + "\\";
- InitializeComponent();
- InitializedData();
- }
- public string CompanyId { get { return companyId; } }
- public int UserId { get { return userId; } }
- private void InitializedData()
- {
- #region Basic Info Tab
- companyInfo = DataAccess.Get_dm_company_information(CompanyId);
- if(companyInfo == null || companyInfo.Rows.Count == 0 ) { return; }
- txtCompanyName.Text = companyInfo.Rows[0]["company_name"].ToString();
- txtRegisterCode.Text = companyInfo.Rows[0]["register_number"].ToString();
- txtCompanyId.Text = companyInfo.Rows[0]["company_id"].ToString();
- txtIncoporationDate.Text = DateTime.Parse(companyInfo.Rows[0]["establish_date"].ToString()).ToShortDateString();
- txtRegisterAddress.Text = companyInfo.Rows[0]["register_number_address"].ToString();
- txtOrgCode.Text = companyInfo.Rows[0]["credit_code"].ToString();
-
- txtBusinessAddress.Text = companyInfo.Rows[0]["company_address"].ToString();
- if (companyInfo.Rows[0]["nature_business_type"].ToString() != "")
- txtOrgType.Text = UIConstants.CompanyOwnerType[int.Parse(companyInfo.Rows[0]["nature_business_type"].ToString())];
- else
- txtOrgType.Text = "未知";
- if (companyInfo.Rows[0]["company_type"].ToString() != "")
- txtCompanyType.Text = UIConstants.CompanyType[int.Parse(companyInfo.Rows[0]["company_type"].ToString())];
- else
- txtCompanyType.Text = "未知";
- txtBusinessType.Text = companyInfo.Rows[0]["business_type"].ToString();
- if (companyInfo.Rows[0]["company_asset_size"].ToString() != "")
- txtAssetSize.Text = UIConstants.CompanyAssetSize[int.Parse(companyInfo.Rows[0]["company_asset_size"].ToString())];
- else
- txtAssetSize.Text = "未知";
-
- txtIsQualifiedAdvisor.Text = companyInfo.Rows[0]["has_consulting_qualification"].ToString() == "1" ? "是" : "否";
- //txtOwner.Text = companyInfo.Rows[0]["establish_date"].ToString();
- //txtAmacUpdateDate.Text = companyInfo.Rows[0]["zjx_last_info_update_time"].ToString();
- //lklAmacURL.Links.Add(Link )companyInfo.Rows[0]["amac_link"].ToString();
- txtCompanyShortName.Text = companyInfo.Rows[0]["company_short_name"].ToString();
- #endregion
- LoadContactsGrid();
- #region Fund List Tab
- Dictionary<int, string> d = new Dictionary<int, string>(UIConstants.HedgeFundStrategy);
- d.Add(DataAccess.DM_NULL, "全部");
- BindingSource bs = new BindingSource();
- bs.DataSource = d;
- cmbStrategy.DataSource = bs;
- cmbStrategy.DisplayMember = "Value";
- cmbStrategy.ValueMember = "Key";
- cmbStrategy.SelectedValue = (int)DataAccess.DM_NULL;
-
- LoadFundGrid();
- #endregion
- #region Contracts Tab
- sbyte jobType = Convert.ToSByte(UIConstants.JobType.联络);
- DataTable dt_dm_user_1 = DataAccess.Get_dm_user(null, jobType);
- clbContactor.DataSource = dt_dm_user_1;
- clbContactor.DisplayMember = "username";
- clbContactor.ValueMember = "userid";
- // 给覆盖此公司的user打上勾
- DataTable dt_company_cover_1 = DataAccess.Get_dm_company_cover(CompanyId, jobType, null);
- for(int i = 0; i < clbContactor.Items.Count; i++)
- {
- string itemUserId = ((DataRowView)clbContactor.Items[i]).Row["userid"].ToString();
-
- if (dt_company_cover_1.Select("userid = " + itemUserId).Length > 0)
- clbContactor.SetItemChecked(i, true);
- }
- // 记录一下初始的勾选
- foreach(DataRowView item in clbContactor.CheckedItems)
- {
- old_selected_contactor.Add(item);
- }
- jobType = Convert.ToSByte(UIConstants.JobType.采集);
- DataTable dt_dm_user_2 = DataAccess.Get_dm_user(null, jobType);
- clbCollector.DataSource = dt_dm_user_2;
- clbCollector.DisplayMember = "username";
- clbCollector.ValueMember = "userid";
- // 给覆盖此公司的user打上勾
- DataTable dt_company_cover_2 = DataAccess.Get_dm_company_cover(CompanyId, jobType, null);
- for (int i = 0; i < clbCollector.Items.Count; i++)
- {
- string itemUserId = ((DataRowView)clbCollector.Items[i]).Row["userid"].ToString();
- if (dt_company_cover_2.Select("userid = " + itemUserId).Length > 0)
- clbCollector.SetItemChecked(i, true);
- }
- // 记录一下初始的勾选
- foreach(DataRowView item in clbCollector.CheckedItems)
- {
- old_selected_collector.Add(item);
- }
- DataTable dt = DataAccess.Get_dm_company_authorization(CompanyId, null);
- if (dt != null && dt.Rows.Count > 0) chkIsAuthorized.Checked = true;
- LoadContractFiles();
- #endregion
- #region Task Tab
- cmbTaskType.Items.Add(UIConstants.JobType.联络.ToString());
- cmbTaskType.Items.Add(UIConstants.JobType.采集.ToString());
- cmbTaskType.SelectedIndex = 0;
- LoadTaskList(UIConstants.JobType.联络);
- #endregion
- }
- #region Basic Info
- private void btnSaveBasicInfo_Click(object sender, EventArgs e)
- {
- if (companyInfo == null || companyInfo.Rows.Count == 0) return;
- string originalShortName = companyInfo.Rows[0]["company_short_name"].ToString();
- string currentShortName = txtCompanyShortName.Text.Trim();
- if (originalShortName == currentShortName) return;
- if (currentShortName.Length > 0)
- {
- int ret = DataAccess.Set_dm_company_information(CompanyId, currentShortName, UserId);
- MessageBox.Show(ret < 0 ? "Oops... 变更存数据库时出了错" : "数据变更已经成功存盘~", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show("公司简称不能空着,把意义不大又重复的词去掉试试?", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- txtCompanyShortName.Focus();
- }
- }
- #endregion
- #region Contact List
- private void LoadContactsGrid()
- {
- contactList = DataAccess.Get_dm_contacts(CompanyId);
- grdContacts.DataSource = contactList;
- grdContacts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
- grdContacts.Columns["id"].Visible = false;
- grdContacts.Columns["company_id"].Visible = false;
- grdContacts.Columns["name"].HeaderText = "姓名";
- grdContacts.Columns["role"].HeaderText = "职务";
- grdContacts.Columns["phone"].HeaderText = "电话";
- grdContacts.Columns["wechat"].HeaderText = "微信";
- grdContacts.Columns["email"].HeaderText = "邮箱";
- grdContacts.Columns["isvalid"].Visible = false;
- grdContacts.Columns["creatorid"].Visible = false;
- grdContacts.Columns["createtime"].Visible = false;
- grdContacts.Columns["updaterid"].Visible = false;
- grdContacts.Columns["updatetime"].Visible = false;
- lblContactsCount.Text = contactList.Rows.Count.ToString();
- }
- private void btnSaveContact_Click(object sender, EventArgs e)
- {
- if(contactList == null ) return;
- int updatedCnt = DataAccess.Set_dm_contacts(contactList, CompanyId, UserId);
- contactList.AcceptChanges();
- MessageBox.Show("成功更新了" + updatedCnt.ToString() + "个联系人", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
-
- }
- #endregion
- #region Fund List
- private void LoadFundGrid()
- {
- fundList = DataAccess.Get_dm_fund_information(null, CompanyId);
- BindingSource bs = new BindingSource();
- bs.DataSource = fundList;
- grdFund.DataSource = bs;
- grdFund.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
- grdFund.Columns["fund_id"].Visible = false;
- grdFund.Columns["raise_type"].Visible = false;
- grdFund.Columns["fund_name"].Visible = false;
- grdFund.Columns["fund_short_name"].HeaderText = "基金简称";
- grdFund.Columns["fund_structure"].Visible = false;
- grdFund.Columns["fund_type"].Visible = false;
- grdFund.Columns["strategy"].Visible = false;
- grdFund.Columns["substrategy"].Visible = false;
- grdFund.Columns["fund_status"].Visible = false;
- grdFund.Columns["base_currency"].Visible = false;
- grdFund.Columns["inception_date"].HeaderText = "成立日";
- grdFund.Columns["initial_unit_value"].Visible = false;
- grdFund.Columns["p_fund_id"].Visible = false;
- grdFund.Columns["p_fund_name"].Visible = false;
- grdFund.Columns["advisor_id"].Visible = false;
- grdFund.Columns["company_name"].Visible = false;
- grdFund.Columns["custodian_id"].Visible = false;
- grdFund.Columns["custodian_name"].HeaderText = "托管";
- grdFund.Columns["trust_id"].Visible = false;
- grdFund.Columns["nav_frequency"].HeaderText = "净值频率";
- grdFund.Columns["manager_type"].Visible = false;
- grdFund.Columns["zjx_last_info_update_time"].Visible = false;
- grdFund.Columns["amac_url"].Visible = false;
- grdFund.Columns["register_number"].HeaderText = "备案编码";
- grdFund.Columns["register_date"].Visible = false;
- grdFund.Columns["main_code"].Visible = false;
- grdFund.Columns["isVisible"].Visible = false;
- grdFund.Columns["is_ranking"].HeaderText = "是否排名";
- grdFund.Columns["is_rating"].HeaderText = "是否评级";
- grdFund.Columns["is_authorized"].HeaderText = "是否授权";
- grdFund.Columns["trust_register_number"].Visible = false;
- grdFund.Columns["isvalid"].Visible = false;
- grdFund.Columns["creatorid"].Visible = false;
- grdFund.Columns["createtime"].Visible = false;
- grdFund.Columns["updaterid"].Visible = false;
- grdFund.Columns["updatetime"].Visible = false;
- grdFund.Columns["max_price_date"].HeaderText = "最新净值日";
- grdFund.Columns["fund_short_name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
- SetStatusStrip(fundList.Rows.Count);
- }
- private void grdFund_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- int rowIndex = e.RowIndex;
- int columnIndex = e.ColumnIndex;
- if (columnIndex < 0 || rowIndex < 0) return;
- DataGridViewRow row = grdFund.Rows[rowIndex];
- string fundId = row.Cells["fund_id"].Value.ToString();
-
- UIFund frm = new UIFund(fundId, UserId);
- frm.ShowDialog();
- }
- private void cmbStrategy_SelectedIndexChanged(object sender, EventArgs e)
- {
- FilterFund();
- }
- private void dtpInceptionDate_ValueChanged(object sender, EventArgs e)
- {
- FilterFund();
- }
- private void FilterFund()
- {
- string strategy = cmbStrategy.SelectedValue.ToString();
- string inception = dtpInceptionDate.Value.ToString();
- string filter = null;
- int cnt = 0;
- if (strategy == DataAccess.DM_NULL.ToString())
- filter = string.Format("inception_date <= #{0}#", inception);
- else
- filter = string.Format("strategy = {0} and inception_date <= #{1}#", strategy, inception);
- if (fundList != null && fundList.Rows.Count > 0)
- {
- BindingSource bs = (BindingSource)grdFund.DataSource;
- bs.Filter = filter;
- cnt = bs.Count;
- }
- SetStatusStrip(cnt);
- }
- private void SetStatusStrip(int cnt)
- {
- ToolStripStatusLabel label = new ToolStripStatusLabel();
- label.Text = "记录条数:" + cnt.ToString();
- sstCompany.Items.Clear();
- sstCompany.Items.Add(label);
- }
- private void pctFundExport_Click(object sender, EventArgs e)
- {
- frmDataManager.ExportDataTable(fundList);
- }
- #endregion
- #region Contract
- private void btnSaveContactor_Click(object sender, EventArgs e)
- {
- List<CompanyCoverUser> coverage = new List<CompanyCoverUser>();
- List<DataRowView> new_selected_contactor = new List<DataRowView>();
- foreach(DataRowView item in clbContactor.CheckedItems)
- new_selected_contactor.Add(item);
- CompanyCoverUser cov1 = CompareCoverage(CompanyId, 1, old_selected_contactor, new_selected_contactor);
- if(cov1 != null )
- coverage.Add(cov1);
- List<DataRowView> new_selected_collector = new List<DataRowView>();
- foreach (DataRowView item in clbCollector.CheckedItems)
- new_selected_collector.Add(item);
- CompanyCoverUser cov2 = CompareCoverage(CompanyId, 2, old_selected_collector, new_selected_collector);
- if(cov2 != null )
- coverage.Add(cov2);
-
- string query = JsonSerializer.Serialize(coverage);
-
- int ret = DataAccess.Set_dm_company_cover(query, UserId);
- int ret2 = DataAccess.Set_dm_company_authorization(CompanyId, chkIsAuthorized.Checked ? 1 : 0, UserId);
- string message = (ret * ret2) < 0 ? "Oops... 变更存数据库时出了错" : "数据变更已经成功存盘~";
- MessageBox.Show(message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- /// <summary>
- /// 前后人员覆盖对比
- /// </summary>
- /// <param name="companyId"></param>
- /// <param name="coverType"></param>
- /// <param name="oldList"></param>
- /// <param name="newList"></param>
- /// <returns></returns>
- private CompanyCoverUser CompareCoverage(string companyId, sbyte coverType, List<DataRowView> oldList, List<DataRowView> newList)
- {
- CompanyCoverUser companyCoverUser = new CompanyCoverUser();
- companyCoverUser.CompanyId = companyId;
- companyCoverUser.CoverType = coverType;
- if (oldList == null || newList == null) return companyCoverUser;
- // 在旧名单里,但不在新名单里的要删掉
- List<DataRowView> itemDeleted = oldList.Except(newList).ToList();
- // 在新名单里,但不在旧名单里的要增加
- List<DataRowView> itemAdded = newList.Except(oldList).ToList();
- int i = 0;
- CompanyCoverUser.Coverage[] covers = null;
- if (itemDeleted.Count > 0 || itemAdded.Count > 0)
- covers = new CompanyCoverUser.Coverage[itemDeleted.Count+itemAdded.Count];
- foreach (DataRowView item in itemDeleted)
- {
- CompanyCoverUser.Coverage cov = new CompanyCoverUser.Coverage();
-
- cov.IsValid = 0;
- cov.UserId = int.Parse(item.Row["userid"].ToString());
- covers[i] = cov;
- i++;
- }
- foreach (DataRowView item in itemAdded)
- {
- CompanyCoverUser.Coverage cov = new CompanyCoverUser.Coverage();
- cov.IsValid = 1;
- cov.UserId = int.Parse(item.Row["userid"].ToString());
- covers[i] = cov;
- i++;
- }
- companyCoverUser.Coverages = covers;
- //ret = JsonSerializer.Serialize(companyCoverUser);
-
- return companyCoverUser;
- }
- private void btnAuthorizeFunds_Click(object sender, EventArgs e)
- {
- UIBuckAuthorizeFund frm = new UIBuckAuthorizeFund(UserId);
- frm.Show();
- }
- /// <summary>
- /// 上传文件 TODO: 文件先写到本地
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnUploadFile_Click(object sender, EventArgs e)
- {
- ofdUploadFile.Title = "文件上传 ... 还没做完呢";
- //ofdUploadFile.DefaultExt = "doc";
-
- //ofdUploadFile.Filter = "所有Word文件(*.doc)|所有pdf文件(*.pdf)|所有文件(*.*)|*.*";
- if(ofdUploadFile.ShowDialog() == DialogResult.OK)
- {
- // TODO: upload files to server. let's fake it for now
- string filePath = ofdUploadFile.FileName;
- string fileName = Path.GetFileName(filePath);
- string saveFileName = this.saveFilePath + fileName;
- try
- {
- if (!Directory.Exists(saveFilePath)) { Directory.CreateDirectory(saveFilePath); }
- File.Copy(filePath, saveFileName, true);
- CreateFileButton(Path.GetFileName(saveFileName));
- }
- catch (Exception ex)
- {
- MessageBox.Show("文件上传失败:" + ex.Message, "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- /// <summary>
- /// 显示已上传文件,每个文件一个按钮
- /// </summary>
- private void LoadContractFiles()
- {
- if (Directory.Exists(this.saveFilePath))
- {
- string[] fileNames = Directory.GetFiles(saveFilePath);
-
- if(fileNames.Length > 0)
- {
- foreach (string fileName in fileNames)
- {
- CreateFileButton(Path.GetFileName(fileName));
- }
- }
- }
- }
- /// <summary>
- /// 为每个上传的文件产生一个按钮来显示
- /// </summary>
- /// <param name="fileName"></param>
- private void CreateFileButton(string fileName)
- {
- Panel panFile = new Panel();
- panFile.BorderStyle = BorderStyle.FixedSingle;
- panFile.Size = btnUploadFile.Size;
- panFile.Text = fileName;
- panFile.Font = new Font("微软雅黑", 10F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134)));
- panFile.Click += PanFile_Click;
- panFile.MouseEnter += PanFile_Enter;
- panFile.MouseLeave += PanFile_MouseLeave;
- Label lblFileName = new Label();
- lblFileName.Text = fileName;
- lblFileName.ForeColor = Color.DodgerBlue;
- lblFileName.Size = new Size(panFile.Width, panFile.Height/2);
- lblFileName.Location = new Point(panFile.Location.X, panFile.Location.Y + panFile.Size.Height/2);
- lblFileName.TextAlign = ContentAlignment.MiddleCenter;
- lblFileName.Click += LblFileName_Click;
- panFile.Controls.Add(lblFileName);
- CircleDeleteControl delIcon = new CircleDeleteControl();
- delIcon.Size = new Size(panFile.Width/8, panFile.Height/8);
- delIcon.Location = new Point(panFile.Width * 3/4, panFile.Width * 1/8);
- delIcon.Visible = true;
- delIcon.Click += DelIcon_Click;
- panFile.Controls.Add(delIcon);
- flowLayoutPanel1.Controls.Add(panFile);
- }
- private void LblFileName_Click(object sender, EventArgs e)
- {
- Control pan = ((Control)sender).Parent;
- PanFile_Click(pan, e);
- }
- private void PanFile_Click(object sender, EventArgs e)
- {
- OpenFile(saveFilePath + ((Panel)sender).Text);
- }
- private void PanFile_Enter(object sender, EventArgs e)
- {
- ((Control)sender).BackColor = Color.LightGray;
- }
- private void PanFile_MouseLeave(object sender, EventArgs e)
- {
- ((Control)sender).BackColor = Color.White;
- }
- private void DelIcon_Click(object sender, EventArgs e)
- {
- DialogResult result = MessageBox.Show("确认要删除此文件么?", "删除文件确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (result == DialogResult.Yes)
- {
- Panel pan = (Panel)((Control)sender).Parent;
- File.Delete(saveFilePath + pan.Text);
- pan.Parent.Controls.Remove(pan);
- }
- }
- private void OpenFile(string fileName)
- {
- ProcessStartInfo startInfo = new ProcessStartInfo
- {
- FileName = fileName,
- UseShellExecute = true
- };
- Process.Start(startInfo);
- }
- #endregion
- #region Task List
- private void LoadTaskList(UIConstants.JobType jobType)
- {
- if (jobType == UIConstants.JobType.联络)
- {
- taskList = DataAccess.Get_dm_contact_task(null, null, CompanyId, null, null, null, null, null, null, null);
- grdTaskList.DataSource = taskList;
- grdTaskList.Columns["task_id"].HeaderText = "ID";
- grdTaskList.Columns["company_short_name"].HeaderText = "公司";
- grdTaskList.Columns["task_date"].HeaderText = "日期";
- grdTaskList.Columns["task_type_name"].HeaderText = "任务";
- grdTaskList.Columns["isvalid_name"].HeaderText = "状态";
- grdTaskList.Columns["priority_name"].HeaderText = "优先级";
- grdTaskList.Columns["follow_up_date"].HeaderText = "跟进日";
- grdTaskList.Columns["company_asset_size_name"].HeaderText = "规模";
- grdTaskList.Columns["creator_name"].HeaderText = "创建";
- grdTaskList.Columns["updater_name"].HeaderText = "更新";
- grdTaskList.Columns["updatetime"].HeaderText = "更新时间";
- grdTaskList.Columns["company_id"].Visible = false;
- grdTaskList.Columns["task_type"].Visible = false;
- grdTaskList.Columns["isvalid"].Visible = false;
- grdTaskList.Columns["priority"].Visible = false;
- grdTaskList.Columns["company_asset_size"].Visible = false;
- grdTaskList.Columns["creatorid"].Visible = false;
- grdTaskList.Columns["createtime"].Visible = false;
- grdTaskList.Columns["updaterid"].Visible = false;
- grdTaskList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
- }
- else
- {
- taskList = DataAccess.Get_dm_collection_task(null, null, CompanyId, null, null, null, null, null, null);
- grdTaskList.DataSource = taskList;
- grdTaskList.Columns["task_id"].HeaderText = "ID";
- grdTaskList.Columns["provider_name"].HeaderText = "来源";
- grdTaskList.Columns["task_date"].HeaderText = "日期";
- grdTaskList.Columns["task_type_name"].HeaderText = "任务";
- grdTaskList.Columns["entity_name"].HeaderText = "主题";
- grdTaskList.Columns["err_message"].HeaderText = "详情";
- grdTaskList.Columns["isvalid_name"].HeaderText = "状态";
- grdTaskList.Columns["creator_name"].HeaderText = "创建";
- grdTaskList.Columns["updater_name"].HeaderText = "更新";
- grdTaskList.Columns["updatetime"].HeaderText = "更新时间";
- grdTaskList.Columns["provider_id"].Visible = false;
- grdTaskList.Columns["task_type"].Visible = false;
- grdTaskList.Columns["entity_id"].Visible = false;
- grdTaskList.Columns["isvalid"].Visible = false;
- grdTaskList.Columns["creatorid"].Visible = false;
- grdTaskList.Columns["createtime"].Visible = false;
- grdTaskList.Columns["updaterid"].Visible = false;
- grdTaskList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
- }
- }
- private void btnAddtTask_Click(object sender, EventArgs e)
- {
- UIConstants.JobType jobType = (UIConstants.JobType)Enum.Parse(typeof(UIConstants.JobType), cmbTaskType.SelectedItem.ToString());
- if (jobType == UIConstants.JobType.联络)
- {
- frmContactTask ctk = new frmContactTask(UserId, CompanyId, companyInfo.Rows[0]["company_short_name"].ToString());
- ctk.ShowDialog();
- // 刷新 grid 数据
- if (ctk.DialogResult == DialogResult.OK)
- {
- LoadTaskList(jobType);
- }
- }
- else
- {
- UICollectionTask ctk = new UICollectionTask(UserId, CompanyId, companyInfo.Rows[0]["company_short_name"].ToString());
- ctk.ShowDialog();
- // 刷新 grid 数据
- if (ctk.DialogResult == DialogResult.OK)
- {
- LoadTaskList(jobType);
- }
- }
- }
- private void cmbTaskType_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (cmbTaskType.Focus())
- {
- UIConstants.JobType jobType = (UIConstants.JobType)Enum.Parse(typeof(UIConstants.JobType), cmbTaskType.SelectedItem.ToString());
- LoadTaskList(jobType);
- }
- }
- private void grdTaskList_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- int rowIndex = e.RowIndex;
- int columnIndex = e.ColumnIndex;
- if (columnIndex < 0 || rowIndex < 0) return;
- DataRow row = taskList.Rows[rowIndex];
- UIConstants.JobType jobType = (UIConstants.JobType)Enum.Parse(typeof(UIConstants.JobType), cmbTaskType.SelectedItem.ToString());
- if (jobType == UIConstants.JobType.联络)
- {
- ContactTask task = new ContactTask(UserId, row.Field<int>("task_id"), row.Field<string>("company_id"), row.Field<string>("company_short_name"),
- row.Field<DateTime>("task_date"), row.Field<short>("task_type"), row.Field<sbyte>("isvalid"), row.Field<sbyte>("priority"),
- row.Field<DateTime?>("follow_up_date"), row.Field<sbyte?>("company_asset_size"),
- row.Field<int?>("creatorid"), row.Field<string>("creator_name"), row.Field<DateTime?>("createtime"),
- row.Field<int?>("updaterid"), row.Field<string>("updater_name"), row.Field<DateTime?>("updatetime"));
- if (task != null)
- {
- frmContactTask ctk = new frmContactTask(task);
- ctk.ShowDialog();
- // 刷新 grid 数据
- if (ctk.DialogResult == DialogResult.OK)
- {
- LoadTaskList(jobType);
- }
- }
- }
- else
- {
- CollectionTask task = new CollectionTask(UserId, row.Field<int>("task_id"), row.Field<string>("provider_id"), row.Field<string>("provider_name"),
- row.Field<DateTime>("task_date"), row.Field<short>("task_type"),
- row.Field<string>("entity_id"), row.Field<string>("entity_name"),
- row.Field<string>("err_message"), row.Field<sbyte>("isvalid"),
- row.Field<int?>("creatorid"), row.Field<string>("creator_name"), row.Field<DateTime?>("createtime"),
- row.Field<int?>("updaterid"), row.Field<string>("updater_name"), row.Field<DateTime?>("updatetime"));
- if (task != null)
- {
- UICollectionTask ctk = new UICollectionTask(task);
- ctk.ShowDialog();
- // 刷新 grid 数据
- if (ctk.DialogResult == DialogResult.OK)
- {
- LoadTaskList(jobType);
- }
- }
- }
- }
- #endregion
- }
- public class CompanyCoverUser
- {
- public string CompanyId { get; set; }
- public sbyte CoverType { get; set; }
- public Coverage[] Coverages { get; set; }
- public class Coverage
- {
- public sbyte IsValid { get; set; }
- public int UserId { get; set; }
- }
- }
- public class CircleDeleteControl : Control
- {
- protected override void OnPaint(PaintEventArgs e)
- {
- //this.BackColor = Color.White;
- base.OnPaint(e);
- Graphics g = e.Graphics;
- g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- Point center = new Point(this.Width/2, this.Height/2);
- // 圆形删除符号的直径可以是控件的最小边长
- int diameter = Math.Min(this.Width, this.Height);
- // 圆形删除符号的内半径
- int innerRadius = diameter / 2;
- using (Pen deletePen = new Pen(Color.Red, 1))
- {
- // 绘制圆形删除符号的背景
- g.DrawEllipse(deletePen, center.X - innerRadius, center.Y - innerRadius, diameter, diameter);
- // 绘制两条相交的对角线
- int offset = (int)Math.Floor(innerRadius / 1.4);
- g.DrawLine(deletePen, center.X - innerRadius - offset, center.Y + innerRadius + offset, center.X + innerRadius + offset, center.Y - innerRadius - offset);
- g.DrawLine(deletePen, center.X - innerRadius - offset, center.Y - innerRadius - offset, center.X + innerRadius + offset, center.Y + innerRadius + offset);
- }
- }
- protected override void OnMouseEnter(EventArgs e)
- {
- base.OnMouseEnter(e);
- this.Cursor = Cursors.Hand;
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- base.OnMouseLeave(e);
- this.Cursor = Cursors.Arrow;
- }
- }
- }
|