Compare commits

...

34 Commits

Author SHA1 Message Date
Falcon
ac0141b4b4 删除多余提示 2024-10-08 11:13:10 +08:00
Falcon
7f61ee3fb3 增加版本显示 2024-10-08 11:10:41 +08:00
Falcon
f5f5bac98a 更改版本号 2024-10-08 11:05:20 +08:00
Falcon
306e06045c 文件附件列表框支持拖放文件 2024-10-08 11:04:23 +08:00
Falcon
62bd620580 新增双击附件自动打开,调整打开选项位置和字体 2024-08-02 15:24:36 +08:00
Falcon
4f49ae9887 修复修改文件名的BUG 2024-08-02 15:17:58 +08:00
Falcon
62d6d6d920 附件增加主键Key标记 2024-08-02 15:07:23 +08:00
Falcon
3ed9596abe 完成附件打开功能 2024-08-02 15:07:05 +08:00
Falcon
c0f2a1ab6e 文件打开功能。未实现文件类型保存 2024-08-01 11:18:49 +08:00
Falcon
19d498cdd5 重命名方法 2024-08-01 09:28:12 +08:00
Falcon
5841d6807e 文件更名 2024-08-01 09:20:15 +08:00
Falcon
a1e2ba1c9f 新增支持文本中点击打开超链接 2024-07-31 14:15:34 +08:00
Falcon
1d1716ca4e 附件增加改名功能 2024-07-31 13:59:05 +08:00
Falcon
52b72a0c3c 增加数据库架构对话框 2024-07-26 11:47:59 +08:00
Falcon
3767a98dde 添加长度设定 2024-07-26 11:47:46 +08:00
Falcon
094447258f 为所有数据库表增加TableBase基类,所有表增加Id和CreateDateTime字段 2024-07-26 11:05:19 +08:00
Falcon
68062259d0 增加显示数据库大小 2024-07-24 17:32:08 +08:00
Falcon
440970632c 调用数据库备份方法备份数据库 2024-07-24 17:16:56 +08:00
Falcon
eebb7d067f 删除无用文件窗体 2024-07-24 16:55:39 +08:00
Falcon
23c73b826e 修改版本 2024-07-24 15:03:08 +08:00
Falcon
2f68a949c5 工具条增加导入附件按钮 2024-07-24 14:50:44 +08:00
Falcon
47ff1f5885 修改导入类型文本 2024-07-24 14:44:18 +08:00
Falcon
3708b67afc 解决方案中移除无用的SharkingTest项目 2024-07-24 10:02:38 +08:00
FalconFly
9f7f107435 tag v1.2.1 2024-07-24 09:57:59 +08:00
FalconFly
d3ffa7c6d7 由于sqlite无法删除列,重新添加DayRange字段,默认值为弃用,并标记为放弃 2024-07-24 09:57:22 +08:00
FalconFly
73d0e32574 默认字符串长度200 2024-07-24 09:56:19 +08:00
FalconFly
fc4d655514 tag 1.2.0 2024-07-23 16:32:10 +08:00
FalconFly
dcf3261dab 增加滚动条 2024-07-23 16:30:27 +08:00
FalconFly
a96b0329d3 新增管理页,数据库压缩,清理和备份 2024-07-23 16:16:11 +08:00
FalconFly
e7f8aaed1f 完成附件功能 2024-07-23 14:45:54 +08:00
FalconFly
8ea15b2ab7 增加复制黏贴按钮 2024-07-22 17:13:55 +08:00
FalconFly
3dc4df4e5b 增加加班信息 2024-07-22 14:40:38 +08:00
FalconFly
715b90972d 增加工作类型,休假,病假,加班等。 2024-07-22 14:21:23 +08:00
FalconFly
a58c8c9fda 优化 2024-07-16 13:37:46 +08:00
25 changed files with 1845 additions and 516 deletions

View File

@ -5,8 +5,6 @@ VisualStudioVersion = 17.6.33829.357
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalendarNotepad", "CalendarNotepad\CalendarNotepad.csproj", "{875F30C8-8B0B-43B6-A4A4-4ED9870E2021}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharkingTest", "SharkingTest\SharkingTest.csproj", "{60DC4219-39A6-4B9B-9172-934C3427E859}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -17,10 +15,6 @@ Global
{875F30C8-8B0B-43B6-A4A4-4ED9870E2021}.Debug|Any CPU.Build.0 = Debug|Any CPU
{875F30C8-8B0B-43B6-A4A4-4ED9870E2021}.Release|Any CPU.ActiveCfg = Release|Any CPU
{875F30C8-8B0B-43B6-A4A4-4ED9870E2021}.Release|Any CPU.Build.0 = Release|Any CPU
{60DC4219-39A6-4B9B-9172-934C3427E859}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{60DC4219-39A6-4B9B-9172-934C3427E859}.Debug|Any CPU.Build.0 = Debug|Any CPU
{60DC4219-39A6-4B9B-9172-934C3427E859}.Release|Any CPU.ActiveCfg = Release|Any CPU
{60DC4219-39A6-4B9B-9172-934C3427E859}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="saveFileName" value="data.db"/>
<add key ="sqliteFile" value="DataSource=work.db"/>
<add key ="sqliteFile" value="DataSource=work.db;"/>
</appSettings>
</configuration>

View File

@ -6,11 +6,26 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.0.0</Version>
<Version>1.4.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SqlSugarCore" Version="5.1.4.162" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -14,11 +14,6 @@ namespace CalendarNotepad.Extends
/// <returns>配置值默认string.Empty</returns>
public static string GetValue(string key) => ConfigurationManager.AppSettings[key] ?? string.Empty;
/// <summary>
/// 保存的文件名sqliteFile
/// </summary>
public static string GetSaveFileName => GetValue("saveFileName") ?? "";
/// <summary>
/// sqliteFile名
/// </summary>

View File

@ -1,5 +1,7 @@
using CalendarNotepad.Models;
using SqlSugar;
using System.Text;
using System.Text.RegularExpressions;
namespace CalendarNotepad.Extends
{
@ -12,15 +14,63 @@ namespace CalendarNotepad.Extends
}
public static ConnectionConfig GetConfig() => new ConnectionConfig {
public static ConnectionConfig GetConfig() => new() {
DbType = DbType.Sqlite,
ConnectionString = AppConfig.SqliteFileName,
IsAutoCloseConnection = false,
};
/// <summary>
/// 初始化数据库
/// </summary>
public void DbInit() {
using var db = new DbContext();
db.CodeFirst.SetStringDefaultLength(200);
db.CodeFirst.InitTables<WorkUnit>();
db.CodeFirst.InitTables<PlusFileUnit>();
db.CodeFirst.InitTables<WorkUnitPlusFile>();
}
/// <summary>
/// 清除数据库垃圾
/// </summary>
public string DbClean() {
StringBuilder sb = new();
int i;
i = this.Deleteable<WorkUnitPlusFile>()
.Where(a => !SqlFunc.Subqueryable<WorkUnit>().Where(b => b.WorkDay == a.WorkDay).Any())
.ExecuteCommand();
sb.AppendLine($"WorkUnitPlusFile 清除{i}条数据。");
i = this.Deleteable<PlusFileUnit>()
.Where(a => !SqlFunc.Subqueryable<WorkUnitPlusFile>().Where(b => b.FileKey == a.FileId).Any())
.ExecuteCommand();
sb.AppendLine($"PlusFileUnit 清除{i}条数据。");
return sb.ToString();
}
/// <summary>
/// 压缩数据库文件
/// </summary>
/// <returns></returns>
public string DbVacuum() {
var file = this.SqliteDbfile;
var oldSize = new FileInfo(file).Length;
this.Ado.ExecuteCommand("VACUUM;");
var newSize = new FileInfo(file).Length;
return $"数据库压缩:原始{oldSize},压缩后{newSize}";
}
/// <summary>
/// sqllite数据库文件
/// </summary>
public string SqliteDbfile {
get {
var regex = new Regex(@"DataSource\s*=\s*(?<key>.*?);");
var mc = regex.Match(AppConfig.SqliteFileName);
var file = mc.Groups["key"].Value;
return file;
}
}
}
}

View File

@ -0,0 +1,40 @@
namespace CalendarNotepad.Extends
{
/// <summary>
/// 文件列表视图模型
/// </summary>
public class ListViewFileModel
{
public ListViewItem Item { get; set; }
public ListViewFileModel() : this("","","初始化") { }
public ListViewFileModel(string? fileName,string? fileKey,string? status) {
var item = new ListViewItem(Path.GetFileName(fileName));
item.SubItems.Add(new ListViewItem.ListViewSubItem { Text = status });
item.SubItems.Add(new ListViewItem.ListViewSubItem { Text = fileKey });
this.Item = item;
}
public ListViewFileModel(ListViewItem item) {
this.Item = item;
}
public ListViewItem ToListViewItem() {
return this.Item;
}
/// <summary>
/// 文件名
/// </summary>
public string? FileName { get => this.Item.Name; set => this.Item.Name = Path.GetFileName(value); }
/// <summary>
/// 文件指纹
/// </summary>
public string? FileKey { get => this.Item.SubItems[2].Text; set => this.Item.SubItems[2].Text = value; }
/// <summary>
/// 文件说明
/// </summary>
public string? Status { get => this.Item.SubItems[1].Text; set => this.Item.SubItems[1].Text = value; }
}
}

