附件增加改名功能

This commit is contained in:
Falcon 2024-07-31 13:59:05 +08:00
parent 52b72a0c3c
commit 1d1716ca4e
2 changed files with 47 additions and 5 deletions

View File

@ -76,6 +76,7 @@
panel2 = new Panel();
panel3 = new Panel();
OpenFileDlg = new OpenFileDialog();
ToolStripMenuItem = new ToolStripMenuItem();
tabControl1.SuspendLayout();
tpWorkManage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
@ -418,28 +419,28 @@
//
// cms_FileList
//
cms_FileList.Items.AddRange(new ToolStripItem[] { ToolStripMenuItem,ToolStripMenuItem,ToolStripMenuItem });
cms_FileList.Items.AddRange(new ToolStripItem[] { ToolStripMenuItem,ToolStripMenuItem,ToolStripMenuItem,ToolStripMenuItem });
cms_FileList.Name = "contextMenuStrip1";
cms_FileList.Size = new Size(101,70);
cms_FileList.Size = new Size(181,114);
//
// 删除ToolStripMenuItem
//
ToolStripMenuItem.Name = "删除ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(100,22);
ToolStripMenuItem.Size = new Size(180,22);
ToolStripMenuItem.Text = "删除";
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
//
// 导入ToolStripMenuItem
//
ToolStripMenuItem.Name = "导入ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(100,22);
ToolStripMenuItem.Size = new Size(180,22);
ToolStripMenuItem.Text = "导入";
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
//
// 下载ToolStripMenuItem
//
ToolStripMenuItem.Name = "下载ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(100,22);
ToolStripMenuItem.Size = new Size(180,22);
ToolStripMenuItem.Text = "下载";
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
//
@ -621,6 +622,13 @@
//
OpenFileDlg.Multiselect = true;
//
// 更名ToolStripMenuItem
//
ToolStripMenuItem.Name = "更名ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(180,22);
ToolStripMenuItem.Text = "更名";
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
//
// WorkMain
//
AutoScaleDimensions = new SizeF(7F,17F);
@ -718,5 +726,6 @@
private FlowLayoutPanel flowLayoutPanel5;
private Button bt_m_dbshc;
private Label label5;
private ToolStripMenuItem ToolStripMenuItem;
}
}

View File

@ -1,5 +1,6 @@
using CalendarNotepad.Extends;
using CalendarNotepad.Models;
using Microsoft.VisualBasic;
using SqlSugar;
namespace CalendarNotepad
@ -360,5 +361,37 @@ namespace CalendarNotepad
var dlg = new dlgDatabaseSchemas();
dlg.Show();
}
private void ToolStripMenuItem_Click(object sender,EventArgs e) {
var items = this.FileListView.SelectedItems;
if(items.Count == 0) {
MessageBox.Show("必须要选择更名的文件");
return;
}
if(items.Count > 1) {
MessageBox.Show("不能同时对多个文件更名,只能选择一个");
return;
}
var item = items[0];
var fileName = item.Text;
var dlgr = Interaction.InputBox($"原文件名:{fileName}",Title: "修改文件名",DefaultResponse: fileName);
if(dlgr == "") {
return;
}
if(fileName == dlgr) {
return;
}
var wd = this.WorkDayKey;
this.Db.Updateable<WorkUnitPlusFile>().Where(a => a.WorkDay == wd).SetColumns(a => a.FileName == dlgr).ExecuteCommand();
item.Text = dlgr;
MessageBox.Show("文件名修改完成");
}
/// <summary>
/// 当前记录日志的键
/// </summary>
public string WorkDayKey {
get => this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
}
}
}