BMS-HOSxP Community

HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: panus_t ที่ มกราคม 16, 2012, 15:53:43 PM

หัวข้อ: ผมประกาศตัวแปรถูกหรือเปล่าครับ
เริ่มหัวข้อโดย: panus_t ที่ มกราคม 16, 2012, 15:53:43 PM
year_th :string;

year_th:=InputQuery('กรุณาใส่ปี พ.ศ.'); 

ทำไหมค่าตรงนี้มันไม่ออก
Value := GetSQLIntegerData('select count(an) from ipt '+
' where year(dchdate)="'+year_th+'" and month(dchdate)="10" '+
' and adjrw < 1 ');
หัวข้อ: Re: ผมประกาศตัวแปรถูกหรือเปล่าครับ
เริ่มหัวข้อโดย: golf_win ที่ มกราคม 16, 2012, 16:16:57 PM
ลองใช้งานที่ table stock_bdg_year น่าจะง่ายกว่านะครับ
หัวข้อ: Re: ผมประกาศตัวแปรถูกหรือเปล่าครับ
เริ่มหัวข้อโดย: udomchok ที่ มกราคม 16, 2012, 18:02:21 PM
year_th :string;

year_th:=InputQuery('กรุณาใส่ปี พ.ศ.'); 

ทำไหมค่าตรงนี้มันไม่ออก
Value := GetSQLIntegerData('select count(an) from ipt '+
' where year(dchdate)="'+year_th+'" and month(dchdate)="10" '+
' and adjrw < 1 ');
year_th เป็น พ.ศ.
year(dchdate) เป็น ค.ศ. นะครับ
หัวข้อ: Re: ผมประกาศตัวแปรถูกหรือเปล่าครับ
เริ่มหัวข้อโดย: panus_t ที่ มกราคม 18, 2012, 09:14:21 AM
year_th :string;

year_th:=InputQuery('กรุณาใส่ปี พ.ศ.'); 

ทำไหมค่าตรงนี้มันไม่ออก
Value := GetSQLIntegerData('select count(an) from ipt '+
' where year(dchdate)="'+year_th+'" and month(dchdate)="10" '+
' and adjrw < 1 ');
year_th เป็น พ.ศ.
year(dchdate) เป็น ค.ศ. นะครับ

ผมลองใส่ input เป็น 2011 ก็ไม่ได้ครับ ไม่มีข้อมูล 
ว่าจะถามต่อว่าถ้าให้ user ใส่ปี พ.ศ.แล้ว เราจะนำมาลบ 543 ได้อย่างไรครับ
ผมไม่ค่อยรู้รูปแบบคำสั่ง...
หัวข้อ: Re: ผมประกาศตัวแปรถูกหรือเปล่าครับ
เริ่มหัวข้อโดย: panus_t ที่ มกราคม 18, 2012, 09:24:03 AM
ออกแล้วครับ สงสัยผมใส่ 2012 ไม่ใช่ 2011
ขอถามต่อว่า ถ้าให้ User ให้ปีงบประมาณ เป็น 2554
1.รูปแบบการนำ year_th มาลบ 543 ก่อนที่จะใส่คำสั่ง
year_en=year-543; ได้หรือเปล่าครับ

Value := GetSQLIntegerData('select count(an) from ipt '+
' where year(dchdate)="'+year_en+'" and month(dchdate)="10" '+
' and adjrw < 1 ');

 2.เดือนตุลาคมต้องเป็น 2010
Value := GetSQLIntegerData('select count(an) from ipt '+
' where year(dchdate)="'+year_en+'" and month(dchdate)="10" '+
' and adjrw < 1 ');
ในคำสั่งข้างบน year-1 ได้อย่างไรครับ
 ;D
หัวข้อ: Re: ผมประกาศตัวแปรถูกหรือเปล่าครับ
เริ่มหัวข้อโดย: nuttavut ที่ มกราคม 18, 2012, 09:28:04 AM
ออกแล้วครับ สงสัยผมใส่ 2012 ไม่ใช่ 2011
ขอถามต่อว่า ถ้าให้ User ให้ปีงบประมาณ เป็น 2554
1.รูปแบบการนำ year_th มาลบ 543 ก่อนที่จะใส่คำสั่ง
year_en=year-543; ได้หรือเปล่าครับ

Value := GetSQLIntegerData('select count(an) from ipt '+
' where year(dchdate)="'+year_en+'" and month(dchdate)="10" '+
' and adjrw < 1 ');

 2.เดือนตุลาคมต้องเป็น 2010
Value := GetSQLIntegerData('select count(an) from ipt '+
' where year(dchdate)="'+year_en+'" and month(dchdate)="10" '+
' and adjrw < 1 ');
ในคำสั่งข้างบน year-1 ได้อย่างไรครับ
 ;D


แปลง String ให้เป็น Integer ก่อนลบกัน
 year_en := inttostr(strtoint(year) - 543) ; 
หัวข้อ: Re: ผมประกาศตัวแปรถูกหรือเปล่าครับ
เริ่มหัวข้อโดย: nuttavut ที่ มกราคม 18, 2012, 09:38:34 AM
หรือศึกษาเพิ่มเติม ตามรูปแบบ รายงานตัวนี้สำหรับการย้อนเดือนตามปีงบประมาณ

date1 :=GetSQLDateData('select min(vstdate) from ovst');
     date2 :=GetSQLDateData('select max(vstdate) from ovst');
     ds1 := formatdatetime('yyyy-mm-dd',date1);
     ds2 := formatdatetime('yyyy-mm-dd',date2);

     fyear := GetPickupList('select distinct(year(vstdate)) + 543 as cc ,vstdate  from ovst'+
                  ' where vstdate between "'+ds1+'" and "'+ds2+'"'+
                  ' group by cc'+
                  ' order by cc desc' );
     year := fyear;
     fyear := inttostr(strtoint(fyear) - 543) ;

     fyear := inttostr(strtoint(fyear) - 1) ;

     m10 := fyear+'-10-01" and "'+ fyear+'-10-31';
     m11 := fyear+'-11-01" and "'+ fyear+'-11-30';
     m12 := fyear+'-12-01" and "'+ fyear+'-12-31';

     fyear := inttostr(strtoint(fyear) + 1) ;

     m1 :=  fyear+'-01-01" and "'+ fyear+'-01-31';
     m2 := GetSQLStringData('select Date_Add("'+ fyear+'-01-31",interval 1 month) as d');
     m2 := fyear+'-02-01" and "'+ m2 ;

     
     m3 := fyear+'-03-01" and "'+ fyear+'-03-31';

     m4 := fyear+'-04-01" and "'+ fyear+'-04-30';
     m5 := fyear+'-05-01" and "'+ fyear+'-05-31';
     m6 := fyear+'-06-01" and "'+ fyear+'-06-30';
     m7 := fyear+'-07-01" and "'+ fyear+'-07-31';
     m8 := fyear+'-08-01" and "'+ fyear+'-08-31';
     m9 := fyear+'-09-01" and "'+ fyear+'-09-30';
หัวข้อ: Re: ผมประกาศตัวแปรถูกหรือเปล่าครับ
เริ่มหัวข้อโดย: panus_t ที่ มกราคม 18, 2012, 10:13:28 AM
Error แบบนี้ทำไงดีครับ..
หัวข้อ: Re: ผมประกาศตัวแปรถูกหรือเปล่าครับ
เริ่มหัวข้อโดย: udomchok ที่ มกราคม 20, 2012, 00:30:29 AM
อาการนี้ส่วนมากพบว่าเกิดจากการเปิด Report designer ก่อนเปิด HOSxP ครับ
ลองปิด Report designer แล้วเปิด HOSxP ขึ้นมาก่อน จากนั้นจึงต่อยเปิด Report Designer ครับ