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

📄 ecoh.cpp

📁 科思ERP部分源码及控件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::RefreshGridData(int mAction)
{
    int i;
    AnsiString ItemStr=GetItemStringToGrid();
    switch(mAction)
    {
       case 0:
         sgEcoh->AddItem(ItemStr);
         sgEcoh->Row=sgEcoh->RowCount-1;
         break;
       case 1:
         sgEcoh->ChangeItem(ItemStr,sgEcoh->Row);
         break;
       case 2:
         sgEcoh->RemoveItem(sgEcoh->Row);
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmEcoh::GetItemStringToGrid()
{
    AnsiString v_ItemStr,s1;
    s1=GetDetailValue("EcodProcess");
    scEcodProcess->LocateKey(s1);
    v_ItemStr =GetDetailValue("EcodLine")+
               "\t"+GetDetailValue("EcodBgoods")+
               "\t"+GetDetailValue("EcodAgoods")+
               "\t"+GetDetailValue("EcodQty")+
               "\t"+GetDetailValue("EcodShl")+
               "\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);
}
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::FormClose(TObject *Sender,
      TCloseAction &Action)
{
   TBillBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    TBillBaseForm::MoveToFirst();
    ChangeToBrowseState();
}
//---------------------------------------------------------------------------
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[3];
    scEcodType->ItemIndex=StrToInt(p->ColData[4])-1;
    scEcodFrom->ItemIndex=StrToInt(p->ColData[5])-1;
    scEcodUnit->LocateKey(p->ColData[6]);
  }
  delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmEcoh::scEcohGoodsClick(TObject *Sender)
{
    if(scEcohGoods->ItemIndex!=-1)
    {
       seEcohGoodsName->Text=scEcohGoods->ItemData[cbItem3];
       FillComboBox(Handle,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(InitRsGoods(WideString(tempS)))
       {
         seEcodAgoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");
         seEcodModel->Text=GetGoodsValue(gtInitRs,"GoodsModel");
         scEcodType->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsType"))-1;
         scEcodFrom->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsFrom"))-1;
         scEcodUnit->LocateKey(GetGoodsValue(gtInitRs,"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();
    }
}
//---------------------------------------------------------------------------
bool __fastcall TfrmEcoh::BeforeCheck()
{
  SetHeadValue("EcohCheck",1);
  SetHeadValue("EcohChecker",g_sdUserCode);
  SetHeadValue("EcohCheckDate",g_sdCurDate);
  return true;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmEcoh::BeforeUnCheck()
{
  SetHeadValue("EcohCheck",0);
  SetHeadValue("EcohChecker","");
  SetHeadValue("EcohCheckDate",NULL);
  return true;
}
//---------------------------------------------------------------------------

void __fastcall TfrmEcoh::sgEcohClick(TObject *Sender)
{
    if(sgEcoh->Row > 0)
    {
      comServer->LocateItemByKey(seEcohCode->Text+"\t"+sgEcoh->TextMatrix[sgEcoh->Row][0]);
      GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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