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

📄 dmah.cpp

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

TfrmDmah *frmDmah;
//---------------------------------------------------------------------------
__fastcall TfrmDmah::TfrmDmah(TComponent* Owner)
    : TGenBaseForm(Owner,euSdDmah,"")
{
    AutoCtl=seDmahCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::InitEditControl()
{
    ClientGroup->AddComponent(1,false,false,true,fpDmah,fpDmah->Name);
    ClientGroup->AddComponent(1,false,true,false,seDmahCode,seDmahCode->Name);
    ClientGroup->AddComponent(1,true,true,true,scDmahFmonth,scDmahFmonth->Name);

    ClientGroup->AddComponent(2,false,false,true,fpDmad,fpDmad->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,seDmadGmtCode,seDmadGmtCode->Name);
    ClientGroup->AddComponent(2,true,true,true,plDmadGoods,plDmadGoods->Name);
    //Dmah
    FillComboBox(scDmahFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
    FillComboBox(scDmahPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where PosTypeFlg=3 order by PosTypeCode","PosTypeName","PosTypeCode");
    FillEdit(seDmadLoc,"SELECT LocName,LocCode from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
    //Dmad
    FillComboBox(scDmadUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::RefreshUpdateData(int MsgSrc,int MsgType)
{
    try
    {
       switch(MsgSrc)
       {
         case euSdFc:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
	           FillComboBox(scDmahFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
	           EndWaitForm();
	           break;
           }
         case euSdPosType:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillComboBox(scDmahPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where PosTypeFlg=3 order by PosTypeCode","PosTypeName","PosTypeCode");
	           EndWaitForm();
	           break;
           }
         case euSdLoc:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillEdit(seDmadLoc,"SELECT LocName,LocCode from sdLoc where LocType=2 order by LocCode","LocName","LocCode");
	           EndWaitForm();
	           break;
           }
         case euSdUnit:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
	           FillComboBox(scDmadUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
	           EndWaitForm();
	           break;
           }
         default:
           break;
       }
    }
    __finally
    {
        //AddCode;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::ClearControl(int Section,bool BringToNext)
{
    if(Section == 1)
    {
       if(!BringToNext)
       {
          seDmahCode->Text = "";
          deDmahDate->Text = g_sdCurDate;
          scDmahFmonth->LocateKey(g_sdMMonth);
          scDmahPosType->ItemIndex = -1;
          labUser->Caption = g_sdUserCode;
          chkDmahCheck->Checked = false;
          labChecker->Caption = "";
          labCheckDate->Caption = "";
          memDmahDesc->Text = "";
       }
       sgDmah->RowCount=1;
    }
    else
    {
       if(!BringToNext)
       {
          seDmadLine->Text=AnsiString(comServer->ItemCount+1);
          seDmadGmtCode->Text="";
          seDmadGmtdLine->Text=0;
          seDmadLoc->ItemIndex = -1;
          seDmadWoCode->Text="";
          seDmadGoods->Text="";
          seDmadGoodsName->Text="";
          scDmadUnit->ItemIndex=-1;
          seDmadQty->Text="0";
          memDmadDesc->Text="";
       }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::GetDataFromComObject(int Section)
{
    if(Section==1)
    {
        seDmahCode->Text=GetHeadValue(fiDmahCode);
        deDmahDate->Text=GetHeadValue(fiDmahDate);
        scDmahFmonth->LocateKey(GetHeadValue(fiDmahFmonth));
        scDmahPosType->LocateKey(GetHeadValue(fiDmahPosType));
        memDmahDesc->Text=GetHeadValue(fiDmahDesc);
        labUser->Caption=GetHeadValue(fiDmahUser);
        chkDmahCheck->Checked=GetHeadValue(fiDmahCheck)=="1";
        labChecker->Caption=GetHeadValue(fiDmahChecker);
        labCheckDate->Caption=GetHeadValue(fiDmahCheckDate);
        if(chkDmahCheck->Checked)
           SetCheckToolbarStatus(true);
        else
           SetCheckToolbarStatus(false);
    }
    else
    {
        seDmadLine->Text=GetDetailValue(fiDmadLine);
        seDmadGmtCode->Text=GetDetailValue(fiDmadGmtCode);
        seDmadGmtdLine->Text=GetDetailValue(fiDmadGmtdLine);
        seDmadLoc->LocateKey(GetDetailValue(fiDmadLoc));
        seDmadWoCode->Text=GetDetailValue(fiDmadWoCode);
        //物料相关资料
        AnsiString FGoodsCode;
        FGoodsCode=GetDetailValue(fiDmadGoods);
        seDmadGoods->Text = FGoodsCode;
        g_sdRsGoods->LocateByKey(WideString(FGoodsCode));
        seDmadGoodsName->Text=GetGoodsValue("GoodsName");
        scDmadUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
        //
        seDmadQty->Text=GetDetailValue(fiDmadQty);
        memDmadDesc->Text=GetDetailValue(fiDmadDesc);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::SendDataToComObject(int Section)
{
    if (Section==1)
    {
       SetHeadValue(fiDmahCode,seDmahCode->Text);
       SetHeadValue(fiDmahDate,deDmahDate->Text);
       SetHeadValue(fiDmahFmonth,scDmahFmonth->Text);
       SetHeadValue(fiDmahPosType,scDmahPosType->ItemData[1]);
       SetHeadValue(fiDmahUser,labUser->Caption);
       SetHeadValue(fiDmahDesc,memDmahDesc->Text);
    }
    else
    {
       SetDetailValue(fiDmadCode,seDmahCode->Text);
       SetDetailValue(fiDmadLine,seDmadLine->Text);
       SetDetailValue(fiDmadGmtCode,seDmadGmtCode->Text);
       SetDetailValue(fiDmadGmtdLine,seDmadGmtdLine->Text);
       SetDetailValue(fiDmadWoCode,seDmadWoCode->Text);
       SetDetailValue(fiDmadQty,seDmadQty->Text);
       SetDetailValue(fiDmadDesc,memDmadDesc->Text);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::WaitUserInput(int Section)
{
    if(Section ==1){
       if(seDmahCode->Enabled)
          seDmahCode->SetFocus();
       else
          deDmahDate->SetFocus();
    }
    else
    {
       ChangeToBrowseState(false);
       if(seDmadLine->Enabled)
          seDmadLine->SetFocus();
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmDmah::GetDataToGrid()
{
    AnsiString ItemStr,s;
    s = GetDetailValue(fiDmadUnit);
    scDmadUnit->LocateKey(s);
    ItemStr=GetDetailValue(fiDmadLine)+
       "\t"+GetDetailValue(fiDmadWoCode)+
       "\t"+GetDetailValue(fiDmadGoods)+
       "\t"+scDmadUnit->ItemData[0]+
       "\t"+GetDetailValue(fiDmadQty)+
       "\t"+GetDetailValue(fiDmadLoc);
    return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::RefreshGridData(int mAction)
{
    int i;
    AnsiString ItemStr=GetDataToGrid();
    switch(mAction)
    {
       case 0: //Add
         sgDmah->AddItem(ItemStr);
         sgDmah->Row=sgDmah->RowCount-1;
         break;
       case 1: //Edit
         sgDmah->ChangeItem(ItemStr,sgDmah->Row);
         break;
       case 2: //Delete
         sgDmah->RemoveItem(sgDmah->Row);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgDmah->RowCount=1;
    if(comServer->RecordCount > 0)
    {
      for(i=0;i<comServer->ItemCount;i++)
      {
         comServer->LocateItemByIndex(i);
         RefreshGridData(0);
      }
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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