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

📄 rmbh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
{
    if(comServer->RecordCount>0)
    {
       GetDataFromComObject(1);
       FillGridWithData();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::GetBill(AnsiString BillID)
{
    bool iRow;
    iRow=comServer->Find("RmbhCode='"+BillID+"'");
    if(iRow)      //FIND THIS BILL
       DisplayBill();
    else
    {
       if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
          AddHeadRecord();
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmRmbh::GetHeadValue(int Index)
{
    return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmRmbh::GetDetailValue(int Index)
{
    return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    ChangeToBrowseState();
    MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::sgRmbhSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if(ARow > 0)
       comServer->LocateItemByKey(WideString(sgRmbh->TextMatrix[ARow][0]));
    if(!comServer->Eof)
       GetDataFromComObject(2);
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::sgRmbhDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgRmbh->Row;
    if(iRow == 0)
       return;
    ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::ChangeToBrowseState(bool t_browse)
{
    if(t_browse)
    {
      sgRmbh->Visible=true;
      fpRmbd->Visible=false;
      sgRmbh->Align=alClient;
      fpRmbd->Align=alNone;
    }
    else
    {
      sgRmbh->Visible=false;
      fpRmbd->Visible=true;
      sgRmbh->Align=alNone;
      fpRmbd->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::btnOKClick(TObject *Sender)
{
    try{
      if(CurrentState==caAddDetail || CurrentState==caAddBill)
      {
         if(DetailState==caAddDetail)
            comServer->AddItem();
         SendDataToComObject(2);
         comServer->AddToObject();
         ClearControl(2,false);
         seRmbdLine->SetFocus();
      }
      else
         ChangeToBrowseState();
    }
    catch(Exception &e)
    {
        throw Exception(e.Message);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::seRmbdGoodsButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="007[物料编码][物料名称][计量单位][领用数量][消耗数量][退料数量][已报废数]SELECT ";
    SqlStr+=" WmdGoods,GoodsName,WmdUnit,WmdQty,WmdUQty,WmdBQty,WmdLQty from sdWmd,sdGoods where ";
    SqlStr+=" GoodsCode=WmdGoods and WmdWoCode='"+seRmbhWo->Text+"' and WmdProcess='"+seRmbdProcess->ItemData[cbItem2]+"' order by WmdGoods";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"工序物料查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
      seRmbdGoods->Text=p->ColData[1];
      seRmbdGoodsName->Text=p->ColData[2];
      scRmbdUnit->LocateKey(p->ColData[3]);
      if(g_sdRsGoods->LocateByKey(WideString(seRmbdGoods->Text))==0)
      {
        scRmbdGoodsType->LocateKey(GetGoodsValue("GoodsType"));
        scRmbdGoodsFrom->LocateKey(GetGoodsValue("GoodsFrom"));
        seRmbdGoodsOoq->Text=GetGoodsValue("GoodsOoq");
      }
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::seRmbdGoodsExit(TObject *Sender)
{
    AnsiString tempS;
    tempS=seRmbdGoods->Text;
    if(!tempS.IsEmpty())
    {
        if(g_sdRsGoods->LocateByKey(WideString(tempS))==0)
        {
          seRmbdGoodsName->Text=GetGoodsValue("GoodsName");
          scRmbdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
          if(GetGoodsValue("GoodsType")!="")
            scRmbdGoodsType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
          else
            scRmbdGoodsType->ItemIndex=-1;

          if(GetGoodsValue("GoodsFrom")!="")
            scRmbdGoodsFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
          else
            scRmbdGoodsFrom->ItemIndex=-1;

          seRmbdGoodsOoq->Text=GetGoodsValue("GoodsOoq");
        }
        else
          ::MessageBox(Handle,"输入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmRmbh::seRmbhCodeKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    AnsiString tempS=seRmbhCode->Text;
    if(Key==13 && CurrentState==caNormal && !tempS.IsEmpty())
    {
       comServer->LocateByKey(WideString(tempS));
       DisplayBill();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::seRmbhWoButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="006[加工单号][加工件码][要求数量][要求日期][订单单号][订单行号]SELECT WoCode,WoGoods,WoQty,WoRDate,";
    SqlStr=SqlStr+"WoSoCode,WoSodLine from sdWo where WoCheck=1 and WoClose=0 ORDER BY WoCode";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"加工订单查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
       seRmbhWo->Text=p->ColData[1];
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::seRmbdProcessButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="004[序号][工序代码][工序名称][在制货位]SELECT WrgNo,WrgProcess,ProcessName,WrgLoc FROM sdWrg,sdProcess ";
    SqlStr=SqlStr+"where WrgProcess=ProcessCode and WrgWo='"+seRmbhWo->Text+"' ORDER BY WrgNo";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"工序资料查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
       seRmbdProcess->LocateKey(p->ColData[2]);
       seRmbdRLoc->LocateKey(p->ColData[4]);
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::seRmbdLocButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    TfrmWnQuery *p;
    SqlStr="007[当前月份][货位编码][货位名称][物料编码][物料名称][计量单位][当前数量]";
    SqlStr+="select MaccFmonth,MaccLoc,LocName,MaccGoods,MaccGoodsName=GoodsName,MaccUnit=GoodsUnitCode,";
    SqlStr+=" MaccAoyQty from sdMacc,sdGoods,sdLg,sdLoc where LocCode=lgLocCode and LocCode=MaccLoc";
    SqlStr+=" and LgGoodsCode=MaccGoods and GoodsCode=MaccGoods and MaccFmonth='"+g_sdMMonth+"'";
    SqlStr+=" and MaccGoods='"+seRmbdGoods->Text+"' and LocType=1 order by LocCode";
    try
    {
      StartWaitForm("正在查询,请稍候...");
      p=new TfrmWnQuery(this,"存储货位库存查询",SqlStr);
    }
    __finally
    {
      EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
       seRmbdLoc->LocateKey(p->ColData[2]);
    }
    delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmRmbh::seRmbdQtyButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="007[物料编码][物料名称][计量单位][领用数量][消耗数量][退料数量][已报废数]SELECT ";
    SqlStr+=" WmdGoods,GoodsName,WmdUnit,WmdQty,WmdUQty,WmdBQty,WmdLQty from sdWmd,sdGoods where ";
    SqlStr+=" GoodsCode=WmdGoods and WmdWoCode='"+seRmbhWo->Text+"' and WmdProcess='"+seRmbdProcess->ItemData[cbItem2]+"' order by WmdGoods";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"工序物料查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    p->ShowModal();
    delete p;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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