sogh_n_o.cpp

来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 986 行 · 第 1/3 页

CPP
986
字号
        break;
      case 1:
        sgSogd->ChangeItem(ItemStr,sgSogd->Row);
        break;
	  case 2:
        sgSogd->RemoveItem(sgSogd->Row);
	}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::DisplayBill()
{
    if(comServer->RecordCount<1)
       return;
    GetDataFromComObject(1);
    ChangeToBrowseState(true);
    FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::GetBill(AnsiString BillID)
{
    if(comServer->Find("SoghCode='"+BillID+"'"))
       DisplayBill();
    else
    {
       if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
          AddHeadRecord();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
	sgSogd->RowCount=1;
		for(i=0;i<comServer->ItemCount;i++)
	{
       comServer->LocateItemByIndex(i);
       RefreshGridData(0);
    }
    comServer->LocateItemByIndex(0);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    TBillBaseForm::MoveToFirst();
    ChangeToBrowseState(true);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::sgSogdDblClick(TObject *Sender)
{
	int iRow;
	iRow=sgSogd->Row;
	if(iRow == 0)
	  return;
	GetDataFromComObject(2);


	ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::ChangeToBrowseState(bool t_browse)
{
    if(t_browse){
      sgSogd->Visible=true;
      FloatPanel2->Visible=false;
      sgSogd->Align=alClient;
      FloatPanel2->Align=alNone;
    }
    else{
      sgSogd->Visible=false;
      FloatPanel2->Visible=true;
      sgSogd->Align=alNone;
      FloatPanel2->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::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 TfrmSogh_N_O::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::seSogdQtyExit(TObject *Sender)
{
    CalculateAmt();
}
//---------------------------------------------------------------------------
void  __fastcall TfrmSogh_N_O::RefreshUpdateData(int MsgSrc,int MsgType)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::seSoghCodeKeyDown(TObject *Sender, WORD &Key,
	  TShiftState Shift)
{
	if(Key==13 && CurrentState==caNormal)
	{
	   comServer->LocateByKey(WideString(seSoghCode->Text));
	   DisplayBill();
	}
}
//---------------------------------------------------------------------------
bool __fastcall TfrmSogh_N_O::SetClients(TGetValueType GetValueType, AnsiString ClientsCode)
{
	seSoghClient->LocateKey(GetClientValue(GetValueType,"ClientCode"));
	if(seSoghCurrency->LocateKey(GetClientValue(GetValueType,"ClientCurrency")))
	{
	  if(seSoghCurrency->ItemData[cbItem4]=="1")
	  {
		seSoghEnrate->Enabled=false;
		seSoghEnrate->Text="1";
	  }
	  else
	  {
		seSoghEnrate->Enabled=true;
		seSoghEnrate->Text=seSoghCurrency->ItemData[cbItem3];
	  }
	}
	scSoghTaxCode->LocateKey(GetClientValue(GetValueType,"ClientTaxCode"));
	scSoghSaler->LocateKey(GetClientValue(GetValueType,"ClientSaler"));

	  Query->Close();
	  Query->Open( "SELECT * FROM sdssite WHERE SsiteDefault=1 and SsiteClient='"+ClientsCode+"'","");
		seSoghSsite->LocateKey(Query->FieldByName("SsiteCode"));
		scSoghTransMode->LocateKey(Query->FieldByName("SsiteTransMode"));
	  Query->Close();


	  Query->Open( "SELECT * FROM sdssd WHERE SsdDefault=1 AND SsdClient='"+ClientsCode+"'","");
		  scSoghSettleMode->LocateKey(Query->FieldByName("SsdPayMode"));
	  Query->Close();
	return true;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmSogh_N_O::SetGoods(TGetValueType GetValueType, AnsiString GoodsCode, int ShowURight)
{

  if (ShowURight==1)
  {
	  if (!IsLegitGU(GoodsCode,Query))
		return false;
  }

  if (!InitRsGoods(GoodsCode))
	  return false;
	  
  seSogdGoods->Text=GetGoodsValue(GetValueType ,"GoodsCode");
  seSogdGoodsName->Text=GetGoodsValue(GetValueType,"GoodsName");
  if(CurrentState!=caNormal)
  {
  seSogdUnit->LocateKey(GetGoodsValue( GetValueType ,"GoodsUnitCode"));
  seSogdConv->Text="1";
  if(GetGoodsValue(GetValueType ,"GoodsMUnit")=="0")
  {
	seSogdUnit->Enabled=false;
	seSogdConv->Enabled=false;
  }
  else
  {
	seSogdUnit->Enabled=true;
	seSogdConv->Enabled=true;
  }
  if(GetGoodsValue(GetValueType ,"GoodsBatch")=="0")
  {
	seSogdBatch->ItemIndex=-1;
	seSogdBatch->Enabled=false;
  }
  else
	seSogdBatch->Enabled=true;
  }
  return true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::CalculateAmt()
{
	double FAmt,FTaxAmt,FVal,FTaxRate,FDiscAmt;
	if (scSoghTaxCode->Text == "")
	   FTaxRate=1;
	else
	   if(scSoghTaxCode->ItemIndex!=-1)
			FTaxRate=scSoghTaxCode->ItemData[cbItem3].ToDouble();

	FVal=DataCarry(seSogdQty->Text.ToDouble()*seSogdPrice->Text.ToDouble(),2,0);
	  FTaxAmt=DataCarry(FVal*FTaxRate,2,0);
//FTaxAmt=DataCarry(FAmt*FTaxRate,2,0);  // FTaxAmt=FVal-FAmt;
  {
  Query->Close();
  Query->Open("SELECT ParameterValue FROM sdParameter WHERE  ParameterCode='10414'","");
	  if (StrToInt(Query->FieldByName("ParameterValue")))
	  {	// 含税价 
		FAmt=DataCarry(FVal-(FVal*FTaxRate),2,0);
		FDiscAmt=DataCarry((FAmt+FTaxAmt)*(seSogdDisc->Text.ToDouble()),2,0);

		seSogdAmt->Text=FAmt;
	  }
	  else		//  不含税价 
	  {   
		FDiscAmt=DataCarry((FVal)*(seSogdDisc->Text.ToDouble()),2,0);

		seSogdAmt->Text=FVal;
	  }	  
  Query->Close();
  }
	
//	FDiscAmt=DataCarry((FAmt+FTaxAmt)*(seSogdDisc->Text.ToDouble()),2,0);
//	seSogdAmt->Text=FAmt;

	seSogdTaxAmt->Text=FTaxAmt;
	seSogdDAmt->Text=FDiscAmt;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::seSoghCurrencyButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="002[货币代码][货币名称]select Currencycode,CurrencyName from sdCurrency,sdssd where ssdCurrency=CurrencyCode and ";
    SqlStr+="ssdClient='"+seSoghClient->ItemData[cbItem2]+"' order by CurrencyCode";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"客户货币查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
      if(seSoghCurrency->LocateKey(p->ColData[1]))
      {
         if(seSoghCurrency->ItemData[cbItem4]=="1")
         {
           seSoghEnrate->Enabled=false;
           seSoghEnrate->Text="1";
         }
         else
         {
           seSoghEnrate->Enabled=true;
           seSoghEnrate->Text=seSoghCurrency->ItemData[cbItem3];
		 }
      }
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::seSoghSsiteButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="003[货运地址代码][货运地址名称][联系人]select SsiteCode,SsiteName,Ssitelinkman from sdSsite where ";
    SqlStr+="SsiteClient='"+seSoghClient->ItemData[cbItem2]+"' order by SsiteCode";
    TfrmWnQuery *p;
    try
    {
      StartWaitForm("正在查询,请稍候...");
      p=new TfrmWnQuery(this,"货运地址查询",SqlStr);
    }
    __finally
    {
      EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
      seSoghSsite->LocateKey(p->ColData[1]);
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::seSogdLocButtonClick(TObject *Sender)
{
	AnsiString SqlStr;
    SqlStr="003[货位编码][货位名称][结存数量]select LocCode,LocName, MaccFopQty from sdLoc,sdLg, sdMacc ";
    SqlStr+="where LocCode=lgLocCode and MaccLoc=LocCode And lgState=1 and ";
    SqlStr+="MaccFMonth=(SELECT FcMonth FROM sdFc WHERE FcCurrent='1') And MaccGoods='"+seSogdGoods->Text+" ' and ";
    SqlStr+="lggoodscode='"+seSogdGoods->Text+"' order by LocCode";
    TfrmWnQuery *p;
    try
    {
      StartWaitForm("正在查询,请稍候...");
      p=new TfrmWnQuery(this,"货位查询",SqlStr);
    }
    __finally
    {
      EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
      seSogdLoc->LocateKey(p->ColData[1]);
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::seSogdPriceExit(TObject *Sender)
{
    CalculateAmt();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::seSogdDiscExit(TObject *Sender)
{
    CalculateAmt();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_N_O::seSogdQtyButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="003[当前月份][计量单位][库存数量]";
    SqlStr+="select MaccFmonth,GoodsUnitCode,MaccAoyQty from sdMacc,sdGoods where MaccGoods=GoodsCode and ";

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?