From 715b90972db952297ca7f5ddb9efb43428f080ff Mon Sep 17 00:00:00 2001
From: FalconFly <12919280+falconfly@user.noreply.gitee.com>
Date: Mon, 22 Jul 2024 14:21:23 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B7=A5=E4=BD=9C=E7=B1=BB?=
=?UTF-8?q?=E5=9E=8B=EF=BC=8C=E4=BC=91=E5=81=87=EF=BC=8C=E7=97=85=E5=81=87?=
=?UTF-8?q?=EF=BC=8C=E5=8A=A0=E7=8F=AD=E7=AD=89=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CalendarNotepad/Models/WorkUnit.cs | 4 +
CalendarNotepad/WorkMain.Designer.cs | 137 ++++++++++++++++++++++++++-
CalendarNotepad/WorkMain.cs | 134 ++++++++++++++++++--------
CalendarNotepad/WorkMain.resx | 48 ++++++++++
4 files changed, 280 insertions(+), 43 deletions(-)
diff --git a/CalendarNotepad/Models/WorkUnit.cs b/CalendarNotepad/Models/WorkUnit.cs
index b1f590a..0dda542 100644
--- a/CalendarNotepad/Models/WorkUnit.cs
+++ b/CalendarNotepad/Models/WorkUnit.cs
@@ -20,5 +20,9 @@ namespace CalendarNotepad.Models
/// 内容
///
public string? WorkMessage { get; set; }
+ ///
+ /// 工作类型。如正常上班,休假,加班等
+ ///
+ public string? WorkType { get; set; }
}
}
diff --git a/CalendarNotepad/WorkMain.Designer.cs b/CalendarNotepad/WorkMain.Designer.cs
index 31c0369..a955dd9 100644
--- a/CalendarNotepad/WorkMain.Designer.cs
+++ b/CalendarNotepad/WorkMain.Designer.cs
@@ -28,6 +28,16 @@
tabControl1 = new TabControl();
tpWorkManage = new TabPage();
splitContainer1 = new SplitContainer();
+ 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();
rtbMsg = new RichTextBox();
tabControl1.SuspendLayout();
@@ -36,6 +46,9 @@
splitContainer1.Panel1.SuspendLayout();
splitContainer1.Panel2.SuspendLayout();
splitContainer1.SuspendLayout();
+ flowLayoutPanel1.SuspendLayout();
+ gbWorkTypes.SuspendLayout();
+ C_WorkTypes.SuspendLayout();
SuspendLayout();
//
// tabControl1
@@ -68,6 +81,8 @@
//
// splitContainer1.Panel1
//
+ splitContainer1.Panel1.Controls.Add(flowLayoutPanel1);
+ splitContainer1.Panel1.Controls.Add(gbWorkTypes);
splitContainer1.Panel1.Controls.Add(mcWorkDay);
//
// splitContainer1.Panel2
@@ -77,6 +92,111 @@
splitContainer1.SplitterDistance = 236;
splitContainer1.TabIndex = 9;
//
+ // flowLayoutPanel1
+ //
+ flowLayoutPanel1.AutoSize = true;
+ flowLayoutPanel1.Controls.Add(btSave);
+ flowLayoutPanel1.Controls.Add(btReset);
+ flowLayoutPanel1.Location = new Point(9,296);
+ flowLayoutPanel1.Name = "flowLayoutPanel1";
+ flowLayoutPanel1.Size = new Size(214,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,198);
+ gbWorkTypes.Name = "gbWorkTypes";
+ gbWorkTypes.Size = new Size(220,92);
+ 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,70);
+ 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;
@@ -99,10 +219,10 @@
rtbMsg.Size = new Size(486,399);
rtbMsg.TabIndex = 7;
rtbMsg.Text = "";
- rtbMsg.TextChanged += rtbMsg_TextChanged;
//
// WorkMain
//
+ AcceptButton = btSave;
AutoScaleDimensions = new SizeF(7F,17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(740,435);
@@ -114,9 +234,14 @@
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);
+ flowLayoutPanel1.ResumeLayout(false);
+ gbWorkTypes.ResumeLayout(false);
+ C_WorkTypes.ResumeLayout(false);
+ C_WorkTypes.PerformLayout();
ResumeLayout(false);
}
@@ -127,5 +252,15 @@
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;
}
}
\ No newline at end of file
diff --git a/CalendarNotepad/WorkMain.cs b/CalendarNotepad/WorkMain.cs
index 52c4c89..19d7c86 100644
--- a/CalendarNotepad/WorkMain.cs
+++ b/CalendarNotepad/WorkMain.cs
@@ -11,48 +11,22 @@ namespace CalendarNotepad
public WorkMain() {
InitializeComponent();
this.rtbMsg.EnableAutoDragDrop = true;
-
- //if(File.Exists(AppConfig.GetSaveFileName)) {
- // var str = ZipExtend.GetFormFile("WorkContext.json");
- // if(str.IsNullOrEmpty()) {
- // return;
- // }
- // var wl = JsonSerializer.Deserialize(str) ?? new WorkUnitList();
- // if(wl == null) {
- // return;
- // }
- // this.Db.Deleteable().ExecuteCommand();
- // foreach(var i in wl) {
- // this.Db.Insertable(i).ExecuteCommand();
- // }
- //}
-
-
-
+ this.DataReset();
+ 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;
+ }
+ }
}
- 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().And(a => a.DayRange == dr && a.WorkDay == wd).ToExpression();
-
- var qu = this.Db.Queryable().Where(exp).ToList();
- if(qu.Any() && msg.IsNullOrEmpty()) {
- this.Db.Deleteable().Where(exp).ExecuteCommand();
- return;
- }
- if(qu.Any() && msg.IsNotNullOrEmpty()) {
- this.Db.Updateable().Where(exp).SetColumns(a => a.WorkMessage == msg).ExecuteCommand();
- return;
- }
- if(!qu.Any() && msg.IsNotNullOrEmpty()) {
- this.Db.Insertable(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) {
@@ -67,12 +41,15 @@ namespace CalendarNotepad
var sr = "全天";
var qu = this.Db.Queryable().Where(a => a.DayRange == sr && a.WorkDay == wd).ToList();
if(qu.Any()) {
- this.rtbMsg.Text = qu.First().WorkMessage;
+ var fir = qu.First();
+ this.rtbMsg.Text = fir.WorkMessage;
+ this.SetWorkType(fir.WorkType);
}
else {
- this.rtbMsg.Rtf = "";
+ this.rtbMsg.Text = "";
+ this.SetWorkType("休假");
}
-
+ this.DataReset();
Task.Factory.StartNew(() => {
this.Invoke(() => {
this.mcWorkDay.BoldedDates = GetBoldDays().ToArray();
@@ -98,5 +75,78 @@ namespace CalendarNotepad
private void WorkMain_Load(object sender,EventArgs e) {
mcWorkDay_DateChanged(null,null);
}
+
+ ///
+ /// 获取工作类型
+ ///
+ ///
+ 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 "";
+ }
+ ///
+ /// 设置工作类型
+ ///
+ /// 工作类型
+ 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 dr = "全天";
+ var msg = this.rtbMsg.Text;
+ var wt = GetWorkType();
+ var exp = Expressionable.Create().And(a => a.DayRange == dr && a.WorkDay == wd).ToExpression();
+ var qu = this.Db.Queryable().Where(exp).ToList();
+ if(qu.Any() && msg.IsNullOrEmpty()) {
+ this.Db.Deleteable().Where(exp).ExecuteCommand();
+ this.DataReset();
+ return;
+ }
+ if(qu.Any() && msg.IsNotNullOrEmpty()) {
+ this.Db.Updateable().Where(exp)
+ .SetColumns(a => a.WorkMessage == msg)
+ .SetColumns(a => a.WorkType == wt)
+ .ExecuteCommand();
+ this.DataReset();
+ return;
+ }
+ if(!qu.Any() && msg.IsNotNullOrEmpty()) {
+ this.Db.Insertable(new WorkUnit {
+ DayRange = dr,WorkDay = wd,WorkMessage = msg,WorkType = wt,
+ }).ExecuteCommand();
+ this.DataReset();
+ return;
+ }
+ }
+
+ private void btReset_Click(object sender,EventArgs e) {
+ mcWorkDay_DateChanged(sender,null);
+ this.DataReset();
+ }
+
+ private void DataChanged() {
+ this.btSave.Enabled = true;
+ this.btReset.Enabled = true;
+ }
+ private void DataReset() {
+ this.btSave.Enabled = false;
+ this.btReset.Enabled = false;
+ }
}
}
diff --git a/CalendarNotepad/WorkMain.resx b/CalendarNotepad/WorkMain.resx
index a395bff..48dfe08 100644
--- a/CalendarNotepad/WorkMain.resx
+++ b/CalendarNotepad/WorkMain.resx
@@ -117,4 +117,52 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
\ No newline at end of file