Commit 246fb849 authored by 徐盼盼's avatar 徐盼盼

Tool

1.新增字段
2.新增、修改记录使用弹窗
3.增加权限控制
parent fb04baf9
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tools.MyData
{
public class EvaluationHelper
{
//public static dataset
}
}
...@@ -119,11 +119,18 @@ ...@@ -119,11 +119,18 @@
</Compile> </Compile>
<Compile Include="MyData\AnlysisHelper.cs" /> <Compile Include="MyData\AnlysisHelper.cs" />
<Compile Include="MyData\DBHelper.cs" /> <Compile Include="MyData\DBHelper.cs" />
<Compile Include="MyData\EvaluationHelper.cs" />
<Compile Include="MyData\SqlHelper.cs" /> <Compile Include="MyData\SqlHelper.cs" />
<Compile Include="MyUtils\DrawHelper.cs" /> <Compile Include="MyUtils\DrawHelper.cs" />
<Compile Include="MyUtils\InputtingService.cs" /> <Compile Include="MyUtils\InputtingService.cs" />
<Compile Include="MyUtils\SegPicture.cs" /> <Compile Include="MyUtils\SegPicture.cs" />
<Compile Include="MyUtils\TimeWatch.cs" /> <Compile Include="MyUtils\TimeWatch.cs" />
<Compile Include="UI\Popups\wEditEvaluation.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\Popups\wEditEvaluation.Designer.cs">
<DependentUpon>wEditEvaluation.cs</DependentUpon>
</Compile>
<Compile Include="UI\sys\wLogin.cs"> <Compile Include="UI\sys\wLogin.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
...@@ -386,6 +393,9 @@ ...@@ -386,6 +393,9 @@
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
</Compile> </Compile>
<EmbeddedResource Include="UI\Popups\wEditEvaluation.resx">
<DependentUpon>wEditEvaluation.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\sys\wLogin.resx"> <EmbeddedResource Include="UI\sys\wLogin.resx">
<DependentUpon>wLogin.cs</DependentUpon> <DependentUpon>wLogin.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
namespace Tools.UI.Popups
{
partial class wEditEvaluation
{
/// <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()
{
this.btnQuit = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel();
this.btnSave = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.cbWho = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.tbReason = new System.Windows.Forms.TextBox();
this.nbMinus = new System.Windows.Forms.NumericUpDown();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.panel2.SuspendLayout();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nbMinus)).BeginInit();
this.SuspendLayout();
//
// btnQuit
//
this.btnQuit.Dock = System.Windows.Forms.DockStyle.Right;
this.btnQuit.Location = new System.Drawing.Point(251, 0);
this.btnQuit.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnQuit.Name = "btnQuit";
this.btnQuit.Size = new System.Drawing.Size(88, 31);
this.btnQuit.TabIndex = 3;
this.btnQuit.Text = "关闭";
this.btnQuit.UseVisualStyleBackColor = true;
this.btnQuit.Click += new System.EventHandler(this.btnQuit_Click);
//
// panel2
//
this.panel2.Controls.Add(this.btnSave);
this.panel2.Controls.Add(this.btnQuit);
this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel2.Location = new System.Drawing.Point(0, 165);
this.panel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(339, 31);
this.panel2.TabIndex = 3;
//
// btnSave
//
this.btnSave.Dock = System.Windows.Forms.DockStyle.Right;
this.btnSave.Location = new System.Drawing.Point(163, 0);
this.btnSave.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(88, 31);
this.btnSave.TabIndex = 4;
this.btnSave.Text = "保存";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// panel1
//
this.panel1.Controls.Add(this.cbWho);
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.tbReason);
this.panel1.Controls.Add(this.nbMinus);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(339, 165);
this.panel1.TabIndex = 4;
//
// cbWho
//
this.cbWho.FormattingEnabled = true;
this.cbWho.Location = new System.Drawing.Point(221, 21);
this.cbWho.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.cbWho.Name = "cbWho";
this.cbWho.Size = new System.Drawing.Size(93, 25);
this.cbWho.TabIndex = 11;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(147, 24);
this.label3.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(68, 17);
this.label3.TabIndex = 10;
this.label3.Text = "员工姓名:";
//
// tbReason
//
this.tbReason.Location = new System.Drawing.Point(97, 68);
this.tbReason.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.tbReason.Multiline = true;
this.tbReason.Name = "tbReason";
this.tbReason.Size = new System.Drawing.Size(217, 79);
this.tbReason.TabIndex = 9;
//
// nbMinus
//
this.nbMinus.Location = new System.Drawing.Point(75, 22);
this.nbMinus.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.nbMinus.Maximum = new decimal(new int[] {
30,
0,
0,
0});
this.nbMinus.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.nbMinus.Name = "nbMinus";
this.nbMinus.Size = new System.Drawing.Size(62, 23);
this.nbMinus.TabIndex = 8;
this.nbMinus.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(19, 68);
this.label2.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(68, 17);
this.label2.TabIndex = 7;
this.label2.Text = "减分原因:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(19, 24);
this.label1.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(44, 17);
this.label1.TabIndex = 6;
this.label1.Text = "减分:";
//
// wEditEvaluation
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(339, 196);
this.Controls.Add(this.panel1);
this.Controls.Add(this.panel2);
this.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.Name = "wEditEvaluation";
this.Text = "员工考核编辑界面";
this.Load += new System.EventHandler(this.wEditEvaluation_Load);
this.panel2.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nbMinus)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btnQuit;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ComboBox cbWho;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox tbReason;
private System.Windows.Forms.NumericUpDown nbMinus;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
}
}
\ No newline at end of file
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;
using Tools.MyCommon;
using Tools.MyUtils;
namespace Tools.UI.Popups
{
public partial class wEditEvaluation : wEditBasic
{
private DataRow _drv;
List<string> UserList = null;
private bool _isCopy = false;
public wEditEvaluation(DataRow drv, bool isCopy = false)
{
this._drv = drv;
this._isCopy = isCopy;
InitializeComponent();
}
private void wEditEvaluation_Load(object sender, EventArgs e)
{
//初始化数据库链接
var link = Utils.GetDbLinkString204("FTT_Work");
this.InitDBHelper(link);
#region 绑定数据
//查询员工姓名
string userSql = $@"SELECT DISTINCT Name FROM dbo.AC_User
WHERE WorkState = '在职' AND IsStop = 0
AND ISNULL(Name, '') NOT IN('', 'test', '王杰平', '李双')
AND UserType NOT IN(5312, 5313)";
var dt = this._db.GetDataTable(userSql, "AC_User", false);
this.UserList = dt.Rows.Cast<DataRow>().Select(r => r[0].ToString()).ToList();
//初始化编辑信息-员工姓名下拉项
this.cbWho.Items.Clear();
this.cbWho.Items.AddRange(this.UserList.ToArray());
#endregion
// 新增
if (wEvaluationOfEmployee.IsAdd)
this.Text = "新增记录";
else
{
if (_isCopy)
this.Text = "复制记录并新增";
else
{
this.Text = "更新记录";
this.nbMinus.Value = (int)_drv["Minus"];
this.cbWho.Text = _drv["Who"].ToString();
this.tbReason.Text = _drv["Reason"].ToString();
}
}
}
public new bool Save()
{
if(!CheckBeforeSave())
return false;
if (wEvaluationOfEmployee.IsAdd || _isCopy)
{
if(!Add(this._drv))
return false;
}
else
{
if (!Edit(this._drv))
return false;
}
return true;
}
public bool CheckBeforeSave()
{
if(this.nbMinus.Value < 1)
{
Utils.Tip("减分不得小于1!");
return false;
}
if (this.cbWho.Text == string.Empty)
{
Utils.Tip("员工姓名必须输入!");
return false;
}
if (this.tbReason.Text == string.Empty)
{
Utils.Tip("减分原因必须输入!");
return false;
}
if (MessageBox.Show("是否确认保存?", "保存前确认", MessageBoxButtons.YesNo) == DialogResult.No)
return false;
this._drv["Minus"] = nbMinus.Value;
this._drv["Who"] = cbWho.Text;
this._drv["Reason"] = tbReason.Text;
return true;
}
private void btnQuit_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnSave_Click(object sender, EventArgs e)
{
if (Save())
{
MessageBox.Show("保存成功!");
DialogResult = DialogResult.OK;
this.Close();
}
}
private bool Add(DataRow r)
{
string sql = $@"INSERT INTO FTT_EvaluationOfEmployee(Minus,Who,Reason,CreateDate,CreateUserName,LastModifiedUserName,LastModifiedDate)
VALUES({r["Minus"]},'{r["Who"]}','{r["Reason"]}',GETDATE(),'{LoginInfo.UserName}','{LoginInfo.UserName}',GETDATE());
SELECT SCOPE_IDENTITY();";
try
{
r["ID"] = this._db.ExecScalar(sql);
r["CreateDate"] = DateTime.Now.ToString("yyyy-MM-dd hh:mm");
r["CreateUserName"] = LoginInfo.UserName;
r["LastModifiedUserName"] = LoginInfo.UserName;
r["LastModifiedDate"] = DateTime.Now.ToString("yyyy-MM-dd hh:mm");
}
catch (Exception ex)
{
Utils.Tip("保存出错:" + ex.Message);
return false;
}
return true;
}
private bool Edit(DataRow r)
{
string sql = $@"UPDATE FTT_EvaluationOfEmployee SET Minus = {r["Minus"]},Who = '{r["Who"]}',Reason = '{r["Reason"]}',
LastModifiedUserName = '{LoginInfo.UserName}',LastModifiedDate = GETDATE()
WHERE ID = {r["ID"]}";
try
{
this._db.ExecNonSql(sql);
r["LastModifiedUserName"] = LoginInfo.UserName;
r["LastModifiedDate"] = DateTime.Now.ToString("yyyy-MM-dd hh:mm");
}
catch (Exception ex)
{
Utils.Tip("保存出错:" + ex.Message);
}
return true;
}
}
}
<?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>
\ No newline at end of file
This diff is collapsed.
...@@ -10,7 +10,7 @@ using System.Windows.Forms; ...@@ -10,7 +10,7 @@ using System.Windows.Forms;
using Tools.MyCommon; using Tools.MyCommon;
using Tools.MyUtils; using Tools.MyUtils;
using Tools.MyData; using Tools.MyData;
using Tools.UI.Popups;
namespace Tools.UI namespace Tools.UI
{ {
public partial class wEvaluationOfEmployee : wEditBasic public partial class wEvaluationOfEmployee : wEditBasic
...@@ -24,9 +24,8 @@ namespace Tools.UI ...@@ -24,9 +24,8 @@ namespace Tools.UI
/// </summary> /// </summary>
string ThisMonthStart => DateTime.Now.ToString("yyyy-MM-01"); string ThisMonthStart => DateTime.Now.ToString("yyyy-MM-01");
List<string> UserList = null; public static bool IsAdd = false;
public static DataRow CurrentEditRow;
bool IsAdd = false;
int EditID = 0; int EditID = 0;
public wEvaluationOfEmployee() public wEvaluationOfEmployee()
...@@ -48,16 +47,32 @@ namespace Tools.UI ...@@ -48,16 +47,32 @@ namespace Tools.UI
} }
public override void InitData() public override void InitData()
{ {
//只取最近两个月的数据 /*LoginInfo.UserName = "徐盼盼";
string sql = $"SELECT * FROM FTT_EvaluationOfEmployee WHERE CreateDate > '{this.LastMonthStart}'"; LoginInfo.IsPrincipal = false;*/
LoginInfo.UserName = "罗显健";
LoginInfo.IsPrincipal = true;
//只取最近两个月的数据 (判断是否部门负责人,根据权限显示对应数据)
string sql = $@"DECLARE @IsPrincipal BIT = {Convert.ToInt32(LoginInfo.IsPrincipal)}
IF(@IsPrincipal = 0)
SELECT * FROM FTT_EvaluationOfEmployee
WHERE Who = '{LoginInfo.UserName}' AND CreateDate > '{this.LastMonthStart}';
ELSE
BEGIN
SELECT * FROM dbo.FTT_EvaluationOfEmployee e
INNER JOIN (
SELECT u.Name FROM dbo.AC_User u
INNER JOIN dbo.AC_GroupUser gu ON gu.UserID = u.ID
WHERE gu.GroupTreeID IN (
SELECT gu.GroupTreeID FROM dbo.AC_GroupUser gu
INNER JOIN dbo.AC_User u ON u.ID = gu.UserID
INNER JOIN dbo.AC_GroupTree gt ON gt.ID = gu.GroupTreeID
WHERE u.Name = '{LoginInfo.UserName}')
) u ON u.Name = e.Who
WHERE e.CreateDate > '{this.LastMonthStart}'
END";
this._ds = this._db.GetData(sql, "FTT_EvaluationOfEmployee"); this._ds = this._db.GetData(sql, "FTT_EvaluationOfEmployee");
//查询员工姓名
string userSql = $@"SELECT DISTINCT Name FROM dbo.AC_User
WHERE WorkState = '在职' AND IsStop = 0
AND ISNULL(Name, '') NOT IN('', 'test', '王杰平', '李双')
AND UserType NOT IN(5312, 5313)";
var dt = this._db.GetDataTable(userSql, "AC_User", false);
this.UserList = dt.Rows.Cast<DataRow>().Select(r => r[0].ToString()).ToList();
} }
public override void InitUI() public override void InitUI()
{ {
...@@ -68,37 +83,44 @@ namespace Tools.UI ...@@ -68,37 +83,44 @@ namespace Tools.UI
this.tscbMonth.Items.Add(this.ThisMonthStart); this.tscbMonth.Items.Add(this.ThisMonthStart);
this.tscbMonth.Items.Add(this.LastMonthStart); this.tscbMonth.Items.Add(this.LastMonthStart);
this.tscbMonth.SelectedIndex = 0; this.tscbMonth.SelectedIndex = 0;
//初始化编辑信息-员工姓名下拉项
this.cbWho.Items.Clear();
this.cbWho.Items.AddRange(this.UserList.ToArray());
} }
public override bool SaveCheck()
private bool CheckBeforeEdit()
{ {
if (this.cbWho.Text == string.Empty) if(!LoginInfo.IsPrincipal)
{ {
Utils.Tip("员工姓名必须输入!"); MessageBox.Show("非部门负责人不可编辑!");
return false; return false;
} }
if (this.tbReason.Text == string.Empty) return true;
{
Utils.Tip("减分原因必须输入!");
return false;
}
bool b = this.IsAdd ? this.AddRow() : this.EditRow();
return b && base.SaveCheck();
} }
//事件:新增记录 //事件:新增记录
private void tsbAdd_Click(object sender, EventArgs e) private void tsbAdd_Click(object sender, EventArgs e)
{ {
this.IsAdd = true; if (!CheckBeforeEdit())
this.Save(); return;
IsAdd = true;
DataRow drv = this._ds.Tables[0].NewRow();
wEditEvaluation wEdit = new wEditEvaluation(drv);
if (wEdit.ShowDialog() == DialogResult.OK)
this._ds.Tables[0].Rows.Add(drv);
} }
//事件:更新记录 //事件:更新记录
private void tsbUpdate_Click(object sender, EventArgs e) private void tsbUpdate_Click(object sender, EventArgs e)
{ {
this.IsAdd = false; if (!CheckBeforeEdit())
this.Save(); return;
if (CurrentEditRow == null)
{
MessageBox.Show("未选择需要编辑的行!");
return;
}
IsAdd = false;
wEditEvaluation wEdit = new wEditEvaluation(CurrentEditRow);
wEdit.ShowDialog();
} }
//事件:生成报告 //事件:生成报告
private void tsbGenReport_Click(object sender, EventArgs e) private void tsbGenReport_Click(object sender, EventArgs e)
...@@ -150,56 +172,10 @@ namespace Tools.UI ...@@ -150,56 +172,10 @@ namespace Tools.UI
var rowIndex = this.dgvDetail.CurrentRow.Index; var rowIndex = this.dgvDetail.CurrentRow.Index;
if (rowIndex < 0 || rowIndex >= this._ds.Tables[0].DefaultView.Count) if (rowIndex < 0 || rowIndex >= this._ds.Tables[0].DefaultView.Count)
return; return;
var drv = this._ds.Tables[0].DefaultView[rowIndex]; CurrentEditRow = this._ds.Tables[0].Rows[rowIndex];
this.EditID = (int)drv["ID"];
this.nbMinus.Value = (int)drv["Minus"];
this.cbWho.Text = drv["Who"].ToString();
this.tbReason.Text = drv["Reason"].ToString();
} }
/// <summary>
/// 新增数据
/// </summary>
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>
/// 更新数据
/// </summary>
private bool EditRow()
{
//查找编辑行
var drEdit = this._ds.Tables[0].Select($"ID={this.EditID}").FirstOrDefault();
if (this.EditID == 0 || drEdit == null)
{
Utils.Tip("请选择您要编辑的行!");
return false;
}
//编辑赋值
drEdit["Minus"] = this.nbMinus.Value;
drEdit["Who"] = this.cbWho.Text;
drEdit["Reason"] = this.tbReason.Text.Trim();
drEdit.EndEdit();
return true;
}
/// <summary> /// <summary>
/// 合并任务延期数据 /// 合并任务延期数据
......
...@@ -132,6 +132,18 @@ ...@@ -132,6 +132,18 @@
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="CreateUserName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CreateDate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="LastModifiedUserName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="LastModifiedDate.UserAddedColumn" 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"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>57</value> <value>57</value>
</metadata> </metadata>
......
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