sexcd.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 261 行
CPP
261 行
//--------------------------------------------------------------------------
#include <vcl.h>
#include "Sexcd.h"
#include "Sexch.h"
#include "wnquery.h"
#include "KSSaleFuc.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, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TStdBaseForm(Owner,chWnd,MidCode,WhereStr)
{
InitControlGroup();
}
//--------------------------------------------------------------------------
__fastcall TfrmSexcd::TfrmSexcd(TComponent* Owner)
: TStdBaseForm(Owner)
{
InitControlGroup();
}
void __fastcall TfrmSexcd::btnOKClick(TObject *Sender)
{
double FVal,FPrice,FQty,FAmt;
int ErrNum;
AnsiString MarkeGoods = " ", msg = "由于你不是下列货物的物料操作员,所以以下货物被取消!\r\n";
try
{
try
{
StartWaitForm("正在生成返修单,请稍候...");
if(sgSexcd->RowCount>1)
{
int j;
j=comServer->ItemCount-1;
if(j>=0)
{
comServer->LocateItemByIndex(j);
j=StrToInt(frmSexch->GetDetailValue("SexcdLine"));
j=j+1;
}
else
j=1;
for(int i=1;i<sgSexcd->RowCount;i++)
{
if(sgSexcd->Cells[1][i]=="√")
{
comServer->AddItem();
if ( !IsLegitGU(sgSexcd->Cells[3][i], Query) ) {
MarkeGoods += sgSexcd->Cells[4][i] + ", ";
continue;
}
SetDetailValue("SexcdCode",frmSexch->seSexchCode->Text);
SetDetailValue("SexcdLine",AnsiString(j));
SetDetailValue("SexcdSretCode",seSexcdSretCode->Text);
SetDetailValue("SexcdSretdLine", sgSexcd->Cells[2][i]);
SetDetailValue("SexcdGoods", sgSexcd->Cells[3][i]);
SetDetailValue("SexcdGoodsName", sgSexcd->Cells[4][i]);
SetDetailValue("SexcdGoodsSpec", sgSexcd->Cells[5][i]);
SetDetailValue("SexcdUnit", sgSexcd->Cells[6][i]);
SetDetailValue("SexcdConv", sgSexcd->Cells[7][i]);
SetDetailValue("SexcdQty", sgSexcd->Cells[9][i]);
SetDetailValue("SexcdPrice", sgSexcd->Cells[10][i]);
FQty=sgSexcd->Cells[9][i].ToDouble();
FPrice=sgSexcd->Cells[10][i].ToDouble();
FVal=(FQty*FPrice);
FAmt=DataCarry(FVal,2,0);
SetDetailValue("SexcdAmt",AnsiString(FAmt));
SetDetailValue("SexcdLoc", sgSexcd->Cells[11][i]);
SetDetailValue("SexcdBatch", sgSexcd->Cells[12][i]);
SetDetailValue("SexcdState", "1");
SetDetailValue("SexcdExes", "0");
SetDetailValue("SexcdDesc", " ");
comServer->AddToObject();
j=j+1;
}
}
if ( MarkeGoods!=" " )
ShowMessage(msg+MarkeGoods);
}// if end.
}
catch(Exception &e)
{
comServer->FreeItem();
this->ModalResult=0;
throw Exception(e.Message);
}
}
__finally
{
EndWaitForm();
}
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexcd::btnCancelClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSexcd::InitControlGroup()
{
sgSexcd->RowCount = 1;
seSexchRate->Text="";
seSexchClient->Text="";
seSexchCurrency->Text="";
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, SretdGoodsName=ISNULL((SELECT GoodsName FROM sdGoods WHERE SretdGoods=GoodsCode),''), ")
+AnsiString(" SretdGoodsSpec=ISNULL((SELECT GoodsSpec FROM sdGoods WHERE SretdGoods=GoodsCode),''), ")
+AnsiString(" 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=new TComResultSet(Handle,g_ClientHandle);
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("SretdGoodsName")+
"\t"+RsSretd->FieldByName("SretdGoodsSpec")+
"\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::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==11 && 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[11][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,SrethClient";
SqlStr+=" from sdSreth,sdCurrency,sdtax";
SqlStr+=" where Srethcurrency=currencycode and Srethtaxcode=taxcode and Srethcheck=1 and Srethclose=0 and Srethcancel=0 ";
if (scSexLimitClient->Checked == true)
SqlStr+=" and SrethClient='"+FSexchClient+"' ";
if (scSexLimitCurrency->Checked == true)
SqlStr+=" 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 + =
减小字号Ctrl + -
显示快捷键?