⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goods.cpp

📁 销售分析,JUSCO,日月周查询,待完善.
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "goods.h"
#include "mainform.h"
#include "datam.h"
#include "daysql.h"
#include "prt.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "SUIButton"
#pragma link "SUIComboBox"
#pragma link "SUIDBCtrls"
#pragma link "SUIEdit"
#pragma link "SUIForm"
#pragma link "SUIImagePanel"
#pragma link "SUIPopupMenu"
#pragma link "SUIGroupBox"
#pragma link "SUIDlg"
#pragma link "SUIListBox"
#pragma link "SUIMemo"
#pragma link "SUIRadioGroup"
#pragma resource "*.dfm"
Tgoodsform *goodsform;
//---------------------------------------------------------------------------
__fastcall Tgoodsform::Tgoodsform(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall Tgoodsform::suiEdit1KeyPress(TObject *Sender, char &Key)
{
 AnsiString str;
if(suiEdit1->Text.IsEmpty())
return;
if(Key==VK_RETURN){
 if(!suiEdit1->Text.IsEmpty()&&(suiEdit1->Text.Length()>=6&&suiEdit1->Text.Length()<=9)){
   if (suiEdit1->Text.Length()==6){
      suiEdit1->Text="000"+suiEdit1->Text.Trim();
   }
   if (suiEdit1->Text.Length()==7){
      suiEdit1->Text="00"+suiEdit1->Text.Trim();
   }
   if (suiEdit1->Text.Length()==8){
      suiEdit1->Text="0"+suiEdit1->Text.Trim();
   }
  str="select itmaster.*,bar2item.barcode from itmaster  left join bar2item on bar2item.item_code=itmaster.item_code where itmaster.item_code='"+suiEdit1->Text.Trim()+"'";
  try{
  dm->tmp->Active=false;
   dm->tmp->SQL->Clear();
   dm->tmp->SQL->Add(str);
    dm->tmp->Active=true;

  }catch(...){
  }
}
}
suiComboBox1->Enabled=dm->tmp->Active;
   suiComboBox2->Enabled=dm->tmp->Active;
     suiComboBox3->Enabled=dm->tmp->Active;
      suiDBLookupComboBox4->Enabled=dm->tmp->Active;
      suiButton1->Enabled=dm->tmp->Active;
       suiButton2->Enabled=dm->tmp->Active;
}
//---------------------------------------------------------------------------






void __fastcall Tgoodsform::suiDBLookupComboBox4Enter(TObject *Sender)
{
  AnsiString str;
  if(dm->tmp->RecordCount==0)
 return;
suiEdit1->Text="";
  str="select itmaster.*,bar2item.barcode from itmaster  left join bar2item on bar2item.item_code=itmaster.item_code where itmaster.vendor_code='"+dm->supply->FieldByName("vendor_code")->AsString+"'";
  try{
  dm->tmp->Active=false;
   dm->tmp->SQL->Clear();
   dm->tmp->SQL->Add(str);
    dm->tmp->Active=true;

  }catch(...){
  }
}
//---------------------------------------------------------------------------

void __fastcall Tgoodsform::suiPanel1DblClick(TObject *Sender)
{
AnsiString str;
suiEdit1->Text="";
 dm->tmp->Filtered=false;
  str="select itmaster.*,bar2item.barcode from itmaster  left join bar2item on bar2item.item_code=itmaster.item_code ";
  try{
  dm->tmp->Active=false;
   dm->tmp->SQL->Clear();
   dm->tmp->SQL->Add(str);
    dm->tmp->Active=true;

  }catch(...){
  }
  

   suiComboBox1->Enabled=dm->tmp->Active;
    suiComboBox2->Enabled=dm->tmp->Active;
     suiComboBox3->Enabled=dm->tmp->Active;
      suiDBLookupComboBox4->Enabled=dm->tmp->Active;
      suiButton1->Enabled=dm->tmp->Active;
       suiButton2->Enabled=dm->tmp->Active;


}
//---------------------------------------------------------------------------







void __fastcall Tgoodsform::suiButton2Click(TObject *Sender)
{
AnsiString str;
if(dm->tmp->Active)
Label7->Caption=" 记录总数:"+IntToStr(dm->tmp->RecordCount)+"   ";

//str="insert into temptable(caption,item_code) select "+usr+suiInputDialog1->ValueText.Trim()+" ,item_code from itmaster
suiInputDialog1->ShowModal();
if( suiInputDialog1->ValueText.IsEmpty()||dm->tmp->RecordCount>13000||!dm->tmp->Active)
return;
 dm->temp->Active=true;
dm->tmp->First();
while(!dm->tmp->Eof){

try{


dm->temp->Append();
dm->temp->FieldByName("caption")->AsString=usr+suiInputDialog1->ValueText.Trim();
dm->temp->FieldByName("item_code")->AsString=dm->tmp->FieldByName("item_code")->AsString;
dm->temp->Post();
}catch(...){
}
 dm->tmp->Next();
 }
 dm->temp->Active=false;
dm->temp->Active=true;
}
//---------------------------------------------------------------------------



void __fastcall Tgoodsform::FormCreate(TObject *Sender)
{
dm->dept->Active=true;
   dm->sect->Active=true;
   dm->artcode->Active=true;
    dm->tmp->Active=false;
 // suiComboBox1->Enabled=dm->tmp->Active;
  //  suiComboBox2->Enabled=dm->tmp->Active;
  //   suiComboBox3->Enabled=dm->tmp->Active;
      suiDBLookupComboBox4->Enabled=dm->tmp->Active;
      suiButton1->Enabled=dm->tmp->Active;
       suiButton2->Enabled=dm->tmp->Active;
        dm->dept->First();
 while(!dm->dept->Eof){

  suiComboBox1->Items->Add(dm->dept->FieldByName("Dept_code")->AsString);
   dm->dept->Next();
     }
        dm->sect->First();
 while(!dm->sect->Eof){
  suiComboBox2->Items->Add(dm->sect->FieldByName("section_code")->AsString);
   dm->sect->Next();
  }



   dm->artcode->First();
 while(!dm->artcode->Eof){
 suiComboBox3->Items->Add(dm->artcode->FieldByName("article_code")->AsString);
 dm->artcode->Next();
}
 //dm->itemconn->DataSet->GetFieldNames(suiListBox1->Items);

}
//---------------------------------------------------------------------------

void __fastcall Tgoodsform::FormDestroy(TObject *Sender)
{

dm->tmp->Filtered=false;
   dm->tmp->Active=false;
}
//---------------------------------------------------------------------------





void __fastcall Tgoodsform::suiButton1Click(TObject *Sender)
{
if (dm->tmp->Active){
SaveDialog1->Filter = "EXCEL files (*.xls)|*.XLS";
  if(SaveDialog1->Execute()){
    dm->LOCAL->DatabaseName=SaveDialog1->InitialDir;
    dm->LOCAL->TableName=SaveDialog1->FileName;

   // SaveDialog1->FileName;
   try{
   dm->TOEXCEL->Source=dm->tmp;
dm->TOEXCEL->Execute() ;
}catch(...){
}
}
 }
}
//---------------------------------------------------------------------------

void __fastcall Tgoodsform::suiComboBox1Enter(TObject *Sender)
{
  AnsiString str;
suiEdit1->Text="";
   str="select itmaster.*,bar2item.barcode from itmaster  left join bar2item on bar2item.item_code=itmaster.item_code where itmaster.dept_code='"+suiComboBox1->Text.Trim()+"'";
  try{
  dm->tmp->Active=false;
   dm->tmp->SQL->Clear();
   dm->tmp->SQL->Add(str);
    dm->tmp->Active=true;

  }catch(...){
  }
}
//---------------------------------------------------------------------------

void __fastcall Tgoodsform::suiComboBox2Enter(TObject *Sender)
{
 AnsiString str;

suiEdit1->Text="";
  str="select itmaster.*,bar2item.barcode from itmaster  left join bar2item on bar2item.item_code=itmaster.item_code where itmaster.section_code='"+suiComboBox2->Text.Trim()+"'";
  try{
  dm->tmp->Active=false;
   dm->tmp->SQL->Clear();
   dm->tmp->SQL->Add(str);
    dm->tmp->Active=true;

  }catch(...){
  }
}
//---------------------------------------------------------------------------

void __fastcall Tgoodsform::suiComboBox3Enter(TObject *Sender)
{
 AnsiString str;

suiEdit1->Text="";
  str="select itmaster.*,bar2item.barcode from itmaster  left join bar2item on bar2item.item_code=itmaster.item_code where itmaster.article_code='"+suiComboBox3->Text.Trim()+"'";
  try{
  dm->tmp->Active=false;
   dm->tmp->SQL->Clear();
   dm->tmp->SQL->Add(str);
    dm->tmp->Active=true;

  }catch(...){
  }
}
//---------------------------------------------------------------------------

void __fastcall Tgoodsform::suiDBEdit3Change(TObject *Sender)
{
  suiButton1->Enabled=dm->tmp->Active;
       suiButton2->Enabled=dm->tmp->Active;
       suiDBLookupComboBox4->Enabled=dm->tmp->Active;
  //   suiComboBox2->Text=dm->sect->FieldByName("section_code")->AsString;
 suiComboBox3->Text=dm->artcode->FieldByName("article_code")->AsString;
//ShowMessage(dm->sect->FieldByName("section_code")->AsString);

}
//---------------------------------------------------------------------------

void __fastcall Tgoodsform::suiDBEdit2Change(TObject *Sender)
{
   suiComboBox2->Text=dm->sect->FieldByName("section_code")->AsString;       
}
//---------------------------------------------------------------------------

void __fastcall Tgoodsform::suiDBEdit1Change(TObject *Sender)
{
  suiComboBox1->Text=dm->dept->FieldByName("dept_code")->AsString;      
}
//---------------------------------------------------------------------------






//void __fastcall Tgoodsform::suiListBox1DblClick(TObject *Sender)
//{
//int i;
    //        i=suiListBox1->ItemIndex;
 //
//suiEdit2->Text=suiListBox1->Items->operator [](i);
//ItemIndex
//}
//---------------------------------------------------------------------------







//void __fastcall Tgoodsform::suiListBox2DblClick(TObject *Sender)
//{
//suiEdit2->Text=suiListBox1->Items->operator [](suiListBox1->ItemIndex)+suiListBox2->Items->operator[](suiListBox2->ItemIndex);
//}
//---------------------------------------------------------------------------

//void __fastcall Tgoodsform::suiListBox3DblClick(TObject *Sender)
//{


//dm->dayseq->ParamByName(suiListBox1->Items->operator [](suiListBox1->ItemIndex));
//if( dm->dayseq->FieldByName(suiListBox1->Items->operator [](suiListBox1->ItemIndex))->AsString.operator [](1).IsNumeric))
//ShowMessage( dm->dayseq->FieldByName(suiListBox1->Items->operator [](suiListBox1->ItemIndex))->DataType());
//suiEdit2->Text=suiEdit2->Text+suiListBox3->Items->operator [](suiListBox3->ItemIndex);
//}
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------






void __fastcall Tgoodsform::suiButton3Click(TObject *Sender)
{
Tprint *form=new Tprint(this);
if (dm->tmp->Filtered){
if (suiRadioButton1->Checked)
form->QRLabel14->Caption=suiRadioButton1->Caption;
else if   (suiRadioButton2->Checked)
form->QRLabel14->Caption=suiRadioButton2->Caption;
else
form->QRLabel14->Caption=suiRadioButton3->Caption;
 }else
  form->QRLabel14->Caption="库存查询条件不限";

form->onstock->PreviewModal();
delete form;
form=NULL;
}
//---------------------------------------------------------------------------



void __fastcall Tgoodsform::suiRadioButton1Click(TObject *Sender)
{
if(suiRadioButton1->Checked)
dm->tmp->Filtered=false;
dm->tmp->Filter="stock_onhand>0";
dm->tmp->Filtered=true;;
}
//---------------------------------------------------------------------------

void __fastcall Tgoodsform::suiRadioButton2Click(TObject *Sender)
{
 if(suiRadioButton2->Checked)
dm->tmp->Filtered=false;
dm->tmp->Filter="stock_onhand<0";
dm->tmp->Filtered=true;;       
}
//---------------------------------------------------------------------------

void __fastcall Tgoodsform::suiRadioButton3Click(TObject *Sender)
{
   if(suiRadioButton3->Checked)
dm->tmp->Filtered=false;
dm->tmp->Filter="stock_onhand=0";
dm->tmp->Filtered=true;;
}
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------



void __fastcall Tgoodsform::suiRadioButton4Click(TObject *Sender)
{
if(suiRadioButton4->Checked) {
if (!suiNumberEdit1->Text.IsEmpty()){
dm->tmp->Filtered=false;
dm->tmp->Filter="stock_onhand='"+suiNumberEdit1->Text.Trim()+"'";
dm->tmp->Filtered=true;}
}
}
//---------------------------------------------------------------------------




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -