?? weeksql.cpp
字號:
void __fastcall Tsumm::suiDBComboBox2DblClick(TObject *Sender)
{
AnsiString str;
if (flag==1){
str="select store,weeklastd ,itmaster.dept_code,itmaster.section_code,itmaster.article_code,itmaster.vendor_code,sellweek.item_code,itmaster.item_desc ,quantity, customs,round((SELL/customs),2) as price , sell FROM sellweek left join itmaster on sellweek.item_code=itmaster.item_code" ;
str=str+" where quantity<>0 and weeklastd >=# "+StrToDate(DateTimePicker1->Date.DateString())+"# and weeklastd <=#"+StrToDate(DateTimePicker2->Date.DateString())+"#" ;
if(!suiComboBox1->Text.IsEmpty()){
str=str+" and store='"+suiComboBox1->Text.Trim()+"' ";
}
}
if (flag==2){
str="select store,itmaster.dept_code,itmaster.section_code,itmaster.article_code,itmaster.vendor_code,sellweek.item_code,itmaster.item_desc,stock_onhand ,SUM(quantity) AS quantities ,SUM(customs) AS allcustoms ,itmaster.price ,SUM(SELL) as total FROM sellweek left join itmaster on sellweek.item_code=itmaster.item_code" ;
str=str+" where weeklastd >=#"+StrToDate(DateTimePicker1->Date.DateString())+"# and weeklastd <=#"+StrToDate(DateTimePicker2->Date.DateString())+"# ";
if(!suiComboBox1->Text.IsEmpty()){
str=str+" and store='"+suiComboBox1->Text.Trim()+"' ";
}
}
if(! suiDBComboBox2->Text.IsEmpty()&&suiDBComboBox2->Text.Length()==3){
str=str+" and itmaster.section_code='"+suiDBComboBox2->Text.Trim()+"'";
tempstr=str;
if (flag==2){
if ( suiRadioButton2->Checked)
str=str+" group by store,article_code,itmaster.dept_code,itmaster.section_code,sellweek.item_code,itmaster.vendor_code,itmaster.item_desc,price,stock_onhand order by SUM(SELL) desc " ;
else
str=str+" group by store,article_code,itmaster.dept_code,itmaster.section_code,sellweek.item_code,itmaster.vendor_code,itmaster.item_desc,price,stock_onhand order by SUM(quantity) desc ";
}
try{
dm->dayseq->Active=false;
dm->dayseq->SQL->Clear();
dm->dayseq->SQL->Add(str);
dm->dayseq->Active=true;
}
catch(...){
dm->dayseq->Active=false;
}
suiDBComboBox1->Text=dm->dayseq->FieldByName("dept_code")->AsString;
suiDBComboBox3->Text="";
suiEdit1->Text="";
suiStatusBar1->SimpleText=" 查詢時間從"+DateTimePicker1->Date.DateString()+"至"+DateTimePicker2->Date.DateString()+" 庫存為本店庫存";;
}
}
//---------------------------------------------------------------------------
void __fastcall Tsumm::suiDBComboBox3DblClick(TObject *Sender)
{
AnsiString str;
if (flag==1){
str="select store,weeklastd ,itmaster.dept_code,itmaster.section_code,itmaster.article_code,itmaster.vendor_code,sellweek.item_code,itmaster.item_desc ,quantity, customs,round((SELL/customs),2) as price , sell FROM sellweek left join itmaster on sellweek.item_code=itmaster.item_code" ;
str=str+" where quantity<>0 and weeklastd >=# "+StrToDate(DateTimePicker1->Date.DateString())+"# and weeklastd <=#"+StrToDate(DateTimePicker2->Date.DateString())+"#" ;
if(!suiComboBox1->Text.IsEmpty()){
str=str+" and store='"+suiComboBox1->Text.Trim()+"' ";
}
}
if (flag==2){
str="select store,itmaster.dept_code,itmaster.section_code,itmaster.article_code,itmaster.vendor_code,sellweek.item_code,itmaster.item_desc,stock_onhand ,SUM(quantity) AS quantities ,SUM(customs) AS allcustoms ,itmaster.price ,SUM(SELL) as total FROM sellweek left join itmaster on sellweek.item_code=itmaster.item_code" ;
str=str+" where weeklastd >=#"+StrToDate(DateTimePicker1->Date.DateString())+"# and weeklastd <=#"+StrToDate(DateTimePicker2->Date.DateString())+"# ";
if(!suiComboBox1->Text.IsEmpty()){
str=str+" and store='"+suiComboBox1->Text.Trim()+"' ";
}
}
if(!suiDBComboBox3->Text.IsEmpty()&&suiDBComboBox3->Text.Length()==4){
str=str+ " and itmaster.article_code='"+suiDBComboBox3->Text.Trim()+"'";
tempstr=str;
if (flag==2){
if ( suiRadioButton2->Checked)
str=str+" group by store,article_code,itmaster.dept_code,itmaster.section_code,sellweek.item_code,itmaster.vendor_code,itmaster.item_desc,price,stock_onhand order by SUM(SELL) desc " ;
else
str=str+" group by store,article_code,itmaster.dept_code,itmaster.section_code,sellweek.item_code,itmaster.vendor_code,itmaster.item_desc,price,stock_onhand order by SUM(quantity) desc ";
}
ShowMessage(str);
try{
dm->dayseq->Active=false;
dm->dayseq->SQL->Clear();
dm->dayseq->SQL->Add(str);
dm->dayseq->Active=true;
}
catch(...){
dm->dayseq->Active=false;
}
suiDBComboBox1->Text=dm->dayseq->FieldByName("dept_code")->AsString;
suiDBComboBox2->Text=dm->dayseq->FieldByName("section_code")->AsString;
suiEdit1->Text="" ;
suiStatusBar1->SimpleText=" 查詢時間從"+DateTimePicker1->Date.DateString()+"至"+DateTimePicker2->Date.DateString()+" 庫存為本店庫存";;
}
}
//---------------------------------------------------------------------------
void __fastcall Tsumm::suiEdit1DblClick(TObject *Sender)
{
AnsiString str;
if (flag==1){
str="select store,weeklastd ,itmaster.dept_code,itmaster.section_code,itmaster.article_code,itmaster.vendor_code,sellweek.item_code,itmaster.item_desc ,quantity, customs,round((SELL/customs),2) as price , sell FROM sellweek left join itmaster on sellweek.item_code=itmaster.item_code" ;
str=str+" where quantity<>0 and weeklastd >=# "+StrToDate(DateTimePicker1->Date.DateString())+"# and weeklastd <=#"+StrToDate(DateTimePicker2->Date.DateString())+"#" ;
if(!suiComboBox1->Text.IsEmpty()){
str=str+" and store='"+suiComboBox1->Text.Trim()+"' ";
}
}
if (flag==2){
str="select store,itmaster.dept_code,itmaster.section_code,itmaster.article_code,itmaster.vendor_code,sellweek.item_code,itmaster.item_desc,stock_onhand ,SUM(quantity) AS quantities ,SUM(customs) AS allcustoms ,itmaster.price ,SUM(SELL) as total FROM sellweek left join itmaster on sellweek.item_code=itmaster.item_code" ;
str=str+" where weeklastd >=#"+StrToDate(DateTimePicker1->Date.DateString())+"# and weeklastd <=#"+StrToDate(DateTimePicker2->Date.DateString())+"# ";
if(!suiComboBox1->Text.IsEmpty()){
str=str+" and store='"+suiComboBox1->Text.Trim()+"' ";
}
}
if(!suiEdit1->Text.IsEmpty()&suiEdit1->Text.Length()==9){
str=str+" and sellweek.item_code='"+suiEdit1->Text.Trim()+"'";
tempstr=str;
if(flag==2){
if ( suiRadioButton2->Checked)
str=str+" group by store,article_code,itmaster.dept_code,itmaster.section_code,sellweek.item_code,itmaster.vendor_code,itmaster.item_desc,price,stock_onhand order by SUM(SELL) desc " ;
else
str=str+" group by store,article_code,itmaster.dept_code,itmaster.section_code,sellweek.item_code,itmaster.vendor_code,itmaster.item_desc,price,stock_onhand order by SUM(quantity) desc ";
}
try{
dm->dayseq->Active=false;
dm->dayseq->SQL->Clear();
dm->dayseq->SQL->Add(str);
dm->dayseq->Active=true;
}
catch(...){
dm->dayseq->Active=false;
}
suiDBComboBox1->Text=dm->dayseq->FieldByName("dept_code")->AsString;
suiDBComboBox2->Text=dm->dayseq->FieldByName("section_code")->AsString;
suiDBComboBox3->Text=dm->dayseq->FieldByName("article_code")->AsString;
}
// suiStatusBar1->SimpleText="全店鋪 總金額:"+FloatToStrF(ctotal,ffCurrency,12,2)+"; 總數量:"+IntToStr(qtotal)+" 查詢時間從"+DateTimePicker1->Date.DateString()+"至"+DateTimePicker2->Date.DateString();
suiStatusBar1->SimpleText=" 查詢時間從"+DateTimePicker1->Date.DateString()+"至"+DateTimePicker2->Date.DateString()+" 庫存為本店庫存";;
}
//---------------------------------------------------------------------------
void __fastcall Tsumm::suiButton4Click(TObject *Sender)
{
suiButton2->Enabled=false;
AnsiString str="select store,itmaster.dept_code,itmaster.section_code,itmaster.article_code,itmaster.vendor_code,sellweek.item_code,itmaster.item_desc,stock_onhand ,SUM(quantity) AS quantities ,SUM(customs) AS allcustoms ,itmaster.price ,SUM(SELL) as total FROM sellweek left join itmaster on sellweek.item_code=itmaster.item_code" ;
str=str+" where weeklastd >=# "+StrToDate(DateTimePicker1->Date.DateString())+"# and weeklastd <=#"+StrToDate(DateTimePicker2->Date.DateString())+"# ";
str=str+" group by store,article_code,itmaster.dept_code,itmaster.section_code,sellweek.item_code,itmaster.vendor_code,itmaster.item_desc,price,stock_onhand ";
if ( suiRadioButton2->Checked)
str=str+" order by SUM(SELL) desc " ;
else
str=str+" order by SUM(quantity) desc ";
//ShowMessage(str);
try{
dm->dayseq->Active=false;
dm->dayseq->SQL->Clear();
dm->dayseq->SQL->Add(str);
dm->dayseq->Active=true;
}
catch(...){
}
suiEdit1->Text="";
suiStatusBar1->SimpleText="查詢時間從"+DateTimePicker1->Date.DateString()+"至"+DateTimePicker2->Date.DateString()+" 庫存為本店庫存";
flag=2;
}
//---------------------------------------------------------------------------
void __fastcall Tsumm::suiListBox1DblClick(TObject *Sender)
{
AnsiString tstr;
float ctotal=0.0;
int qtotal=0;
int stotal=0;
if(!dm->dayseq->Active||flag!=1||!suiCheckBox1->Checked){
return;
}
if (Trim(tempstr).IsEmpty()){
tempstr=AnsiString(dm->dayseq->SQL->Text);
tstr=dm->dayseq->SQL->Text+" and month(weeklastd)="+(suiListBox1->TopIndex+1)+" order by weeklastd";//+suiListBox1->TopIndex;
} else{
tstr=Trim(tempstr)+" and month(weeklastd)="+(suiListBox1->TopIndex+1)+" order by weeklastd";
}
ShowMessage(tstr);
try{
dm->dayseq->Active=false;
dm->dayseq->SQL->Clear();
dm->dayseq->SQL->Add(tstr);
dm->dayseq->Active=true;
}
catch(...){
dm->dayseq->Active=false;
}
if (!suiEdit1->Text.IsEmpty()){
dm->dayseq->DisableControls();
dm->dayseq->First();
while( !dm->dayseq->Eof){
ctotal=ctotal+ dm->dayseq->FieldByName("sell")->AsFloat;
qtotal=qtotal+dm->dayseq->FieldByName("quantity")->AsInteger;
stotal=stotal+dm->dayseq->FieldByName("Customs")->AsInteger;
dm->dayseq->Next();
}
dm->dayseq->EnableControls();
suiStatusBar1->SimpleText="該項目匯總結果 "+suiListBox1->Items->operator [](suiListBox1->TopIndex)+"銷售數量:"+IntToStr(qtotal)+" 銷售客數為"+IntToStr(stotal)+" 銷售金額:"+FormatFloat("0.0",ctotal);
}
}
//---------------------------------------------------------------------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -