sogh_n_o.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 986 行 · 第 1/3 页
CPP
986 行
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Sogh_N_O.h"
#include "KSSaleFuc.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "BillBaseForm"
#pragma link "DateEdit"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSogh_N_O *frmSogh_N_O;
//---------------------------------------------------------------------------
__fastcall TfrmSogh_N_O::TfrmSogh_N_O(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TBillBaseForm(Owner,chWnd,MidCode,WhereStr)
{
SetAutoCodeString(seSoghCode,"Acm-013"); // sogh Y
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::InitEditControl()
{
ClientGroup->AddComponent(1,false,false,true,FloatPanel1,FloatPanel1->Name);
ClientGroup->AddComponent(1,true,true,true,FloatPanel3,FloatPanel3->Name);
ClientGroup->AddComponent(1,true,true,false,sgSogd,sgSogd->Name);
ClientGroup->AddComponent(1,false,true,false,seSoghCode,seSoghCode->Name);
ClientGroup->AddComponent(1,false,true,true,seSoghClient,seSoghClient->Name);
ClientGroup->AddComponent(1,true,true,true,scSoghType,scSoghType->Name);
ClientGroup->AddComponent(1,true,true,true,scSoghState,scSoghState->Name);
ClientGroup->AddComponent(1,false,true,true,scSoghTaxCode,scSoghTaxCode->Name);
ClientGroup->AddComponent(1,true,true,true,scSoghFmonth,scSoghFmonth->Name);
// ClientGroup->AddComponent(1,false,true,true,scSoghSaler,scSoghSaler->Name);
ClientGroup->AddComponent(2,false,false,true,FloatPanel2,FloatPanel2->Name);
ClientGroup->AddComponent(2,false,false,true,seSogdGoods,seSogdGoods->Name);
ClientGroup->AddComponent(2,true,true,true,seSogdGoodsName,seSogdGoodsName->Name);
ClientGroup->AddComponent(2,false,false,true,seSogdUnit,seSogdUnit->Name);
ClientGroup->AddComponent(2,true,true,true,seSogdConv,seSogdConv->Name);
ClientGroup->AddComponent(2,true,true,true,seSogdAmt,seSogdAmt->Name);
ClientGroup->AddComponent(2,true,true,true,seSogdDAmt,seSogdDAmt->Name);
ClientGroup->AddComponent(2,true,true,true,seSogdTaxAmt,seSogdTaxAmt->Name);
ClientGroup->AddComponent(2,false,false,true,deSogdRecDate,deSogdRecDate->Name);
ClientGroup->AddComponent(2,true,true,true,GroupBox4,GroupBox4->Name);
ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);
//Sogh
FillComboBox(Handle,scSoghFmonth,"SELECT FcMonth FROM sdFc","FcMonth");
FillComboBox(Handle,scSoghPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where postypeflg=2 order by PosTypeCode","PosTypeName","PosTypeCode");
FillEdit(Query,seSoghClient,"SELECT ClientName,ClientCode,ClientCurrency,ClientTaxCode FROM sdClient where ClientCancel=0","ClientName","ClientCode","ClientCurrency","ClientTaxCode");
FillComboBox(Handle,scSoghDeliver,"SELECT DeliverName,DeliverCode FROM sdDeliver order by DeliverCode","DeliverName","DeliverCode");
FillComboBox(Handle,scSoghTaxCode,"SELECT TaxName,TaxCode,TaxRate FROM sdTax order by TaxCode","TaxName","TaxCode","TaxRate");
//DONE:BUG NO.741 FIXED 9-10
AnsiString sSql;
sSql =AnsiString("select currencycode,currencyname,currencyrate=coalesce(rateratio,1),currencylocal from sdcurrency,sdrate");
sSql+=" where currencycode*=ratecurrency and ";
sSql+=" ratefmonth='"+g_sdSMonth+"'";
FillEdit(Query,seSoghCurrency,sSql,"CurrencyName","CurrencyCode","CurrencyRate","CurrencyLocal");
FillEdit(Query,seSoghSsite,"SELECT SsiteName,SsiteCode FROM sdSsite","SSiteName","SsiteCode");
FillComboBox(Handle,scSoghTransMode,"SELECT TransModeName,TransModeCode FROM sdTransMode order by TransModeCode","TransModeName","TransModeCode");
FillComboBox(Handle,scSoghSettleMode,"select settlemodename,settlemodecode from sdsettlemode order by settlemodename","settleModeName","SettleModeCode");
FillComboBox(Handle,scSoghSaler,"Select Salercode, UserName As Salername from sduser,sdsaler where salercode=usercode order by username","SalerName","SalerCode");
//Sogd
FillEdit(Query,seSogdLoc,"select LocCode,LocName from sdLoc where Loctype=1 or loctype=4 order by LocCode","LocName","LocCode");
FillEdit(Query,seSogdUnit,"SELECT UnitCode,UnitName FROM sdUnit ","UnitName","UnitCode");
FillEdit(Query,seSogdBatch,"SELECT BatchCode,BatchDesc FROM sdBatch ","BatchDesc","BatchCode");
scSoghType->ClearAll();
scSoghType->AddItems("据订单发货","1");
scSoghType->AddItems("非订单发货","2");
scSoghState->ClearAll();
scSoghState->AddItems("预备","1");
scSoghState->AddItems("确认","2");
scSoghState->AddItems("待下达","3");
scSoghState->AddItems("已下达","4");
scSoghState->AddItems("已完成","5");
scSogdState->ClearAll();
scSogdState->AddItems("预备","1");
scSogdState->AddItems("确认","2");
scSogdState->AddItems("待下达","3");
scSogdState->AddItems("已下达","4");
scSogdState->AddItems("已完成","5");
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::ClearControl(int Section,bool BringToNext)
{
if(Section == 1)
{
if(!BringToNext)
{
seSoghCode->Text = "";
scSoghType->LocateKey("2");
scSoghFmonth->Text = g_sdSMonth;
scSoghPosType->ItemIndex = -1;
deSoghDate->Text = g_sdCurDate;
seSoghClient->ItemIndex = -1;
scSoghDeliver->ItemIndex = -1;
seSoghSsite->ItemIndex = -1;
seSoghCurrency->ItemIndex = -1;
seSoghEnrate->Text = "1";
scSoghTransMode->ItemIndex = -1;
seSoghTransCode->Text = "";
scSoghTaxCode->ItemIndex = 1;
seSoghDesc->Text = "";
scSoghSettleMode->ItemIndex = -1;
scSoghSaler->ItemIndex = -1;
scSoghUser->Text = g_sdUserCode;
cheSoghCheck->Checked = false;
seSoghChecker->Text = "";
cheSoghCancel->Checked = false;
cheSoghClose->Checked = false;
lbSoghSysDate->Caption = "";
scSoghState->ItemIndex = 0;
}
sgSogd->RowCount=1;
}
else if(Section==2)
{
if(!BringToNext)
{
seSogdLine->Text = AnsiString(comServer->ItemCount+1);
seSogdGoods->Text ="";
seSogdGoodsName->Text ="";
seSogdUnit->ItemIndex = -1;
seSogdConv->Text = "1";
seSogdPrice->Text = "0";
seSogdQty->Text = "0";
seSogdAmt->Text = "0.00";
seSogdTaxAmt->Text = "0.00";
seSogdDisc->Text = "0.00";
seSogdDAmt->Text = "0.00";
labSogdOQty->Caption = "0";
labSogdBQty->Caption = "0";
labSogdVQty->Caption = "0";
labSogdFQty->Caption = "0";
labSogdEQty->Caption = "0";
cheSogdClose->Checked = false;
seSogdCloseDate->Text = "";
scSogdState->ItemIndex= 1;
deSogdRecDate->Text = g_sdCurDate;
seSogdLoc->ItemIndex = -1;
seSogdBatch->Text="";
memSogdDesc->Text="";
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::GetDataFromComObject(int Section)
{
if(Section==1)
{
seSoghCode->Text = GetHeadValue("SoghCode");
scSoghType->LocateKey(GetHeadValue("SoghType"));
scSoghFmonth->Text = GetHeadValue("SoghFmonth");
scSoghPosType->LocateKey(GetHeadValue("SoghPosType"));
deSoghDate->Text = GetHeadValue("SoghDate");
seSoghClient->LocateKey(GetHeadValue("SoghClient"));
seSoghCurrency->LocateKey(GetHeadValue("SoghCurrency"));
if(seSoghCurrency->ItemData[cbItem4]=="1")
seSoghEnrate->Enabled=false;
seSoghEnrate->Text = GetHeadValue("SoghEnrate");
scSoghTaxCode->LocateKey(GetHeadValue("SoghTaxCode"));
scSoghDeliver->LocateKey(GetHeadValue("SoghDeliver"));
seSoghSsite->LocateKey(GetHeadValue("SoghSsite"));
scSoghTransMode->LocateKey(GetHeadValue("SoghTransMode"));
seSoghTransCode->Text = GetHeadValue("SoghTransCode");
scSoghUser->Text = GetHeadValue("SoghUser");
// scSoghUser->Text = "USER NAME" ;
scSoghState->LocateKey(GetHeadValue("SoghState"));
scSoghSaler->LocateKey(GetHeadValue("SoghSaler"));
scSoghSettleMode->LocateKey(GetHeadValue("SoghSettleMode"));
cheSoghCheck->Checked = GetHeadValue("SoghCheck")=="1";
seSoghChecker->Text=GetHeadValue("SoghChecker");
cheSoghCancel->Checked = GetHeadValue("SoghCancel")=="1";
cheSoghClose->Checked=GetHeadValue("SoghClose")=="1";
lbSoghSysDate->Caption = GetHeadValue("SoghSysDate");
seSoghDesc->Text = GetHeadValue("SoghDesc");
SetCheckToolbarStatus(cheSoghCheck->Checked);
SetCancelToolbarStatus(cheSoghCancel->Checked);
SetCloseToolbarStatus(cheSoghClose->Checked);
}
else
{
seSogdLine->Text = GetDetailValue("SogdLine");
seSogdGoods->Text = GetDetailValue("SogdGoods");
seSogdGoodsName->Text = GetDetailValue("SogdGoodsName");
seSogdGoodsSpec->Text = GetDetailValue("SogdGoodsSpec");
seSogdUnit->LocateKey(GetDetailValue("SogdUnit"));
seSogdConv->Text = GetDetailValue("SogdConv");
seSogdQty->Text = GetDetailValue("SogdQty");
seSogdPrice->Text = GetDetailValue("SogdPrice");
seSogdAmt->Text = GetDetailValue("SogdAmt");
seSogdTaxAmt->Text = GetDetailValue("SogdTaxAmt");
seSogdDisc->Text = GetDetailValue("SogdDisc");
seSogdDAmt->Text = GetDetailValue("SogdDAmt");
labSogdOQty->Caption = GetDetailValue("SogdOQty");
labSogdBQty->Caption = GetDetailValue("SogdBQty");
labSogdVQty->Caption = GetDetailValue("SogdVQty");
labSogdFQty->Caption = GetDetailValue("SogdFQty");
labSogdEQty->Caption = GetDetailValue("SogdEQty");
seSogdLoc->LocateKey(GetDetailValue("SogdLoc"));
seSogdBatch->Text = GetDetailValue("SogdBatch");
deSogdRecDate->Text = GetDetailValue("SogdRecDate");
memSogdDesc->Text=GetDetailValue("SogdDesc");
cheSogdClose->Checked = GetDetailValue("SogdClose")=="1";
seSogdCloseDate->Text = GetDetailValue("SogdCloseDate");
scSogdState->LocateKey(GetDetailValue("SogdState"));
SetCloseItemStatus(cheSogdClose->Checked);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::SendDataToComObject(int Section)
{
AnsiString s;
if(Section==1)
{
if ( seSoghCode->Text.IsEmpty() )
throw Exception("发货单号不能为空!");
if ( scSoghFmonth->Text.IsEmpty())
throw Exception("财务月份不能为空!");
if ( seSoghClient->ItemData[cbItem2]=="" )
throw Exception("客户不能为空!");
if ( seSoghCurrency->ItemData[cbItem2]=="" )
throw Exception("币种不能为空!");
if ( scSoghTaxCode->ItemData[cbItem2]=="" )
throw Exception("税码不能为空!");
if ( scSoghSaler->Text.IsEmpty() )
throw Exception("业务员不能为空!");
SetHeadValue("SoghCode",seSoghCode->Text);
SetHeadValue("SoghType","2"/*scSoghType->ItemData[cbItem2]*/);
SetHeadValue("SoghPosType",scSoghPosType->ItemData[cbItem2]);
SetHeadValue("SoghFmonth",scSoghFmonth->Text);
SetHeadValue("SoghDate",deSoghDate->Text);
SetHeadValue("SoghClient",seSoghClient->ItemData[cbItem2]);
SetHeadValue("SoghCurrency",seSoghCurrency->ItemData[cbItem2]);
SetHeadValue("SoghEnrate",seSoghEnrate->Text);
SetHeadValue("SoghTaxCode",scSoghTaxCode->ItemData[cbItem2]);
SetHeadValue("SoghTransCode",seSoghTransCode->Text);
SetHeadValue("SoghDeliver",scSoghDeliver->ItemData[cbItem2]);
SetHeadValue("SoghSsite",seSoghSsite->ItemData[cbItem2]);
SetHeadValue("SoghTransMode",scSoghTransMode->ItemData[cbItem2]);
SetHeadValue("SoghSettleMode",scSoghSettleMode->ItemData[cbItem2]);
SetHeadValue("SoghSaler",scSoghSaler->ItemData[cbItem2]);
SetHeadValue("SoghDesc",seSoghDesc->Text);
SetHeadValue("SoghUser",g_sdUserCode);
SetHeadValue("SoghState",scSoghState->ItemData[cbItem2]);
}
else
{
InitRsGoods(seSogdGoods->Text);
if(seSogdGoods->Text.IsEmpty())
throw Exception("物料编码不能为空!");
if(seSogdUnit->ItemData[cbItem2]=="")
throw Exception("计量单位不能为空!");
if(seSogdPrice->Text.IsEmpty())
throw Exception("销售价!");
if(deSogdRecDate->Text.IsEmpty())
throw Exception("交货日不能为空");
if(GetGoodsValue(gtInitRs,"GoodsBatch")=="1"&&seSogdBatch->Text.IsEmpty())
throw Exception("该物料需要批次管理");
CalculateAmt();
SetDetailValue("SogdCode",seSoghCode->Text);
SetDetailValue("SogdLine",seSogdLine->Text);
SetDetailValue("SogdGoods",seSogdGoods->Text);
SetDetailValue("SogdGoodsName",seSogdGoodsName->Text);
SetDetailValue("SogdGoodsSpec",seSogdGoodsSpec->Text);
SetDetailValue("SogdUnit",seSogdUnit->ItemData[cbItem2]);
SetDetailValue("SogdConv",seSogdConv->Text);
SetDetailValue("SogdQty",seSogdQty->Text);
SetDetailValue("SogdPrice",seSogdPrice->Text);
SetDetailValue("SogdAmt",seSogdAmt->Text);
SetDetailValue("SogdTaxAmt",seSogdTaxAmt->Text);
SetDetailValue("SogdDisc",seSogdDisc->Text);
SetDetailValue("SogdDAmt",seSogdDAmt->Text);
SetDetailValue("SogdLoc",seSogdLoc->ItemData[cbItem2]);
SetDetailValue("SogdRecDate",deSogdRecDate->Text);
SetDetailValue("SogdBatch",seSogdBatch->ItemData[cbItem2]);
SetDetailValue("SogdDesc",memSogdDesc->Text);
SetDetailValue("SogdState",scSogdState->ItemData[cbItem2]);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::WaitUserInput(int Section)
{
if(Section ==1){
if(seSoghCode->Enabled)
seSoghCode->SetFocus();
}
else{
ChangeToBrowseState(false);
if(seSogdLine->Enabled)
seSogdLine->SetFocus();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSogh_N_O::GetItemString()
{
AnsiString ItemStr;
ItemStr = "\t"+GetDetailValue("SogdLine")+
"\t"+GetDetailValue("SogdGoods")+
"\t"+GetDetailValue("SogdGoodsName")+
"\t"+GetDetailValue("SogdGoodsSpec")+
"\t"+GetDetailValue("SogdUnit")+
"\t"+GetDetailValue("SogdPrice")+
"\t"+GetDetailValue("SogdQty")+
"\t"+GetDetailValue("SogdAmt")+
"\t"+GetDetailValue("SogdTaxAmt")+
"\t"+GetDetailValue("SogdDAmt")+
"\t"+GetDetailValue("SogdOQty");
return(ItemStr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::RefreshGridData(int mAction)
{
AnsiString ItemStr;
ItemStr=GetItemString();
switch(mAction)
{
case 0:
sgSogd->AddItem(ItemStr);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?