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

📄 gmth_d.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Gmth_D.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_D *frmGmth_D;
//---------------------------------------------------------------------------
__fastcall TfrmGmth_D::TfrmGmth_D(TComponent* Owner)
    : TBillBaseForm(Owner,euSdGmth_D,"")
{
    AutoCtl=seGmthCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_D::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(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);
    //
    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");
    FillComboBox(scGmthDept,"SELECT DeptName,DeptCode FROM sdDept where DeptEnd=1 Order by DeptCode","DeptName","DeptCode");
    //Gmtd
    FillComboBox(scGmtdUnit,"SELECT UnitName,UnitCode FROM sdUnit order by UnitCode","UnitName","UnitCode");
    FillEdit(seGmtdSLoc,"SELECT LocName,LocCode FROM sdLoc where LocType=1 order by LocCode","LocName","LocCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_D::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 where PosTypeFlg=3 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 LocName,LocCode FROM sdLoc where LocType=1 order by LocCode","LocName","LocCode");
	           EndWaitForm();
	           break;
           }
         case euSdDept:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillComboBox(scGmthDept,"SELECT DeptName,DeptCode FROM sdDept where DeptEnd=1 Order by DeptCode","DeptName","DeptCode");
	           EndWaitForm();
	           break;
           }
         default:
           break;
       }
    }
    __finally
    {
        //AddCode;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_D::ClearControl(int Section,bool BringToNext)
{
    if(Section == 1)
    {
       if(!BringToNext)
       {
          seGmthCode->Text="";
          deGmthDate->Text=g_sdCurDate;
          scGmthFmonth->LocateKey(g_sdMMonth);
          scGmthPosType->ItemIndex=-1;
          scGmthType->ItemIndex=4;
          scGmthDept->ItemIndex=-1;
          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";
          seGmtdSLoc->ItemIndex=-1;
          memGmtdDesc->Text="";
       }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_D::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));
      scGmthDept->LocateKey(GetHeadValue(fiGmthDept));
      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);
      seGmtdSLoc->LocateKey(GetDetailValue(fiGmtdSLoc));
      memGmtdDesc->Text=GetDetailValue(fiGmtdDesc);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_D::SendDataToComObject(int Section)
{
    if(Section==1)
    {
       SetHeadValue(fiGmthCode,seGmthCode->Text);
       SetHeadValue(fiGmthDate,deGmthDate->Text);
       SetHeadValue(fiGmthFmonth,scGmthFmonth->Text);
       SetHeadValue(fiGmthPosType,scGmthPosType->ItemData[1]);
       SetHeadValue(fiGmthDept,scGmthDept->ItemData[1]);
       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(fiGmtdSLoc,seGmtdSLoc->ItemData[1]);
       SetDetailValue(fiGmtdDesc,memGmtdDesc->Text);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_D::WaitUserInput(int Section)
{
    if(Section ==1){
       if(seGmthCode->Enabled)
          seGmthCode->SetFocus();
       else
          deGmthDate->SetFocus();
    }
    else
    {
       ChangeToBrowseState(false);
       if(seGmtdLine->Enabled)
          seGmtdLine->SetFocus();
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGmth_D::GetDataToGrid()
{
    AnsiString ItemStr;
    ItemStr=GetDetailValue(fiGmtdLine)+
       "\t"+GetDetailValue(fiGmtdGoods)+
       "\t"+GetDetailValue(fiGmtdUnit)+
       "\t"+GetDetailValue(fiGmtdQty)+
       "\t"+GetDetailValue(fiGmtdSLoc);
    return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_D::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_D::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgGmth->RowCount=1;
    if(comServer->RecordCount > 0)
    {
      for(i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);

⌨️ 快捷键说明

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