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

📄 gpch.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Gpch.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"

TfrmGpch *frmGpch;
//---------------------------------------------------------------------------
__fastcall TfrmGpch::TfrmGpch(TComponent* Owner)
        : TBillBaseForm(Owner,euSdGpch,"")
{
 AutoCtl=seGpchCode;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::ClearValueGrid()
{
 scGpcdOPlan->Text="";
 scGpcdOPlan->ItemIndex=-1;
 scGpcdNPlan->Text="";
 scGpcdNPlan->ItemIndex=-1;
 for(int i=0;i<14;i++)
  for (int j=0;j<4;j++)
   sgdValue->Cells[i][j]="";
 sgdValue->Cells[1][0]="安全库存";
 sgdValue->Cells[2][0]="再订货点";
 sgdValue->Cells[3][0]="批量";
 sgdValue->Cells[4][0]="订货周期";
 sgdValue->Cells[5][0]="最大库存";
 sgdValue->Cells[6][0]="发放批量";
 sgdValue->Cells[7][0]="损耗率";
 sgdValue->Cells[8][0]="最小包装";
 sgdValue->Cells[9][0]="采购提前期";
 sgdValue->Cells[10][0]="完工停放期";
 sgdValue->Cells[11][0]="最小库存";
 sgdValue->Cells[12][0]="积压天数";
 sgdValue->Cells[13][0]="呆滞天数";
 sgdValue->Cells[0][1]="原  值";
 sgdValue->Cells[0][2]="修改值";

}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::InitEditControl()
{
    ClientGroup->AddComponent(1,false,false,true,fpGpchHead,fpGpchHead->Name);
    ClientGroup->AddComponent(1,false,true,false,seGpchCode,seGpchCode->Name);

    ClientGroup->AddComponent(2,false,false,true,GroupBox1,GroupBox1->Name);
    ClientGroup->AddComponent(2,false,false,true,GroupBox2,GroupBox2->Name);
    ClientGroup->AddComponent(2,false,false,true,sgdValue,sgdValue->Name);
    ClientGroup->AddComponent(2,false,true,true,seGpcdLine,seGpcdLine->Name);
    ClientGroup->AddComponent(2,false,true,true,seGpcdGoods,seGpcdGoods->Name);
    ClientGroup->AddComponent(2,true,true,true,scGpcdOPlan,scGpcdOPlan->Name);
    ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
    ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);

    //Gpcd
    FillComboBox(scGpcdGccr,"select GccrName memo,GccrCode from sdGccr order by GccrCode","memo","GccrCode");
    scGpcdOPlan->ClearAll();
    scGpcdOPlan->AddItems("1-MRP","1");
    scGpcdOPlan->AddItems("2-MPS","2");
    scGpcdOPlan->AddItems("3-订货点","3");
    scGpcdOPlan->AddItems("4-预测","4");
    scGpcdOPlan->AddItems("5-成套件","5");
    scGpcdOPlan->AddItems("6-自定义","6");
    scGpcdNPlan->ClearAll();
    scGpcdNPlan->AddItems("1-MRP","1");
    scGpcdNPlan->AddItems("2-MPS","2");
    scGpcdNPlan->AddItems("3-订货点","3");
    scGpcdNPlan->AddItems("4-预测","4");
    scGpcdNPlan->AddItems("5-成套件","5");
    scGpcdNPlan->AddItems("6-自定义","6");
}
//---------------------------------------------------------------------------
void __fastcall TfrmGpch::ClearControl(int Section,bool BringToNext)
{
    if (Section == 1)
    {
       if (! BringToNext)
       {
          seGpchCode->Text="";
          deGpchDate->Text=g_sdCurDate;
          labSysDate->Caption="";
          labGpchUser->Caption=g_sdUserCode;
          labGpchChecker->Caption="";
          cbxGpchCheck->Checked=false;
          //新增单据,工具栏使能
          SetCheckToolbarStatus(false);
       }
       sgGpch->RowCount=1;
    }
    else if (Section==2)
    {
       if (!BringToNext)
       {
          seGpcdLine->Text=AnsiString(comServer->ItemCount+1);;
          seGpcdGoods->Text="";
          scGpcdGccr->Text="";
          scGpcdGccr->ItemIndex=-1;
          ClearValueGrid();
          memGpcdDesc->Text ="";
       }
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::GetDataFromComObject(int Section)
{
    AnsiString s;
    if (Section==1)
    {
        seGpchCode->Text=GetHeadValue(fiGpchCode);
        deGpchDate->Text=GetHeadValue(fiGpchDate);
        labSysDate->Caption=GetHeadValue(fiGpchSysDate);
        labGpchUser->Caption=GetHeadValue(fiGpchUser);
        labGpchChecker->Caption=GetHeadValue(fiGpchChecker);
        cbxGpchCheck->Checked=(GetHeadValue(fiGpchCheck)=="1");
        //根据审核状态,设置工具栏
        if(GetHeadValue(fiGpchCheck)=="1")
         SetCheckToolbarStatus(true);
        else
         SetCheckToolbarStatus(false);
    }
    else
    {
        seGpcdLine->Text=GetDetailValue(fiGpcdLine);
        seGpcdGoods->Text=GetDetailValue(fiGpcdGoods);
        scGpcdGccr->LocateKey(GetDetailValue(fiGpcdGccr));
        SetValueGridFromServer();
        memGpcdDesc->Text =GetDetailValue(fiGpcdDesc);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGpch::SetValueGridFromServer()
{
 AnsiString tmp=GetDetailValue(fiGpcdOPlan);
 scGpcdOPlan->LocateKey(GetDetailValue(fiGpcdOPlan));
 scGpcdNPlan->LocateKey(GetDetailValue(fiGpcdNPlan));

 sgdValue->Cells[1][1]=GetDetailValue(fiGpcdOSoQ);
 sgdValue->Cells[1][2]=GetDetailValue(fiGpcdNSoq);
 sgdValue->Cells[2][1]=GetDetailValue(fiGpcdORoq);
 sgdValue->Cells[2][2]=GetDetailValue(fiGpcdNRoq);
 sgdValue->Cells[3][1]=GetDetailValue(fiGpcdOEoq);
 sgdValue->Cells[3][2]=GetDetailValue(fiGpcdNEoq);
 sgdValue->Cells[4][1]=GetDetailValue(fiGpcdOEoi);
 sgdValue->Cells[4][2]=GetDetailValue(fiGpcdNEoi);
 sgdValue->Cells[5][1]=GetDetailValue(fiGpcdOXoq);
 sgdValue->Cells[5][2]=GetDetailValue(fiGpcdNXoq);
 sgdValue->Cells[6][1]=GetDetailValue(fiGpcdOOoq);
 sgdValue->Cells[6][2]=GetDetailValue(fiGpcdNOoq);
 sgdValue->Cells[7][1]=GetDetailValue(fiGpcdOWr);
 sgdValue->Cells[7][2]=GetDetailValue(fiGpcdNWr);
 sgdValue->Cells[8][1]=GetDetailValue(fiGpcdOMpq);
 sgdValue->Cells[8][2]=GetDetailValue(fiGpcdNMpq);
 sgdValue->Cells[9][1]=GetDetailValue(fiGpcdOPlt);
 sgdValue->Cells[9][2]=GetDetailValue(fiGpcdNPlt);
 sgdValue->Cells[10][1]=GetDetailValue(fiGpcdOPot);
 sgdValue->Cells[10][2]=GetDetailValue(fiGpcdNPot);
 sgdValue->Cells[11][1]=GetDetailValue(fiGpcdONoq);
 sgdValue->Cells[11][2]=GetDetailValue(fiGpcdNNoq);
 sgdValue->Cells[12][1]=GetDetailValue(fiGpcdOOd);
 sgdValue->Cells[12][2]=GetDetailValue(fiGpcdNOd);
 sgdValue->Cells[13][1]=GetDetailValue(fiGpcdOId);
 sgdValue->Cells[13][2]=GetDetailValue(fiGpcdNId);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGpch::WriteServerFromValueGrid()
{
 CheckGridValue();
 SetDetailValue(fiGpcdOPlan,scGpcdOPlan->ItemData[1]);
 SetDetailValue(fiGpcdNPlan,scGpcdNPlan->ItemData[1]);

 SetDetailValue(fiGpcdOSoQ,sgdValue->Cells[1][1]);
 SetDetailValue(fiGpcdNSoq,sgdValue->Cells[1][2]);
 SetDetailValue(fiGpcdORoq,sgdValue->Cells[2][1]);
 SetDetailValue(fiGpcdNRoq,sgdValue->Cells[2][2]);
 SetDetailValue(fiGpcdOEoq,sgdValue->Cells[3][1]);
 SetDetailValue(fiGpcdNEoq,sgdValue->Cells[3][2]);
 SetDetailValue(fiGpcdOEoi,sgdValue->Cells[4][1]);
 SetDetailValue(fiGpcdNEoi,sgdValue->Cells[4][2]);
 SetDetailValue(fiGpcdOXoq,sgdValue->Cells[5][1]);
 SetDetailValue(fiGpcdNXoq,sgdValue->Cells[5][2]);
 SetDetailValue(fiGpcdOOoq,sgdValue->Cells[6][1]);
 SetDetailValue(fiGpcdNOoq,sgdValue->Cells[6][2]);
 SetDetailValue(fiGpcdOWr,sgdValue->Cells[7][1]);
 SetDetailValue(fiGpcdNWr,sgdValue->Cells[7][2]);
 SetDetailValue(fiGpcdOMpq,sgdValue->Cells[8][1]);
 SetDetailValue(fiGpcdNMpq,sgdValue->Cells[8][2]);
 SetDetailValue(fiGpcdOPlt,sgdValue->Cells[9][1]);
 SetDetailValue(fiGpcdNPlt,sgdValue->Cells[9][2]);
 SetDetailValue(fiGpcdOPot,sgdValue->Cells[10][1]);
 SetDetailValue(fiGpcdNPot,sgdValue->Cells[10][2]);
 SetDetailValue(fiGpcdONoq,sgdValue->Cells[11][1]);
 SetDetailValue(fiGpcdNNoq,sgdValue->Cells[11][2]);
 SetDetailValue(fiGpcdOOd,sgdValue->Cells[12][1]);
 SetDetailValue(fiGpcdNOd,sgdValue->Cells[12][2]);
 SetDetailValue(fiGpcdOId,sgdValue->Cells[13][1]);
 SetDetailValue(fiGpcdNId,sgdValue->Cells[13][2]);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGpch::CheckGridValue()
{
 AnsiString sValue;
 for(int i=1;i<3;i++)
  for(int j=1;j<14;j++)
  {
   sValue=Trim(sgdValue->Cells[j][i]);
   if(sValue == "")
    sgdValue->Cells[j][i]="0";
   else
   {
    try
    {
     if(j<12)
      StrToFloat(sValue);
     else
      StrToInt(sValue);
    }
    catch(...)
    {
     throw Exception("数值填写有错误,请更正!");
    }
   }
  }
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::SendDataToComObject(int Section)
{
    if (Section==1)  // Head
    {
        SetHeadValue(fiGpchCode,seGpchCode->Text);
        SetHeadValue(fiGpchDate,deGpchDate->Text);
        SetHeadValue(fiGpchUser,labGpchUser->Caption);
    }
    else
    {
        SetDetailValue(fiGpcdCode,seGpchCode->Text);
        SetDetailValue(fiGpcdLine,seGpcdLine->Text);
        SetDetailValue(fiGpcdGoods,seGpcdGoods->Text);
        SetDetailValue(fiGpcdGccr,scGpcdGccr->ItemData[1]);
        WriteServerFromValueGrid();
        SetDetailValue(fiGpcdDesc,memGpcdDesc->Text);

   }
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::WaitUserInput(int Section)
{
   if (Section ==1)
   {
    if(seGpchCode->Enabled)
      seGpchCode->SetFocus();
    else
      deGpchDate->SetFocus();
   }
   else
   {
      sgGpch->Visible=false;
      fpGpcdDetail->Visible=true;
      if(seGpcdGoods->Enabled)
       seGpcdGoods->SetFocus();
      else
       scGpcdGccr->SetFocus();
   }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGpch::GetDataToGrid()
{
    AnsiString ItemStr;
    g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiGpcdGoods)));
    ItemStr="\t"+GetDetailValue(fiGpcdLine)+
            "\t"+GetDetailValue(fiGpcdGoods)+
            "\t"+GetGoodsValue("GoodsName")+
            "\t"+GetDetailValue(fiGpcdGccr)+
            "\t"+GetDetailValue(fiGpcdDesc);

⌨️ 快捷键说明

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