⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sivoh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivoh::FormShow(TObject *Sender)
{
//       InitEditControl();
       ClearControl(1,false);
       ClearControl(2,false);
       TGenBaseForm::MoveToFirst();
       ChangeToBrowseState(true);

}
//---------------------------------------------------------------------------

void __fastcall TfrmSivoh::sgSivodSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if (ARow == 0)
    {
       return;
    }
    comServer->LocateItemByKey(WideString(sgSivod->TextMatrix[ARow][1]));
    if (!comServer->Eof)
    {
       GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------


void __fastcall TfrmSivoh::ChangeToBrowseState(bool Browse)
{
       FloatPanel2->Visible=false;
       FloatPanel2->Align=alNone;
       btnOK->Enabled=false;
       btnCancel->Enabled=false;
       sgSivod->Visible=true;
       sgSivod->Align=alClient;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivoh::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);
        }
      }
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivoh::btnCancelClick(TObject *Sender)
{
       CancelChange();
       btnOK->Enabled=false;

}
//---------------------------------------------------------------------------




void __fastcall TfrmSivoh::scSivohTaxCodeClick(TObject *Sender)
{
   SetHeadValue(fiSivohTaxCode,seSivohTaxCode->ItemData[cbItem2]);
   seSivohTaxRate->Text=GetHeadValue(fiSivohTaxRate);
}
//---------------------------------------------------------------------------


void __fastcall TfrmSivoh::scSivohCacCodeClick(TObject *Sender)
{
     lbSivohCacBankName->Caption=scSivohCacCode->ItemData[cbItem2];
}
//---------------------------------------------------------------------------



void __fastcall TfrmSivoh::GenrateBill()
{
  try{
       TfrmSoghDisp *frmSoghDisp= new TfrmSoghDisp(this);
       frmSoghDisp->BillNumID=seSivohSoCode->Text;
       frmSoghDisp->ShowModal();
     if(frmSoghDisp->ModalResult==mrOk)
       {
         int MaxLine=1;
         Currency TaxAmt;
          if(comServer->ItemCount>0)
            {
             comServer->LocateItemByIndex(comServer->ItemCount-1);
             MaxLine=StrToInt(GetDetailValue(fiSivodLine))+1;
            }
         for(int i=1;i<frmSoghDisp->SoghGrid->RowCount;i++)
           {
            if(frmSoghDisp->SoghGrid->TextMatrix[i][1]=="√")
              {
                frmSoghDisp->comServer->LocateByKey(WideString(frmSoghDisp->SoghGrid->TextMatrix[i][2]));
                for(int j=0;j<frmSoghDisp->comServer->ItemCount;j++)
                 {
                  frmSoghDisp->comServer->LocateItemByIndex(j);
                  if(frmSoghDisp->GetDetailValue(fiSogdState)=="8")
                  {
                  comServer->AddItem();
                   //给发票单单号(SivodCode)赋值
                   SetDetailValue(fiSivodTaxPrice,seSivohTaxRate->Text);
                   SetDetailValue(fiSivodCode,seSivohCode->Text);
                   SetDetailValue(fiSivodLine,IntToStr(MaxLine++));
                   //给发货单单号(SivodSogCode)赋值
                    SetDetailValue(fiSivodSogCode,frmSoghDisp->GetDetailValue(fiSogdCode));
                    SetDetailValue(fiSivodGoods,frmSoghDisp->GetDetailValue(fiSogdGoods));
                    TaxAmt=DataCarry(GetDetailValue(fiSivodAmt).ToDouble()*seSivohTaxRate->Text.ToDouble(),2,0);
                    SetDetailValue(fiSivodTaxAmt,AnsiString(TaxAmt));
                    SetDetailValue(fiSivodTaxPrice,FormatFloat("0.0000",GetDetailValue(fiSivodPrice).ToDouble()*(1+seSivohTaxRate->Text.ToDouble()*0.01)));
                    SetDetailValue(fiSivodUnit,frmSoghDisp->GetDetailValue(fiSogdUnit));
                    SetDetailValue(fiSivodQty,frmSoghDisp->GetDetailValue(fiSogdQty));
                    SetDetailValue(fiSivodPrice,frmSoghDisp->GetDetailValue(fiSogdPrice));
                    SetDetailValue(fiSivodLoc,frmSoghDisp->GetDetailValue(fiSogdLoc));
                    SetDetailValue(fiSivodAmt,frmSoghDisp->GetDetailValue(fiSogdAmt));
                    SetDetailValue(fiSivodDesc," ");
                    comServer->AddToObject();
                  }
               }
             }
            }
          FillGridWithData();
        }
     }
   __finally
   {
       delete frmSoghDisp;
       CancelChange();
  }
}

void __fastcall TfrmSivoh::sgSivodDblClick(TObject *Sender)
{
      int iRow;
      iRow=sgSivod->Row;
      if (iRow == 0)
      {
         return;
      }
      comServer->LocateItemByKey(WideString(sgSivod->TextMatrix[iRow][1]));
         GetDataFromComObject(2);
         sgSivod->Visible=false;
         sgSivod->Align=alNone;
         btnCancel->Enabled=true;
      if(CurrentState==caGenBill)
           btnOK->Enabled=true;
         FloatPanel2->Visible=true;
         FloatPanel2->Align=alClient;


}
//---------------------------------------------------------------------------






void  __fastcall TfrmSivoh::RefreshUpdateData(int MsgSrc,int MsgType)
{
  switch(MsgSrc)
       {
      case euSdDept:
           if(ShowUpdateMessage(MsgSrc,MsgType))
           {
           KeyCode=scSivohDept->ItemData[cbItem2];
           FillComboBox(scSivohDept,"Select DeptCode,DeptName from sdDept","DeptName","DeptCode");
           scSivohDept->LocateKey(KeyCode);
           }
           break;
      case euSdSettleMode:
           if(ShowUpdateMessage(MsgSrc,MsgType))
           {
           KeyCode=seSivohSettleMode->ItemData[cbItem2];
           FillEdit(seSivohSettleMode,"Select SettleModeCode,SettleModeName from sdSettleMode","SettleModeName","SettleModeCode");
           seSivohSettleMode->LocateKey(KeyCode);
           }
           break;
      case euSdCac:
           if(ShowUpdateMessage(MsgSrc,MsgType))
           {
           KeyCode=scSivohCacCode->Text;
           FillComboBox(scSivohCacCode,"Select CacCode,CacBankName from sdCac","CacCode","CacBankName");
           scSivohCacCode->LocateKey(KeyCode);
           }
           break;
       }

}


void __fastcall TfrmSivoh::seSivohCodeKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    if(Key==13 && CurrentState==caNormal)
    {
      comServer->LocateByKey(WideString(seSivohCode->Text));
      DisplayBill();
    }

}
//---------------------------------------------------------------------------

