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

📄 forecasth.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
         sgForeCasth->RemoveItem(sgForeCasth->Row);
    }
}
//---------------------------------------------------------------------------

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

void __fastcall TfrmForeCasth::DisplayBill()
{
    if(comServer->RecordCount>0)
    {
        GetDataFromComObject(1);
        FillGridWithData();
    }
}
//---------------------------------------------------------------------------

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

AnsiString __fastcall TfrmForeCasth::GetHeadValue(int Index)
{
    return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmForeCasth::GetDetailValue(int Index)
{
    return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------

void __fastcall TfrmForeCasth::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------

void __fastcall TfrmForeCasth::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------

void __fastcall TfrmForeCasth::FormCreate(TObject *Sender)
{
    FormIniFile="D:\Test.Ini";
    SetGridWidth(Name,sgForeCasth,FormIniFile);
}
//---------------------------------------------------------------------------

void __fastcall TfrmForeCasth::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TBillBaseForm::FormClose(Sender,Action);
    WriteGridWidth(Name,sgForeCasth,FormIniFile);
}
//---------------------------------------------------------------------------

void __fastcall TfrmForeCasth::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    ChangeToBrowseState();
    MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmForeCasth::sgForeCasthSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if(ARow > 0)
       comServer->LocateItemByKey(WideString(sgForeCasth->TextMatrix[ARow][0]));
    if(!comServer->Eof)
       GetDataFromComObject(2);
}
//---------------------------------------------------------------------------

void __fastcall TfrmForeCasth::sgForeCasthDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgForeCasth->Row;
    if(iRow == 0)
       return;
    ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------

void __fastcall TfrmForeCasth::ChangeToBrowseState(bool t_browse)
{
    if(t_browse)
    {
       sgForeCasth->Visible=true;
       ftForeCastDetail->Visible=false;
       sgForeCasth->Align=alClient;
       ftForeCastDetail->Align=alNone;
    }
    else
    {
       sgForeCasth->Visible=false;
       ftForeCastDetail->Visible=true;
       sgForeCasth->Align=alNone;
       ftForeCastDetail->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmForeCasth::btnOKClick(TObject *Sender)
{
    if(CurrentState==caAddDetail||CurrentState==caAddBill)
    {
       if(DetailState==caAddDetail)
          comServer->AddItem();
       SendDataToComObject(2);
       comServer->AddToObject();
       ClearControl(2,false);
       seForeCastdLine->SetFocus();
    }
    else
       ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmForeCasth::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmForeCasth::seForeCasthCodeKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    AnsiString tempS=seForeCasthCode->Text;
    if(Key==13 && CurrentState==caNormal && !tempS.IsEmpty())
    {
       comServer->LocateByKey(WideString(tempS));
       DisplayBill();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmForeCasth::seForeCastdGoodsKeyDown(TObject *Sender,
      WORD &Key, TShiftState Shift)
{
    AnsiString  FKeystr=seForeCastdGoods->Text;
    if(Key==13 && CurrentState!=caNormal && !FKeystr.IsEmpty())
    {
       g_sdRsGoods->LocateByKey(WideString(FKeystr));
       if(GetGoodsValue("GoodsName")!="")
       {
          seForeCastdGoodsName->Text=GetGoodsValue("GoodsName");
          scForeCastdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
          scForeCastdType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
          scForeCastdFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
          seForeCastdEoq->Text=GetGoodsValue("GoodsEoq");
          seForeCastdEoi->Text=GetGoodsValue("GoodsEoi");
          seForeCastdSafeQty->Text=GetGoodsValue("GoodsSafeQty");
       }
       else
          MessageDlg("货物编码:'"+FKeystr+"'不存在!",mtWarning,TMsgDlgButtons()<<mbOK,0);
    }

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

void __fastcall TfrmForeCasth::seForeCastdGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="007[物料编码][物料名称][版本号][型号][类型][计量单位][批量]";
  SqlStr+="Select GoodsCode,GoodsName,GoodsVer,GoodsModel,GoodsType,GoodsUnitCode,GoodsEoq from sdGoods where (GoodsType=1 or GoodsType=2) and GoodsFrom=2 order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"产品数据查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seForeCastdGoods->Text=p->ColData[1];
    if(g_sdRsGoods->LocateByKey(WideString(seForeCastdGoods->Text))==0)
    {
      seForeCastdGoodsName->Text=GetGoodsValue("GoodsName");
      scForeCastdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
      scForeCastdType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
      scForeCastdFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
      seForeCastdEoq->Text=GetGoodsValue("GoodsEoq");
      seForeCastdEoi->Text=GetGoodsValue("GoodsEoi");
      seForeCastdSafeQty->Text=GetGoodsValue("GoodsSafeQty");
    }
  }
  delete p;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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