ผู้เขียน หัวข้อ: ตัวอย่าง Script สำหรับการนำเข้าข้อมูลตาราง dttm  (อ่าน 10896 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ naj

  • Hero Member
  • *****
  • กระทู้: 2,449
  • Respect: +8
    • ดูรายละเอียด
    • http://www.luangphopern-hospital.com
ใช้สำหรับนำเข้ารายการทันตกรรมจากตาราง 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.  
« แก้ไขครั้งสุดท้าย: มิถุนายน 22, 2009, 07:14:21 AM โดย naj »
Yindee And Tan

ออฟไลน์ atit

  • Hero Member
  • *****
  • กระทู้: 1,233
  • ขออภัย ความรู้ไม่มาก
  • Respect: +3
    • ดูรายละเอียด
Re: ตัวอย่าง Script สำหรับการนำเข้าข้อมูลตาราง dttm
« ตอบกลับ #1 เมื่อ: มิถุนายน 22, 2009, 10:07:44 AM »
0
 ;D
"-"           รู้อะไรไม่สู้รู้วิชา รู้จักหาในบอร์ดเป็นยอดคน                   tel 081-3202497 
ความรู้เพียงเล็กน้อย อาจช่วยคนเป็นร้อยแก้ปัญหา
เพราะฉะนั้น อย่ากลัวที่จะบอกสิ่งที่คุณรู้กับคนอื่น แม้จะเป็นเรื่องพื้นๆ ก็ตาม
cen-os 64 bit ,ram 4 g ,my sql 5.1.33
วิธีแนะนำตัวเอง  http://hosxp.net/index.php?option=com_smf&Itemid=28&topic=4413.0
ก่อนตั้งกระทู้ใหม่ ลองหาดูกระทู่เก่าก่อนดีบ่? อาจได้คำตอบเร็วกว่าเด้อ   http://hosxp.net/index.php?option=com_smf&Itemid=28&action=search
วิธีขอบคุณผู้ที่ตอบคำถามถูกใจ   http://hosxp.net/index.php?option=com_smf&Itemid=28&topic=8180.0
การเปิดใช้ Server แยก เก็บรูปภาพ/log http://hosxp.net/index.php?option=com_smf&Itemid=28&topic=10169.0
การติดตั้ง mysql http://hosxp.net/index.php?option=com_smf&Itemid=28&topic=11513.0
sql วันละคำกับคุณperjer http://hosxp.net/index.php?option=com_smf&Itemid=28&topic=4007.0
8)ยินดีต้อนรับสู่สังคมแห่งการแบ่งปัน- การแบ่งปันทำให้สังคมน่าอยู่- ;Dขอขอบคุณ
- อ.mn ผู้เขียนโปรแกรมดีๆและช่วยขึ้นระบบ
- อ.อ๊อด,อ.นาจ,อ.ขวด,อ.โก้,อ.nutawut,อ.ตั๊ก,อ.JD,อ.กิจ...ที่คอยช่วยเหลือและให้ความรู้
- ทุกท่านที่ช่วย review โปรแกรมทำให้เราได้ใช้โปรแกรมที่สุดยอด(อยากให้เป็นโปรแกรมระดับประเทศเร็วๆจังจะได้ไม่ต้องง้อ สปสช 5555 :D)

doramon

  • บุคคลทั่วไป
Re: ตัวอย่าง Script สำหรับการนำเข้าข้อมูลตาราง dttm
« ตอบกลับ #2 เมื่อ: มิถุนายน 22, 2009, 12:42:26 PM »
0
สุดยอด