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

📄 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, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
    : TBillBaseForm(Owner,chWnd,MidCode,WhereStr)
{
    SetAutoCodeString(seGmthCode,"ACM-006");
//    l_RsGoods=new TComResultSet(Handle,g_ClientHandle);
//    l_RsGoods->Open("select * from sdGoods order by GoodsCode","GoodsCode");
}
//---------------------------------------------------------------------------
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(Handle,scGmthFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
    FillComboBox(Handle,scGmthPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where PosTypeFlg=3 order by PosTypeCode","PosTypeName","PosTypeCode");
    FillComboBox(Handle,scGmthDept,"SELECT DeptName,DeptCode FROM sdDept where DeptEnd=1 Order by DeptCode","DeptName","DeptCode");
    //Gmtd
    FillComboBox(Handle,scGmtdUnit,"SELECT UnitName,UnitCode FROM sdUnit order by UnitCode","UnitName","UnitCode");
    FillEdit(Handle,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(Handle,scGmthFmonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
	           EndWaitForm();
	           break;
           }
         case euSdPosType:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
	           FillComboBox(Handle,scGmthPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where PosTypeFlg=3 order by PosTypeCode","PosTypeName","PosTypeCode");
	           EndWaitForm();
	           break;
           }
         case euSdUnit:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
	           FillComboBox(Handle,scGmtdUnit,"SELECT UnitName,UnitCode from sdUnit order by UnitCode","UnitName","UnitCode");
	           EndWaitForm();
	           break;
           }
         case euSdLoc:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillEdit(Handle,seGmtdSLoc,"SELECT LocName,LocCode FROM sdLoc where LocType=1 order by LocCode","LocName","LocCode");
	           EndWaitForm();
	           break;
           }
         case euSdDept:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillComboBox(Handle,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("GmthCode");
      deGmthDate->Text=GetHeadValue("GmthDate");
      scGmthFmonth->LocateKey(GetHeadValue("GmthFmonth"));
      scGmthPosType->LocateKey(GetHeadValue("GmthPosType"));
      scGmthType->LocateKey(GetHeadValue("GmthType"));
      scGmthDept->LocateKey(GetHeadValue("GmthDept"));
      chkGmthCheck->Checked=GetHeadValue("GmthCheck")=="1" ;
      if(chkGmthCheck->Checked)
         SetCheckToolbarStatus(true);
      else
         SetCheckToolbarStatus(false);
      labChecker->Caption=GetHeadValue("GmthChecker");
      labCheckDate->Caption=GetHeadValue("GmthCheckDate");
      memGmthDesc->Text=GetHeadValue("GmthDesc");
    }
    else
    {
      seGmtdLine->Text=GetDetailValue("GmtdLine");
      seGmtdGoods->Text=GetDetailValue("GmtdGoods");
//      l_RsGoods->LocateByKey(WideString(GetDetailValue("GmtdGoods")));
//      seGmtdGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");
      seGmtdGoodsName->Text=GetDetailValue("GmtdGoodsName");
      scGmtdUnit->LocateKey(GetGoodsValue(gtInitRs,"GoodsUnitCode"));
      if(GetGoodsValue(gtInitRs,"GoodsType")!="")
        scGmtdGoodsType->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsType"))-1;
      else
        scGmtdGoodsType->ItemIndex=-1;

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

      seGmtdQty->Text=GetDetailValue("GmtdQty");
      seGmtdSLoc->LocateKey(GetDetailValue("GmtdSLoc"));
      memGmtdDesc->Text=GetDetailValue("GmtdDesc");
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_D::SendDataToComObject(int Section)
{
    if(Section==1)
    {
       SetHeadValue("GmthCode",seGmthCode->Text);
       SetHeadValue("GmthDate",deGmthDate->Text);
       SetHeadValue("GmthFmonth",scGmthFmonth->Text);
       SetHeadValue("GmthPosType",scGmthPosType->ItemData[1]);
       SetHeadValue("GmthDept",scGmthDept->ItemData[1]);
       SetHeadValue("GmthUser",labUser->Caption);
       SetHeadValue("GmthDesc",memGmthDesc->Text);
    }
    else
    {
       SetDetailValue("GmtdCode",seGmthCode->Text);
       SetDetailValue("GmtdLine",seGmtdLine->Text);
       SetDetailValue("GmtdGoods",seGmtdGoods->Text);
       SetDetailValue("GmtdUnit",scGmtdUnit->ItemData[1]);
       SetDetailValue("GmtdQty",seGmtdQty->Text);
       SetDetailValue("GmtdSLoc",seGmtdSLoc->ItemData[1]);
       SetDetailValue("GmtdDesc",memGmtdDesc->Text);
       SetDetailValue("GmtdGoodsspce"," ");
       SetDetailValue("GmtdGoodsname",seGmtdGoodsName->Text);
       SetDetailValue("GmtdPQty",0);
       SetDetailValue("GmtdCQty",0);
    }
}
//---------------------------------------------------------------------------
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("GmtdLine")+
       "\t"+GetDetailValue("GmtdGoods")+
       "\t"+GetDetailValue("GmtdGoodsname")+
       "\t"+GetDetailValue("GmtdGoodsspce")+
       "\t"+GetDetailValue("GmtdUnit")+
       "\t"+GetDetailValue("GmtdQty")+
       "\t"+GetDetailValue("GmtdSLoc");
    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++)
      {

⌨️ 快捷键说明

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