เป็น script สำหรับดึงค่า trx ที่หายกลับมาใช้ใหม่ โดยสามารถดึงตามวันที่ และ an
เพื่อโรงบาลไหนนำไปใช้ประโยชน์ครับ
ลองติดตั้งดูแล้วไม่ได้ครับ มันไม่นำเข้าให้ append แล้วก็ไม่ได้ รกวนขอโค๊ดของ script หน่อย
souceunit beforeDelAdmit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Edit2: TEdit;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit3: TEdit;
Label3: TLabel;
pg: TProgressBar;
procedure Button1Click(Sender: TObject);
private
public
//function MessageDlgPos ( const Message : string; DialogType : TMsgDlgType; Buttons : TMsgDlgButtons; HelpContext : Longint; X, Y : Integer ) : Integer;
end;
function MessageDlgPos ( const Message : string; DialogType : TMsgDlgType; Buttons : TMsgDlgButtons; HelpContext : Longint; X, Y : Integer ) : Integer;
var
Form1: TForm1;
ds1:String; // Begin date
ds2:String; // End date
C_DATE1 : String; // Condition Date 1
C_DATE2 : String;
aa :string;
implementation
{$R *.dfm}
//=============================
procedure TForm1.Button1Click(Sender: TObject);
var tc,ts:tclientdataset; i:integer;
begin
if Application.MessageBox(
'á¹èã¨ÇèÒ¨Ðà¾ÔèÁ¢ÑÍÁÙÅËÃ×ÍäÁè?',
'CONFIRM',
MB_YESNO Or MB_ICONQUESTION) = '6' then
begin
get_initial;
tc:=tclientdataset.create(nil);
ts:=tclientdataset.create(nil);
tc.data:=hosxp_getdataset('select order_no from opitemrece_trx where vstdate between "'+ds1+'" and "'+ds2+'" and an is not null and order_no not in (select order_no from opitemrece where vstdate between "'+ds1+'" and "'+ds2+'" and an is not null) ');
pg.position:=0;
pg.max:=tc.recordcount;
while not tc.eof do
begin
//showmessage(tc.fields[0].asstring);
hosxp_getdataset('insert into opitemrece select * from opitemrece_trx where vstdate between "'+ds1+'" and "'+ds2+'" and an is not null and order_no not in (select order_no from opitemrece where vstdate between "'+ds1+'" and "'+ds2+'" and an is not null)');
pg.position:=pg.position+1;
application.processmessages;
tc.next;
end;
showmessage('àÃÕºÃéÍÂáÅéÇ');
tc.free;
ts.free;
end;
end;
//=============================
procedure TForm1.Button2Click(Sender: TObject);
var tc,ts:tclientdataset; i:integer;
begin
if Application.MessageBox(
'á¹èã¨ÇèÒ¨Ðà¾ÔèÁ¢ÑÍÁÙÅËÃ×ÍäÁè?',
'CONFIRM',
MB_YESNO Or MB_ICONQUESTION) = '6' then
begin
get_initial;
tc:=tclientdataset.create(nil);
ts:=tclientdataset.create(nil);
tc.data:=hosxp_getdataset('select order_no,icode from opitemrece_trx where an="'+txAN.text+'"');
pg.position:=0;
pg.max:=tc.recordcount;
while not tc.eof do
begin
//showmessage(tc.fields[0].asstring);
hosxp_getdataset('insert into opitemrece select * from opitemrece_trx where an="'+txAN.text+'"');
pg.position:=pg.position+1;
application.processmessages;
tc.next;
end;
showmessage('àÃÕºÃéÍÂáÅéÇ');
tc.free;
ts.free;
end;
end;
procedure get_initial;
begin
ds1 := formatdatetime('yyyy-mm-dd', cxdateedit1.date); // Set ds1 = dateedit1
ds2 := formatdatetime('yyyy-mm-dd', cxdateedit2.date); // Set ds2 = dateedit2
//linelimit := txLimit.Text; // set linelimit
//C_MESSAGE := '';
// set date state
//showmessage(ds1);
end;
end.
DFMobject Form1: TForm1
Left =100
Top = 100
Caption = 'Script ´Ö¤èÒ TRX ¡ÅѺÁÒãªéãËÁè '
ClientHeight = 492
ClientWidth = 567
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PixelsPerInch = 96
TextHeight = 13
object JvNavPanelHeader1: TJvNavPanelHeader
Left = 0
Top = 0
Width = 839
Height = 40
Align = alTop
Caption = ''
Font.Charset = DEFAULT_CHARSET
Font.Color = clWhite
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ParentFont = False
ImageIndex = 0
end
object SeSkinPanel2: TSeSkinPanel
Left = 0
Top = 43
Width = 839
Height = 101
Performance = kspNoBuffer
Transparent = False
Align = alTop
AnimateRoll = False
BevelWidth = 1
BorderWidth = 3
ButtonKind = pbkRoll
Caption = ' ÊÒÁÒáÓ˹´à×è͹ä¢àÅ×Í¡ªèÇÇѹ·ÕèÁÒÃѺºÃÔ¡ÒÃä´é'
Rolled = False
ParentRoll = False
ShowBevel = True
ShowButton = True
ShowCaption = True
SkinObject = 'Panel'
ExplicitWidth = 634
NormalHeight = {00000000}
object Label2: TLabel
Left = 70
Top = 60
Width = 50
Height = 18
Caption = 'µÑéáµèÇѹ·Õè'
end
object LbAN: TLabel
Left = 45
Top = 30
Width = 50
Height = 18
Caption = 'AN ·ÕèµéÍ¡ÒôÖ'
end
object Lbto: TLabel
Left = 250
Top = 60
Width = 50
Height = 18
Caption = 'Ö'
end
object cxDateEdit1: TcxDateEdit
Left = 140
Top = 55
TabOrder = 1
Width = 100
end
object cxDateEdit2: TcxDateEdit
Left = 280
Top = 55
TabOrder = 1
Width = 100
end
object txAN: TEdit
Left = 140
Top = 25
Width = 70
Height = 31
TabOrder = 10
Text = '123456789'
end
end
object Button1: TButton
Left = 80
Top = 290
Width = 393
Height = 73
Caption = ' ´Ö TRX ¡ÅѺÁÒãªéãËÁè µÒÁÇѹ·Õè'
TabOrder = 2
OnClick = Button1Click
end
object Button2: TButton
Left = 80
Top = 180
Width = 393
Height = 73
Caption = ' ´Ö TRX ¡ÅѺÁÒãªéãËÁè µÒÁ AN '
TabOrder = 2
OnClick = Button2Click
end
object pg: TProgressBar
Left = 80
Top = 400
Width = 393
Height = 17
TabOrder = 6
end
end