private void 归档ToolStripMenuItem_Click(object sender, EventArgs e) { string fileid = skinDataGridView1.CurrentRow.Cells["FileId"].Value.ToString(); bool check = AuthPermission.Auth(LoginUser.UserId, Convert.ToInt32(fileid), FilePermission.Archive); if (check) { DialogResult dlg = MessageBox.Show("是否归档该文件", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlg == System.Windows.Forms.DialogResult.Yes) { bool c = new FileBLL().UpdateFileArchive(Convert.ToInt32(fileid), true); if (c) { MessageBox.Show("归档该文件成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("归档该文件失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } } else { MessageBox.Show("您没有权限归档该文件", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void 查看ToolStripMenuItem_Click(object sender, EventArgs e) { frmLoading.ShowTop(); //Add By 顾挺 2017-05-12 意图:学员单线程打开文件,体验实在太差,为了增强用户体验,因为大文件加载速度实在太慢,添加多线程 //开启任务 AT.Create <string[]>(() => { string fileid = skinDataGridView1.CurrentRow.Cells["FileId"].Value.ToString(); bool check = AuthPermission.Auth(LoginUser.UserId, Convert.ToInt32(fileid), FilePermission.Read); if (check) { return(LoadData(fileid)); } else { MessageBox.Show("您没有权限阅读该文件", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(null); //上一步任务成功之后,执行下一个操作 }).Run((i) => { if (i != null) { ShowFileDialog(i[2], i[0], i[1], i[3]); } //完成所有操作执行操作 }, () => { frmLoading.Close(); }); }
private void OpenFile(string fileID) { if (string.IsNullOrWhiteSpace(fileID)) { return; } //开启任务 AT.Create <string[]>(() => { string fileid = fileID; bool check = AuthPermission.Auth(LoginUser.UserId, Convert.ToInt32(fileid), FilePermission.Read); if (check) { return(LoadData(fileid)); } else { MessageBox.Show("您没有权限阅读该文件", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(null); //上一步任务成功之后,执行下一个操作 }).Run((i) => { if (i != null) { ShowFileDialog(i[2], i[0], i[1], i[3]); } //完成所有操作执行操作 }, () => { frmLoading.Close(); }); }
private void 借阅ToolStripMenuItem_Click(object sender, EventArgs e) { string fileid = skinDataGridView1.CurrentRow.Cells["FileId"].Value.ToString(); bool check = AuthPermission.Auth(LoginUser.UserId, Convert.ToInt32(fileid), FilePermission.Share); if (check) { frmPermissionConfig frm = new frmPermissionConfig(Convert.ToInt32(fileid)); frm.ShowDialog(); } else { MessageBox.Show("您没有权限借阅该文件", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void 载ToolStripMenuItem_Click(object sender, EventArgs e) { //获得文件编号 string fileid = skinDataGridView1.CurrentRow.Cells["FileId"].Value.ToString(); string ext = skinDataGridView1.CurrentRow.Cells["FileExt"].Value.ToString(); //检测是否具备下载权限 bool check = AuthPermission.Auth(LoginUser.UserId, Convert.ToInt32(fileid), FilePermission.Download); if (check) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = string.Format("资料文件(*.{0})|*.{1}", ext, ext); sfd.FilterIndex = 1; //设置顺序 if (sfd.ShowDialog() == DialogResult.OK) { string localFilePath = sfd.FileName.ToString(); //获得文件路径 var lst = new FileBLL().GetOne(Convert.ToInt32(fileid)); ; if (lst != null && lst.Count > 0) { try { //生成本地文件 var Files = (Byte[])lst[0].FileData; var name = GenerateCheckCode(20); var path = localFilePath; var bw = new BinaryWriter(System.IO.File.Open(path, FileMode.OpenOrCreate)); bw.Write(Files, 0, Files.Length); bw.Flush(); bw.Close(); } catch { } } } } else { MessageBox.Show("您没有权限下载该文件", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { //获得文件编号 string fileid = skinDataGridView1.CurrentRow.Cells["FileId"].Value.ToString(); bool check = AuthPermission.Auth(LoginUser.UserId, Convert.ToInt32(fileid), FilePermission.Delete); if (check) { List <FileSystem.Model.File> model = new FileBLL().GetOne(Convert.ToInt32(fileid)); if (model != null && model.Count > 0) { if (!model[0].FileArchive) { DialogResult dlg = MessageBox.Show("您是否确认要删除该文件?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlg == DialogResult.Yes) { //删除文件 bool c = new FileBLL().Delete(Convert.ToInt32(fileid)); if (c) { MessageBox.Show("删除成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Hand); this.skinDataGridView1.Rows.Remove(skinDataGridView1.CurrentRow); } else { MessageBox.Show("删除失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } else { MessageBox.Show("删除失败,该文件已归档!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } } else { MessageBox.Show("您没有权限删除该文件", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }