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

📄 sodt.cpp

📁 速达开源ERP系统
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Sodt.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"
TfrmSodt *frmSodt;
//---------------------------------------------------------------------------
__fastcall TfrmSodt::TfrmSodt(TComponent* Owner)
    : TRecBaseForm(Owner,euSdSodt,"")
{

}
//---------------------------------------------------------------------------
__fastcall TfrmSodt::TfrmSodt(TComponent* Owner,AnsiString LocCode,AnsiString GoodsCode)
    : TRecBaseForm(Owner,euSdSodt,"")
{
    ClearControl(false);
    FLocCode=LocCode;
    FGoodsCode=GoodsCode;
    sgSodt->RowCount=1;
    LabCurFmonth->Caption=g_sdIMonth;
    LabSodtGoods->Caption=FGoodsCode;
    if(g_sdRsGoods->LocateByKey(WideString(FGoodsCode))==0)
       LabSodtGoodsName->Caption=GetGoodsValue("GoodsName");
    scSodtLoc->LocateKey(FLocCode);
    AnsiString FilStr="sodtFmonth='"+g_sdIMonth+"' and sodtGoods='"+FGoodsCode+"' and sodtLoc='"+FLocCode+"'";
    comServer->FilterString=WideString(FilStr);
    comServer->Query();
    if(comServer->RecordCount>0)
    {
       FillGridWithData();
       comServer->MoveFirst();
       GetDataFromComObject();
    }
}

//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSodt::GetFieldValue(int FieldIndex)
{
    return ReadFieldValue(comServer,FieldIndex);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSodt::SetFieldValue(int iFieldIndex,AnsiString sFieldValue)
{
    WriteFieldValue(comServer,iFieldIndex,sFieldValue);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSodt::ClearControl(bool BringToNext)
{
    if(!BringToNext)
    {
       scSodtSoCode->ItemIndex = -1;
       seSodtBoyQty->Text   = "0";
       seSodtBopQty->Text   = "0";
       seSodtIopQty->Text   = "0";
       seSodtOopQty->Text   = "0";
       seSodtIoyQty->Text   = "0";
       seSodtOoyQty->Text   = "0";
       seSodtAoyQty->Text   = "0";
       cheSodtClose->Checked=false;
       cheSodtInit->Checked=false;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmSodt::GetDataFromComObject()
{
//    scSodtLoc->LocateKey(GetFieldValue(fiSodtLoc));
    scSodtSoCode->Text   = GetFieldValue(fiSodtSoCode);
    seSodtBoyQty->Text   = GetFieldValue(fiSodtBoyQty);
    seSodtBopQty->Text   = GetFieldValue(fiSodtBopQty);
    seSodtIopQty->Text   = GetFieldValue(fiSodtIopQty);
    seSodtOopQty->Text   = GetFieldValue(fiSodtOopQty);
    seSodtIoyQty->Text   = GetFieldValue(fiSodtIoyQty);
    seSodtOoyQty->Text   = GetFieldValue(fiSodtOoyQty);
    seSodtAoyQty->Text   = GetFieldValue(fiSodtAoyQty);
    cheSodtInit->Checked=GetFieldValue(fiSodtInit)=="1";
    if(cheSodtInit->Checked)
    {
      tbEditHead->Enabled=false;
      tbDeleteHead->Enabled=false;
    }
    else
    {
      tbEditHead->Enabled=true;
      tbDeleteHead->Enabled=true;    
    }
    cheSodtClose->Checked=GetFieldValue(fiSodtClose)=="1";
}
//---------------------------------------------------------------------------
void __fastcall TfrmSodt::SendDataToComObject()
{
    SetFieldValue(fiSodtFmonth,g_sdIMonth);
    SetFieldValue(fiSodtGoods,FGoodsCode);
    SetFieldValue(fiSodtLoc,FLocCode);
    SetFieldValue(fiSodtSoCode,scSodtSoCode->Text);
    SetFieldValue(fiSodtBoyQty,seSodtBoyQty->Text);
    SetFieldValue(fiSodtBopQty,seSodtBopQty->Text);
    SetFieldValue(fiSodtIoyQty,seSodtIoyQty->Text);
    SetFieldValue(fiSodtOopQty,seSodtOopQty->Text);
    SetFieldValue(fiSodtInit,cheSodtInit->Checked?"1":"0");
}
//---------------------------------------------------------------------------
void __fastcall TfrmSodt::WaitUserInput()
{
    scSodtSoCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSodt::GetDataToGrid()
{
    AnsiString  tempS;
    tempS = GetFieldValue(fiSodtSoCode)+
            "\t" + GetFieldValue(fiSodtBoyQty)+
            "\t" + GetFieldValue(fiSodtBopQty);
    return(tempS);
}
//---------------------------------------------------------------------------

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

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

void __fastcall TfrmSodt::InitEditControl()
{
    ClientGroup->AddComponent(2,false,false,true,fpSodt,fpSodt->Name);
    ClientGroup->AddComponent(2,true,true,true,fpSodt1,fpSodt1->Name);
    ClientGroup->AddComponent(2,true,true,true, scSodtLoc,scSodtLoc->Name);
    ClientGroup->AddComponent(2,true,true,true, seSodtIopQty,seSodtIopQty->Name);
    ClientGroup->AddComponent(2,true,true,true, seSodtOopQty,seSodtOopQty->Name);
    ClientGroup->AddComponent(2,true,true,true, seSodtAoyQty,seSodtAoyQty->Name);
    ClientGroup->AddComponent(2,true,true,true, cheSodtClose,cheSodtClose->Name);
    ClientGroup->AddComponent(2,false,false,true, cheSodtInit,cheSodtInit->Name);
    ClientGroup->AddComponent(2,true,true,false, sgSodt,sgSodt->Name);
    FillComboBox(scSodtLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
    FillComboBox(scSodtSoCode,"select SohCode from sdSoh where SohCheck=1 and SohClose=0 order by SohCode","SohCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmSodt::RefreshUpdateData(int MsgSrc,int MsgType)
{
    try
    {
       switch (MsgSrc)
       {
         case euSdLoc:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillComboBox(scSodtLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
	           EndWaitForm();
	           break;
           }
         case euSdSoh:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillComboBox(scSodtSoCode,"select BatchCode,memo=BatchCode+space(1)+BatchDesc from sdBatch order by BatchCode","memo","BatchCode");
	           EndWaitForm();
	           break;
           }
         default:
           break;
       }
    }
    __finally
    {
       //AddCode;
    }
}
//---------------------------------------------------------

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


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

void __fastcall TfrmSodt::muPreviousClick(TObject *Sender)
{
    if(sgSodt->RowCount > 1 && sgSodt->Row > 1)
    {
       sgSodt->Row=sgSodt->Row-1;
       sgSodtClick(NULL);
    }
}
//---------------------------------------------------------------------------

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

void __fastcall TfrmSodt::muLastClick(TObject *Sender)
{
    if(sgSodt->RowCount > 1)
    {
      sgSodt->Row=sgSodt->RowCount-1;
      sgSodtClick(NULL);
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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