/// <summary> /// 数据初始化 /// </summary> private void InitData() { //DataTable dt = new DataTable(); //dt.Columns.Add("file_version"); //dt.Columns.Add("file_modifyTime"); //dt.Columns.Add("file_userName"); //dt.Columns.Add("file_size"); //dt.Columns.Add("downLink"); //for (int i = 0; i < 10; i++) //{ // DataRow row = dt.NewRow(); // row[0] = "1.0"; // row[1] = "2015-02-02"; // row[2] = "王君海"; // row[3] = "20M"; // row[4] = "下载"; // dt.Rows.Add(row); //} BLL.FileVersionBll verBll = new BLL.FileVersionBll(); DataSet ds = verBll.GetList(" isdeleted = 0 and File_Id = " + file.ID, " ver desc, id asc"); if (ds != null && ds.Tables.Count > 0) { DataTable orgdt = ds.Tables[0]; DataTable dt = new DataTable(); dt.Columns.Add("id"); dt.Columns.Add("file_version"); dt.Columns.Add("file_modifyTime"); dt.Columns.Add("file_userName"); dt.Columns.Add("file_userIp"); dt.Columns.Add("file_size"); dt.Columns.Add("downLink"); dt.Columns.Add("saveas"); dt.Columns.Add("File_ID"); dt.Columns.Add("ClientPath"); if (orgdt != null && orgdt.Rows.Count > 0) { for (int i = 0; i < orgdt.Rows.Count; i++) { DataRow row = dt.NewRow(); row[0] = orgdt.Rows[i]["id"].ToString(); row[1] = orgdt.Rows[i]["Ver"].ToString(); row[2] = new DateTime(long.Parse(orgdt.Rows[i]["File_Modify_Time"].ToString())).ToString(); row[3] = orgdt.Rows[i]["UserName"].ToString(); row[4] = orgdt.Rows[i]["Ip"].ToString(); row[5] = Bll.SystemBll.ChangeFileSize(orgdt.Rows[i]["File_Size"].ToString()); row[6] = "同步到本地"; row[7] = "另存为"; row[8] = orgdt.Rows[i]["File_ID"]; row[9] = orgdt.Rows[i]["ClientPath"]; dt.Rows.Add(row); } } this.skinDataGridView_history.DataSource = dt; } }
/// <summary> /// 修改属性 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { try { FileBll fileBll = new FileBll(); Model.FileModel fileModel = fileBll.GetModel(this.file.ID); if (fileModel == null || string.IsNullOrEmpty(fileModel.File_Name)) { MessageBoxEx.Show("该文件的信息异常!"); return; } FileVersionBll verBll = new FileVersionBll(); var fileVer = new BLL.FileVersionBll().GetModel(this.fileLog.FileVerID); var content = verBll.GetContent(fileVer.ID); // 获取文件信息 this.saveFileDialog1.Filter = string.Format("*{0}|*.*", fileModel.File_Ext);; this.saveFileDialog1.ShowDialog(); string fileSavePath = this.saveFileDialog1.FileName; if (string.IsNullOrEmpty(fileSavePath)) { return; } //文件存放路径 string newPath = fileSavePath.EndsWith(fileModel.File_Ext) ? fileSavePath : fileSavePath + fileModel.File_Ext; FileWinexploer.CreateFile(content, newPath, fileVer.File_Modify_Time); MessageBoxEx.Show("保存成功!"); } catch (Exception ee) { this.DialogResult = System.Windows.Forms.DialogResult.None; MessageBoxEx.Show("存储失败!" + ee.Message); } }