void __fastcall TfrmSivoh::seSivohSoCodeButtonClick(TObject *Sender)
{
   if(seSivohClient->Text.IsEmpty())
      throw Exception("客户代码不能为空");
   AnsiString SqlStr="004[客户代码][订单号][币种][税码]select sohclient,sohcode,SohCurrency,SohTaxCode from sdsoh";
   SqlStr=SqlStr+" where SohClient='"+seSivohClient->ItemData[cbItem2]+"' and SohCheck=1 and SohCancel=0 order by sohclient";
   TfrmWnQuery *p=new TfrmWnQuery(this,"请选择订单",SqlStr);
   try
   {
    if(p->ShowModal()==mrOk)
      {
       seSivohSoCode->Text=p->ColData[2];
       seSivohTaxCode->LocateKey(p->ColData[3]);
       seSivohTaxRate->Text=seSivohTaxCode->ItemData[cbItem3];
       seSivohCurrency->LocateKey(p->ColData[4]);
       seSivohEnrate->Text=seSivohTaxCode->ItemData[cbItem3];
       seSivohSoCodeExit(Sender);
      }
   }
   __finally
   {
   delete p;
   }
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivoh::seSivohSoCodeExit(TObject *Sender)
{
    if(!seSivohSoCode->Text.IsEmpty())
     {
      SetHeadValue(fiSivohSoCode,seSivohSoCode->Text);
      seSivohTaxCode->LocateKey(GetHeadValue(fiSivohTaxCode));
      seSivohTaxRate->Text=seSivohTaxCode->ItemData[cbItem3];
      seSivohCurrency->LocateKey(GetHeadValue(fiSivohCurrency));
      seSivohEnrate->Text=seSivohTaxCode->ItemData[cbItem3];
      seSivohSaler->LocateKey(GetHeadValue(fiSivohSaler));
     }

}
//---------------------------------------------------------------------------

void __fastcall TfrmSivoh::seSivodSogCodeButtonClick(TObject *Sender)
{
   AnsiString SqlStr="012[发货单号][行号][物料编号][物料名称][规格][单位][单价][数量][金额][税额][折让金额][发货货位]";
   SqlStr=SqlStr+AnsiString("select SogdCode,SogdLine,sogdGoods,SogdGoodsName=GoodsName,SogdModel=GoodsModel,SogdUnit,Sogdprice,SogdQty,SogdAmt,SogdTaxAmt,SogdRAmt,SogdLoc");
   SqlStr=SqlStr+" From sdSogd,sdGoods where SogdGoods=GoodsCode and SogdSoCode='"+seSivohSoCode->Text+"' and SogdCode in (select SoghCode from sdSogh where SoghCheck=1 and SoghCancel=0)";
   TfrmWnQuery *p=new TfrmWnQuery(this,"发货单物料查询",SqlStr);
   try
   {
    if(p->ShowModal()==mrOk)
      {
       seSivodSogCode->Text=p->ColData[1];
       seSivodGoods->Text=p->ColData[3];
       seSivodGoodsName->Text=p->ColData[4];
       seSivodModel->Text=p->ColData[5];
       seSivodUnit->Text=p->ColData[6];
       seSivodPrice->Text=p->ColData[7];
       seSivodQty->Text=p->ColData[8];
       seSivodAmt->Text=p->ColData[9];
       seSivodTaxAmt->Text=p->ColData[10];
       seSivodZkAmt->Text=p->ColData[11];
       seSivodLoc->Text=p->ColData[12];
       CalculateAmt();
      }
   }
   __finally
   {
   delete p;
   }

}
//---------------------------------------------------------------------------

void __fastcall TfrmSivoh::seSivodGoodsButtonClick(TObject *Sender)
{
 if(seSivodSogCode->Text.IsEmpty())
    throw Exception("发货单号不能为空!");
 else
 {
   AnsiString SqlStr="012[发货单号][行号][物料编号][物料名称][规格][单位][单价][数量][金额][税额][折让金额][发货货位]";
   SqlStr=SqlStr+"select SogdCode,SogdLine,sogdGoods,SogdGoodsName=GoodsName,SogdModel=GoodsModel,SogdUnit,Sogdprice,SogdQty,SogdAmt,SogdTaxAmt,SogdRAmt,SogdLoc";
   SqlStr=SqlStr+" From sdSogd,SdGoods where SogdGoods=GoodsCode and SogdCode='"+seSivodSogCode->Text+"' and SogdCode in (select SoghCode from sdSogh where SoghCheck=1 and SoghCancel=0)";
   TfrmWnQuery *p=new TfrmWnQuery(this,"发货单物料查询",SqlStr);
   try
   {
    if(p->ShowModal()==mrOk)
      {
       seSivodGoods->Text=p->ColData[3];
       seSivodGoodsName->Text=p->ColData[4];
       seSivodModel->Text=p->ColData[5];
       seSivodUnit->Text=p->ColData[6];
       seSivodPrice->Text=p->ColData[7];
       seSivodQty->Text=p->ColData[8];
       seSivodAmt->Text=p->ColData[9];
       seSivodTaxAmt->Text=p->ColData[10];
       seSivodZkAmt->Text=p->ColData[11];
       seSivodLoc->Text=p->ColData[12];
       CalculateAmt();
      }
   }
   __finally
   {
   delete p;
   }
 }
}
//---------------------------------------------------------------------------
void __fastcall TfrmSivoh::CalculateAmt()
{
    seSivodTaxPrice->Text=AnsiString(DataCarry(seSivodPrice->Text.ToDouble()*seSivohTaxRate->Text.ToDouble(),2,0));
    seSivodSumAmt->Text=FormatFloat("0.00",seSivodAmt->Text.ToDouble()+seSivodTaxAmt->Text.ToDouble());
}
void __fastcall TfrmSivoh::seSivohBankNoButtonClick(TObject *Sender)
{

  if(seSivohClient->Text.IsEmpty())
     throw Exception("客户代码不能为空");
  if(seSivohCurrency->Text.IsEmpty())
     throw Exception("币种不能为空");
  AnsiString SqlStr;
  SqlStr="003[结算币种][银行名称][帐号]select SsdCurrency,SsdBankName,SsdBankNo from sdSsd";
  SqlStr=SqlStr+" where SsdClient='"+seSivohClient->ItemData[cbItem2]+"' and SsdCurrency='"+seSivohCurrency->ItemData[cbItem2]+"'";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"客户银行帐号查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seSivohBankNo->Text=p->ColData[3];
    lbSivohBankName->Caption=p->ColData[2];
   }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivoh::seSivohClientButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="004[客户代码][客户名称][税号][地址]select ClientCode,ClientName,ClientTaxNo,ClientAddr from sdClient";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"客户查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seSivohClient->LocateKey(p->ColData[1]);
    seSivohTaxNo->Text=p->ColData[3];
    seSivohAddr->Text=p->ColData[4];
   }
  delete p;

}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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