BMS-HOSxP Community

HOSxP => Report Exchange => ข้อความที่เริ่มโดย: gu_prajag ที่ ตุลาคม 21, 2014, 10:16:54 AM

หัวข้อ: ดึงรายที่ต้องการ ใส่ใน combo box แล้วนำตัวแปรที่ได้ไปใช้งาน
เริ่มหัวข้อโดย: gu_prajag ที่ ตุลาคม 21, 2014, 10:16:54 AM
ผมสร้างจาก Report Design ครับ เช่น
ตัวแปร
var
date1,date2 : datetime;
ds1,ds2,ds3 : string;

-----------------------------------------------
procedure GlobalOnCreate;
begin
   GetDateRangeDialog(date1, date2);
   ds1 := FormatDateTime('yyyy-mm-dd', date1);
   ds2 := FormatDateTime('yyyy-mm-dd', date2);
++++++++++++++++++++++++++++++++++++
  ให้เลือกรายการยา 'select * from from drugitems' <--
  เก็บในตัวแปร ds3 (icode)           <--
++++++++++++++++++++++++++++++++++++
   ChangeReportSQL('select d.icode,d.name,d.strength,d.units,op.unitprice,sum(op.qty) as sum_qty,sum(op.sum_price) as sum_total_price '+
' from drugitems d '+
' left outer join opitemrece op on d.icode = op.icode '+
' where (op.vstdate between "'+ds1+'" and "'+ds2+'") and d.icode="'+ds3+'" '+ นำตัวแปร ds3 มาใช้ จากที่เลือกรายการยามาครับ
' group by d.icode order by sum_total_price desc ');

 end;
หัวข้อ: Re: ดึงรายที่ต้องการ ใส่ใน combo box แล้วนำตัวแปรที่ได้ไปใช้งาน
เริ่มหัวข้อโดย: gu_prajag ที่ ตุลาคม 21, 2014, 12:14:32 PM
ได้หละ
ds3:=GetPickupList('select concat(icode,":",name) as name from drugitems order by name');
แล้วค่อยเอา ds3 มันตัดให้เหลือแค่รหัส icode
หัวข้อ: Re: ดึงรายที่ต้องการ ใส่ใน combo box แล้วนำตัวแปรที่ได้ไปใช้งาน
เริ่มหัวข้อโดย: udomchok ที่ ตุลาคม 22, 2014, 15:16:11 PM
ได้หละ
ds3:=GetPickupList('select concat(icode,":",name) as name from drugitems order by name');
แล้วค่อยเอา ds3 มันตัดให้เหลือแค่รหัส icode

เอา icode ไป concat ไว้ข้างหน้า ระวังเวลาเรียกใช้จะลำบากนะครับ
ควรเอาชื่อยาไว้ข้างหน้ามากกว่า หรือลองดูการทำรายงาน โดยใช้ GetPickupList ร่วมกับ GetSQLStringData จากรายงานที่ผมเคยทำไว้ครับ
http://hosxp.net/index.php?option=com_smf&Itemid=28&topic=12853.0