View File

@ -0,0 +1,84 @@
using CalendarNotepad.Models;
using System.Security.Cryptography;
using System.Text;
namespace CalendarNotepad.Extends
{
/// <summary>
/// 附件操作
/// </summary>
public static class PlusFile
{
/// <summary>
/// 获取MD5码
/// </summary>
public static string GetMd5(string fileContent) {
var ibs = Encoding.UTF8.GetBytes(fileContent);
return GetMd5(ibs);
}
/// <summary>
/// 获取MD5码
/// </summary>
public static string GetMd5(byte[] content) {
using var md5 = MD5.Create();
var md5bs = md5.ComputeHash(content);
StringBuilder sb = new(md5bs.Length * 2);
for(int i = 0;i < md5bs.Length;i++) {
sb.Append(md5bs[i].ToString("X2"));
}
return sb.ToString();
}
/// <summary>
/// 读取文件内容
/// </summary>
/// <param name="fullFilePath"></param>
/// <returns></returns>
public static byte[] LoadFile(string fullFilePath) {
if(!File.Exists(fullFilePath)) {
throw new FileNotFoundException();
}
var fileInfo = new FileInfo(fullFilePath);
var fileSize = fileInfo.Length;
if(fileSize > 4 * 1024 * 1024) {
throw new OutOfMemoryException();
}
using FileStream fs = fileInfo.OpenRead();
using BinaryReader br = new BinaryReader(fs);
var length = (int)fs.Length;
var buf = br.ReadBytes(length);
return buf;
}
/// <summary>
/// 写入文件内容
/// </summary>
/// <param name="fullFilePath"></param>
/// <param name="content"></param>
public static void SaveFile(string fullFilePath,byte[] content) {
if(File.Exists(fullFilePath)) {
File.Delete(fullFilePath);
}
using var fs = new FileStream(fullFilePath,FileMode.CreateNew,FileAccess.Write);
using var bw = new BinaryWriter(fs);
bw.Write(content);
bw.Flush();
bw.Close();
}
/// <summary>
/// 存储文件到数据库
/// </summary>
/// <param name="db">数据库上下文</param>
/// <param name="fullFilePath">完整文件名</param>
/// <returns>文件指纹</returns>
public static string SaveFileToDb(DbContext db,string fullFilePath) {
var fc = PlusFile.LoadFile(fullFilePath);
var fk = PlusFile.GetMd5(fc);
var pfu = new PlusFileUnit { FileContent = fc,FileId = fk };
var qu = db.Queryable<PlusFileUnit>().Where(a => a.FileId == fk);
if(qu.Any()) {
return qu.First().FileId;
}
db.Insertable(pfu).ExecuteCommand();
return fk;
}
}
}

View File

@ -12,7 +12,7 @@ namespace CalendarNotepad.Extends
/// <summary>
/// 压缩文件名
/// </summary>
public static string ZipFileName { get; set; } = AppConfig.GetSaveFileName;
public static string ZipFileName { get; set; } = "";
/// <summary>
/// 某个文件保存到压缩文件内
/// </summary>

View File

@ -1,170 +0,0 @@
namespace CalendarNotepad
{
partial class Main
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if(disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
mcWorkDay = new MonthCalendar();
splitContainer1 = new SplitContainer();
groupBox1 = new GroupBox();
rbAllDay = new RadioButton();
rbAfternoon = new RadioButton();
rbMorning = new RadioButton();
label1 = new Label();
rtbMsg = new RichTextBox();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout();
splitContainer1.Panel2.SuspendLayout();
splitContainer1.SuspendLayout();
groupBox1.SuspendLayout();
SuspendLayout();
//
// mcWorkDay
//
mcWorkDay.FirstDayOfWeek = Day.Monday;
mcWorkDay.Location = new Point(9,9);
mcWorkDay.MaxSelectionCount = 1;
mcWorkDay.MinDate = new DateTime(2000,1,1,0,0,0,0);
mcWorkDay.Name = "mcWorkDay";
mcWorkDay.ShowTodayCircle = false;
mcWorkDay.TabIndex = 0;
mcWorkDay.DateChanged += monthCalendar1_DateChanged;
mcWorkDay.DateSelected += monthCalendar1_DateSelected;
//
// splitContainer1
//
splitContainer1.Dock = DockStyle.Fill;
splitContainer1.FixedPanel = FixedPanel.Panel1;
splitContainer1.Location = new Point(0,0);
splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
splitContainer1.Panel1.Controls.Add(groupBox1);
splitContainer1.Panel1.Controls.Add(mcWorkDay);
//
// splitContainer1.Panel2
//
splitContainer1.Panel2.Controls.Add(label1);
splitContainer1.Panel2.Controls.Add(rtbMsg);
splitContainer1.Size = new Size(642,400);
splitContainer1.SplitterDistance = 234;
splitContainer1.TabIndex = 1;
//
// groupBox1
//
groupBox1.Controls.Add(rbAllDay);
groupBox1.Controls.Add(rbAfternoon);
groupBox1.Controls.Add(rbMorning);
groupBox1.Location = new Point(12,201);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(201,51);
groupBox1.TabIndex = 5;
groupBox1.TabStop = false;
groupBox1.Text = "时间段";
//
// rbAllDay
//
rbAllDay.AutoSize = true;
rbAllDay.Checked = true;
rbAllDay.Location = new Point(6,22);
rbAllDay.Name = "rbAllDay";
rbAllDay.Size = new Size(50,21);
rbAllDay.TabIndex = 1;
rbAllDay.TabStop = true;
rbAllDay.Text = "全天";
rbAllDay.UseVisualStyleBackColor = true;
//
// rbAfternoon
//
rbAfternoon.AutoSize = true;
rbAfternoon.Location = new Point(118,22);
rbAfternoon.Name = "rbAfternoon";
rbAfternoon.Size = new Size(50,21);
rbAfternoon.TabIndex = 3;
rbAfternoon.Text = "下午";
rbAfternoon.UseVisualStyleBackColor = true;
//
// rbMorning
//
rbMorning.AutoSize = true;
rbMorning.Location = new Point(62,22);
rbMorning.Name = "rbMorning";
rbMorning.Size = new Size(50,21);
rbMorning.TabIndex = 2;
rbMorning.Text = "上午";
rbMorning.UseVisualStyleBackColor = true;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(3,9);
label1.Name = "label1";
label1.Size = new Size(56,17);
label1.TabIndex = 1;
label1.Text = "信息记录";
//
// rtbMsg
//
rtbMsg.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
rtbMsg.EnableAutoDragDrop = true;
rtbMsg.Location = new Point(3,35);
rtbMsg.Name = "rtbMsg";
rtbMsg.Size = new Size(389,353);
rtbMsg.TabIndex = 0;
rtbMsg.Text = "";
rtbMsg.TextChanged += rtbMsg_TextChanged;
//
// Main
//
AutoScaleDimensions = new SizeF(7F,17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(642,400);
Controls.Add(splitContainer1);
Name = "Main";
Text = "工作记录";
FormClosing += Main_FormClosing;
Load += Main_Load;
splitContainer1.Panel1.ResumeLayout(false);
splitContainer1.Panel2.ResumeLayout(false);
splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
splitContainer1.ResumeLayout(false);
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
ResumeLayout(false);
}
#endregion
private MonthCalendar mcWorkDay;
private SplitContainer splitContainer1;
private RadioButton rbAllDay;
private RadioButton rbAfternoon;
private RadioButton rbMorning;
private RichTextBox rtbMsg;
private Label label1;
private GroupBox groupBox1;
}
}

View File

@ -1,87 +0,0 @@
using CalendarNotepad.Extends;
using CalendarNotepad.Models;
namespace CalendarNotepad
{
public partial class Main:Form
{
public WorkContext Context { get; set; }
public Shaking SaveFileShaking { get; set; } = new Shaking(5);
public Main() {
this.Context = new WorkContext();
InitializeComponent();
//this.Context.LoadFromFile();
this.Context.GetWorkListFormZipFile();
var today = DateTime.Now.ToString("yyyyMMdd");
this.mcWorkDay.TodayDate = DateTime.Now;
this.rbAllDay.Checked = true;
var unit = this.Context.GetUnit(today,GetDateRange());
this.rtbMsg.Text = unit.WorkMessage;
}
private void monthCalendar1_DateChanged(object sender,DateRangeEventArgs e) {
var selectedDate = e.Start.ToString("yyyyMMdd");
var selectedRange = GetDateRange();
var unit = this.Context.GetUnit(selectedDate,selectedRange);
this.rtbMsg.Text = unit.WorkMessage;
}
private void monthCalendar1_DateSelected(object sender,DateRangeEventArgs e) {
//MessageBox.Show("monthCalendar1_DateSelected");
}
/// <summary>
/// 返回当前选择的时间段
/// </summary>
/// <returns>时间段</returns>
private string GetDateRange() =>
this.rbAllDay.Checked ? "全天" :
this.rbMorning.Checked ? "上午" :
this.rbAfternoon.Checked ? "下午" :
"";
private void rtbMsg_TextChanged(object sender,EventArgs e) {
var data = new WorkUnit {
DayRange = GetDateRange(),
WorkDay = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd"),
WorkMessage = this.rtbMsg.Text,
};
this.Context.AddOrReplace(data);
//this.SaveFileShaking.Run(this.Context.SaveToFile);
this.SaveFileShaking.Run(this.Context.SaveWorkListToZipFile);
}
private void Main_FormClosing(object sender,FormClosingEventArgs e) {
this.SaveFileShaking.RunNow();
}
private void Main_Load(object sender,EventArgs e) {
Task.Factory.StartNew(async () => {
while(true) {
if(this.Context == null) {
continue;
}
var days = new List<DateTime>();
var curD = this.mcWorkDay.SelectionStart;
var year = curD.Year;
var month = curD.Month;
for(DateTime i = new DateTime(year,month,1);i.Month == curD.Month;i = i.AddDays(1)) {
var df = i.ToString("yyyyMMdd");
var m = this.Context.GetUnit(df,GetDateRange());
if(m.WorkMessage.IsNotNullOrEmpty()) {
days.Add(i);
}
}
this.Invoke(() => {
this.mcWorkDay.BoldedDates = days.ToArray();
});
await Task.Delay(5 * 1000);
}
});
}
}
}

View File

@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;
namespace CalendarNotepad.Models
{
/// <summary>
/// 附件文件单元
/// </summary>
public class PlusFileUnit:TableBase
{
/// <summary>
/// 文件指纹ID
/// </summary>
[Key]
public string? FileId { get; set; }
/// <summary>
/// 文件内容
/// </summary>
public byte[]? FileContent { get; set; }
/// <summary>
/// 文件类型 .jpj .txt等
/// </summary>
public string? FileType { get; set; }
}
}

View File

@ -1,15 +0,0 @@
namespace CalendarNotepad.Models
{
public class SaveFileModel
{
/// <summary>
/// 数据版本
/// </summary>
public int Ver { get; set; } = 1;
/// <summary>
/// 工作列表
/// </summary>
public WorkUnitList WorkList { get; set; } = new WorkUnitList();
}
}

View File

@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
namespace CalendarNotepad.Models
{
/// <summary>
/// 数据表基类
/// </summary>
public abstract class TableBase
{
/// <summary>
/// 数据主键
/// </summary>
[Key]
[SqlSugar.SugarColumn(Length = 32)]
public string Id { get; set; } = Guid.NewGuid().ToString("N");
/// <summary>
/// 记录创建或最后修改时间
/// </summary>
public DateTime CreateDateTime { get; set; } = DateTime.Now;
}
}

View File

@ -1,125 +0,0 @@
using CalendarNotepad.Extends;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
namespace CalendarNotepad.Models
{
/// <summary>
/// 上下文
/// </summary>
public class WorkContext
{
/// <summary>
/// 数据版本
/// </summary>
public int Ver { get; set; } = 1;
/// <summary>
/// 工作列表
/// </summary>
private WorkUnitList WorkList { get; set; } = new WorkUnitList();
private static object _lockObj = new object();
public void AddOrReplace(WorkUnit unit) {
lock(_lockObj) {
var qu = this.WorkList.Where(a => a.WorkDay == unit.WorkDay && a.DayRange == unit.DayRange);
if(qu.Any() && unit.WorkMessage.IsNullOrEmpty()) {
qu.ToList().ForEach(a => this.WorkList.Remove(a));
return;
}
if(qu.Any() && unit.WorkMessage.IsNotNullOrEmpty()) {
qu.ToList().ForEach(a => a.WorkMessage = unit.WorkMessage);
return;
}
if(!qu.Any() && unit.WorkMessage.IsNullOrEmpty()) {
return;
}
if(!qu.Any() && unit.WorkMessage.IsNotNullOrEmpty()) {
this.WorkList.Add(unit);
return;
}
}
}
/// <summary>
/// 获取工作单元
/// </summary>
/// <param name="workDay">工作日期</param>
/// <param name="workRange">工作范围</param>
/// <returns></returns>
public WorkUnit GetUnit(string workDay,string workRange) {
var qu = this.WorkList.Where(a => a.WorkDay == workDay && a.DayRange == workRange);
return qu.Any() ? qu.First() : new WorkUnit { DayRange = workRange,WorkDay = workDay,WorkMessage = "" };
}
public void SaveToFile() {
var file = AppConfig.GetSaveFileName;
if(file.IsNullOrEmpty()) {
MessageBox.Show("没有配置数据保存文件!");
return;
}
if(!Path.IsPathFullyQualified(file)) {
file = Path.Combine(Application.StartupPath,file);
}
var path = Path.GetDirectoryName(file);
if(!Directory.Exists(path)) {
Directory.CreateDirectory(path);
}
if(File.Exists(file)) {
File.Delete(file);
}
var jsonModel = new SaveFileModel {
Ver = this.Ver,WorkList = this.WorkList,
};
var str = JsonSerializer.Serialize(jsonModel);
File.WriteAllText(file,str,Encoding.UTF8);
}
public void SaveWorkListToZipFile() {
var str = JsonSerializer.Serialize(this.WorkList);
ZipExtend.SaveToFile(str,"WorkContext.json");
}
public void GetWorkListFormZipFile() {
var str = ZipExtend.GetFormFile("WorkContext.json");
if(str.IsNullOrEmpty()) {
return;
}
this.WorkList = JsonSerializer.Deserialize<WorkUnitList>(str) ?? new WorkUnitList();
}
public void LoadFromFile() {
var file = AppConfig.GetSaveFileName;
if(file.IsNullOrEmpty()) {
MessageBox.Show("没有配置数据保存文件!");
return;
}
if(!Path.IsPathFullyQualified(file)) {
file = Path.Combine(Application.StartupPath,file);
}
if(!File.Exists(file)) {
MessageBox.Show("没有找到数据文件!");
return;
}
try {
var str = File.ReadAllText(file);
var obj = JsonSerializer.Deserialize<SaveFileModel>(str);
if(obj == null) {
MessageBox.Show("保存数据格式错误!");
}
if(obj?.Ver == 1) {
this.WorkList = obj.WorkList;
}
}
catch(Exception ex) {
MessageBox.Show(ex.ToString());
return;
}
}
}
}

View File

@ -1,21 +1,36 @@
namespace CalendarNotepad.Models
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CalendarNotepad.Models
{
/// <summary>
/// 工作记录单元
/// </summary>
public class WorkUnit
[Table("WorkUnit")]
public class WorkUnit:TableBase
{
/// <summary>
/// 工作日期
/// </summary>
[Key]
public string? WorkDay { get; set; }
/// <summary>
/// 时间段
/// </summary>
public string? DayRange { get; set; }
/// <summary>
/// 内容
/// </summary>
public string? WorkMessage { get; set; }
/// <summary>
/// 工作类型。如正常上班,休假,加班等
/// </summary>
public string? WorkType { get; set; }
/// <summary>
/// 加班信息
/// </summary>
public string? Workout { get; set; }
/// <summary>
/// 当日时间段
/// </summary>
[Obsolete("不再使用,旧数据保留,新数据设置为弃用",false)]
[MaxLength(2)]
public string? DayRange { get; set; } = "弃用";
}
}

View File

@ -1,7 +0,0 @@
namespace CalendarNotepad.Models
{
/// <summary>
/// 工作记录列表。不要直接使用此类通过Workcontext进行操作
/// </summary>
public class WorkUnitList:List<WorkUnit> { }
}

View File

@ -0,0 +1,21 @@
namespace CalendarNotepad.Models
{
/// <summary>
/// 工作单元附件对应关系
/// </summary>
public class WorkUnitPlusFile:TableBase
{
/// <summary>
/// 工作日期
/// </summary>
public string? WorkDay { get; set; }
/// <summary>
/// 文件指纹
/// </summary>
public string? FileKey { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string? FileName { get; set; }
}
}

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace CalendarNotepad.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CalendarNotepad.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -25,27 +25,93 @@
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WorkMain));
tabControl1 = new TabControl();
tpWorkManage = new TabPage();
splitContainer1 = new SplitContainer();
groupBox1 = new GroupBox();
C_WorkOut = new FlowLayoutPanel();
radioButton9 = new RadioButton();
radioButton6 = new RadioButton();
radioButton8 = new RadioButton();
radioButton7 = new RadioButton();
flowLayoutPanel1 = new FlowLayoutPanel();
btSave = new Button();
btReset = new Button();
gbWorkTypes = new GroupBox();
C_WorkTypes = new FlowLayoutPanel();
radioButton1 = new RadioButton();
radioButton3 = new RadioButton();
radioButton2 = new RadioButton();
radioButton4 = new RadioButton();
radioButton5 = new RadioButton();
mcWorkDay = new MonthCalendar();
splitContainer2 = new SplitContainer();
rtbMsg = new RichTextBox();
toolStrip1 = new ToolStrip();
tsp_Copy = new ToolStripButton();
tsb_palse = new ToolStripButton();
toolStripSeparator1 = new ToolStripSeparator();
tsb_loadin = new ToolStripButton();
FileListView = new ListView();
cms_FileList = new ContextMenuStrip(components);
ToolStripMenuItem = new ToolStripMenuItem();
toolStripSeparator2 = new ToolStripSeparator();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
tabPage1 = new TabPage();
flowLayoutPanel5 = new FlowLayoutPanel();
bt_m_dbshc = new Button();
label5 = new Label();
flowLayoutPanel4 = new FlowLayoutPanel();
bt_m_Backup = new Button();
label1 = new Label();
flowLayoutPanel3 = new FlowLayoutPanel();
bt_m_ys = new Button();
label3 = new Label();
lab_m_dbsize = new Label();
flowLayoutPanel2 = new FlowLayoutPanel();
bt_m_Clean = new Button();
label2 = new Label();
panel2 = new Panel();
panel3 = new Panel();
OpenFileDlg = new OpenFileDialog();
tabControl1.SuspendLayout();
tpWorkManage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout();
splitContainer1.Panel2.SuspendLayout();
splitContainer1.SuspendLayout();
groupBox1.SuspendLayout();
C_WorkOut.SuspendLayout();
flowLayoutPanel1.SuspendLayout();
gbWorkTypes.SuspendLayout();
C_WorkTypes.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer2).BeginInit();
splitContainer2.Panel1.SuspendLayout();
splitContainer2.Panel2.SuspendLayout();
splitContainer2.SuspendLayout();
toolStrip1.SuspendLayout();
cms_FileList.SuspendLayout();
tabPage1.SuspendLayout();
flowLayoutPanel5.SuspendLayout();
flowLayoutPanel4.SuspendLayout();
flowLayoutPanel3.SuspendLayout();
flowLayoutPanel2.SuspendLayout();
SuspendLayout();
//
// tabControl1
//
tabControl1.Controls.Add(tpWorkManage);
tabControl1.Controls.Add(tabPage1);
tabControl1.Dock = DockStyle.Fill;
tabControl1.Location = new Point(0,0);
tabControl1.Name = "tabControl1";
tabControl1.SelectedIndex = 0;
tabControl1.Size = new Size(740,435);
tabControl1.Size = new Size(719,459);
tabControl1.TabIndex = 0;
//
// tpWorkManage
@ -54,7 +120,7 @@
tpWorkManage.Location = new Point(4,26);
tpWorkManage.Name = "tpWorkManage";
tpWorkManage.Padding = new Padding(3);
tpWorkManage.Size = new Size(732,405);
tpWorkManage.Size = new Size(711,429);
tpWorkManage.TabIndex = 1;
tpWorkManage.Text = "录入记录";
tpWorkManage.UseVisualStyleBackColor = true;
@ -68,15 +134,190 @@
//
// splitContainer1.Panel1
//
splitContainer1.Panel1.AutoScroll = true;
splitContainer1.Panel1.Controls.Add(groupBox1);
splitContainer1.Panel1.Controls.Add(flowLayoutPanel1);
splitContainer1.Panel1.Controls.Add(gbWorkTypes);
splitContainer1.Panel1.Controls.Add(mcWorkDay);
//
// splitContainer1.Panel2
//
splitContainer1.Panel2.Controls.Add(rtbMsg);
splitContainer1.Size = new Size(726,399);
splitContainer1.Panel2.Controls.Add(splitContainer2);
splitContainer1.Size = new Size(705,423);
splitContainer1.SplitterDistance = 236;
splitContainer1.TabIndex = 9;
//
// groupBox1
//
groupBox1.AutoSize = true;
groupBox1.Controls.Add(C_WorkOut);
groupBox1.Location = new Point(6,273);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(220,82);
groupBox1.TabIndex = 9;
groupBox1.TabStop = false;
groupBox1.Text = "加班";
//
// C_WorkOut
//
C_WorkOut.Controls.Add(radioButton9);
C_WorkOut.Controls.Add(radioButton6);
C_WorkOut.Controls.Add(radioButton8);
C_WorkOut.Controls.Add(radioButton7);
C_WorkOut.Dock = DockStyle.Fill;
C_WorkOut.Location = new Point(3,19);
C_WorkOut.Name = "C_WorkOut";
C_WorkOut.Size = new Size(214,60);
C_WorkOut.TabIndex = 0;
//
// radioButton9
//
radioButton9.AutoSize = true;
radioButton9.Checked = true;
radioButton9.Location = new Point(3,3);
radioButton9.Name = "radioButton9";
radioButton9.Size = new Size(38,21);
radioButton9.TabIndex = 0;
radioButton9.TabStop = true;
radioButton9.Text = "无";
radioButton9.UseVisualStyleBackColor = true;
//
// radioButton6
//
radioButton6.AutoSize = true;
radioButton6.Location = new Point(47,3);
radioButton6.Name = "radioButton6";
radioButton6.Size = new Size(86,21);
radioButton6.TabIndex = 4;
radioButton6.Text = "工作日加班";
radioButton6.UseVisualStyleBackColor = true;
//
// radioButton8
//
radioButton8.AutoSize = true;
radioButton8.Location = new Point(3,30);
radioButton8.Name = "radioButton8";
radioButton8.Size = new Size(110,21);
radioButton8.TabIndex = 6;
radioButton8.Text = "法定节假日加班";
radioButton8.UseVisualStyleBackColor = true;
//
// radioButton7
//
radioButton7.AutoSize = true;
radioButton7.Location = new Point(119,30);
radioButton7.Name = "radioButton7";
radioButton7.Size = new Size(86,21);
radioButton7.TabIndex = 5;
radioButton7.Text = "休息日加班";
radioButton7.UseVisualStyleBackColor = true;
//
// flowLayoutPanel1
//
flowLayoutPanel1.AutoSize = true;
flowLayoutPanel1.Controls.Add(btSave);
flowLayoutPanel1.Controls.Add(btReset);
flowLayoutPanel1.Dock = DockStyle.Bottom;
flowLayoutPanel1.Location = new Point(0,394);
flowLayoutPanel1.Name = "flowLayoutPanel1";
flowLayoutPanel1.Size = new Size(236,29);
flowLayoutPanel1.TabIndex = 8;
//
// btSave
//
btSave.Location = new Point(3,3);
btSave.Name = "btSave";
btSave.Size = new Size(75,23);
btSave.TabIndex = 8;
btSave.Text = "保存";
btSave.UseVisualStyleBackColor = true;
btSave.Click += btSave_Click;
//
// btReset
//
btReset.Location = new Point(84,3);
btReset.Name = "btReset";
btReset.Size = new Size(75,23);
btReset.TabIndex = 9;
btReset.Text = "还原";
btReset.UseVisualStyleBackColor = true;
btReset.Click += btReset_Click;
//
// gbWorkTypes
//
gbWorkTypes.Controls.Add(C_WorkTypes);
gbWorkTypes.Location = new Point(6,189);
gbWorkTypes.Name = "gbWorkTypes";
gbWorkTypes.Size = new Size(220,84);
gbWorkTypes.TabIndex = 7;
gbWorkTypes.TabStop = false;
gbWorkTypes.Text = "类型";
//
// C_WorkTypes
//
C_WorkTypes.Controls.Add(radioButton1);
C_WorkTypes.Controls.Add(radioButton3);
C_WorkTypes.Controls.Add(radioButton2);
C_WorkTypes.Controls.Add(radioButton4);
C_WorkTypes.Controls.Add(radioButton5);
C_WorkTypes.Dock = DockStyle.Fill;
C_WorkTypes.Location = new Point(3,19);
C_WorkTypes.Name = "C_WorkTypes";
C_WorkTypes.Size = new Size(214,62);
C_WorkTypes.TabIndex = 2;
//
// radioButton1
//
radioButton1.AutoSize = true;
radioButton1.Location = new Point(3,3);
radioButton1.Name = "radioButton1";
radioButton1.Size = new Size(50,21);
radioButton1.TabIndex = 0;
radioButton1.Text = "工作";
radioButton1.UseVisualStyleBackColor = true;
//
// radioButton3
//
radioButton3.AutoSize = true;
radioButton3.Checked = true;
radioButton3.Location = new Point(59,3);
radioButton3.Name = "radioButton3";
radioButton3.Size = new Size(50,21);
radioButton3.TabIndex = 1;
radioButton3.TabStop = true;
radioButton3.Text = "休假";
radioButton3.UseVisualStyleBackColor = true;
//
// radioButton2
//
radioButton2.AutoSize = true;
radioButton2.Location = new Point(115,3);
radioButton2.Name = "radioButton2";
radioButton2.Size = new Size(50,21);
radioButton2.TabIndex = 1;
radioButton2.Text = "病假";
radioButton2.UseVisualStyleBackColor = true;
//
// radioButton4
//
radioButton4.AutoSize = true;
radioButton4.Location = new Point(3,30);
radioButton4.Name = "radioButton4";
radioButton4.Size = new Size(50,21);
radioButton4.TabIndex = 2;
radioButton4.Text = "年假";
radioButton4.UseVisualStyleBackColor = true;
//
// radioButton5
//
radioButton5.AutoSize = true;
radioButton5.Location = new Point(59,30);
radioButton5.Name = "radioButton5";
radioButton5.Size = new Size(50,21);
radioButton5.TabIndex = 3;
radioButton5.Text = "事假";
radioButton5.UseVisualStyleBackColor = true;
//
// mcWorkDay
//
mcWorkDay.FirstDayOfWeek = Day.Sunday;
@ -90,33 +331,365 @@
mcWorkDay.TitleForeColor = Color.FromArgb(255,128,128);
mcWorkDay.DateChanged += mcWorkDay_DateChanged;
//
// splitContainer2
//
splitContainer2.Dock = DockStyle.Fill;
splitContainer2.Location = new Point(0,0);
splitContainer2.Name = "splitContainer2";
splitContainer2.Orientation = Orientation.Horizontal;
//
// splitContainer2.Panel1
//
splitContainer2.Panel1.Controls.Add(rtbMsg);
splitContainer2.Panel1.Controls.Add(toolStrip1);
//
// splitContainer2.Panel2
//
splitContainer2.Panel2.Controls.Add(FileListView);
splitContainer2.Size = new Size(465,423);
splitContainer2.SplitterDistance = 328;
splitContainer2.TabIndex = 10;
//
// rtbMsg
//
rtbMsg.Dock = DockStyle.Fill;
rtbMsg.EnableAutoDragDrop = true;
rtbMsg.Location = new Point(0,0);
rtbMsg.Location = new Point(0,25);
rtbMsg.Name = "rtbMsg";
rtbMsg.Size = new Size(486,399);
rtbMsg.Size = new Size(465,303);
rtbMsg.TabIndex = 7;
rtbMsg.Text = "";
rtbMsg.TextChanged += rtbMsg_TextChanged;
rtbMsg.LinkClicked += rtbMsg_LinkClicked;
rtbMsg.TextChanged += rtbMsg_TextChanged_1;
//
// toolStrip1
//
toolStrip1.Items.AddRange(new ToolStripItem[] { tsp_Copy,tsb_palse,toolStripSeparator1,tsb_loadin });
toolStrip1.Location = new Point(0,0);
toolStrip1.Name = "toolStrip1";
toolStrip1.Size = new Size(465,25);
toolStrip1.TabIndex = 8;
toolStrip1.Text = "toolStrip1";
//
// tsp_Copy
//
tsp_Copy.DisplayStyle = ToolStripItemDisplayStyle.Text;
tsp_Copy.ImageTransparentColor = Color.Magenta;
tsp_Copy.Name = "tsp_Copy";
tsp_Copy.Size = new Size(36,22);
tsp_Copy.Text = "复制";
tsp_Copy.TextAlign = ContentAlignment.MiddleRight;
tsp_Copy.Click += tsp_Copy_Click;
//
// tsb_palse
//
tsb_palse.DisplayStyle = ToolStripItemDisplayStyle.Text;
tsb_palse.Image = (Image)resources.GetObject("tsb_palse.Image");
tsb_palse.ImageTransparentColor = Color.Magenta;
tsb_palse.Name = "tsb_palse";
tsb_palse.Size = new Size(36,22);
tsb_palse.Text = "粘贴";
tsb_palse.Click += tsb_palse_Click;
//
// toolStripSeparator1
//
toolStripSeparator1.Name = "toolStripSeparator1";
toolStripSeparator1.Size = new Size(6,25);
//
// tsb_loadin
//
tsb_loadin.DisplayStyle = ToolStripItemDisplayStyle.Text;
tsb_loadin.Image = (Image)resources.GetObject("tsb_loadin.Image");
tsb_loadin.ImageTransparentColor = Color.Magenta;
tsb_loadin.Name = "tsb_loadin";
tsb_loadin.Size = new Size(60,22);
tsb_loadin.Text = "导入附件";
tsb_loadin.Click += tsb_loadin_Click;
//
// FileListView
//
FileListView.ContextMenuStrip = cms_FileList;
FileListView.Dock = DockStyle.Fill;
FileListView.FullRowSelect = true;
FileListView.GridLines = true;
FileListView.Location = new Point(0,0);
FileListView.Name = "FileListView";
FileListView.Size = new Size(465,91);
FileListView.TabIndex = 9;
FileListView.UseCompatibleStateImageBehavior = false;
FileListView.View = View.Details;
FileListView.DragDrop += FileListView_DragDrop;
FileListView.DragEnter += FileListView_DragEnter;
FileListView.DoubleClick += FileListView_DoubleClick;
//
// cms_FileList
//
cms_FileList.Items.AddRange(new ToolStripItem[] { ToolStripMenuItem,toolStripSeparator2,ToolStripMenuItem,ToolStripMenuItem,ToolStripMenuItem,ToolStripMenuItem });
cms_FileList.Name = "contextMenuStrip1";
cms_FileList.Size = new Size(101,120);
//
// 打开ToolStripMenuItem
//
ToolStripMenuItem.Font = new Font("微软雅黑",9F,FontStyle.Bold,GraphicsUnit.Point);
ToolStripMenuItem.Name = "打开ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(100,22);
ToolStripMenuItem.Text = "打开";
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
//
// toolStripSeparator2
//
toolStripSeparator2.Name = "toolStripSeparator2";
toolStripSeparator2.Size = new Size(97,6);
//
// 删除ToolStripMenuItem
//
ToolStripMenuItem.Name = "删除ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(100,22);
ToolStripMenuItem.Text = "删除";
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
//
// 导入ToolStripMenuItem
//
ToolStripMenuItem.Name = "导入ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(100,22);
ToolStripMenuItem.Text = "导入";
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
//
// 下载ToolStripMenuItem
//
ToolStripMenuItem.Name = "下载ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(100,22);
ToolStripMenuItem.Text = "下载";
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
//
// 更名ToolStripMenuItem
//
ToolStripMenuItem.Name = "更名ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(100,22);
ToolStripMenuItem.Text = "更名";
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
//
// tabPage1
//
tabPage1.Controls.Add(flowLayoutPanel5);
tabPage1.Controls.Add(flowLayoutPanel4);
tabPage1.Controls.Add(flowLayoutPanel3);
tabPage1.Controls.Add(flowLayoutPanel2);
tabPage1.Controls.Add(panel2);
tabPage1.Controls.Add(panel3);
tabPage1.Location = new Point(4,26);
tabPage1.Name = "tabPage1";
tabPage1.Padding = new Padding(3);
tabPage1.Size = new Size(711,429);
tabPage1.TabIndex = 2;
tabPage1.Text = "管理";
tabPage1.UseVisualStyleBackColor = true;
//
// flowLayoutPanel5
//
flowLayoutPanel5.AutoSize = true;
flowLayoutPanel5.Controls.Add(bt_m_dbshc);
flowLayoutPanel5.Controls.Add(label5);
flowLayoutPanel5.Dock = DockStyle.Top;
flowLayoutPanel5.Location = new Point(3,120);
flowLayoutPanel5.Name = "flowLayoutPanel5";
flowLayoutPanel5.Padding = new Padding(5);
flowLayoutPanel5.Size = new Size(705,39);
flowLayoutPanel5.TabIndex = 6;
//
// bt_m_dbshc
//
bt_m_dbshc.Location = new Point(8,8);
bt_m_dbshc.Name = "bt_m_dbshc";
bt_m_dbshc.Size = new Size(75,23);
bt_m_dbshc.TabIndex = 0;
bt_m_dbshc.Text = "架构";
bt_m_dbshc.UseVisualStyleBackColor = true;
bt_m_dbshc.Click += bt_m_dbshc_Click;
//
// label5
//
label5.AutoSize = true;
label5.Font = new Font("微软雅黑",12F,FontStyle.Regular,GraphicsUnit.Point);
label5.Location = new Point(89,5);
label5.Name = "label5";
label5.Size = new Size(122,21);
label5.TabIndex = 1;
label5.Text = "查看数据库架构";
//
// flowLayoutPanel4
//
flowLayoutPanel4.AutoSize = true;
flowLayoutPanel4.Controls.Add(bt_m_Backup);
flowLayoutPanel4.Controls.Add(label1);
flowLayoutPanel4.Dock = DockStyle.Top;
flowLayoutPanel4.Location = new Point(3,81);
flowLayoutPanel4.Name = "flowLayoutPanel4";
flowLayoutPanel4.Padding = new Padding(5);
flowLayoutPanel4.Size = new Size(705,39);
flowLayoutPanel4.TabIndex = 5;
//
// bt_m_Backup
//
bt_m_Backup.Location = new Point(8,8);
bt_m_Backup.Name = "bt_m_Backup";
bt_m_Backup.Size = new Size(75,23);
bt_m_Backup.TabIndex = 0;
bt_m_Backup.Text = "备份";
bt_m_Backup.UseVisualStyleBackColor = true;
bt_m_Backup.Click += bt_m_Backup_Click;
//
// label1
//
label1.AutoSize = true;
label1.Font = new Font("微软雅黑",12F,FontStyle.Regular,GraphicsUnit.Point);
label1.Location = new Point(89,5);
label1.Name = "label1";
label1.Size = new Size(266,21);
label1.TabIndex = 1;
label1.Text = "备份数据文件,以便将来出错时还原";
//
// flowLayoutPanel3
//
flowLayoutPanel3.AutoSize = true;
flowLayoutPanel3.Controls.Add(bt_m_ys);
flowLayoutPanel3.Controls.Add(label3);
flowLayoutPanel3.Controls.Add(lab_m_dbsize);
flowLayoutPanel3.Dock = DockStyle.Top;
flowLayoutPanel3.Location = new Point(3,42);
flowLayoutPanel3.Name = "flowLayoutPanel3";
flowLayoutPanel3.Padding = new Padding(5);
flowLayoutPanel3.Size = new Size(705,39);
flowLayoutPanel3.TabIndex = 4;
//
// bt_m_ys
//
bt_m_ys.Location = new Point(8,8);
bt_m_ys.Name = "bt_m_ys";
bt_m_ys.Size = new Size(75,23);
bt_m_ys.TabIndex = 0;
bt_m_ys.Text = "压缩";
bt_m_ys.UseVisualStyleBackColor = true;
bt_m_ys.Click += bt_m_ys_Click;
//
// label3
//
label3.AutoSize = true;
label3.Font = new Font("微软雅黑",12F,FontStyle.Regular,GraphicsUnit.Point);
label3.Location = new Point(89,5);
label3.Name = "label3";
label3.Size = new Size(266,21);
label3.TabIndex = 1;
label3.Text = "压缩数据库文件尺寸,减少文件大小";
//
// lab_m_dbsize
//
lab_m_dbsize.AutoSize = true;
lab_m_dbsize.Font = new Font("微软雅黑",12F,FontStyle.Regular,GraphicsUnit.Point);
lab_m_dbsize.Location = new Point(361,5);
lab_m_dbsize.Name = "lab_m_dbsize";
lab_m_dbsize.Size = new Size(42,21);
lab_m_dbsize.TabIndex = 2;
lab_m_dbsize.Text = "当前";
//
// flowLayoutPanel2
//
flowLayoutPanel2.AutoSize = true;
flowLayoutPanel2.AutoSizeMode = AutoSizeMode.GrowAndShrink;
flowLayoutPanel2.Controls.Add(bt_m_Clean);
flowLayoutPanel2.Controls.Add(label2);
flowLayoutPanel2.Dock = DockStyle.Top;
flowLayoutPanel2.Location = new Point(3,3);
flowLayoutPanel2.Name = "flowLayoutPanel2";
flowLayoutPanel2.Padding = new Padding(5);
flowLayoutPanel2.Size = new Size(705,39);
flowLayoutPanel2.TabIndex = 3;
//
// bt_m_Clean
//
bt_m_Clean.Location = new Point(8,8);
bt_m_Clean.Name = "bt_m_Clean";
bt_m_Clean.Size = new Size(75,23);
bt_m_Clean.TabIndex = 0;
bt_m_Clean.Text = "清理";
bt_m_Clean.UseVisualStyleBackColor = true;
bt_m_Clean.Click += bt_m_Clean_Click;
//
// label2
//
label2.AutoSize = true;
label2.Font = new Font("微软雅黑",12F,FontStyle.Regular,GraphicsUnit.Point);
label2.Location = new Point(89,5);
label2.Name = "label2";
label2.Size = new Size(170,21);
label2.TabIndex = 1;
label2.Text = "清除数据库中无用垃圾";
//
// panel2
//
panel2.AutoSize = true;
panel2.Dock = DockStyle.Top;
panel2.Location = new Point(3,3);
panel2.Name = "panel2";
panel2.Size = new Size(705,0);
panel2.TabIndex = 2;
//
// panel3
//
panel3.AutoSize = true;
panel3.Dock = DockStyle.Top;
panel3.Location = new Point(3,3);
panel3.Name = "panel3";
panel3.Size = new Size(705,0);
panel3.TabIndex = 1;
//
// OpenFileDlg
//
OpenFileDlg.Multiselect = true;
//
// WorkMain
//
AutoScaleDimensions = new SizeF(7F,17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(740,435);
ClientSize = new Size(719,459);
Controls.Add(tabControl1);
Name = "WorkMain";
StartPosition = FormStartPosition.CenterScreen;
Text = "工作记录";
FormClosing += WorkMain_FormClosing;
Load += WorkMain_Load;
tabControl1.ResumeLayout(false);
tpWorkManage.ResumeLayout(false);
splitContainer1.Panel1.ResumeLayout(false);
splitContainer1.Panel1.PerformLayout();
splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
splitContainer1.ResumeLayout(false);
groupBox1.ResumeLayout(false);
C_WorkOut.ResumeLayout(false);
C_WorkOut.PerformLayout();
flowLayoutPanel1.ResumeLayout(false);
gbWorkTypes.ResumeLayout(false);
C_WorkTypes.ResumeLayout(false);
C_WorkTypes.PerformLayout();
splitContainer2.Panel1.ResumeLayout(false);
splitContainer2.Panel1.PerformLayout();
splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainer2).EndInit();
splitContainer2.ResumeLayout(false);
toolStrip1.ResumeLayout(false);
toolStrip1.PerformLayout();
cms_FileList.ResumeLayout(false);
tabPage1.ResumeLayout(false);
tabPage1.PerformLayout();
flowLayoutPanel5.ResumeLayout(false);
flowLayoutPanel5.PerformLayout();
flowLayoutPanel4.ResumeLayout(false);
flowLayoutPanel4.PerformLayout();
flowLayoutPanel3.ResumeLayout(false);
flowLayoutPanel3.PerformLayout();
flowLayoutPanel2.ResumeLayout(false);
flowLayoutPanel2.PerformLayout();
ResumeLayout(false);
}
@ -127,5 +700,52 @@
private MonthCalendar mcWorkDay;
private RichTextBox rtbMsg;
private SplitContainer splitContainer1;
private GroupBox gbWorkTypes;
private RadioButton radioButton3;
private RadioButton radioButton2;
private RadioButton radioButton1;
private FlowLayoutPanel C_WorkTypes;
private RadioButton radioButton4;
private RadioButton radioButton5;
private Button btSave;
private FlowLayoutPanel flowLayoutPanel1;
private Button btReset;
private RadioButton radioButton6;
private RadioButton radioButton7;
private RadioButton radioButton8;
private GroupBox groupBox1;
private FlowLayoutPanel C_WorkOut;
private RadioButton radioButton9;
private ToolStrip toolStrip1;
private ToolStripButton tsp_Copy;
private ToolStripButton tsb_palse;
private ListView FileListView;
private ContextMenuStrip cms_FileList;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
private OpenFileDialog OpenFileDlg;
private ToolStripMenuItem ToolStripMenuItem;
private TabPage tabPage1;
private Panel panel3;
private Label label3;
private Button bt_m_ys;
private FlowLayoutPanel flowLayoutPanel3;
private FlowLayoutPanel flowLayoutPanel2;
private Button bt_m_Clean;
private Label label2;
private Panel panel2;
private FlowLayoutPanel flowLayoutPanel4;
private Button bt_m_Backup;
private Label label1;
private SplitContainer splitContainer2;
private ToolStripSeparator toolStripSeparator1;
private ToolStripButton tsb_loadin;
private Label lab_m_dbsize;
private FlowLayoutPanel flowLayoutPanel5;
private Button bt_m_dbshc;
private Label label5;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripSeparator toolStripSeparator2;
}
}

