/// <summary> /// 清除详情区 /// </summary> private void ClearDetail() { this.Invoke(new Action(() => { ContentRTB.Clear(); txtfilename.Text = ""; txttitle.Text = ""; txthour.Text = ""; txtremark.Text = ""; cbstatus.SelectedIndex = 0; cbprocessor.SelectedIndex = 0; txtid.Text = ""; txtrelor.Text = ""; txtcompor.Text = ""; })); }
private void Planlist_DoubleClickWork(ListView l, EventArgs e) { this.Invoke(new Action(() => { DataRow item = null; loadpc.Visible = true; item = (DataRow)(l.SelectedItems[0]).Tag; txtid.Text = item["id"].ToString(); txtfilename.Text = item["filename"].ToString(); txttitle.Text = item["title"].ToString(); txthour.Text = item["hour"].ToString(); cbstatus.SelectedIndex = int.Parse(item["status"].ToString()); cbprocessor.SelectedValue = item["processor"].ToString(); txtremark.Text = item["remark"].ToString(); estimateDate.Text = item["estimate"].ToString(); txtrelor.Text = item["relor"].ToString(); if (File.Exists(FilePath + "\\" + item["filename"].ToString() + ".rtf")) { IntPtr vHandle = _lopen(FilePath + "\\" + item["filename"].ToString() + ".rtf", OF_READWRITE | OF_SHARE_DENY_NONE); if (vHandle == HFILE_ERROR) { MessageBoxEx.Show(this, "文件被占用"); ContentRTB.Clear(); return; } CloseHandle(vHandle); //判断之后一定要关闭!!! FileInfo fi = new FileInfo(FilePath + "\\" + item["filename"].ToString() + ".rtf"); DateTime dt = fi.LastWriteTime; DataSet ds = MySqlHelper.ExecuteSQL("select * from pasn where id= " + txtid.Text); DateTime dt1 = Convert.ToDateTime(ds.Tables[0].Rows[0]["lastwritetime"]); TimeSpan span = dt.Subtract(dt1); //如果服务器较新,用服务器的文件,第二次再打开的时候,因为从服务器下载了,所以本地文件会更新 if (span.Seconds < 0) { var r = DownLoadFile(FileUrl + item["filename"].ToString() + ".rtf", FilePath + "\\" + item["filename"].ToString() + ".rtf", progressBar1); if (r) { ContentRTB.LoadFile(FilePath + "\\" + item["filename"].ToString() + ".rtf", RichTextBoxStreamType.RichText); } else { MessageBoxEx.Show(this, "下载文件失败"); ContentRTB.Clear(); } } else { ContentRTB.LoadFile(FilePath + "\\" + item["filename"].ToString() + ".rtf", RichTextBoxStreamType.RichText); } } else { var r = DownLoadFile(FileUrl + item["filename"].ToString() + ".rtf", FilePath + "\\" + item["filename"].ToString() + ".rtf", progressBar1); if (r) { ContentRTB.LoadFile(FilePath + "\\" + item["filename"].ToString() + ".rtf", RichTextBoxStreamType.RichText); } else { MessageBoxEx.Show(this, "下载文件失败"); ContentRTB.Clear(); } } this.loadpc.Visible = false; })); }