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

📄 ecoh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmEcoh::GetItemStringToGrid()
{
    AnsiString v_ItemStr,s1;
    s1=GetDetailValue(fiEcodProcess);
    scEcodProcess->LocateKey(s1);
    v_ItemStr =GetDetailValue(fiEcodLine)+
               "\t"+GetDetailValue(fiEcodBgoods)+
               "\t"+GetDetailValue(fiEcodAgoods)+
               "\t"+GetDetailValue(fiEcodQty)+
               "\t"+GetDetailValue(fiEcodShl)+
               "\t"+scEcodProcess->ItemData[1];
    return v_ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::DisplayBill()
{
    if(comServer->RecordCount>0)
    {
      GetDataFromComObject(1);
      FillGridWithData();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::GetBill(AnsiString BillID)
{
    bool iRow;
    iRow=comServer->Find("EcohCode='"+BillID+"'");
    if(iRow)      //FIND THIS BILL
       DisplayBill();
    else
    {
       if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
          AddHeadRecord();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmEcoh::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgEcoh->RowCount=1;
    if(comServer->RecordCount>0)
    {
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          RefreshGridData(0);
      }
    }
    else
      ClearControl(2,false);
}
//---------------------------------------------------------------------------

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

AnsiString __fastcall TfrmEcoh::GetDetailValue(int Index)
{
     return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::SetHeadValue(int Index,AnsiString Value)
{
     WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------

void __fastcall TfrmEcoh::SetDetailValue(int Index,AnsiString Value)
{
     WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::FormCreate(TObject *Sender)
{
     FormIniFile="D:\Test.Ini";
     SetGridWidth(Name,sgEcoh,FormIniFile);
}
//---------------------------------------------------------------------------

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

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

void __fastcall TfrmEcoh::sgEcohDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgEcoh->Row;
    if(iRow == 0)
       return;
    ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------

void __fastcall TfrmEcoh::ChangeToBrowseState(bool agree)
{
    if(agree)
    {
       sgEcoh->Visible=true;
       FloatPanel2->Visible=false;
       sgEcoh->Align=alClient;
       FloatPanel2->Align=alNone;
    }
    else
    {
       sgEcoh->Visible=false;
       FloatPanel2->Visible=true;
       sgEcoh->Align=alNone;
       FloatPanel2->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::btnOKClick(TObject *Sender)
{
    try{
      if((CurrentState==caAddDetail)||(CurrentState==caAddBill))
      {
         if(DetailState==caAddDetail)
            comServer->AddItem();
         SendDataToComObject(2);
         comServer->AddToObject();
         ClearControl(2,false);
         //连续增加时返回焦点
         if(seEcodLine->Enabled)
            seEcodLine->SetFocus();
      }
      else
         ChangeToBrowseState();
    }
    catch(Exception &e)
    {
        throw Exception(e.Message);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::scEcodBgoodsClick(TObject *Sender)
{
    AnsiString s;
    s = Trim(scEcodBgoods->Text);
    if(!s.IsEmpty())
       seEcodBgoodsName->Text=scEcodBgoods->ItemData[2];
}
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::seEcodAgoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="006[物料编码][物料名称][型号][类型][来源][计量单位]";
  SqlStr+="Select GoodsCode,GoodsName,GoodsModel,GoodsType,GoodsFrom,GoodsUnitCode from sdGoods where GoodsType<>1 order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"子件物料数据查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seEcodAgoods->Text=p->ColData[1];;
    seEcodAgoodsName->Text=p->ColData[2];
    seEcodModel->Text=p->ColData[4];
    scEcodUnit->Text=p->ColData[6];
    if(g_sdRsGoods->LocateByKey(WideString(seEcodAgoods->Text))==0)
    {
      scEcodType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
      scEcodFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
    }
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmEcoh::scEcohGoodsClick(TObject *Sender)
{
    if(scEcohGoods->ItemIndex!=-1)
    {
       seEcohGoodsName->Text=scEcohGoods->ItemData[cbItem3];
       FillComboBox(scEcodBgoods,"SELECT memo=BomdGoods+'('+GoodsName+')',BomdGoods,GoodsName FROM sdBomd,sdGoods Where GoodsCode=BomdGoods and BomdPgoods='"+scEcohGoods->ItemData[1]+"' order by BomdGoods","memo","BomdGoods","GoodsName");
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmEcoh::seEcodAgoodsExit(TObject *Sender)
{
    AnsiString tempS;
    tempS=seEcodAgoods->Text;
    if(!tempS.IsEmpty())
    {
       if(g_sdRsGoods->LocateByKey(WideString(tempS))==0)
       {
         seEcodAgoodsName->Text=GetGoodsValue("GoodsName");
         seEcodModel->Text=GetGoodsValue("GoodsModel");
         scEcodType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
         scEcodFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
         scEcodUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
       }
       else
         ::MessageBox(Handle,"输入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmEcoh::seEcohCodeKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    AnsiString tempS=seEcohCode->Text;
    if(Key==13 && CurrentState==caNormal && !tempS.IsEmpty())
    {
       comServer->LocateByKey(WideString(tempS));
       DisplayBill();
    }
}
//---------------------------------------------------------------------------





⌨️ 快捷键说明

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