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

📄 gmth_a.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Gmth_A.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"

TfrmGmth_A *frmGmth_A;
//---------------------------------------------------------------------------
__fastcall TfrmGmth_A::TfrmGmth_A(TComponent* Owner)
    : TBillBaseForm(Owner,euSdGmth_A,"")
{
    AutoCtl=seGmthCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::InitEditControl()
{
    ClientGroup->AddComponent(1,false,false,true,fpGmth,fpGmth->Name);
    ClientGroup->AddComponent(1,true,true,true,scGmthType,scGmthType->Name);
    ClientGroup->AddComponent(1,false,true,false,seGmthCode,seGmthCode->Name);
    ClientGroup->AddComponent(1,true,true,true,scGmthFmonth,scGmthFmonth->Name);
    ClientGroup->AddComponent(1,false,true,true,seGmthWo,seGmthWo->Name);
    ClientGroup->AddComponent(2,false,false,true,fpGmtd,fpGmtd->Name);
    ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
    ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);
    ClientGroup->AddComponent(2,false,true,true,seGmtdLine,seGmtdLine->Name);
    ClientGroup->AddComponent(2,true,true,true,plGmtdGoods,plGmtdGoods->Name);
    ClientGroup->AddComponent(2,true,true,true,seGmtdDLoc,seGmtdDLoc->Name);
    ClientGroup->AddComponent(2,false,true,true,seGmtdGoods,seGmtdGoods->Name);
    //
    scGmthType->ClearAll();
    scGmthType->AddItems("R-工单定额领料","1");
    scGmthType->AddItems("W-工单自由领料","2");
    scGmthType->AddItems("A-工单工序补料","3");
    scGmthType->AddItems("C-共用材料领料","4");
    scGmthType->AddItems("D-部门直接领料","5");
    //Gmth
    FillComboBox(scGmthFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
    FillComboBox(scGmthPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where PosTypeFlg=3 order by PosTypeCode","PosTypeName","PosTypeCode");
    //Gmtd
    FillEdit(seGmtdProcess,"SELECT ProcessCode,ProcessName from sdProcess order by ProcessCode","ProcessName","ProcessCode");
    FillEdit(seGmtdSLoc,"SELECT LocCode,LocName from sdLoc where LocType=1 order by LocCode","LocName","LocCode");
    FillEdit(seGmtdDLoc,"SELECT LocCode,LocName from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
    FillComboBox(scGmtdUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::RefreshUpdateData(int MsgSrc,int MsgType)
{
    try
    {
       switch (MsgSrc)
       {
         case euSdFc:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
	           FillComboBox(scGmthFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
	           EndWaitForm();
	           break;
           }
         case euSdPosType:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
	           FillComboBox(scGmthPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType order by PosTypeCode","PosTypeName","PosTypeCode");
	           EndWaitForm();
	           break;
           }
         case euSdUnit:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
	           FillComboBox(scGmtdUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
	           EndWaitForm();
	           break;
           }
         case euSdLoc:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillEdit(seGmtdSLoc,"SELECT LocCode,LocName from sdLoc where LocType=1 order by LocCode","LocName","LocCode");
               FillEdit(seGmtdDLoc,"SELECT LocCode,LocName from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
	           EndWaitForm();
	           break;
           }
         case euSdProcess:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillEdit(seGmtdProcess,"SELECT ProcessCode,ProcessName from sdProcess order by ProcessCode","ProcessName","ProcessCode");
	           EndWaitForm();
	           break;
           }
         default:
           break;
       }
    }
    __finally
    {
       //EndWaitForm();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::ClearControl(int Section,bool BringToNext)
{
    if(Section == 1){
      if(!BringToNext){
         seGmthCode->Text="";
         deGmthDate->Text=g_sdCurDate;
         scGmthFmonth->LocateKey(g_sdMMonth);
         scGmthPosType->ItemIndex=-1;
         scGmthPosType->Text="";
         scGmthType->ItemIndex=2;
         seGmthWo->Text = "";
         labUser->Caption=g_sdUserCode;
         chkGmthCheck->Checked=false;
         labChecker->Caption="";
         labCheckDate->Caption="";
         memGmthDesc->Text="";
      }
      sgGmth->RowCount=1;
    }
    else{
      if(!BringToNext){
         seGmtdLine->Text=AnsiString(comServer->ItemCount+1);
         seGmtdGoods->Text="";
         seGmtdGoodsName->Text="";
         scGmtdUnit->ItemIndex=-1;
         scGmtdGoodsType->ItemIndex=-1;
         scGmtdGoodsFrom->ItemIndex=-1;
         seGmtdGoodsOoq->Text="";
         seGmtdQty->Text="0.00";
         seGmtdProcess->ItemIndex=-1;
         seGmtdDLoc->ItemIndex=-1;
         seGmtdSLoc->ItemIndex=-1;
         memGmtdDesc->Text="";
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::GetDataFromComObject(int Section)
{
    if(Section==1)
    {
      seGmthCode->Text=GetHeadValue(fiGmthCode);
      deGmthDate->Text=GetHeadValue(fiGmthDate);
      scGmthFmonth->LocateKey(GetHeadValue(fiGmthFmonth));
      scGmthPosType->LocateKey(GetHeadValue(fiGmthPosType));
      scGmthType->LocateKey(GetHeadValue(fiGmthType));
      seGmthWo->Text=GetHeadValue(fiGmthWoCode);
      chkGmthCheck->Checked=GetHeadValue(fiGmthCheck)=="1" ;
      if(chkGmthCheck->Checked)
         SetCheckToolbarStatus(true);
      else
         SetCheckToolbarStatus(false);
      labChecker->Caption=GetHeadValue(fiGmthChecker);
      labCheckDate->Caption=GetHeadValue(fiGmthCheckDate);
      memGmthDesc->Text=GetHeadValue(fiGmthDesc);
    }
    else
    {
      seGmtdLine->Text=GetDetailValue(fiGmtdLine);

      seGmtdGoods->Text=GetDetailValue(fiGmtdGoods);

      g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiGmtdGoods)));
      seGmtdGoodsName->Text=GetGoodsValue("GoodsName");
      scGmtdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
      if(GetGoodsValue("GoodsType")!="")
        scGmtdGoodsType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
      else
        scGmtdGoodsType->ItemIndex=-1;

      if(GetGoodsValue("GoodsFrom")!="")
        scGmtdGoodsFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
      else
        scGmtdGoodsFrom->ItemIndex=-1;
      seGmtdGoodsOoq->Text=GetGoodsValue("GoodsOoq");

      seGmtdQty->Text=GetDetailValue(fiGmtdQty);
      seGmtdProcess->LocateKey(GetDetailValue(fiGmtdProcess));
      seGmtdDLoc->LocateKey(GetDetailValue(fiGmtdDLoc));
      seGmtdSLoc->LocateKey(GetDetailValue(fiGmtdSLoc));
      memGmtdDesc->Text=GetDetailValue(fiGmtdDesc);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::SendDataToComObject(int Section)
{
    if(Section==1)
    {
       SetHeadValue(fiGmthCode,seGmthCode->Text);
       SetHeadValue(fiGmthDate,deGmthDate->Text);
       SetHeadValue(fiGmthFmonth,scGmthFmonth->Text);
       SetHeadValue(fiGmthPosType,scGmthPosType->ItemData[1]);
       SetHeadValue(fiGmthWoCode,seGmthWo->Text);
       SetHeadValue(fiGmthUser,labUser->Caption);
       SetHeadValue(fiGmthDesc,memGmthDesc->Text);
    }
    else
    {
       SetDetailValue(fiGmtdCode,seGmthCode->Text);
       SetDetailValue(fiGmtdLine,seGmtdLine->Text);
       SetDetailValue(fiGmtdGoods,seGmtdGoods->Text);
       SetDetailValue(fiGmtdQty,seGmtdQty->Text);
       SetDetailValue(fiGmtdWoCode,seGmthWo->Text);
       SetDetailValue(fiGmtdProcess,seGmtdProcess->ItemData[1]);//领料工序
       SetDetailValue(fiGmtdDLoc,seGmtdDLoc->ItemData[1]);      //领料货位
       SetDetailValue(fiGmtdSLoc,seGmtdSLoc->ItemData[1]);      //发料货位
       SetDetailValue(fiGmtdDesc,memGmtdDesc->Text);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::WaitUserInput(int Section)
{
    if(Section ==1){
       if(CurrentState==caAddHead)
          seGmthCode->SetFocus();
       else
          deGmthDate->SetFocus();
    }
    else
    {
       ChangeToBrowseState(false);
       if(seGmtdLine->Enabled)
          seGmtdLine->SetFocus();
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGmth_A::GetDataToGrid()
{
    AnsiString ItemStr,s,s1;
    s1=GetDetailValue(fiGmtdUnit);
    scGmtdUnit->LocateKey(s1);
    ItemStr=GetDetailValue(fiGmtdLine)+
            "\t"+GetDetailValue(fiGmtdGoods)+
            "\t"+scGmtdUnit->ItemData[0]+
            "\t"+GetDetailValue(fiGmtdQty)+
            "\t"+GetDetailValue(fiGmtdSLoc)+
            "\t"+GetDetailValue(fiGmtdDLoc)+
            "\t"+GetDetailValue(fiGmtdProcess);
    return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::RefreshGridData(int mAction)
{
    int i;
    AnsiString ItemStr=GetDataToGrid();
    switch(mAction)
    {
       case 0: //Add
         sgGmth->AddItem(ItemStr);
         sgGmth->Row=sgGmth->RowCount-1;
         break;
       case 1: //Edit
         sgGmth->ChangeItem(ItemStr,sgGmth->Row);
         break;
       case 2: //Delete
         sgGmth->RemoveItem(sgGmth->Row);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgGmth->RowCount=1;
    if(comServer->RecordCount > 0)
    {
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          RefreshGridData(0);
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::DisplayBill()
{
    if(comServer->RecordCount>0){
       GetDataFromComObject(1);
       FillGridWithData();
       if(sgGmth->RowCount >1)
       {
         AnsiString Keystr;
         Keystr=sgGmth->Cells[0][sgGmth->Row];
         comServer->LocateItemByKey(WideString(Keystr));

⌨️ 快捷键说明

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