sogd_s_o.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 292 行
CPP
292 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Sogd_S_O.h"
#include "Sogh_S_O.h"
#include "wnquery.h"
#include "KSSaleFuc.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "StdBaseForm"
#pragma resource "*.dfm"
TfrmSogd_S_O *frmSogd_S_O;
//---------------------------------------------------------------------------
__fastcall TfrmSogd_S_O::TfrmSogd_S_O(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TStdBaseForm(Owner,chWnd,MidCode,WhereStr)
{
InitControlGroup();
}
__fastcall TfrmSogd_S_O::TfrmSogd_S_O(TComponent* Owner)
: TStdBaseForm(Owner)
{
InitControlGroup();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogd_S_O::seSogdSoCodeButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="005[销售订单][开单日期][币种][税码][业务员]select sohcode,sohdate,currencyname,taxname,sohsaler from sdsoh,sdcurrency,sdtax";
SqlStr+=" where Sohcurrency=currencycode and Sohtaxcode=taxcode and Sohcheck=1 and Sohclose=0 and Sohcancel=0 ";
if (cbSameTax->Checked)
SqlStr+=" and SohtaxCode='"+FSoghTax+"' ";
if (cbSameClient->Checked)
SqlStr+=" and SohClient='"+FSoghClient+"' ";
if (cbSameCurrency->Checked)
SqlStr+=" and Sohcurrency='"+FSoghCurrency+"' ";
SqlStr+=" order by Sohcode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"销售订单查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seSogdSoCode->Text=p->ColData[1];
FillGridWithData();
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogd_S_O::bbSelAllClick(TObject *Sender)
{
for(int i=1;i<sgSod->RowCount;i++)
sgSod->Cells[1][i] = "√";
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogd_S_O::bbSelNoneClick(TObject *Sender)
{
for(int i=1;i<sgSod->RowCount;i++)
sgSod->Cells[1][i] = "";
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogd_S_O::btnOKClick(TObject *Sender)
{
double FVal,FPrice,FQty,FTax,FAmt,FDisc;
int ErrNum;
AnsiString MarkeGoods = " ", msg = "由于你不是下列货物的物料操作员,所以以下货物被取消!\r\n";
try
{
StartWaitForm("正在生成发货单,请稍候...");
if(sgSod->RowCount>1)
{
int j;
j=comServer->ItemCount-1;
if(j>=0)
{
comServer->LocateItemByIndex(j);
j=StrToInt(frmSogh_S_O->GetDetailValue("SogdLine"));
j=j+1;
}
else
j=1;
for(int i=1;i<sgSod->RowCount;i++)
{
if(sgSod->Cells[1][i]=="√")
{
comServer->AddItem();
if ( !IsLegitGU(sgSod->Cells[3][i], Query) ) {
MarkeGoods += sgSod->Cells[4][i] + ", ";
continue;
}
SetDetailValue("SogdCode",frmSogh_S_O->seSoghCode->Text);
SetDetailValue("SogdCode",seSogdSoCode->Text);
SetDetailValue("SogdLine",AnsiString(j));
SetDetailValue("SogdSoCode",seSogdSoCode->Text);
SetDetailValue("SogdSodLine", sgSod->Cells[2][i]);
SetDetailValue("SogdGoods", sgSod->Cells[3][i]);
SetDetailValue("SogdGoodsName",sgSod->Cells[4][i]);
SetDetailValue("SogdGoodsSpec",sgSod->Cells[5][i]);
SetDetailValue("SogdUnit", sgSod->Cells[6][i]);
SetDetailValue("SogdConv", sgSod->Cells[7][i]);
SetDetailValue("SogdLoc", sgSod->Cells[8][i]);
SetDetailValue("SogdQty", sgSod->Cells[10][i]);
SetDetailValue("SogdPrice", sgSod->Cells[11][i]);
FQty=sgSod->Cells[10][i].ToDouble();
FPrice=sgSod->Cells[11][i].ToDouble();
FVal=(FQty*FPrice)/(1+FSoghTaxRate);
FAmt=DataCarry(FVal,2,0);
FTax=DataCarry(FVal*FSoghTaxRate,2,0);
SetDetailValue("SogdAmt",AnsiString(FAmt));
SetDetailValue("SogdTaxAmt",AnsiString(FTax));
SetDetailValue("SogdDisc",sgSod->Cells[14][i]);
FDisc=sgSod->Cells[14][i].ToDouble();
FVal=DataCarry((FQty*FPrice)*FDisc,2,0);
SetDetailValue("SogdDAmt",AnsiString(FVal));
SetDetailValue("SogdRecDate", sgSod->Cells[16][i]);
SetDetailValue("SogdDesc"," ");
SetDetailValue("SogdBatch"," ");
SetDetailValue("SogdState","1");
comServer->AddToObject();
j=j+1;
}
}
if ( MarkeGoods != " " )
ShowMessage(msg+MarkeGoods);
} // end if .
}
catch(Exception &e)
{
comServer->FreeItem();
this->ModalResult=0;
throw Exception(e.Message);
}
EndWaitForm();
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogd_S_O::btnCancelClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogd_S_O::InitControlGroup()
{
sgSod->RowCount = 1;
seSogdSoCode->Text="";
seSoghClient->Text=frmSogh_S_O->seSoghClient->Text;
seSoghClient->Enabled=false;
FSoghClient=frmSogh_S_O->seSoghClient->ItemData[cbItem2];
seSoghCurrency->Text=frmSogh_S_O->seSoghCurrency->Text;
seSoghCurrency->Enabled=false;
FSoghCurrency=frmSogh_S_O->seSoghCurrency->ItemData[cbItem2];
seSoghRate->Text=frmSogh_S_O->seSoghEnrate->Text;
seSoghTax->Text=frmSogh_S_O->scSoghTaxCode->Text;
seSoghTax->Enabled=false;
FSoghTax=frmSogh_S_O->scSoghTaxCode->ItemData[cbItem2];
if(frmSogh_S_O->scSoghTaxCode->ItemIndex==-1)
FSoghTaxRate=0;
else
FSoghTaxRate=frmSogh_S_O->scSoghTaxCode->ItemData[cbItem3].ToDouble();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogd_S_O::FillGridWithData()
{
double FVal,FQty,FPrice,FTax,FAmt,FDisc,FDAmt;
AnsiString ItemStr,s_SQL;
s_SQL=AnsiString(" Select SodLine,SodGoods,SodGoodsName=ISNULL((SELECT GoodsName FROM sdGoods WHERE SodGoods=GoodsCode),''),")
+AnsiString(" SodGoodsSpec=ISNULL((SELECT GoodsSpec FROM sdGoods WHERE SodGoods=GoodsCode),''),SodUnit,SodConv,SodQty=SodQty-SodSQty,")
+AnsiString(" SodPrice,SodRecDate,SodDisc from sdSod where SodCode='"+seSogdSoCode->Text+"'")
+AnsiString(" and SodClose = 0 and SodQty-SodSQty>0 order by Sodline");
TComResultSet *RsSogd;
sgSod->RowCount=1;
try
{
StartWaitForm("正在查询数据,请稍候...");
RsSogd=new TComResultSet(Handle,g_ClientHandle);
RsSogd->Open(WideString(s_SQL),WideString(""));
while( RsSogd->Eof == 0)
{
FQty=RsSogd->FieldByName("SodQty").ToDouble();
FPrice=RsSogd->FieldByName("SodPrice").ToDouble();
FDisc=RsSogd->FieldByName("SodDisc").ToDouble();
FVal=FQty*FPrice;
FAmt=DataCarry(FVal,2,0);
FTax=DataCarry(FAmt*FSoghTaxRate,2,0);
FDAmt=DataCarry(FVal*FDisc,2,0);
ItemStr="\t"+AnsiString("√") +
"\t"+RsSogd->FieldByName("SodLine")+
"\t"+RsSogd->FieldByName("SodGoods")+
"\t"+RsSogd->FieldByName("SodGoodsName")+
"\t"+RsSogd->FieldByName("SodGoodsSpec")+
"\t"+RsSogd->FieldByName("SodUnit")+
"\t"+RsSogd->FieldByName("SodConv")+
"\t"+""+
"\t"+RsSogd->FieldByName("SodQty")+
"\t"+RsSogd->FieldByName("SodQty")+
"\t"+RsSogd->FieldByName("SodPrice")+
"\t"+AnsiString(FAmt)+
"\t"+AnsiString(FTax)+
"\t"+RsSogd->FieldByName("SodDisc")+
"\t"+AnsiString(FDAmt)+
"\t"+RsSogd->FieldByName("SodRecDate");
sgSod->AddItem(ItemStr);
RsSogd->MoveNext();
}
RsSogd->Close();
delete RsSogd;
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogd_S_O::GetComObject(TComServer *comServerPtr)
{
comServer = comServerPtr;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TfrmSogd_S_O::sgSodDblClick(TObject *Sender)
{
AnsiString SqlStr;
int ARow=sgSod->Row;
if (ARow >0)
{
if(sgSod->Col==1)
{
if (sgSod->Cells[1][ARow] == "√")
sgSod->Cells[1][ARow] = "";
else
sgSod->Cells[1][ARow] = "√";
}
else if(sgSod->Col==8 && sgSod->Cells[1][ARow] == "√")
{
SqlStr="002[货位代码][货位名称]select loccode,locname from sdLoc,sdlg ";
SqlStr+=" where lgLoccode=loccode and lggoodscode='"+sgSod->Cells[3][ARow]+"'";
SqlStr+= " and LocType=1 order by locCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"货位查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sgSod->Cells[8][ARow]=p->ColData[1];
}
delete p;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogd_S_O::sgSodSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if(sgSod->Cells[sgSod->Col][sgSod->Row]=="√")
sgSod->ReadOnly=true;
else
sgSod->ReadOnly=false;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?