BMS-HOSxP Community

HOSxP => Delphi / Pascal => ข้อความที่เริ่มโดย: naj ที่ มิถุนายน 22, 2009, 07:07:04 AM

หัวข้อ: ตัวอย่าง Script สำหรับการนำเข้าข้อมูลตาราง dttm
เริ่มหัวข้อโดย: naj ที่ มิถุนายน 22, 2009, 07:07:04 AM
ใช้สำหรับนำเข้ารายการทันตกรรมจากตาราง nondrugitems เข้าไปตาราง dttm รายการที่นำเข้าได้แก่
code ,name,icode,opd_price1,ipd_price1  เท่านั้นครับ ส่วนรายละเอียดที่เหลืออื่น เช่น icd9,icd10 การจัดหมวดงานคงต้องตามไปแก้แบบ manual ผ่านเมนูรายการหัตถการทันตกรรม ครับ...เด้อ......พี่น้อง
จั๋งซี้มันต้องถอน :D :D :D :D :D :D :D
ชื่อ Import Data To DTTM Table
Fun For Fun :) :) :) :) :) :) :)
คำเตือน Script นี้จะทำการลบข้อมูลในตาราง dttm ก่อนแล้วจึงนำเข้า ดังนั้นขอแนะนำให้สำรองข้อมูลก่อนนำไปใช้

โค๊ด: Delphi
  1. unit Unit18;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, ComCtrls;
  8.  
  9. type
  10.   TForm18 = class(TForm)
  11.     Button1: TButton;
  12.     pg: TProgressBar;
  13.     procedure Button1Click(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.   end;
  19.  
  20. var
  21.   Form18: TForm18;
  22.  
  23. implementation
  24.  
  25. {$R *.dfm}
  26. function addzero(s: string; i: integer): string;
  27. begin
  28.   //result:=s;
  29.   while length(s) < i do
  30.   begin
  31.     s := '0' + s;
  32.   end;
  33.   result := s;
  34. end;
  35.  
  36. procedure TForm18.Button1Click(Sender: TObject);
  37. var tc:tclientdataset;
  38. a:interger;
  39. s:string;
  40.  
  41. begin
  42.   //tc:=tclientdataset.create(nil);
  43.   //tc.data:=hosxp_getdataset('show tables');
  44.  pg.min:=0;
  45.  pg.position:=0;
  46.  a:=0;
  47.  fcds2.close;
  48.  fcds2.datarequest('select * from nondrugitems where income="16" and istatus="Y" order by name');
  49.  fcds2.open;
  50.  pg.max:=fcds2.recordcount;
  51.  fcds2.first;
  52.  fcds.datarequest('EXEC delete from dttm');
  53.  fcds.datarequest('select * from dttm');
  54.  fcds.open;
  55.  while not fcds2.eof do
  56.  begin
  57.  a:=a+1;
  58.  s:=inttostr(a);
  59.   pg.position:= pg.position+1;
  60.   fcds.insert;
  61.   fcds['icode']:=fcds2['icode'];
  62.   fcds['name']:=fcds2['name'];
  63.   fcds['opd_price1']:=fcds2['price'];
  64.   fcds['ipd_price1']:=fcds2['ipd_price'];
  65.   fcds['code']:=addzero(s,6);
  66.   fcds.post;
  67.   fcds2.next;
  68.  end;
  69.  applyupdate_fcds(-1);
  70.  fcds2.close;
  71.  fcds.close;
  72.  showmessage('&#168;&#211;&#185;&#199;&#185; record &#183;&#213;&#232;&#185;&#211;&#224;&#162;&#233;&#210;&#183;&#209;&#233;&#167;&#203;&#193;&#180;   '+inttostr(pg.max) +' Records');
  73.  Showmessage('Process Done');
  74.  end;
  75. end.
  76.  
  77.  
หัวข้อ: Re: ตัวอย่าง Script สำหรับการนำเข้าข้อมูลตาราง dttm
เริ่มหัวข้อโดย: atit ที่ มิถุนายน 22, 2009, 10:07:44 AM
 ;D
หัวข้อ: Re: ตัวอย่าง Script สำหรับการนำเข้าข้อมูลตาราง dttm
เริ่มหัวข้อโดย: doramon ที่ มิถุนายน 22, 2009, 12:42:26 PM
สุดยอด