HistoryDataForm2_Task.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using CasunCommon.BaseUI;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace PMSUI
  12. {
  13. public partial class HistoryDataForm2_Task : CasunForm
  14. {
  15. public HistoryDataForm2_Task(string value)
  16. {
  17. TaskID = value;
  18. InitializeComponent();
  19. this.Name = CasunUILib.EForms.HistoryTaskBookQuery.ToString();
  20. }
  21. private static string TaskID = "";
  22. private void Init()
  23. {
  24. ///////////
  25. CasunUILib.DgvModel(dataGridView1);
  26. }
  27. private void HistoryDataForm2_Task_Load(object sender, EventArgs e)
  28. {
  29. if (!InitDBNameToShowNameDic())
  30. {
  31. this.Close();
  32. return;
  33. }
  34. Init();
  35. dataGridView1.MultiSelect = true;
  36. InitDgv();
  37. }
  38. /// <summary>
  39. /// 设置双缓冲
  40. /// </summary>
  41. /// <param name="c"></param>
  42. public static void SetDoubleBuffered(System.Windows.Forms.Control c)
  43. { //请参考下面的博客 //http://blogs.msdn.com/oldnewthing/archive/2006/01/03/508694.aspx
  44. if (System.Windows.Forms.SystemInformation.TerminalServerSession)
  45. return;
  46. System.Reflection.PropertyInfo aProp = typeof(System.Windows.Forms.Control).GetProperty("DoubleBuffered"
  47. , System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
  48. aProp.SetValue(c, true, null);
  49. }
  50. private void InitDgv()
  51. {
  52. dataGridView1.Columns.Clear();
  53. dataGridView1.DataSource = null;
  54. dataGridView1.DataSource =
  55. dataGridView1.DataSource = CFormColumnManager.GetDGVDataSource(this.Name, "PMS_his_HistoryTaskBook",
  56. "order by TaskID",
  57. "TaskID ='" + TaskID + "'");
  58. }
  59. /// <summary>
  60. /// 用于事件重复使用
  61. /// </summary>
  62. private Dictionary<string, string> DBNameToShowNameDic = new Dictionary<string, string>();
  63. private bool InitDBNameToShowNameDic()
  64. {
  65. if (!CFormColumnManager.GetDBNameToShowNameDic(this.Name, out DBNameToShowNameDic))
  66. {
  67. MessageBox.Show(CLanguageManager.LanguageChange("加载界面配置失败,请重启尝试恢复。"));
  68. return false;
  69. }
  70. return true;
  71. }
  72. private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  73. {
  74. try
  75. {
  76. int currentRow = e.RowIndex;
  77. if (currentRow != -1 && dataGridView1.Rows[currentRow] != null)
  78. {
  79. //if (e.ColumnIndex == dataGridView1.Rows[currentRow].Cells[DBNameToShowNameDic["BookID"]].ColumnIndex)
  80. {
  81. HistoryDataForm3_Step frm = new HistoryDataForm3_Step(dataGridView1.Rows[currentRow].Cells[DBNameToShowNameDic["BookID"]].Value.ToString());
  82. frm.ShowDialog();
  83. //dataGridView1.Rows[currentRow].Cells[e.ColumnIndex].ToolTipText = "12345123125123";
  84. }
  85. }
  86. }
  87. catch (Exception ex)
  88. {
  89. MessageBox.Show(CLanguageManager.LanguageChange("更改过设置后请重新打开该子界面"));
  90. }
  91. }
  92. }
  93. }