⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventadd.pas

📁 三層源碼,DELPHI寫的三層源碼,三層源碼,
💻 PAS
字号:
unit eventadd;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, ComCtrls, xpButton, Menus;

type
  Tevent_add = class(TForm)
    Bevel1: TBevel;
    Label2: TLabel;
    ComboBox2: TComboBox;
    Label1: TLabel;
    Label4: TLabel;
    Memo1: TMemo;
    date1: TDateTimePicker;
    Edit1: TEdit;
    ComboBox1: TComboBox;
    Label5: TLabel;
    xpButton1: TxpButton;
    xpButton2: TxpButton;
    Label3: TLabel;
    Edit2: TEdit;
    Label6: TLabel;
    Edit3: TEdit;
    xpButton3: TxpButton;
    pop1: TPopupMenu;
    procedure xpButton1Click(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure FormShow(Sender: TObject);
    procedure xpButton2Click(Sender: TObject);
    procedure xpButton3Click(Sender: TObject);
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    function checkinput:boolean;
    procedure clearedit;
    procedure makepopup;
    procedure onpopup(Sender: TObject);
    { Private declarations }
  public
    { Public declarations }
  end;

var
  event_add: Tevent_add;

implementation
uses sldata,shareunit;
{$R *.DFM}

function Tevent_add.checkinput:boolean;
var x:string;
begin
x:='0000';
if edit1.text<>'' then x[1]:='1';
if edit2.text<>'' then x[2]:='1';
if edit3.text<>'' then x[3]:='1';
if memo1.text<>'' then x[4]:='1';
result:=x='1111';
end;

procedure Tevent_add.clearedit;
begin
combobox1.itemindex:=0;
combobox2.itemindex:=0;
date1.date:=date;
edit1.text:='';
edit2.text:='';
edit3.text:='';
memo1.text:='';
edit2.setfocus;
end;

procedure Tevent_add.makepopup;
var msg:string; n:integer;
    pitem:tmenuitem;
begin
pop1.Items.Clear;
with tstringlist.create do
  try
  add(makeparams('operid',inttostr(Query_event)));
  add(makeparams('funid',inttostr(public_list_ex02)));
  msg:=text;
  finally
  free;
  end;
sl_data.querysinfo.data:=sl_data.querysinfo.DataRequest(msg);
if sl_data.querysinfo.RecordCount>0 then
for n:=1 to sl_data.querysinfo.RecordCount do
   begin
   pitem:=tmenuitem.Create(pop1.Items);
   pitem.Caption:=sl_data.querysinfo['remark'];
   pitem.Hint:=sl_data.querysinfo['remark'];
   pitem.OnClick:=onpopup;
   pop1.Items.Add (pitem);
   sl_data.querysinfo.Next;
   end;
end;

procedure Tevent_add.onpopup(Sender: TObject);
begin
memo1.lines.add(tmenuitem(sender).hint);
end;

procedure Tevent_add.xpButton1Click(Sender: TObject);
var msg:string;
begin
if checkinput then
   begin
   with tstringlist.create do
     try
     add(makeparams('trepeat',combobox2.text));
     add(makeparams('tinqt',edit1.text));
     add(makeparams('tuid',edit2.text));
     add(makeparams('textday',edit3.text));
     add(makeparams('tfilter',combobox1.text));
     add(makeparams('tremark',XorEncode(floattostr(pi),memo1.text)));
     add(makeparams('tinure_date',datetostr(date1.date)));
     msg:=text;
     finally
     free;
     end;
   if sl_data.event_model(public_add,msg)then
     begin
     showmessage('记录添加成功!');
     clearedit;
     end;   
   end else showmessage('请输入完整信息!');
end;

procedure Tevent_add.FormPaint(Sender: TObject);
begin
sl_data.formonpaint(self);
end;

procedure Tevent_add.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
If Key = #13 Then
  Begin
  If HiWord(GetKeyState(VK_SHIFT)) <> 0 then
     SelectNext(Sender as TWinControl,False,True)
  else
   SelectNext(Sender as TWinControl,True,True);
   Key := #0
  end;
end;

procedure Tevent_add.FormShow(Sender: TObject);
begin
clearedit;
end;

procedure Tevent_add.xpButton2Click(Sender: TObject);
begin
close;
end;

procedure Tevent_add.xpButton3Click(Sender: TObject);
var p:TPoint;
begin
makepopup;
GetCursorPos(p);
pop1.Popup(p.x,p.y);
end;

procedure Tevent_add.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if not ((key in[96..105])or(key in[48..57])or(key in[8,13,110,190])) then
   begin
   showmessage('不是有效的字符.请重新输入.');
   tedit(sender).Clear;
   end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -