sretd.cpp

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

CPP
277
字号
//--------------------------------------------------------------------------
#include <vcl.h>
#include "Sretd.h"
#include "Sreth.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"

TfrmSretd  *frmSretd;
//--------------------------------------------------------------------------
__fastcall TfrmSretd::TfrmSretd(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
		: TStdBaseForm(Owner,chWnd,MidCode,WhereStr)
{
  InitControlGroup();
}
__fastcall TfrmSretd::TfrmSretd(TComponent* Owner)
 : TStdBaseForm(Owner)
{
 InitControlGroup();
}
//--------------------------------------------------------------------------

void __fastcall TfrmSretd::btnOKClick(TObject *Sender)
{
  double FVal,FPrice,FQty,FTax,FAmt;
  int ErrNum;
  AnsiString MarkeGoods = " ", msg = "由于你不是下列货物的物料操作员,所以以下货物被取消!\r\n";

  try
  {
   try
   {
	StartWaitForm("正在生成退货单,请稍候...");
	if(sgSretd->RowCount>1)
	{
	   int j;
	   j=comServer->ItemCount-1;
	   if(j>=0)
	   {
		  comServer->LocateItemByIndex(j);
		  j=StrToInt(frmSreth->GetDetailValue("SretdLine"));
		  j=j+1;
	   }
	   else
		  j=1;
	   for(int i=1;i<sgSretd->RowCount;i++)
	   {
		   if(sgSretd->Cells[1][i]=="√")
		   {
			   comServer->AddItem();
			   if ( !IsLegitGU(sgSretd->Cells[3][i], Query) ) {
				  MarkeGoods += sgSretd->Cells[4][i] + ", ";
				  continue;
			   }
			   SetDetailValue("SretdCode",frmSreth->seSrethCode->Text);
			   SetDetailValue("SretdLine",AnsiString(j));
			   SetDetailValue("SretdSogCode",seSretdSogCode->Text);
			   SetDetailValue("SretdSogdLine", sgSretd->Cells[2][i]);
			   SetDetailValue("SretdGoods", sgSretd->Cells[3][i]);
			   SetDetailValue("SretdGoodsName", sgSretd->Cells[4][i]);
			   SetDetailValue("SretdGoodsSpec", sgSretd->Cells[5][i]);
			   SetDetailValue("SretdUnit", sgSretd->Cells[6][i]);
			   SetDetailValue("SretdConv", sgSretd->Cells[7][i]);
			   SetDetailValue("SretdQty", sgSretd->Cells[9][i]);
			   SetDetailValue("SretdPrice", sgSretd->Cells[10][i]);
			   FQty=sgSretd->Cells[9][i].ToDouble();
			   FPrice=sgSretd->Cells[10][i].ToDouble();
			   FVal=(FQty*FPrice)/(1+FSrethTaxRate);
			   FAmt=DataCarry(FVal,2,0);
			   FTax=DataCarry(FVal*FSrethTaxRate,2,0);
			   SetDetailValue("SretdAmt",AnsiString(FAmt));
			   SetDetailValue("SretdTaxAmt",AnsiString(FTax));
			   SetDetailValue("SretdLoc", sgSretd->Cells[11][i]);
			   SetDetailValue("SretdBatch", sgSretd->Cells[12][i]);
			   SetDetailValue("SretdExes","0");
			   SetDetailValue("SretdDesc"," ");
			   SetDetailValue("SretdState", "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);
   }
  }
  __finally
  {
	EndWaitForm();
  }
  Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSretd::btnCancelClick(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSretd::InitControlGroup()
{
    sgSretd->RowCount = 1;
    seSretdSogCode->Text="";
    seSrethClient->Text=frmSreth->seSrethClient->Text;
    seSrethClient->Enabled=false;
    FSrethClient=frmSreth->seSrethClient->ItemData[cbItem2];
    seSrethCurrency->Text=frmSreth->seSrethCurrency->Text;
    seSrethCurrency->Enabled=false;
    FSrethCurrency=frmSreth->seSrethCurrency->ItemData[cbItem2];
    seSrethRate->Text=frmSreth->seSrethEnrate->Text;
    seSrethTax->Text=frmSreth->scSrethTaxCode->Text;
    seSrethTax->Enabled=false;
    FSrethTax=frmSreth->scSrethTaxCode->ItemData[cbItem2];
    if(frmSreth->scSrethTaxCode->ItemData[cbItem3] == "")
     FSrethTaxRate=0;
    else
     FSrethTaxRate=frmSreth->scSrethTaxCode->ItemData[cbItem3].ToDouble();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSretd::FillGridWithData()
{

    AnsiString  ItemStr,s_SQL;
    double d_SogdQty;
	s_SQL=AnsiString(" Select SogdLine,sogdGoods,sogdGoodsName=ISNULL((SELECT GoodsName FROM sdGoods WHERE SogdGoods=GoodsCode),''), ")
		 +AnsiString(" SogdGoodsSpec=ISNULL((SELECT GoodsSpec FROM sdGoods WHERE SogdGoods=GoodsCode),''), ")
		 +AnsiString(" sogdUnit,SogdConv,SogdQty=SogdQty-SogdBQty, ")
		 +AnsiString(" SogdLoc,SogdBatch,SogdPrice from sdSogd where SogdCode='"+seSretdSogCode->Text+"'")
         +AnsiString(" and SogdClose = 0 and SogdQty-SogdBQty>0 order by Sogdline");

    sgSretd->RowCount=1;
    TComResultSet *RsSretd;
    try
    {
      StartWaitForm("正在查询数据,请稍候......");
      RsSretd=new  TComResultSet(Handle,g_ClientHandle);
      RsSretd->Open(WideString(s_SQL),WideString(""));
      sgSretd->RowCount=1;
      while( RsSretd->Eof == 0)
      {
       d_SogdQty=StrToFloat(RsSretd->FieldByName("SogdQty"));
       if(d_SogdQty > 0)
       {
         ItemStr="\t"+AnsiString("√") +
                 "\t"+RsSretd->FieldByName("SogdLine")+
                 "\t"+RsSretd->FieldByName("SogdGoods")+
                 "\t"+RsSretd->FieldByName("SogdGoodsName")+
                 "\t"+RsSretd->FieldByName("SogdGoodsSpec")+
                 "\t"+RsSretd->FieldByName("SogdUnit")+
                 "\t"+RsSretd->FieldByName("SogdConv")+
                 "\t"+RsSretd->FieldByName("SogdQty")+
                 "\t"+RsSretd->FieldByName("SogdQty")+
                 "\t"+RsSretd->FieldByName("SogdPrice")+
                 "\t"+RsSretd->FieldByName("SogdLoc")+
                 "\t"+RsSretd->FieldByName("SogdBatch");
         sgSretd->AddItem(ItemStr);
       }
       RsSretd->MoveNext();
      }
      RsSretd->Close();
      delete RsSretd;
    }
    __finally
    {
      EndWaitForm();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmSretd::GetComObject(TComServer *comServerPtr)
{
    comServer = comServerPtr;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TfrmSretd::sgSretdDblClick(TObject *Sender)
{
    AnsiString SqlStr;
    int ARow=sgSretd->Row;
    if (ARow >0)
    {
      if(sgSretd->Col==1)
      {
        if (sgSretd->Cells[1][ARow] == "√")
          sgSretd->Cells[1][ARow] =  "";
        else
          sgSretd->Cells[1][ARow] =  "√";
      }
      else if(sgSretd->Col==11 && sgSretd->Cells[1][ARow] == "√")
      {
        SqlStr="002[货位代码][货位名称]select loccode,locname from sdLoc,sdlg ";
        SqlStr+=" where lgLoccode=loccode and lggoodscode='"+sgSretd->Cells[3][ARow]+"' order by loccode";
        TfrmWnQuery *p;
        try
        {
          StartWaitForm("正在查询,请稍候...");
          p=new TfrmWnQuery(this,"货位查询",SqlStr);
        }
        __finally
        {
          EndWaitForm();
        }
        if(p->ShowModal()==mrOk)
        {
          sgSretd->Cells[11][ARow]=p->ColData[1];
        }
        delete p;
      }
    }
}

//---------------------------------------------------------------------------

void __fastcall TfrmSretd::bbSelAllClick(TObject *Sender)
{
  for(int i=1;i<sgSretd->RowCount;i++)
    sgSretd->Cells[1][i] = "√";
}
//---------------------------------------------------------------------------

void __fastcall TfrmSretd::bbSelNoneClick(TObject *Sender)
{
  for(int i=1;i<sgSretd->RowCount;i++)
    sgSretd->Cells[1][i] = "";
}
//---------------------------------------------------------------------------


void __fastcall TfrmSretd::seSretdSogCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="005[发货单号][发货日期][币种][税码][业务员]select Soghcode,Soghdate, ";
  SqlStr+=" currencyname=ISNULL((SELECT CurrencyName FROM sdCurrency WHERE Soghcurrency=currencycode),'') ,";
  SqlStr+=" taxname=ISNULL((SELECT taxname FROM sdtax WHERE Soghtaxcode=taxcode),''),SoghUser, SoghClient ";
  SqlStr+=" from sdSogh";
  SqlStr+=" where Soghcheck=1 and Soghclose=0 and Soghcancel=0 ";
  if (cbSameClientName->Checked)
	SqlStr+=" and SoghClient='"+FSrethClient+"' ";
  if (cbSameCurrency->Checked)
	SqlStr+=" and Soghcurrency='"+FSrethCurrency+"' ";
  if(cbSameTax->Checked)
	SqlStr+=" and SoghtaxCode='"+FSrethTax+"' ";

  SqlStr+=" order by Soghcode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"发货单查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seSretdSogCode->Text=p->ColData[1];
    FillGridWithData();
  }
  delete p;  
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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