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

📄 dtht.cpp

📁 速达开源ERP系统
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Dtht.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmDtht *frmDtht;
//---------------------------------------------------------------------------
__fastcall TfrmDtht::TfrmDtht(TComponent* Owner)
    : TRecBaseForm(Owner,euSdDtht,"")
{

}
//---------------------------------------------------------------------------
__fastcall TfrmDtht::TfrmDtht(TComponent* Owner,AnsiString LocCode,AnsiString GoodsCode)
    : TRecBaseForm(Owner,euSdDtht,"")
{
    ClearControl(false);
    FLocCode=LocCode;
    FGoodsCode=GoodsCode;
    sgDtht->RowCount=1;
    LabCurFmonth->Caption=g_sdIMonth;
    LabDthtGoods->Caption=FGoodsCode;
    if(g_sdRsGoods->LocateByKey(WideString(FGoodsCode))==0)
       LabDthtGoodsName->Caption=GetGoodsValue("GoodsName");
    scDthtLoc->LocateKey(FLocCode);
    AnsiString FilStr="DthtFmonth='"+g_sdIMonth+"' and DthtGoods='"+FGoodsCode+"' and DthtLoc='"+FLocCode+"'";
    comServer->FilterString=WideString(FilStr);
    comServer->Query();    
    if(comServer->RecordCount>0)
    {
       FillGridWithData();
       comServer->MoveFirst();
       GetDataFromComObject();
    }
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmDtht::GetFieldValue(int FieldIndex)
{
    return ReadFieldValue(comServer,FieldIndex);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDtht::SetFieldValue(int iFieldIndex,AnsiString sFieldValue)
{
    WriteFieldValue(comServer,iFieldIndex,sFieldValue);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDtht::ClearControl(bool BringToNext)
{
    if(!BringToNext)
    {
       scDthtDept->ItemIndex= -1;
       seDthtBoyQty->Text   = "0";
       seDthtBopQty->Text   = "0";
       seDthtIopQty->Text   = "0";
       seDthtOopQty->Text   = "0";
       seDthtIoyQty->Text   = "0";
       seDthtOoyQty->Text   = "0";
       seDthtAoyQty->Text   = "0";
       cheDthtClose->Checked=false;
       cheDthtInit->Checked =false;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDtht::GetDataFromComObject()
{
//    scDthtLoc->LocateKey(GetFieldValue(fiDthtLoc));
    scDthtDept->LocateKey(GetFieldValue(fiDthtDept));
    seDthtBoyQty->Text   = GetFieldValue(fiDthtBoyQty);
    seDthtBopQty->Text   = GetFieldValue(fiDthtBopQty);
    seDthtIopQty->Text   = GetFieldValue(fiDthtIopQty);
    seDthtOopQty->Text   = GetFieldValue(fiDthtOopQty);
    seDthtIoyQty->Text   = GetFieldValue(fiDthtIoyQty);
    seDthtOoyQty->Text   = GetFieldValue(fiDthtOoyQty);
    seDthtAoyQty->Text   = GetFieldValue(fiDthtAoyQty);
    cheDthtInit->Checked=GetFieldValue(fiDthtInit)=="1";
    if(cheDthtInit->Checked)
    {
      tbEditHead->Enabled=false;
      tbDeleteHead->Enabled=false;
    }
    else
    {
      tbEditHead->Enabled=true;
      tbDeleteHead->Enabled=true;
    }
    cheDthtClose->Checked=GetFieldValue(fiDthtClose)=="1";
}
//---------------------------------------------------------------------------
void __fastcall TfrmDtht::SendDataToComObject()
{
    SetFieldValue(fiDthtFmonth,g_sdIMonth);
    SetFieldValue(fiDthtGoods,FGoodsCode);
    SetFieldValue(fiDthtLoc,FLocCode);
    SetFieldValue(fiDthtDept,scDthtDept->ItemData[1]);
    SetFieldValue(fiDthtBoyQty,seDthtBoyQty->Text);
    SetFieldValue(fiDthtBopQty,seDthtBopQty->Text);
    SetFieldValue(fiDthtIoyQty,seDthtIoyQty->Text);
    SetFieldValue(fiDthtOoyQty,seDthtOoyQty->Text);
    SetFieldValue(fiDthtInit,cheDthtInit->Checked?"1":"0");
}
//---------------------------------------------------------------------------
void __fastcall TfrmDtht::WaitUserInput()
{
    scDthtDept->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmDtht::GetDataToGrid()
{
    AnsiString  tempS;
    tempS = GetFieldValue(fiDthtDept)+
            "\t" + GetFieldValue(fiDthtBoyQty)+
            "\t" + GetFieldValue(fiDthtBopQty);
    return(tempS);
}
//---------------------------------------------------------------------------

void __fastcall TfrmDtht::RefreshGridData(int mAction)
{
    AnsiString ItemStr;
    ItemStr = GetDataToGrid();
    if(mAction == 0)
    {
        sgDtht->AddItem(ItemStr);
        sgDtht->Row=sgDtht->RowCount-1;
    }
    else if(mAction == 1)
    {
        sgDtht->ChangeItem(ItemStr,sgDtht->Row);
    }
    else if(mAction == 2)
    {
        sgDtht->RemoveItem(sgDtht->Row);
    }
    GetDataFromComObject();
}
//---------------------------------------------------------------------------

void __fastcall TfrmDtht::FillGridWithData()
{
    AnsiString ItemStr;
    comServer->MoveFirst();
    sgDtht->RowCount = 1;
    while(comServer->Eof == 0)
    {
       ItemStr = GetDataToGrid();
       sgDtht->AddItem(ItemStr);
       comServer->MoveNext();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmDtht::InitEditControl()
{
    ClientGroup->AddComponent(2,false,false,true,fpDtht,fpDtht->Name);
    ClientGroup->AddComponent(2,true,true,true,fpDtht1,fpDtht1->Name);
    ClientGroup->AddComponent(2,true,true,true, scDthtLoc,scDthtLoc->Name);
    ClientGroup->AddComponent(2,true,true,true, seDthtIopQty,seDthtIopQty->Name);
    ClientGroup->AddComponent(2,true,true,true, seDthtOopQty,seDthtOopQty->Name);
    ClientGroup->AddComponent(2,true,true,true, seDthtAoyQty,seDthtAoyQty->Name);
    ClientGroup->AddComponent(2,true,true,true, cheDthtClose,cheDthtClose->Name);
    ClientGroup->AddComponent(2,false,false,true, cheDthtInit,cheDthtInit->Name);
    ClientGroup->AddComponent(2,true,true,false, sgDtht,sgDtht->Name);
    FillComboBox(scDthtLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
    FillComboBox(scDthtDept,"select DeptCode,memo=DeptCode+space(1)+DeptName from sdDept order by DeptCode","memo","DeptCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmDtht::RefreshUpdateData(int MsgSrc,int MsgType)
{
    try
    {
       switch (MsgSrc)
       {
         case euSdLoc:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillComboBox(scDthtLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
	           EndWaitForm();
	           break;
           }
         case euSdDept:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillComboBox(scDthtDept,"select DeptCode,memo=DeptCode+space(1)+DeptName from sdDept order by DeptCode","memo","DeptCode");
	           EndWaitForm();
	           break;
           }
         default:
           break;
       }
    }
    __finally
    {
       //AddCode;
    }
}
//---------------------------------------------------------

void __fastcall TfrmDtht::FormClose(TObject *Sender, TCloseAction &Action)
{
    TRecBaseForm::FormClose(Sender,Action);
/*
    AnsiString FormIniFile = "D:\Test.Ini";
    WriteGridWidth(Name,sgPg,FormIniFile);
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmDtht::FormCreate(TObject *Sender)
{
/*
    AnsiString FormIniFile="D:\Test.Ini";
    SetGridWidth(Name,sgPg,FormIniFile);
*/
}
//---------------------------------------------------------------------------

void __fastcall TfrmDtht::sgDthtClick(TObject *Sender)
{
    int ARow;
    ARow=sgDtht->Row;
    if(ARow > 0)
    {
       AnsiString KeyStr=sgDtht->Cells[0][ARow]+LabCurFmonth->Caption
                        +FLocCode+LabDthtGoods->Caption;
       comServer->LocateByKey(WideString(KeyStr));
    }
    if(!comServer->Eof)
       GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmDtht::muFirstClick(TObject *Sender)
{
    if(sgDtht->RowCount > 1)
    {
       sgDtht->Row=1;
       sgDthtClick(NULL);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmDtht::muPreviousClick(TObject *Sender)
{
    if(sgDtht->RowCount > 1 && sgDtht->Row > 1)
    {
       sgDtht->Row=sgDtht->Row-1;
       sgDthtClick(NULL);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmDtht::muNextClick(TObject *Sender)
{
    if(sgDtht->RowCount > 1 && sgDtht->Row < sgDtht->RowCount-1)
    {
       sgDtht->Row=sgDtht->Row+1;
       sgDthtClick(NULL);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmDtht::muLastClick(TObject *Sender)
{
    if(sgDtht->RowCount > 1)
    {
      sgDtht->Row=sgDtht->RowCount-1;
      sgDthtClick(NULL);
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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