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

📄 rmbh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Rmbh.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "BillBaseForm"
#pragma link "DateEdit"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"

TfrmRmbh *frmRmbh;
//---------------------------------------------------------------------------
__fastcall TfrmRmbh::TfrmRmbh(TComponent* Owner)
    : TBillBaseForm(Owner,euSdRmbh,"")
{
    AutoCtl=seRmbhCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::InitEditControl()
{
    ClientGroup->AddComponent(1,false,false,true,fpRmbh,fpRmbh->Name);
    ClientGroup->AddComponent(1,false,true,false,seRmbhCode,seRmbhCode->Name);
    ClientGroup->AddComponent(1,false,true,true,seRmbhWo,seRmbhWo->Name);
    ClientGroup->AddComponent(1,true,true,true,chkRmbhCheck,chkRmbhCheck->Name);
    ClientGroup->AddComponent(1,true,true,true,scRmbhFmonth,scRmbhFmonth->Name);

    ClientGroup->AddComponent(2,false,false,true,fpRmbd,fpRmbd->Name);
    ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
    ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);
    ClientGroup->AddComponent(2,true,true,true,plRmbdGoods,plRmbdGoods->Name);
    ClientGroup->AddComponent(2,false,true,true,seRmbdProcess,seRmbdProcess->Name);
    ClientGroup->AddComponent(2,true,true,true,seRmbdRLoc,seRmbdRLoc->Name);
    ClientGroup->AddComponent(2,false,true,true,seRmbdLine,seRmbdLine->Name);
    //Rmbh
    FillComboBox(scRmbhFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
    FillComboBox(scRmbhPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where PosTypeFlg=3 order by PosTypeCode","PosTypeName","PosTypeCode");
    //Rmbd
    FillComboBox(scRmbdUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
    FillEdit(seRmbdRLoc,"SELECT LocName,LocCode from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
    FillEdit(seRmbdLoc,"SELECT LocName,LocCode from sdLoc where LocType=1 order by LocCode","LocName","LocCode");
    FillEdit(seRmbdProcess,"SELECT ProcessName,ProcessCode from sdProcess order by ProcessCode","ProcessName","ProcessCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::RefreshUpdateData(int MsgSrc,int MsgType)
{
    try
    {
       switch (MsgSrc)
       {
         case euSdFc:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
	           FillComboBox(scRmbhFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
	           EndWaitForm();
	           break;
           }
         case euSdPosType:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
	           FillComboBox(scRmbhPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType order by PosTypeCode","PosTypeName","PosTypeCode");
	           EndWaitForm();
	           break;
           }
         case euSdUnit:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
	           FillComboBox(scRmbdUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
	           EndWaitForm();
	           break;
           }
         case euSdLoc:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillEdit(seRmbdRLoc,"SELECT LocName,LocCode from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
               FillEdit(seRmbdLoc,"SELECT LocName,LocCode from sdLoc where LocType=1 order by LocCode","LocName","LocCode");
	           EndWaitForm();
	           break;
           }
         case euSdProcess:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillEdit(seRmbdProcess,"SELECT ProcessName,ProcessCode from sdProcess order by ProcessCode","ProcessName","ProcessCode");
	           EndWaitForm();
	           break;
           }
         default:
           break;
       }
    }
    __finally
    {
        //AddCode
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::ClearControl(int Section,bool BringToNext)
{
    if(Section == 1)
    {
       if(!BringToNext)
       {
          seRmbhCode->Text="";
          deRmbhDate->Text=g_sdCurDate;
          scRmbhFmonth->LocateKey(g_sdMMonth);
          scRmbhPosType->ItemIndex=-1;
          seRmbhWo->Text="";
          labUser->Caption=g_sdUserCode;
          chkRmbhCheck->Checked=false;
          labChecker->Caption="";
          labCheckDate->Caption="";
          memRmbhDesc->Text="";
       }
       sgRmbh->RowCount=1;
    }
    else
    {
       if(!BringToNext)
       {
          seRmbdLine->Text=AnsiString(comServer->ItemCount+1);
          seRmbdGoods->Text="";
          seRmbdGoodsName->Text="";
          scRmbdUnit->ItemIndex=-1;
          scRmbdGoodsType->ItemIndex=-1;
          scRmbdGoodsFrom->ItemIndex=-1;
          seRmbdGoodsOoq->Text="";
          seRmbdQty->Text="0.00";
          seRmbdProcess->ItemIndex=-1;
          seRmbdRLoc->ItemIndex=-1;
          seRmbdLoc->ItemIndex=-1;
          memRmbdDesc->Text="";
       }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::GetDataFromComObject(int Section)
{
    if(Section==1)
    {
        seRmbhCode->Text=GetHeadValue(fiRmbhCode);
        deRmbhDate->Text=GetHeadValue(fiRmbhDate);
        scRmbhFmonth->LocateKey(GetHeadValue(fiRmbhFmonth));
        scRmbhPosType->LocateKey(GetHeadValue(fiRmbhPosType));
        seRmbhWo->Text=GetHeadValue(fiRmbhWoCode);
        memRmbhDesc->Text=GetHeadValue(fiRmbhDesc);
        chkRmbhCheck->Checked=GetHeadValue(fiRmbhCheck)=="1";
        if(chkRmbhCheck->Checked)
           SetCheckToolbarStatus(true);
        else
           SetCheckToolbarStatus(false);
        labChecker->Caption=GetHeadValue(fiRmbhChecker);
        labCheckDate->Caption=GetHeadValue(fiRmbhCheckDate);
        labUser->Caption=GetHeadValue(fiRmbhUser);
    }
    else
    {
        seRmbdLine->Text=GetDetailValue(fiRmbdLine);
        seRmbdGoods->Text=GetDetailValue(fiRmbdGoods);

        g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiRmbdGoods)));
        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");

        seRmbdQty->Text=GetDetailValue(fiRmbdQty);
        seRmbdProcess->LocateKey(GetDetailValue(fiRmbdProcess));
        seRmbdRLoc->LocateKey(GetDetailValue(fiRmbdRLoc));
        seRmbdLoc->LocateKey(GetDetailValue(fiRmbdLoc));
        memRmbdDesc->Text=GetDetailValue(fiRmbdDesc);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::SendDataToComObject(int Section)
{
    if(Section==1)
    {
       SetHeadValue(fiRmbhCode,seRmbhCode->Text);
       SetHeadValue(fiRmbhDate,deRmbhDate->Text);
       SetHeadValue(fiRmbhFmonth,scRmbhFmonth->Text);
       SetHeadValue(fiRmbhPosType,scRmbhPosType->ItemData[1]);
       SetHeadValue(fiRmbhWoCode,seRmbhWo->Text);
       SetHeadValue(fiRmbhUser,labUser->Caption);
       SetHeadValue(fiRmbhDesc,memRmbhDesc->Text);
    }
    else
    {
       SetDetailValue(fiRmbdCode,seRmbhCode->Text);
       SetDetailValue(fiRmbdLine,seRmbdLine->Text);
       SetDetailValue(fiRmbdProcess,seRmbdProcess->ItemData[1]);
       SetDetailValue(fiRmbdRLoc,seRmbdRLoc->ItemData[1]);       
       SetDetailValue(fiRmbdGoods,seRmbdGoods->Text);
       SetDetailValue(fiRmbdLoc,seRmbdLoc->ItemData[1]);
       SetDetailValue(fiRmbdQty,seRmbdQty->Text);
       SetDetailValue(fiRmbdDesc,memRmbdDesc->Text);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::WaitUserInput(int Section)
{
    if(Section ==1){
       if(seRmbhCode->Enabled)
          seRmbhCode->SetFocus();
       else
          deRmbhDate->SetFocus();
    }
    else
    {
       ChangeToBrowseState(false);
       if(seRmbdLine->Enabled)
          seRmbdLine->SetFocus();
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmRmbh::GetDataToGrid()
{
    AnsiString ItemStr;
    ItemStr=GetDetailValue(fiRmbdLine)+
            "\t"+GetDetailValue(fiRmbdGoods)+
            "\t"+GetDetailValue(fiRmbdUnit)+
            "\t"+GetDetailValue(fiRmbdQty)+
            "\t"+GetDetailValue(fiRmbdProcess)+
            "\t"+GetDetailValue(fiRmbdRLoc)+
            "\t"+GetDetailValue(fiRmbdLoc);
    return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::RefreshGridData(int mAction)
{
    int i;
    AnsiString ItemStr=GetDataToGrid();
    switch(mAction)
    {
       case 0: //Add
         sgRmbh->AddItem(ItemStr);
         sgRmbh->Row=sgRmbh->RowCount-1;
         break;
       case 1: //Edit
         sgRmbh->ChangeItem(ItemStr,sgRmbh->Row);
         break;
       case 2: //Delete
         sgRmbh->RemoveItem(sgRmbh->Row);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgRmbh->RowCount=1;
    if(comServer->RecordCount > 0)
    {
      for(i=0;i<comServer->ItemCount;i++)
      {
         comServer->LocateItemByIndex(i);
         RefreshGridData(0);
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRmbh::DisplayBill()

⌨️ 快捷键说明

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