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

📄 sugt.cpp

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

}
//---------------------------------------------------------------------------
__fastcall TfrmSugt::TfrmSugt(TComponent* Owner,AnsiString LocCode,AnsiString GoodsCode)
    : TRecBaseForm(Owner,euSdSugt,"")
{
    ClearControl(false);
    FLocCode=LocCode;
    FGoodsCode=GoodsCode;
    sgSugt->RowCount=1;
    LabCurFmonth->Caption=g_sdIMonth;
    LabSugtGoods->Caption=FGoodsCode;
    if(g_sdRsGoods->LocateByKey(WideString(FGoodsCode))==0)
       LabSugtGoodsName->Caption=GetGoodsValue("GoodsName");
    scSugtLoc->LocateKey(FLocCode);
    AnsiString FilStr="SugtFmonth='"+g_sdIMonth+"' and sugtGoods='"+FGoodsCode+"' and sugtLoc='"+FLocCode+"'";
    comServer->FilterString=WideString(FilStr);
    comServer->Query();    
    if(comServer->RecordCount>0)
    {
       FillGridWithData();
       comServer->MoveFirst();
       GetDataFromComObject();
    }
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmSugt::GetFieldValue(int FieldIndex)
{
    return ReadFieldValue(comServer,FieldIndex);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSugt::SetFieldValue(int iFieldIndex,AnsiString sFieldValue)
{
    WriteFieldValue(comServer,iFieldIndex,sFieldValue);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSugt::ClearControl(bool BringToNext)
{
    if(!BringToNext)
    {
       scSugtSugCode->ItemIndex = -1;
       seSugtBoyQty->Text   = "0";
       seSugtBopQty->Text   = "0";
       seSugtIopQty->Text   = "0";
       seSugtOopQty->Text   = "0";
       seSugtIoyQty->Text   = "0";
       seSugtOoyQty->Text   = "0";
       seSugtAoyQty->Text   = "0";
       cheSugtClose->Checked=false;
       cheSugtInit->Checked=false;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmSugt::GetDataFromComObject()
{
//    scSugtLoc->LocateKey(GetFieldValue(fiSugtLoc));
    scSugtSugCode->Text  = GetFieldValue(fiSugtSugCode);
    seSugtBoyQty->Text   = GetFieldValue(fiSugtBoyQty);
    seSugtBopQty->Text   = GetFieldValue(fiSugtBopQty);
    seSugtIopQty->Text   = GetFieldValue(fiSugtIopQty);
    seSugtOopQty->Text   = GetFieldValue(fiSugtOopQty);
    seSugtIoyQty->Text   = GetFieldValue(fiSugtIoyQty);
    seSugtOoyQty->Text   = GetFieldValue(fiSugtOoyQty);
    seSugtAoyQty->Text   = GetFieldValue(fiSugtAoyQty);
    cheSugtInit->Checked=GetFieldValue(fiSugtInit)=="1";
    if(cheSugtInit->Checked)
    {
      tbEditHead->Enabled=false;
      tbDeleteHead->Enabled=false;
    }
    else
    {
      tbEditHead->Enabled=true;
      tbDeleteHead->Enabled=true;    
    }
    cheSugtClose->Checked=GetFieldValue(fiSugtClose)=="1";
}
//---------------------------------------------------------------------------
void __fastcall TfrmSugt::SendDataToComObject()
{
    SetFieldValue(fiSugtFmonth,g_sdIMonth);
    SetFieldValue(fiSugtGoods,FGoodsCode);
    SetFieldValue(fiSugtLoc,FLocCode);
    SetFieldValue(fiSugtSugCode,scSugtSugCode->Text);
    SetFieldValue(fiSugtBoyQty,seSugtBoyQty->Text);
    SetFieldValue(fiSugtBopQty,seSugtBopQty->Text);
    SetFieldValue(fiSugtIoyQty,seSugtIoyQty->Text);
    SetFieldValue(fiSugtOopQty,seSugtOopQty->Text);
    SetFieldValue(fiSugtInit,cheSugtInit->Checked?"1":"0");
}
//---------------------------------------------------------------------------
void __fastcall TfrmSugt::WaitUserInput()
{
    scSugtSugCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSugt::GetDataToGrid()
{
    AnsiString  tempS;
    tempS = GetFieldValue(fiSugtSugCode)+
            "\t" + GetFieldValue(fiSugtBoyQty)+
            "\t" + GetFieldValue(fiSugtBopQty);
    return(tempS);
}
//---------------------------------------------------------------------------

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

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

void __fastcall TfrmSugt::InitEditControl()
{
    ClientGroup->AddComponent(2,false,false,true,fpSugt,fpSugt->Name);
    ClientGroup->AddComponent(2,true,true,true,fpSugt1,fpSugt1->Name);
    ClientGroup->AddComponent(2,true,true,true, scSugtLoc,scSugtLoc->Name);
    ClientGroup->AddComponent(2,true,true,true, seSugtIopQty,seSugtIopQty->Name);
    ClientGroup->AddComponent(2,true,true,true, seSugtOopQty,seSugtOopQty->Name);
    ClientGroup->AddComponent(2,true,true,true, seSugtAoyQty,seSugtAoyQty->Name);
    ClientGroup->AddComponent(2,true,true,true, cheSugtClose,cheSugtClose->Name);
    ClientGroup->AddComponent(2,false,false,true, cheSugtInit,cheSugtInit->Name);
    ClientGroup->AddComponent(2,true,true,false, sgSugt,sgSugt->Name);
    FillComboBox(scSugtLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
    FillComboBox(scSugtSugCode,"select SughCode from sdSugh where SughCheck=1 order by SughCode","SughCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmSugt::RefreshUpdateData(int MsgSrc,int MsgType)
{
    try
    {
       switch (MsgSrc)
       {
         case euSdLoc:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillComboBox(scSugtLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
	           EndWaitForm();
	           break;
           }
         case euSdSugt:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillComboBox(scSugtSugCode,"select SughCode from sdSugh where SughCheck=1 order by SughCode","SughCode");
	           EndWaitForm();
	           break;
           }
         default:
           break;
       }
    }
    __finally
    {
       //AddCode;
    }
}
//---------------------------------------------------------

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


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

void __fastcall TfrmSugt::muPreviousClick(TObject *Sender)
{
    if(sgSugt->RowCount > 1 && sgSugt->Row > 1)
    {
       sgSugt->Row=sgSugt->Row-1;
       sgSugtClick(NULL);
    }
}
//---------------------------------------------------------------------------

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

void __fastcall TfrmSugt::muLastClick(TObject *Sender)
{
    if(sgSugt->RowCount > 1)
    {
      sgSugt->Row=sgSugt->RowCount-1;
      sgSugtClick(NULL);
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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