📄 sexcd.cpp
字号:
//--------------------------------------------------------------------------
#include <vcl.h>
#include "Sexcd.h"
#include "Sexch.h"
#include "wnquery.h"
#include "func.h"
//--------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "SDComboBox"
#pragma link "StdBaseForm"
#pragma resource "*.dfm"
TfrmSexcd *frmSexcd;
//--------------------------------------------------------------------------
__fastcall TfrmSexcd::TfrmSexcd(TComponent* Owner)
: TStdBaseForm(Owner)
{
InitControlGroup();
}
//--------------------------------------------------------------------------
void __fastcall TfrmSexcd::btnOKClick(TObject *Sender)
{
double FVal,FPrice,FQty,FAmt;
int ErrNum;
try
{
StartWaitForm("正在生成返修单,请稍候...");
if(sgSexcd->RowCount>1)
{
int j;
j=comServer->ItemCount-1;
if(j>=0)
{
comServer->LocateItemByIndex(j);
j=StrToInt(frmSexch->GetDetailValue(fiSexcdLine));
j=j+1;
}
else
j=1;
for(int i=1;i<sgSexcd->RowCount;i++)
{
if(sgSexcd->Cells[1][i]=="√")
{
comServer->AddItem();
SetDetailValue(fiSexcdCode,frmSexch->seSexchCode->Text);
SetDetailValue(fiSexcdLine,AnsiString(j));
SetDetailValue(fiSexcdSretCode,seSexcdSretCode->Text);
SetDetailValue(fiSexcdSretdLine, sgSexcd->Cells[2][i]);
SetDetailValue(fiSexcdGoods, sgSexcd->Cells[3][i]);
SetDetailValue(fiSexcdUnit, sgSexcd->Cells[4][i]);
SetDetailValue(fiSexcdConv, sgSexcd->Cells[5][i]);
SetDetailValue(fiSexcdQty, sgSexcd->Cells[7][i]);
SetDetailValue(fiSexcdPrice, sgSexcd->Cells[8][i]);
FQty=sgSexcd->Cells[7][i].ToDouble();
FPrice=sgSexcd->Cells[8][i].ToDouble();
FVal=(FQty*FPrice);
FAmt=DataCarry(FVal,2,0);
SetDetailValue(fiSexcdAmt,AnsiString(FAmt));
SetDetailValue(fiSexcdLoc, sgSexcd->Cells[9][i]);
SetDetailValue(fiSexcdBatch, sgSexcd->Cells[10][i]);
SetDetailValue(fiSexcdState, "1");
try
{
comServer->AddToObject();
}
catch(Exception &e)
{
comServer->Cancel();
this->ModalResult=0;
throw Exception(e.Message);
}
j=j+1;
}
}
}
}
__finally
{
EndWaitForm();
}
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexcd::btnCancelClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexcd::InitControlGroup()
{
sgSexcd->RowCount = 1;
seSexcdSretCode->Text="";
seSexchClient->Text=frmSexch->seSexchClient->Text;
seSexchClient->Enabled=false;
FSexchClient=frmSexch->seSexchClient->ItemData[cbItem2];
seSexchCurrency->Text=frmSexch->seSexchCurrency->Text;
seSexchCurrency->Enabled=false;
FSexchCurrency=frmSexch->seSexchCurrency->ItemData[cbItem2];
seSexchRate->Text=frmSexch->seSexchEnrate->Text;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexcd::FillGridWithData()
{
AnsiString ItemStr,s_SQL;
s_SQL=AnsiString(" Select SretdLine,sretdGoods,sretdUnit,SretdConv,SretdQty=SretdQty-SretdFQty,")
+AnsiString(" SretdLoc,SretdBatch,SretdPrice from sdSretd where SretdCode='"+seSexcdSretCode->Text+"'")
+AnsiString(" and SretdClose = 0 and SretdQty-SretdfQty>0 order by Sretdline");
sgSexcd->RowCount=1;
TComResultSet *RsSretd;
try
{
StartWaitForm("正在查询数据,请稍候......");
RsSretd=NewResultSet();
RsSretd->Open(s_SQL,"");
sgSexcd->RowCount=1;
while( RsSretd->Eof == 0)
{
ItemStr="\t"+AnsiString("√") +
"\t"+RsSretd->FieldByName("SretdLine")+
"\t"+RsSretd->FieldByName("SretdGoods")+
"\t"+RsSretd->FieldByName("SretdUnit")+
"\t"+RsSretd->FieldByName("SretdConv")+
"\t"+RsSretd->FieldByName("SretdQty")+
"\t"+RsSretd->FieldByName("SretdQty")+
"\t"+RsSretd->FieldByName("SretdPrice")+
"\t"+RsSretd->FieldByName("SretdLoc")+
"\t"+RsSretd->FieldByName("SretdBatch");
sgSexcd->AddItem(ItemStr);
RsSretd->MoveNext();
}
RsSretd->Close();
delete RsSretd;
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexcd::GetComObject(TComServer *comServerPtr)
{
comServer = comServerPtr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexcd::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexcd::sgSexcdDblClick(TObject *Sender)
{
AnsiString SqlStr;
int ARow=sgSexcd->Row;
if (ARow >0)
{
if(sgSexcd->Col==1)
{
if (sgSexcd->Cells[1][ARow] == "√")
sgSexcd->Cells[1][ARow] = "";
else
sgSexcd->Cells[1][ARow] = "√";
}
else if(sgSexcd->Col==9 && sgSexcd->Cells[1][ARow] == "√")
{
SqlStr="002[货位代码][货位名称]select loccode,locname from sdLoc,sdlg ";
SqlStr+=" where lgLoccode=loccode and lggoodscode='"+sgSexcd->Cells[3][ARow]+"' order by loccode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"货位查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sgSexcd->Cells[9][ARow]=p->ColData[1];
}
delete p;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexcd::bbSelAllClick(TObject *Sender)
{
for(int i=1;i<sgSexcd->RowCount;i++)
sgSexcd->Cells[1][i] = "√";
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexcd::bbSelNoneClick(TObject *Sender)
{
for(int i=1;i<sgSexcd->RowCount;i++)
sgSexcd->Cells[1][i] = "";
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexcd::seSexcdSretCodeButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="005[退货单号][退货日期][币种][税码][业务员]select Srethcode,Srethdate,currencyname,taxname,SrethUser from sdSreth,sdCurrency,sdtax";
SqlStr+=" where Srethcurrency=currencycode and Srethtaxcode=taxcode and Srethcheck=1 and Srethclose=0 and Srethcancel=0 ";
SqlStr+=" and SrethClient='"+FSexchClient+"' and Srethcurrency='"+FSexchCurrency+"' ";
SqlStr+=" order by Srethcode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"退货单查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seSexcdSretCode->Text=p->ColData[1];
FillGridWithData();
}
delete p;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -