Commit 2d42ea26 authored by tr's avatar tr

1、员工审核优化:增加报表生成和去重

parent d338c5bb
......@@ -363,6 +363,18 @@ namespace Tools.MyUtils
}
}
/// <summary>
/// 非法行(null, 删除行, 游离行)
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
public static bool IsIllegalDataRow(DataRow dr)
{
return dr == null
|| dr.RowState == DataRowState.Deleted
|| dr.RowState == DataRowState.Detached;
}
#endregion
#region (扩展)整型范围
......
......@@ -320,6 +320,16 @@ namespace Tools.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap 生成 {
get {
object obj = ResourceManager.GetObject("生成", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
......
......@@ -196,6 +196,9 @@
<data name="清空" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\清空.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="生成" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\生成.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="类" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\类.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
......
......@@ -435,6 +435,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="favior.ico" />
<None Include="Resources\生成.png" />
<None Include="Resources\最小化.png" />
<None Include="Resources\最大化.png" />
<None Include="Resources\关闭.png" />
......
......@@ -29,9 +29,6 @@
private void InitializeComponent()
{
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.tsbAdd = new System.Windows.Forms.ToolStripButton();
this.tsbUpdate = new System.Windows.Forms.ToolStripButton();
this.tsbHelp = new System.Windows.Forms.ToolStripButton();
this.panel1 = new System.Windows.Forms.Panel();
this.cbWho = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
......@@ -44,6 +41,13 @@
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.tscbMonth = new System.Windows.Forms.ToolStripComboBox();
this.tsbAdd = new System.Windows.Forms.ToolStripButton();
this.tsbUpdate = new System.Windows.Forms.ToolStripButton();
this.tsbGenReport = new System.Windows.Forms.ToolStripButton();
this.tsbHelp = new System.Windows.Forms.ToolStripButton();
this.toolStrip1.SuspendLayout();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nbMinus)).BeginInit();
......@@ -55,6 +59,10 @@
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsbAdd,
this.tsbUpdate,
this.toolStripSeparator1,
this.tsbGenReport,
this.tscbMonth,
this.toolStripSeparator2,
this.tsbHelp});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
......@@ -62,33 +70,6 @@
this.toolStrip1.TabIndex = 0;
this.toolStrip1.Text = "toolStrip1";
//
// tsbAdd
//
this.tsbAdd.Image = global::Tools.Properties.Resources.新增;
this.tsbAdd.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbAdd.Name = "tsbAdd";
this.tsbAdd.Size = new System.Drawing.Size(76, 22);
this.tsbAdd.Text = "添加记录";
this.tsbAdd.Click += new System.EventHandler(this.tsbAdd_Click);
//
// tsbUpdate
//
this.tsbUpdate.Image = global::Tools.Properties.Resources.编辑;
this.tsbUpdate.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbUpdate.Name = "tsbUpdate";
this.tsbUpdate.Size = new System.Drawing.Size(76, 22);
this.tsbUpdate.Text = "更新记录";
this.tsbUpdate.Click += new System.EventHandler(this.tsbUpdate_Click);
//
// tsbHelp
//
this.tsbHelp.Image = global::Tools.Properties.Resources.使用说明;
this.tsbHelp.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbHelp.Name = "tsbHelp";
this.tsbHelp.Size = new System.Drawing.Size(76, 22);
this.tsbHelp.Text = "操作说明";
this.tsbHelp.Click += new System.EventHandler(this.tsbHelp_Click);
//
// panel1
//
this.panel1.Controls.Add(this.cbWho);
......@@ -218,6 +199,58 @@
this.Column3.Name = "Column3";
this.Column3.ReadOnly = true;
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
//
// tscbMonth
//
this.tscbMonth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.tscbMonth.Name = "tscbMonth";
this.tscbMonth.Size = new System.Drawing.Size(121, 25);
//
// tsbAdd
//
this.tsbAdd.Image = global::Tools.Properties.Resources.新增;
this.tsbAdd.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbAdd.Name = "tsbAdd";
this.tsbAdd.Size = new System.Drawing.Size(76, 22);
this.tsbAdd.Text = "添加记录";
this.tsbAdd.Click += new System.EventHandler(this.tsbAdd_Click);
//
// tsbUpdate
//
this.tsbUpdate.Image = global::Tools.Properties.Resources.编辑;
this.tsbUpdate.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbUpdate.Name = "tsbUpdate";
this.tsbUpdate.Size = new System.Drawing.Size(76, 22);
this.tsbUpdate.Text = "更新记录";
this.tsbUpdate.Click += new System.EventHandler(this.tsbUpdate_Click);
//
// tsbGenReport
//
this.tsbGenReport.Image = global::Tools.Properties.Resources.生成;
this.tsbGenReport.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbGenReport.Name = "tsbGenReport";
this.tsbGenReport.Size = new System.Drawing.Size(76, 22);
this.tsbGenReport.Text = "生成报告";
this.tsbGenReport.Click += new System.EventHandler(this.tsbGenReport_Click);
//
// tsbHelp
//
this.tsbHelp.Image = global::Tools.Properties.Resources.使用说明;
this.tsbHelp.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbHelp.Name = "tsbHelp";
this.tsbHelp.Size = new System.Drawing.Size(76, 22);
this.tsbHelp.Text = "操作说明";
this.tsbHelp.Click += new System.EventHandler(this.tsbHelp_Click);
//
// wEvaluationOfEmployee
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
......@@ -258,5 +291,9 @@
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
private System.Windows.Forms.ToolStripButton tsbGenReport;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripComboBox tscbMonth;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
}
}
\ No newline at end of file
......@@ -15,9 +15,18 @@ namespace Tools.UI
{
public partial class wEvaluationOfEmployee : wEditBasic
{
/// <summary>
/// 上个月起始日期
/// </summary>
string LastMonthStart => DateTime.Now.AddMonths(-1).ToString("yyyy-MM-01");
/// <summary>
/// 本月起始日期
/// </summary>
string ThisMonthStart => DateTime.Now.ToString("yyyy-MM-01");
bool IsAdd = false;
int EditID = 0;
public wEvaluationOfEmployee()
{
InitializeComponent();
......@@ -37,7 +46,9 @@ namespace Tools.UI
}
public override void InitData()
{
this._ds = this._db.GetData(this.ModuleTableList, true);
//只取最近两个月的数据
string sql = $"SELECT * FROM FTT_EvaluationOfEmployee WHERE CreateDate > '{this.LastMonthStart}'";
this._ds = this._db.GetData(sql, "FTT_EvaluationOfEmployee");
}
public override void InitUI()
{
......@@ -47,6 +58,10 @@ namespace Tools.UI
this.dgvDetail.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
this.dgvDetail.DataSource = this._ds.Tables[0].DefaultView;
this.dgvDetail.CellMouseClick += DgvDetail_CellMouseClick;
//初始化下拉项
this.tscbMonth.Items.Add(this.ThisMonthStart);
this.tscbMonth.Items.Add(this.LastMonthStart);
this.tscbMonth.SelectedIndex = 0;
}
public override bool SaveCheck()
{
......@@ -60,16 +75,8 @@ namespace Tools.UI
Utils.Tip("减分原因必须输入!");
return false;
}
if (this.IsAdd)
{
this.AddRow();
}
else
{
if(!this.EditRow())
return false;
}
return base.SaveCheck();
bool b = this.IsAdd ? this.AddRow() : this.EditRow();
return b && base.SaveCheck();
}
//事件:新增记录
......@@ -84,6 +91,41 @@ namespace Tools.UI
this.IsAdd = false;
this.Save();
}
//事件:生成报告
private void tsbGenReport_Click(object sender, EventArgs e)
{
if (this.tscbMonth.Text.Trim() == "")
{
Utils.Tip("请先选择月份!");
return;
}
//考勤数据-分组
var dic = new Dictionary<string, List<DataRow>>();
var rows = this._ds.Tables[0].Select($"CreateDate > '{this.tscbMonth.Text}'");
foreach (DataRow r in rows)
{
if (Utils.IsIllegalDataRow(r))
continue;
var who = r["Who"].ToString();
if (!dic.Keys.Contains(who))
{
dic.Add(who, new List<DataRow>());
}
dic[who].Add(r);
}
//报告生成
var report = string.Empty;
foreach (var k in dic.Keys)
{
if (dic[k].Count == 0)
continue;
report += $"{k}\t合计:{dic[k].Select(r => r["Minus"] == DBNull.Value ? 0 : Convert.ToInt32(r["Minus"])).Sum()}\r\n";
report += $"{string.Join("\r\n", dic[k].Select(r => $"分值:{r["Minus"]}\t原因:{r["Reason"]}"))}\r\n\r\n";
}
if (string.IsNullOrEmpty(report))
report = "暂无记录!";
Utils.Tip(report, 600, 400);
}
//事件:操作说明
private void tsbHelp_Click(object sender, EventArgs e)
{
......@@ -105,14 +147,25 @@ namespace Tools.UI
/// <summary>
/// 新增数据
/// </summary>
private void AddRow()
private bool AddRow()
{
var filter = $"Who='{this.cbWho.Text}' and Reason='{this.tbReason.Text}' and CreateDate>'{this.ThisMonthStart}'";
var rows = this._ds.Tables[0].Select(filter);
if (rows.Length > 0)
{
Utils.Tip("扣分记录已存在,请检查!");
return false;
}
//増行
var drNew = this._ds.Tables[0].NewRow();
drNew["Minus"] = this.nbMinus.Value;
drNew["Who"] = this.cbWho.Text;
drNew["Reason"] = this.tbReason.Text.Trim();
drNew["CreateDate"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
drNew.EndEdit();
this._ds.Tables[0].Rows.Add(drNew);
return true;
}
/// <summary>
/// 更新数据
......@@ -134,5 +187,7 @@ namespace Tools.UI
return true;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment