📄 sexch.cpp
字号:
{
WriteFieldValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::FormShow(TObject *Sender)
{
ClearControl(1,false);
ClearControl(2,false);
TGenBaseForm::MoveToFirst();
ChangeToBrowseState(true);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::sgSexcdSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if (ARow == 0)
{
return;
}
comServer->LocateItemByKey(WideString(sgSexcd->TextMatrix[ARow][1]));
if (!comServer->Eof)
{
GetDataFromComObject(2);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::sgSexcdDblClick(TObject *Sender)
{
int iRow;
iRow=sgSexcd->Row;
if (iRow == 0)
{
return;
}
comServer->LocateItemByKey(WideString(sgSexcd->TextMatrix[iRow][1]));
GetDataFromComObject(2);
sgSexcd->Visible=false;
sgSexcd->Align=alNone;
FloatPanel2->Visible=true;
FloatPanel2->Align=alClient;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::ChangeToBrowseState(bool Browse)
{
FloatPanel2->Visible=false;
FloatPanel2->Align =alNone;
sgSexcd->Visible=true;
sgSexcd->Align=alClient;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::btnOKClick(TObject *Sender)
{
if ((CurrentState==caAddDetail)||(CurrentState==caAddBill))
{
try
{
if(DetailState==caAddDetail)
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
ClearControl(2,false);
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
else
ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::GenrateBill()
{
int TempCount;
TempCount = comServer->ItemCount;
StartWaitForm("正在启动生成界面");
TfrmSexcd *p=new TfrmSexcd(this);
try
{
p->GetComObject(comServer);
EndWaitForm();
p->ShowModal();
if (TempCount < comServer->ItemCount)
TGenBaseForm::SaveRecord();
else
CancelChange();
}
__finally
{
delete p;
}
}
void __fastcall TfrmSexch::RefreshUpdateData(int MsgSrc,int MsgType)
{
AnsiString KeyCode;
switch(MsgSrc)
{
case euSdSexcRr:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=scSexchRr->Text;
FillComboBox(scSexchRr,"SELECT SexcRrCode FROM sdSexcRr","SexcRrCode");
scSexchRr->LocateKey(KeyCode);
}
break;
//Sexcd
case euSdUnit:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=seSexcdUnit->Text;
FillEdit(seSexcdUnit,"SELECT UnitCode,UnitName FROM sdUnit","UnitName","UnitCode");
seSexcdUnit->LocateKey(KeyCode);
}
break;
}
}
void __fastcall TfrmSexch::seSexchCodeKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key==13 && CurrentState==caNormal)
{
comServer->LocateByKey(WideString(seSexchCode->Text));
DisplayBill();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::seSexchClientButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="005[客户编码][客户名称][主币种][主税种][客户地址]select clientcode,clientname,clientcurrency,clienttaxcode,clientaddr from sdclient where clientcancel=0 order by clientcode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"客户资料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seSexchClient->LocateKey(p->ColData[1]);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::seSexchCurrencyButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="002[货币代码][货币名称]select Currencycode,CurrencyName from sdCurrency,sdssd where ssdCurrency=CurrencyCode and ";
SqlStr+="ssdClient='"+seSexchClient->ItemData[cbItem2]+"' order by CurrencyCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"客户货币查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
if(seSexchCurrency->LocateKey(p->ColData[1]))
{
if(seSexchCurrency->ItemData[cbItem4]=="1")
{
seSexchEnrate->Enabled=false;
seSexchEnrate->Text="1";
}
else
{
seSexchEnrate->Enabled=true;
seSexchEnrate->Text=seSexchCurrency->ItemData[cbItem3];
}
}
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::seSexcdSretCodeButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="010[退货单号][行号][物料编码][计量单位][换算系数][退货数量][换货数呈][单价][货位][批号]";
SqlStr+="select sretdcode,sretdline,sretdgoods,sretdunit,sretdConv,sretdqty,sretdeqty,sretdprice,sretdloc,sretdbatch from sdsretd,sdsreth where sretdcode=srethcode and srethcheck=1 and ";
SqlStr+="srethclient='"+seSexchClient->ItemData[cbItem2]+"' and srethcurrency='"+seSexchCurrency->ItemData[cbItem2]+"' order by srethdate desc";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"销售退货单查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seSexcdSretCode->Text=p->ColData[1];
seSexcdSretdLine->Text=p->ColData[2];
seSexcdGoods->Text=p->ColData[3];
seSexcdUnit->LocateKey(p->ColData[4]);
seSexcdConv->Text=p->ColData[5];
seSexcdPrice->Text=p->ColData[8];
if(g_sdRsGoods->LocateByKey(WideString(seSexcdGoods->Text))==0)
seSexcdGoodsName->Text=GetGoodsValue("GoodsName");
seSexcdLoc->LocateKey(p->ColData[9]);
seSexcdBatch->Text=p->ColData[10];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::seSexcdQtyButtonClick(TObject *Sender)
{
AnsiString SqlStr;
TfrmWnQuery *p;
SqlStr="008[退货单号][行号][物料编码][计量单位][换算系数][退货数量][换货数量][单价]";
SqlStr+="select Sretdcode,Sretdline,Sretdgoods,Sretdunit,Sretdconv,Sretdqty,Sretdeqty,Sretdprice from sdSretd where ";
SqlStr+="Sretdcode='"+seSexcdSretCode->Text+"' and SretdLine="+seSexcdSretdLine->Text;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"退货单查询",SqlStr);
}
__finally
{
EndWaitForm();
}
p->ShowModal();
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::seSexcdQtyExit(TObject *Sender)
{
CalculateAmt();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::seSexcdPriceExit(TObject *Sender)
{
CalculateAmt();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::CalculateAmt()
{
double FVal;
FVal=seSexcdQty->Text.ToDouble()*seSexcdPrice->Text.ToDouble();
FVal=DataCarry(FVal,2,0);
seSexcdAmt->Text=FVal;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexch::seSexcdBatchButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="005[批号代码][说明][数量][生效日期][失效日期]";
SqlStr+=" select BatchCode,BatchDesc,BatchQty,BatchEffectDate,BatchAbateDate from sdBatch";
SqlStr+=" where BatchEffectDate<='"+g_sdCurDate+"' and BatchAbateDate>'"+g_sdCurDate+"' order by BatchCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"批号查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seSexcdBatch->LocateKey(p->ColData[1]);
}
delete p;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -