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

📄 soh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 3 页
字号:
          FloatPanel2->Align=alClient;
          if(seSodGoods->Enabled)
            seSodGoods->SetFocus();
       }
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::RefreshGridData(int mAction)
{

        int i;
        AnsiString ItemStr;
        switch(mAction)
        {
           case 0:
             ItemStr="\t"+GetDetailValue(fiSodLine)+"\t"+GetDetailValue(fiSodGoods)+"\t"+
                   GetDetailValue(fiSodUnit)+"\t"+
                    GetDetailValue(fiSodConv)+"\t"+GetDetailValue(fiSodQty)+"\t"+
                    GetDetailValue(fiSodPrice)+"\t"+GetDetailValue(fiSodAmt)+"\t"+GetDetailValue(fiSodTaxAmt)+"\t"+
                    FormatFloat("0.00",GetDetailValue(fiSodAmt).ToDouble()+GetDetailValue(fiSodTaxAmt).ToDouble())+"\t"+
                    GetDetailValue(fiSodDAmt);
             sgSod->AddItem(ItemStr);
             break;
           case 1:
             ItemStr="\t"+GetDetailValue(fiSodLine)+"\t"+GetDetailValue(fiSodGoods)+"\t"+
                    GetDetailValue(fiSodUnit)+"\t"+
                    GetDetailValue(fiSodConv)+"\t"+GetDetailValue(fiSodQty)+"\t"+
                    GetDetailValue(fiSodPrice)+"\t"+GetDetailValue(fiSodAmt)+"\t"+GetDetailValue(fiSodTaxAmt)+"\t"+
                    FormatFloat("0.00",GetDetailValue(fiSodAmt).ToDouble()+GetDetailValue(fiSodTaxAmt).ToDouble())+"\t"+
                    GetDetailValue(fiSodDAmt);
                 sgSod->ChangeItem(ItemStr,sgSod->Row);
                  break;
           case 2:
             sgSod->RemoveItem(sgSod->Row);
        }
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::DisplayBill()
{
       if(comServer->RecordCount<1)
         return;
        GetDataFromComObject(1);
         ChangeToBrowseState(true);
        FillGridWithData();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::GetBill(AnsiString BillID)
{
       if(comServer->Find("SohCode='"+BillID+"'"))
       {
           DisplayBill();
       }
       else
    if (ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
         {
               AddHeadRecord();
          }
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::FillGridWithData()
{
      int i;
      AnsiString ItemStr;
      sgSod->RowCount=1;
      if(comServer->RecordCount<1)
       return;
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          RefreshGridData(0);
      }
    comServer->LocateItemByIndex(0);
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmSoh::GetHeadValue(int Index)
{
        WideString S;
        S = ReadFieldValue(comServer,Index);
        return S;
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmSoh::GetDetailValue(int Index)
{
        WideString S;
        S = ReadItemValue(comServer,Index);
        return S;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoh::SetHeadValue(int Index,AnsiString Value)
{
       WriteFieldValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoh::SetDetailValue(int Index,AnsiString Value)
{
       WriteItemValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------



void __fastcall TfrmSoh::FormShow(TObject *Sender)
{
       ClearControl(1,false);
       ClearControl(2,false);
       TBillBaseForm::MoveToFirst();
       ChangeToBrowseState(true);
}
//---------------------------------------------------------------------------

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

void __fastcall TfrmSoh::sgSodDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgSod->Row;
    if (iRow == 0)
    {
       return;
    }
    comServer->LocateItemByKey(WideString(sgSod->TextMatrix[iRow][1]));

    if (!comServer->Eof)
    {
       GetDataFromComObject(2);
       sgSod->Visible=false;
       sgSod->Align=alNone;
       FloatPanel2->Visible=true;
       FloatPanel2->Align=alClient;
       btnCancel->Enabled=true;
    }
}
//---------------------------------------------------------------------------

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

void __fastcall TfrmSoh::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 TfrmSoh::btnCancelClick(TObject *Sender)
{
        CancelChange();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::seSodPriceExit(TObject *Sender)
{
    CalculateAmt();
}
//---------------------------------------------------------------------------


void __fastcall TfrmSoh::seSodQtyExit(TObject *Sender)
{
  CalculateAmt();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::seSodGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="004[物料编码][物料名称][计量单位][多计量单位]select GoodsCode,GoodsName,GoodsUnitCode,GoodsMUnit from sdgoods,sdsgd where ";
  SqlStr+="sgdClientCode='"+seSohClient->ItemData[1]+"' and SgdGoodsCode=GoodsCode order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"客户物料查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seSodGoods->Text=p->ColData[1];
    seSodGoodsName->Text=p->ColData[2];
    SetRelativeState(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::seSodGoodsExit(TObject *Sender)
{
  SetRelativeState(seSodGoods->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoh::RefreshUpdateData(int MsgSrc,int MsgType)
{
  AnsiString KeyCode;
  switch(MsgSrc)
    {
     case euSdTax:
//          if(ShowUpdateMessage(MsgSrc,MsgType))
//          {
            KeyCode=scSohTaxCode->ItemData[cbItem2];
            FillComboBox(scSohTaxCode,"SELECT TaxName,TaxCode,TaxRate FROM sdTax","TaxName","TaxCode","TaxRate");
            scSohTaxCode->LocateKey(KeyCode);
//            }
          break;
     case euSdSaler:
          if(ShowUpdateMessage(MsgSrc,MsgType))
          {
            KeyCode=scSohSaler->ItemData[cbItem2];
            FillComboBox(scSohSaler,"select usercode,username from sduser ,sdsaler where usercode=salercode order by usercode","UserName","UserCode");
            scSohSaler->LocateKey(KeyCode);
           }
          break;
     case euSdClient:
          if(ShowUpdateMessage(MsgSrc,MsgType))
          {
             KeyCode=seSohClient->Text;
             FillEdit(seSohClient,"SELECT ClientCode,ClientName FROM sdClient where ClientCancel=0","ClientName","ClientCode");
             seSohClient->LocateKey(KeyCode);
           }
          break;
     case euSdSettleMode:
          if(ShowUpdateMessage(MsgSrc,MsgType))
            {
             KeyCode=scSohSettleMode->ItemData[cbItem2];
             FillComboBox(scSohSettleMode,"SELECT SettleModeCode,SettleModeName FROM sdSettleMode","SettleModeName","SettleModeCode");
             scSohSettleMode->LocateKey(KeyCode);
            }
          break;
     case euSdDeliver:
          if(ShowUpdateMessage(MsgSrc,MsgType))
            {
            KeyCode=scSohDeliver->ItemData[cbItem2];
            FillComboBox(scSohDeliver,"SELECT DeliverName,DeliverCode FROM sdDeliver","DeliverName","DeliverCode");
            scSohDeliver->LocateKey(KeyCode);
            }
          break;
     case euSdTransMode:
          if(ShowUpdateMessage(MsgSrc,MsgType))
           {
            KeyCode=scSohTransMode->ItemData[cbItem2];
            FillComboBox(scSohTransMode,"SELECT TransModeCode,TransModeName FROM sdTransMode","TransModeName","TransModeCode");
            scSohTransMode->LocateKey(KeyCode);

⌨️ 快捷键说明

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