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

📄 poh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 3 页
字号:
        SetDetailValue(fiPodQty,sePodQty->Text);
        if(sePodPrice->Text == "")
         throw Exception("请输入采购单价");
        SetDetailValue(fiPodPrice,sePodPrice->Text);
        SetDetailValue(fiPodType,scPodType->ItemData[cbItem2]);
        SetDetailValue(fiPodFrom,scPodFrom->ItemData[cbItem2]);
        SetDetailValue(fiPodStatus,scPodStatus->ItemData[cbItem2]);
        SetDetailValue(fiPodDept,scPodDept->ItemData[cbItem2]);
        SetDetailValue(fiPodFromCode,sePodFromCode->Text);
        SetDetailValue(fiPodFromLine,sePodFromLine->Text);
        SetDetailValue(fiPodBatch,scPodBatch->Text);
        SetDetailValue(fiPodSendDate,dePodSendDate->Text);
        SetDetailValue(fiPodRecDate,dePodRecDate->Text);
        SetDetailValue(fiPodReqDate,dePodReqDate->Text);
        SetDetailValue(fiPodSo,sePodSo->Text);
        SetDetailValue(fiPodSodLine,sePodSodLine->Text);
        SetDetailValue(fiPodDesc,memPodDesc->Text);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPoh::WaitUserInput(int Section)
{
    if (Section ==1)
    {
     if(sePohCode->Enabled)
        sePohCode->SetFocus();
     sePohCurrencyExit(NULL);
    }
    else
    {
     sgPoh->Visible=false;
     FloatPanel2->Visible=true;
     if(sePodGoods->Enabled)
       sePodGoods->SetFocus();
     pv_GoodsCode=sePodGoods->Text;
     SetDetail(sePodGoods->Text);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPoh::RefreshGridData(int mAction)
{
    int i;
    AnsiString ItemStr=GetItemStringToGrid();
    switch(mAction)
    {
       case 0:
         sgPoh->AddItem(ItemStr);
         break;
       case 1:
         i = sgPoh->Row;
         sgPoh->ChangeItem(ItemStr,i);
         break;
       case 2:
         sgPoh->RemoveItem(sgPoh->Row);
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPoh::GetItemStringToGrid()
{
    AnsiString s_ItemStr;
    s_ItemStr ="\t"+GetDetailValue(fiPodLine)+
               "\t"+GetDetailValue(fiPodGoods)+
               "\t"+GetDetailValue(fiPodUnit)+
               "\t"+GetDetailValue(fiPodQty)+
               "\t"+GetDetailValue(fiPodPrice)+
               "\t"+GetDetailValue(fiPodAmt)+
               "\t"+GetDetailValue(fiPodRecDate);
     return s_ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::DisplayBill()
{
    GetDataFromComObject(1);
    FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::GetBill(AnsiString BillID)
{
    int iRow;
    iRow=comServer->Find("PohCode='"+BillID+"'");
    if (iRow>0)      //FIND THIS BILL
    {
       DisplayBill();
    }
    else
       if (ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
       {
           AddHeadRecord();
       }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgPoh->RowCount=1;
    if(comServer->RecordCount>0)
    {
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          RefreshGridData(0);
      }
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPoh::GetHeadValue(int Index)
{
     return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPoh::GetDetailValue(int Index)
{
     return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------

void __fastcall TfrmPoh::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TGenBaseForm::FormClose(Sender,Action);
//    WriteGridWidth(Name,sgPoh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::FormShow(TObject *Sender)
{
     ClearControl(1,false);
     ClearControl(2,false);
     TGenBaseForm::MoveToFirst();
     ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::sgPohSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if (ARow > 0)
    {
       comServer->LocateItemByKey(WideString(sgPoh->TextMatrix[ARow][1]));
    }
    if (!comServer->Eof)
    {
       GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::sgPohDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgPoh->Row;
    if (iRow == 0)
    {
       return;
    }
    sgPoh->Visible=false;
    FloatPanel2->Visible=true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::ChangeToBrowseState(bool agree)
{
      sgPoh->Visible=true;
      FloatPanel2->Visible=false;
      if(agree == false)
       sgPoh->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::btnOKClick(TObject *Sender)
{
  try
  {
    if ((CurrentState==caAddDetail)||(CurrentState==caAddBill))
    {
       if(DetailState==caAddDetail)
           comServer->AddItem();
       SendDataToComObject(2);
       comServer->AddToObject();
       ClearControl(2,false);
       if(sePodGoods->Enabled)
        sePodGoods->SetFocus();
    }
    else
       ChangeToBrowseState();
  }
  catch(Exception &e)
  {
   throw Exception(e.Message);
  }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------


void __fastcall TfrmPoh::sePodGoodsExit(TObject *Sender)
{
   SetDetail(Trim(sePodGoods->Text));
}
//---------------------------------------------------------------------------

void __fastcall TfrmPoh::sePodGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="006[物料编码][物料名称][计量单位][多计量单位][批次管理][订单管理]select GoodsCode,GoodsName,GoodsUnitCode,GoodsMUnit,GoodsBatch,GoodsTrackSo from sdgoods,sdpgd where ";
  SqlStr+="PgdSupplyCode='"+scPohSupply->ItemData[1]+"' and PgdGoodsCode=GoodsCode order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"供应商物料查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    sePodGoods->Text=p->ColData[1];
    SetDetail(sePodGoods->Text);
  }
  delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPoh::RefreshUpdateData(int MsgSrc,int MsgType)
{
  switch(MsgSrc)
  {
   case euSdPmode:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPohPmode,"SELECT PmodeCode,PmodeName FROM sdPmode order by PmodeCode","PmodeName","PmodeCode");
    }
    break;
   case euSdTax:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPohTaxCode,"SELECT TaxCode,TaxName FROM sdTax order by TaxCode","TaxName","TaxCode");
    }
    break;
   case euSdSettleMode:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPohSettleMode,"SELECT SettleModeCode,SettleModeName FROM sdSettleMode order by SettleModeCode","SettleModeName","SettleModeCode");
    }
    break;
   case euSdCurrency:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
      AnsiString sSql;
      sSql =AnsiString("select currencycode,currencyname,currencyrate=coalesce(rateratio,1),currencylocal from sdcurrency,sdrate");
      sSql+=" where currencycode*=ratecurrency and ";
      sSql+=" ratefmonth='"+g_sdPMonth+"'";
      FillEdit(sePohCurrency,sSql,"CurrencyName","CurrencyCode","CurrencyRate","CurrencyLocal");
    }
    break;
   case euSdSupply:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPohSupply,"SELECT SupplyCode,SupplyName,SupplyTaxCode,SupplyTaxNo FROM sdSupply  where supplycancel=0  order by SupplyCode",
                  "SupplyName","SupplyCode","SupplyTaxCode","SupplyTaxNo");
    }
    break;
   case euSdTransMode:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPohTransMode,"SELECT TransModeCode,TransModeName FROM sdTransMode Order by TransModeCode","TransModeName","TransModeCode");
    }
    break;
   case euSdDeliver:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPohDeliver,"SELECT DeliverCode,DeliverName FROM sdDeliver Order by DeliverCode","DeliverName","DeliverCode");
    }
    break;
   case euSdPsite:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillEdit(sePohPsite,"SELECT PsiteCode,PsiteName FROM sdPsite Order by PsiteCode","PsiteName","PsiteCode");
    }
    break;
   case euSdBuyer:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPohBuyer,"select UserCode,UserName from sdBuyer,sduser where UserCode=BuyerCode order by UserCode","UserName","UserCode");
    }
    break;
   case euSdUnit:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillEdit(sePodUnit,"SELECT UnitName memo,UnitCode,UnitRate FROM sdUnit Order by UnitCode","Memo","UnitCode","UnitRate");
    }
    break;
   case euSdDept:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPodDept,"select deptname memo,deptcode from sddept order by deptCode","Memo","DeptCode");
    }
    break;
   case euSdBatch:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPodBatch,"SELECT BatchCode FROM sdBatch Order by BatchCode","BatchCode");
    }
    break;
   default:
    break;
  }
}
//---------------------------------------------------------------------------


void __fastcall TfrmPoh::SetDetail(AnsiString gc)

⌨️ 快捷键说明

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