View File

@ -1,6 +1,9 @@
using CalendarNotepad.Extends;
using CalendarNotepad.Models;
using Microsoft.VisualBasic;
using SqlSugar;
using System.Diagnostics;
using System.Reflection;
namespace CalendarNotepad
{
@ -10,49 +13,46 @@ namespace CalendarNotepad
public WorkMain() {
InitializeComponent();
string version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "";
version = version == "" ? "" : $"({version})";
this.Text = $"工作日志记录{version}";
this.rtbMsg.EnableAutoDragDrop = true;
this.OnDataReset();
this.rtbMsg.TextChanged += RtbMsg_TextChanged;
foreach(var c in this.C_WorkTypes.Controls) {
var rab = c as RadioButton;
if(rab != null) {
rab.CheckedChanged += Rab_CheckedChanged;
}
}
foreach(var c in this.C_WorkOut.Controls) {
var rab = c as RadioButton;
if(rab != null) {
rab.CheckedChanged += Rab_CheckedChanged;
}
}
var fieViewWidth = this.FileListView.Width;
this.FileListView.Columns.Add(new ColumnHeader {
Text = "附件",Width = fieViewWidth - 200,TextAlign = HorizontalAlignment.Left,
});
this.FileListView.Columns.Add(new ColumnHeader {
Text = "类型",Width = 100,TextAlign = HorizontalAlignment.Left,
});
this.FileListView.Columns.Add(new ColumnHeader {
Text = "文件指纹",Width = 100,TextAlign = HorizontalAlignment.Left,
});
//if(File.Exists(AppConfig.GetSaveFileName)) {
// var str = ZipExtend.GetFormFile("WorkContext.json");
// if(str.IsNullOrEmpty()) {
// return;
// }
// var wl = JsonSerializer.Deserialize<WorkUnitList>(str) ?? new WorkUnitList();
// if(wl == null) {
// return;
// }
// this.Db.Deleteable<WorkUnit>().ExecuteCommand();
// foreach(var i in wl) {
// this.Db.Insertable(i).ExecuteCommand();
// }
//}
this.FileListView.AllowDrop = true;
}
private void rtbMsg_TextChanged(object sender,EventArgs e) {
private void Rab_CheckedChanged(object? sender,EventArgs e) {
this.DataChanged();
}
var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
var dr = "全天";
var msg = this.rtbMsg.Text;
var exp = Expressionable.Create<WorkUnit>().And(a => a.DayRange == dr && a.WorkDay == wd).ToExpression();
var qu = this.Db.Queryable<WorkUnit>().Where(exp).ToList();
if(qu.Any() && msg.IsNullOrEmpty()) {
this.Db.Deleteable<WorkUnit>().Where(exp).ExecuteCommand();
return;
}
if(qu.Any() && msg.IsNotNullOrEmpty()) {
this.Db.Updateable<WorkUnit>().Where(exp).SetColumns(a => a.WorkMessage == msg).ExecuteCommand();
return;
}
if(!qu.Any() && msg.IsNotNullOrEmpty()) {
this.Db.Insertable<WorkUnit>(new WorkUnit {
DayRange = dr,WorkDay = wd,WorkMessage = msg,
}).ExecuteCommand();
return;
}
private void RtbMsg_TextChanged(object? sender,EventArgs e) {
this.DataChanged();
}
private void WorkMain_FormClosing(object sender,FormClosingEventArgs e) {
@ -64,15 +64,30 @@ namespace CalendarNotepad
private void mcWorkDay_DateChanged(object sender,DateRangeEventArgs e) {
var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
var sr = "全天";
var qu = this.Db.Queryable<WorkUnit>().Where(a => a.DayRange == sr && a.WorkDay == wd).ToList();
this.FileListView.Items.Clear();
var qu = this.Db.Queryable<WorkUnit>().Where(a => a.WorkDay == wd).ToList();
if(!qu.Any()) {
this.rtbMsg.Text = "";
this.SetWorkType("休假");
this.SetWorkOut("无");
}
if(qu.Any()) {
this.rtbMsg.Text = qu.First().WorkMessage;
}
else {
this.rtbMsg.Rtf = "";
}
var fir = qu.First();
this.rtbMsg.Text = fir.WorkMessage;
this.SetWorkType(fir.WorkType);
this.SetWorkOut(fir.Workout ?? "无");
var plsq = this.Db.Queryable<WorkUnitPlusFile>().Where(a => a.WorkDay == wd).ToList();
if(plsq.Any()) {
foreach(var i in plsq) {
var lit1 = new ListViewItem(i.FileName);
lit1.SubItems.Add(new ListViewItem.ListViewSubItem { Text = "已导入" });
lit1.SubItems.Add(new ListViewItem.ListViewSubItem { Text = i.FileKey });
this.FileListView.Items.Add(lit1);
}
}
}
this.OnDataReset();
Task.Factory.StartNew(() => {
this.Invoke(() => {
this.mcWorkDay.BoldedDates = GetBoldDays().ToArray();
@ -96,7 +111,370 @@ namespace CalendarNotepad
}
private void WorkMain_Load(object sender,EventArgs e) {
mcWorkDay_DateChanged(null,null);
mcWorkDay_DateChanged(sender,new DateRangeEventArgs(this.mcWorkDay.SelectionStart,this.mcWorkDay.SelectionEnd));
Task.Factory.StartNew(() => {
try {
while(true) {
var size = new FileInfo(this.Db.SqliteDbfile).Length;
this.Invoke(() => {
this.lab_m_dbsize.Text = $"数据库大小({size})";
});
Task.Delay(TimeSpan.FromSeconds(1));
}
}
catch(Exception) { }
});
}
/// <summary>
/// 获取工作类型
/// </summary>
/// <returns></returns>
private string GetWorkType() {
foreach(Control c in this.C_WorkTypes.Controls) {
var rb = c as RadioButton;
if(rb != null && rb.Checked) {
return rb.Text;
}
}
return "";
}
/// <summary>
/// 设置工作类型
/// </summary>
/// <param name="t">工作类型</param>
private void SetWorkType(string? t) {
if(t.IsNullOrEmpty()) {
return;
}
foreach(Control c in this.C_WorkTypes.Controls) {
var rb = c as RadioButton;
if(rb != null && rb.Text == t) {
rb.Checked = true;
return;
}
}
}
private void btSave_Click(object sender,EventArgs e) {
var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
var msg = this.rtbMsg.Text;
var wt = GetWorkType();
var wo = this.GetWorkOut();
var exp = Expressionable.Create<WorkUnit>().And(a => a.WorkDay == wd).ToExpression();
var qu = this.Db.Queryable<WorkUnit>().Where(exp).ToList();
if(qu.Any() && msg.IsNullOrEmpty()) {
this.Db.Deleteable<WorkUnit>().Where(exp).ExecuteCommand();
this.OnDataReset();
return;
}
if(qu.Any() && msg.IsNotNullOrEmpty()) {
this.Db.Updateable<WorkUnit>().Where(exp)
.SetColumns(a => a.WorkMessage == msg)
.SetColumns(a => a.WorkType == wt)
.SetColumns(a => a.Workout == wo)
.ExecuteCommand();
this.OnDataReset();
return;
}
if(!qu.Any() && msg.IsNotNullOrEmpty()) {
this.Db.Insertable<WorkUnit>(new WorkUnit {
WorkDay = wd,
WorkMessage = msg,WorkType = wt,Workout = wo,
}).ExecuteCommand();
this.OnDataReset();
return;
}
}
private void btReset_Click(object sender,EventArgs e) {
mcWorkDay_DateChanged(sender,new DateRangeEventArgs(this.mcWorkDay.SelectionStart,this.mcWorkDay.SelectionEnd));
this.OnDataReset();
}
private void DataChanged() {
this.btSave.Enabled = true;
this.btReset.Enabled = true;
}
private void OnDataReset() {
this.btSave.Enabled = false;
this.btReset.Enabled = false;
}
/// <summary>
/// 设置加班信息
/// </summary>
/// <param name="wo"></param>
private void SetWorkOut(string wo) {
if(wo.IsNullOrEmpty()) {
return;
}
foreach(var c in this.C_WorkOut.Controls) {
var ra = c as RadioButton;
if(ra != null && ra.Text == wo) {
ra.Checked = true;
return;
}
}
}
/// <summary>
/// 获取加班信息
/// </summary>
/// <returns></returns>
private string GetWorkOut() {
foreach(var c in this.C_WorkOut.Controls) {
var ra = c as RadioButton;
if(ra != null && ra.Checked) {
return ra.Text;
}
}
return "";
}
private void rtbMsg_LinkClicked(object sender,LinkClickedEventArgs e) {
if(e.LinkText.IsNullOrEmpty()) {
return;
}
try {
Process.Start(new ProcessStartInfo {
FileName = e.LinkText,
UseShellExecute = true,
});
}
catch(Exception ex) {
MessageBox.Show(ex.ToString());
}
}
private void tsp_Copy_Click(object sender,EventArgs e) {
if(this.rtbMsg.SelectedText.IsNullOrEmpty()) {
this.rtbMsg.SelectAll();
}
Clipboard.SetText(this.rtbMsg.SelectedText);
}
private void tsb_palse_Click(object sender,EventArgs e) {
this.rtbMsg.AppendText(Clipboard.GetText());
}
private void rtbMsg_TextChanged_1(object sender,EventArgs e) {
}
private void ToolStripMenuItem_Click(object sender,EventArgs e) {
var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
var items = this.FileListView.SelectedItems;
if(items.Count == 0) {
MessageBox.Show("没有选择列表项!");
return;
}
if(MessageBox.Show($"共选择了{items.Count}项,是否全部删除?","警告",MessageBoxButtons.OKCancel) == DialogResult.Cancel) {
return;
}
foreach(ListViewItem i in items) {
this.FileListView.Items.Remove(i);
this.Db.Deleteable<WorkUnitPlusFile>()
.Where(a => a.WorkDay == wd && a.FileKey == i.SubItems[2].Text)
.ExecuteCommand();
}
}
private void ToolStripMenuItem_Click(object sender,EventArgs e) {
var dlgFile = OpenFileDlg.ShowDialog();
if(dlgFile == DialogResult.Cancel) {
return;
}
if(OpenFileDlg.SafeFileNames.Length == 0) {
return;
}
var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
foreach(var f in OpenFileDlg.FileNames) {
var fk = PlusFile.SaveFileToDb(this.Db,f);
this.Db.Insertable(new WorkUnitPlusFile {
FileKey = fk,
WorkDay = wd,
FileName = Path.GetFileName(f),
}).ExecuteCommand();
this.FileListView.Items.Add(new ListViewFileModel(f,fk,"已导入").ToListViewItem());
}
}
private void ToolStripMenuItem_Click(object sender,EventArgs e) {
var items = this.FileListView.SelectedItems;
if(items.Count == 0) {
MessageBox.Show("没有选择文件");
return;
}
foreach(ListViewItem i in items) {
var sdlg = new SaveFileDialog {
Title = "保存附件",
FileName = Path.GetFileName(i.Text),
};
var dresult = sdlg.ShowDialog();
if(dresult != DialogResult.OK) {
return;
}
var filePath = sdlg.FileName;
var fileKey = i.SubItems[2].Text;
var qu = this.Db.Queryable<PlusFileUnit>().Where(a => a.FileId == fileKey).ToList();
if(qu.Any()) {
var fir = qu.First();
if(fir.FileContent != null) {
PlusFile.SaveFile(filePath,fir.FileContent);
}
}
}
}
private void bt_m_ys_Click(object sender,EventArgs e) {
var r = this.Db.DbVacuum();
MessageBox.Show(r);
}
private void bt_m_Clean_Click(object sender,EventArgs e) {
var r = this.Db.DbClean();
MessageBox.Show(r);
}
private void bt_m_Backup_Click(object sender,EventArgs e) {
var sdlg = new SaveFileDialog {
Title = "备份数据库",
FileName = Path.GetFileName($"workdb.{DateTime.Now.ToString("yyyyMMdd")}.bak"),
};
var dresult = sdlg.ShowDialog();
if(dresult != DialogResult.OK) {
return;
}
var filePath = sdlg.FileName;
//File.Copy(this.Db.SqliteDbfile,filePath);
this.Db.DbMaintenance.BackupDataBase(null,filePath);
MessageBox.Show("备份完成");
}
private void tsb_loadin_Click(object sender,EventArgs e) {
ToolStripMenuItem_Click(sender,EventArgs.Empty);
}
private void bt_m_dbshc_Click(object sender,EventArgs e) {
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 fileKey = item.SubItems[2].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 && a.FileKey == fileKey).SetColumns(a => a.FileName == dlgr).ExecuteCommand();
item.Text = dlgr;
MessageBox.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 fk = item.SubItems[2].Text;
var fileName = item.Text;
var qu = this.Db.Queryable<PlusFileUnit>()
.Where(a => a.FileId == fk)
.Select(a => a.FileContent)
.ToList();
if(!qu.Any() || qu.First() == null) {
MessageBox.Show("打开文件错误,没有找到文件,需要重新导入文件!");
return;
}
var fc = qu.First();
var tempPath = Path.GetTempPath();
//var ran = new Random();
//var fn = ran.NextInt64(10000,99999).ToString();
var path = Path.Combine(tempPath,"CalendarNotepadFile");
if(!Directory.Exists(path)) {
Directory.CreateDirectory(path);
}
var fullPath = Path.Combine(path,fileName);
if(File.Exists(fullPath)) {
File.Delete(fullPath);
}
using(var fs = File.Create(fullPath,fc.Length)) {
fs.Write(fc,0,fc.Length);
fs.Close();
}
Process process = new Process();
process.StartInfo.FileName = fullPath;
process.StartInfo.UseShellExecute = true;
process.EnableRaisingEvents = true;
process.Exited += new EventHandler((s,e) => {
File.Delete(fullPath);
});
// 启动进程
process.Start();
}
private void FileListView_DoubleClick(object sender,EventArgs e) {
ToolStripMenuItem_Click(sender,e);
}
private void FileListView_DragEnter(object sender,DragEventArgs e) {
if(e.Data == null) {
e.Effect = DragDropEffects.None;
return;
}
var isfd = e.Data.GetDataPresent(DataFormats.FileDrop);
if(isfd) {
e.Effect = DragDropEffects.Copy;
return;
}
e.Effect = DragDropEffects.None;
}
private void FileListView_DragDrop(object sender,DragEventArgs e) {
if(e.Data == null) {
return;
}
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
foreach(string file in files) {
var fk = PlusFile.SaveFileToDb(this.Db,file);
this.Db.Insertable(new WorkUnitPlusFile {
FileKey = fk,
WorkDay = wd,
FileName = Path.GetFileName(file),
}).ExecuteCommand();
this.FileListView.Items.Add(new ListViewFileModel(file,fk,"已导入").ToListViewItem());
}
}
/// <summary>
/// 当前记录日志的键
/// </summary>
public string WorkDayKey {
get => this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
}
}
}

View File

@ -117,4 +117,242 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="tabControl1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="tpWorkManage.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="splitContainer1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="groupBox1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="C_WorkOut.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="flowLayoutPanel1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="btSave.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="btReset.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="gbWorkTypes.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="C_WorkTypes.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="mcWorkDay.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="splitContainer2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rtbMsg.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolStrip1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="FileListView.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="cms_FileList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>127, 17</value>
</metadata>
<metadata name="tabPage1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="flowLayoutPanel5.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="flowLayoutPanel4.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="flowLayoutPanel3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="flowLayoutPanel2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="panel2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="panel3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="C_WorkOut.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton9.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton6.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton8.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton7.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton9.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton6.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton8.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton7.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="btSave.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="btReset.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="C_WorkTypes.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton4.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton5.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton4.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="radioButton5.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="tsb_palse.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb
J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj
CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN
AAAAAElFTkSuQmCC
</value>
</data>
<data name="tsb_loadin.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb
J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj
CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN
AAAAAElFTkSuQmCC
</value>
</data>
<metadata name="flowLayoutPanel5.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bt_m_dbshc.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label5.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bt_m_dbshc.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label5.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="flowLayoutPanel4.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bt_m_Backup.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bt_m_Backup.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="flowLayoutPanel3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bt_m_ys.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lab_m_dbsize.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bt_m_ys.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lab_m_dbsize.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="flowLayoutPanel2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bt_m_Clean.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bt_m_Clean.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="panel2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="panel3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="OpenFileDlg.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>248, 17</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>36</value>
</metadata>
</root>

View File

@ -0,0 +1,57 @@
namespace CalendarNotepad
{
partial class dlgDatabaseSchemas
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if(disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
richTextBox1 = new RichTextBox();
SuspendLayout();
//
// richTextBox1
//
richTextBox1.Dock = DockStyle.Fill;
richTextBox1.Location = new Point(0,0);
richTextBox1.Name = "richTextBox1";
richTextBox1.Size = new Size(432,281);
richTextBox1.TabIndex = 0;
richTextBox1.Text = "";
//
// dlgDatabaseSchemas
//
AutoScaleDimensions = new SizeF(7F,17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(432,281);
Controls.Add(richTextBox1);
Name = "dlgDatabaseSchemas";
StartPosition = FormStartPosition.CenterParent;
Text = "数据库架构文本";
Load += dlgDatabaseSchemas_Load;
ResumeLayout(false);
}
#endregion
private RichTextBox richTextBox1;
}
}

View File

@ -0,0 +1,35 @@
using CalendarNotepad.Extends;
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 CalendarNotepad
{
public partial class dlgDatabaseSchemas:Form
{
public dlgDatabaseSchemas() {
InitializeComponent();
}
private void dlgDatabaseSchemas_Load(object sender,EventArgs e) {
StringBuilder sb = new();
using var db = new DbContext();
var tables = db.DbMaintenance.GetTableInfoList(false);
sb.AppendLine($"查询共{tables.Count}张表");
foreach(var t in tables) {
sb.AppendLine($"Table{t.Name}");
var cols = db.DbMaintenance.GetColumnInfosByTableName(t.Name,false);
foreach(var c in cols) {
sb.AppendLine($" Column{c.DbColumnName}{c.DataType}:{c.Length}:{c.ColumnDescription}");
}
}
this.richTextBox1.Text = sb.ToString();
}
}
}

View File

@ -117,40 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="mcWorkDay.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="splitContainer1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="groupBox1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rbAllDay.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rbAfternoon.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rbMorning.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rtbMsg.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rbAllDay.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rbAfternoon.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rbMorning.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>