using CasunCommon.BaseUI; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PMSUI { public partial class HistoryDataForm2_Task : CasunForm { public HistoryDataForm2_Task(string value) { TaskID = value; InitializeComponent(); this.Name = CasunUILib.EForms.HistoryTaskBookQuery.ToString(); } private static string TaskID = ""; private void Init() { /////////// CasunUILib.DgvModel(dataGridView1); } private void HistoryDataForm2_Task_Load(object sender, EventArgs e) { if (!InitDBNameToShowNameDic()) { this.Close(); return; } Init(); dataGridView1.MultiSelect = true; InitDgv(); } /// /// 设置双缓冲 /// /// public static void SetDoubleBuffered(System.Windows.Forms.Control c) { //请参考下面的博客 //http://blogs.msdn.com/oldnewthing/archive/2006/01/03/508694.aspx if (System.Windows.Forms.SystemInformation.TerminalServerSession) return; System.Reflection.PropertyInfo aProp = typeof(System.Windows.Forms.Control).GetProperty("DoubleBuffered" , System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); aProp.SetValue(c, true, null); } private void InitDgv() { dataGridView1.Columns.Clear(); dataGridView1.DataSource = null; dataGridView1.DataSource = dataGridView1.DataSource = CFormColumnManager.GetDGVDataSource(this.Name, "PMS_his_HistoryTaskBook", "order by TaskID", "TaskID ='" + TaskID + "'"); } /// /// 用于事件重复使用 /// private Dictionary DBNameToShowNameDic = new Dictionary(); private bool InitDBNameToShowNameDic() { if (!CFormColumnManager.GetDBNameToShowNameDic(this.Name, out DBNameToShowNameDic)) { MessageBox.Show(CLanguageManager.LanguageChange("加载界面配置失败,请重启尝试恢复。")); return false; } return true; } private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { int currentRow = e.RowIndex; if (currentRow != -1 && dataGridView1.Rows[currentRow] != null) { //if (e.ColumnIndex == dataGridView1.Rows[currentRow].Cells[DBNameToShowNameDic["BookID"]].ColumnIndex) { HistoryDataForm3_Step frm = new HistoryDataForm3_Step(dataGridView1.Rows[currentRow].Cells[DBNameToShowNameDic["BookID"]].Value.ToString()); frm.ShowDialog(); //dataGridView1.Rows[currentRow].Cells[e.ColumnIndex].ToolTipText = "12345123125123"; } } } catch (Exception ex) { MessageBox.Show(CLanguageManager.LanguageChange("更改过设置后请重新打开该子界面")); } } } }