📄 windel.~pas
字号:
unit WinDel;
//****************************************************************
//*公司名:华夏数码有限公司
//*系统名:考勤管理系统
//*程序名:WinDel
//*
//*--------------------------------------------------------------
//* [年月日] [制造者]
//*--------------------------------------------------------------
//* 2005/12/29 徐二芳
//*
//****************************************************************
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data,clsmain,System.Data.OleDb,borland.Vcl.SysUtils,
System.Resources;
type
TWinDel = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
GroupBox1: System.Windows.Forms.GroupBox;
Butdelete: System.Windows.Forms.Button;
Butcancel: System.Windows.Forms.Button;
CheckBox1: System.Windows.Forms.CheckBox;
CheckBox2: System.Windows.Forms.CheckBox;
dtpriqi: System.Windows.Forms.DateTimePicker;
dtpyuefen: System.Windows.Forms.DateTimePicker;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
procedure TWinDel_Load(sender: System.Object; e: System.EventArgs);
procedure TWinDel_Closed(sender: System.Object; e: System.EventArgs);
procedure Butdelete_Click(sender: System.Object; e: System.EventArgs);
procedure Butcancel_Click(sender: System.Object; e: System.EventArgs);
procedure TWinDel_KeyPress(sender: System.Object; e: System.Windows.Forms.KeyPressEventArgs);
procedure TWinDel_KeyDown(sender: System.Object; e: System.Windows.Forms.KeyEventArgs);
procedure CheckBox1_CheckedChanged(sender: System.Object; e: System.EventArgs);
procedure CheckBox2_CheckedChanged(sender: System.Object; e: System.EventArgs);
{$ENDREGION}
strict protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
private
function data_del: boolean;
{ Private Declarations }
public
constructor Create;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(TWinDel))]
implementation
{$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>
procedure TWinDel.InitializeComponent;
var
resources: System.Resources.ResourceManager;
begin
resources := System.Resources.ResourceManager.Create(TypeOf(TWinDel));
Self.Butdelete := System.Windows.Forms.Button.Create;
Self.Butcancel := System.Windows.Forms.Button.Create;
Self.GroupBox1 := System.Windows.Forms.GroupBox.Create;
Self.dtpyuefen := System.Windows.Forms.DateTimePicker.Create;
Self.dtpriqi := System.Windows.Forms.DateTimePicker.Create;
Self.CheckBox2 := System.Windows.Forms.CheckBox.Create;
Self.CheckBox1 := System.Windows.Forms.CheckBox.Create;
Self.GroupBox1.SuspendLayout;
Self.SuspendLayout;
//
// Butdelete
//
Self.Butdelete.Location := System.Drawing.Point.Create(72, 160);
Self.Butdelete.Name := 'Butdelete';
Self.Butdelete.Size := System.Drawing.Size.Create(75, 40);
Self.Butdelete.TabIndex := 0;
Self.Butdelete.Text := '删 除 ';
Include(Self.Butdelete.Click, Self.Butdelete_Click);
//
// Butcancel
//
Self.Butcancel.Location := System.Drawing.Point.Create(184, 160);
Self.Butcancel.Name := 'Butcancel';
Self.Butcancel.Size := System.Drawing.Size.Create(75, 40);
Self.Butcancel.TabIndex := 1;
Self.Butcancel.Text := '取 消';
Include(Self.Butcancel.Click, Self.Butcancel_Click);
//
// GroupBox1
//
Self.GroupBox1.Controls.Add(Self.dtpyuefen);
Self.GroupBox1.Controls.Add(Self.dtpriqi);
Self.GroupBox1.Controls.Add(Self.CheckBox2);
Self.GroupBox1.Controls.Add(Self.CheckBox1);
Self.GroupBox1.Location := System.Drawing.Point.Create(40, 32);
Self.GroupBox1.Name := 'GroupBox1';
Self.GroupBox1.Size := System.Drawing.Size.Create(264, 104);
Self.GroupBox1.TabIndex := 2;
Self.GroupBox1.TabStop := False;
Self.GroupBox1.Text := ' 请选择删除方式:';
//
// dtpyuefen
//
Self.dtpyuefen.CustomFormat := 'yyyy-MM';
Self.dtpyuefen.Enabled := False;
Self.dtpyuefen.Format := System.Windows.Forms.DateTimePickerFormat.Custom;
Self.dtpyuefen.Location := System.Drawing.Point.Create(104, 56);
Self.dtpyuefen.Name := 'dtpyuefen';
Self.dtpyuefen.Size := System.Drawing.Size.Create(136, 21);
Self.dtpyuefen.TabIndex := 3;
//
// dtpriqi
//
Self.dtpriqi.Enabled := False;
Self.dtpriqi.Location := System.Drawing.Point.Create(104, 24);
Self.dtpriqi.Name := 'dtpriqi';
Self.dtpriqi.Size := System.Drawing.Size.Create(136, 21);
Self.dtpriqi.TabIndex := 2;
//
// CheckBox2
//
Self.CheckBox2.Location := System.Drawing.Point.Create(24, 56);
Self.CheckBox2.Name := 'CheckBox2';
Self.CheckBox2.TabIndex := 1;
Self.CheckBox2.Text := '删除月份:';
Include(Self.CheckBox2.CheckedChanged, Self.CheckBox2_CheckedChanged);
//
// CheckBox1
//
Self.CheckBox1.Location := System.Drawing.Point.Create(24, 24);
Self.CheckBox1.Name := 'CheckBox1';
Self.CheckBox1.TabIndex := 0;
Self.CheckBox1.Text := '删除日期:';
Include(Self.CheckBox1.CheckedChanged, Self.CheckBox1_CheckedChanged);
//
// TWinDel
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
Self.ClientSize := System.Drawing.Size.Create(344, 245);
Self.Controls.Add(Self.GroupBox1);
Self.Controls.Add(Self.Butcancel);
Self.Controls.Add(Self.Butdelete);
Self.Icon := (System.Drawing.Icon(resources.GetObject('$this.Icon')));
Self.KeyPreview := True;
Self.MaximizeBox := False;
Self.Name := 'TWinDel';
Self.Text := '删除数据';
Include(Self.KeyDown, Self.TWinDel_KeyDown);
Include(Self.KeyPress, Self.TWinDel_KeyPress);
Include(Self.Load, Self.TWinDel_Load);
Include(Self.Closed, Self.TWinDel_Closed);
Self.GroupBox1.ResumeLayout(False);
Self.ResumeLayout(False);
end;
{$ENDREGION}
procedure TWinDel.Dispose(Disposing: Boolean);
begin
if Disposing then
begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor TWinDel.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
// TODO: Add any constructor code after InitializeComponent call
//
end;
//****************************************************************
//* 窗体加载 [Load]
//*
//* [参数]
//* 1:系统参数
//* 2:系统参数
//* [返回]
//* 无
//****************************************************************
procedure TWinDel.TWinDel_Load(sender: System.Object; e: System.EventArgs);
begin
try
clsmain.WinDelshowfla:=true;
except
on ex:exception do
begin
messagebox.Show('TWinDel.TWinDel_Load:('+ex.message+')','考勤管理系统');
end;
end;
end;
//****************************************************************
//* 窗体卸载 [closed]
//*
//* [参数]
//* 1:系统参数
//* 2:系统参数
//* [返回]
//* 无
//****************************************************************
procedure TWinDel.TWinDel_Closed(sender: System.Object; e: System.EventArgs);
begin
try
clsmain.WinDelshowfla:=false;
except
on ex:exception do
begin
messagebox.Show('TWinDel.TWinDel_Closed:('+ex.message+')','考勤管理系统');
end;
end;
end;
//****************************************************************
//* TWinlogin_Keydown
//*
//* [参数]
//* 1:系统参数
//* 2:系统参数
//* [返回]
//* 无
//****************************************************************
procedure TWinDel.TWinDel_KeyDown(sender: System.Object; e: System.Windows.Forms.KeyEventArgs);
begin
try
case e.KeyCode of
//f7:='确定'
keys.F7:
begin
e.Handled:=false;
self.Butdelete.Focus();
end;
// f9='取消'
keys.F9:
begin
e.Handled:=false;
self.butcancel.Focus();
end;
end;
except
on ex:exception do
begin
messagebox.Show('TWinDel.TWinDel_KeyDown:('+ex.message+')','考勤管理系统');
end;
end;
end;
//****************************************************************
//* TWinlogin_KeyPress
//*
//* [参数]
//* 1:系统参数
//* 2:系统参数
//* [返回]
//* 无
//****************************************************************
procedure TWinDel.TWinDel_KeyPress(sender: System.Object; e: System.Windows.Forms.KeyPressEventArgs);
begin
try
Case e.KeyChar of
char(13):
begin
e.Handled := False;
SendKeys.Send('{Tab}');
end;
end;
except
on ex:Exception do
begin
messagebox.Show('TWinDel.TWinDel_KeyPress : (' + ex.message + ') ' , '考勤管理系统');
end;
end;
end;
//****************************************************************
//*Butdelete_Click
//*
//* [参数]
//* 1:系统参数
//* 2:系统参数
//* [返回]
//* 无
//****************************************************************
procedure TWinDel.Butdelete_Click(sender: System.Object; e: System.EventArgs);
begin
try
if MessageBox.Show('真的要删除该条记录吗?','提示',MessageBoxButtons.OKCancel,MessageboxIcon.Information) =
System.Windows.Forms.DialogResult.OK then
begin
//数据删除
If Data_Del() = True Then
begin
messagebox.Show('数据已删除完成。', '考勤管理系统');
end
Else
begin
messagebox.Show('数据删除失败。', '考勤管理系统');
End;
end;
except
on ex:exception do
begin
messagebox.Show('TWinDel.Butdelete_Click:('+ex.message+')','考勤管理系统');
end;
end;
end;
//****************************************************************e
//*Butcancel_Click
//*
//* [参数]
//* 1:系统参数
//* 2:系统参数
//* [返回]
//* 无
//****************************************************************
procedure TWinDel.Butcancel_Click(sender: System.Object; e: System.EventArgs);
begin
try
self.Close;
except
on ex:exception do
begin
messagebox.Show('TWinDel.Butdelete_Click:('+ex.message+')','考勤管理系统');
end;
end;
end;
//****************************************************************
//* 数据删除
//*
//* [参数]
//* 无
//* [返回]
//* 实行状况
//* True:成功
//* False:失败
//****************************************************************
function twindel.data_del():boolean;
var
W_SQL:string;
w_dtpriqi:string;
w_dtpyuefen:string;
begin
try
//设置当前光标为忙等待状态
self.Cursor:=cursors.WaitCursor;
w_dtpriqi := dtpriqi.Text.Trim();
w_dtpyuefen:=dtpyuefen.Text.Trim();
w_SQL := '';
w_SQL := w_SQL + ' DELETE FROM 员工出勤表';
w_SQL := w_SQL + ' WHERE 日期='''+w_dtpriqi+'''';
w_SQL := w_SQL + ' OR left(日期,7)='''+w_dtpyuefen+'''';
clsmain.TClass1.Create.BeginTrans(); //开始事务
clsmain.TClass1.Create.Cmn_Ado_Execute(w_SQL); //执行SQL语句
clsmain.TClass1.Create.Commit(); //提交事务
//设置当前光标为默认状态
self.Cursor := Cursors.Default;
//正常返回值的设定
result:=true;
except
on ex:exception do
begin
//事务回滚
clsmain.TClass1.Create.rollback();
result:=false;
messagebox.Show('TWinDel.Butdelete_Click:('+ex.message+')','考勤管理系统');
end;
end;
end;//****************************************************************
//* CheckBox1_CheckedChanged 控制出勤月份的可用状态
//* [参数]
//* 无
//*
//* [返回]
//* 无
//****************************************************************
procedure TWinDel.CheckBox2_CheckedChanged(sender: System.Object; e: System.EventArgs);
begin
try
IF CheckBox2.Checked =true then
begin
CheckBox1.Checked:=false;
dtpriqi.Enabled :=false;
dtpyuefen.Enabled:=true;
end
else
begin
dtpriqi.Enabled :=true;
dtpyuefen.Enabled:=false;
end;
except
on ex:exception do
begin
messagebox.Show('TWinDel.CheckBox2_CheckedChanged:('+ex.message+')','考勤管理系统');
end;
end;
end;
//****************************************************************
//* CheckBox1_CheckedChanged 控制出勤日期的可用状态
//* [参数]
//* 无
//*
//* [返回]
//* 无
//****************************************************************
procedure TWinDel.CheckBox1_CheckedChanged(sender: System.Object; e: System.EventArgs);
begin
try
IF CheckBox1.Checked =true then
begin
dtpriqi.Enabled :=true;
dtpyuefen.Enabled:=false;
end
else
begin
dtpriqi.Enabled :=false;
// dtpyuefen.Enabled:=true;
end;
except
on ex:exception do
begin
messagebox.Show('TWinDel.CheckBox1_CheckedChanged:('+ex.message+')','考勤管理系统');
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -