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

📄 ulh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Ulh.h"
#include "Uld.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "GenBaseForm"
#pragma link "fpanel"
#pragma link "SDGrid"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma resource "*.dfm"

TfrmUlh *frmUlh;

//---------------------------------------------------------------------------
__fastcall TfrmUlh::TfrmUlh(TComponent* Owner)
        : TGenBaseForm(Owner,euSdUlh,"")
{
 AutoCtl=seUlhCode;
}
//---------------------------------------------------------------------------

void __fastcall TfrmUlh::InitEditControl()
{
    ClientGroup->AddComponent(1,false,false,true,FloatPanel1,FloatPanel1->Name);
    ClientGroup->AddComponent(1,false,true,false,seUlhCode,seUlhCode->Name);
    ClientGroup->AddComponent(1,false,true,true,scUlhSupply,scUlhSupply->Name);

    ClientGroup->AddComponent(2,false,false,true,FloatPanel2,FloatPanel2->Name);
    ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);
    ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);

    ClientGroup->AddComponent(2,false,true,true,seUldPoCode,seUldPoCode->Name);
    ClientGroup->AddComponent(2,true,true,true,seUldPodLine,seUldPodLine->Name);
    ClientGroup->AddComponent(2,true,true,true,seUldGoods,seUldGoods->Name);
    ClientGroup->AddComponent(2,true,true,true,seUldGoodsName,seUldGoodsName->Name);
    ClientGroup->AddComponent(2,true,true,true,seUldUnit,seUldUnit->Name);
    ClientGroup->AddComponent(2,true,true,true,seUldPoQty,seUldPoQty->Name);
    ClientGroup->AddComponent(2,true,true,true,GroupBox2,GroupBox2->Name);
    ClientGroup->AddComponent(2,false,false,true,seUldUrQty,seUldUrQty->Name);

    AnsiString sSQL;
    sSQL=" select supplyname,supplycode ";
    sSQL=sSQL+" from sdsupply ";
    sSQL=sSQL+"  where supplycancel=0 order by supplycode ";
    FillComboBox(scUlhSupply,sSQL,"supplyname","SupplyCode");
    FillEdit(seUldUnit,"select unitcode,unitname from sdunit","UnitName","UnitCode");
    FillEdit(seUldPsite,"select PsiteName,PsiteCode from sdPsite","PsiteName","PsiteCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmUlh::ClearControl(int Section,bool BringToNext)
{
    if (Section == 1)
    {
       if (! BringToNext)
       {
          seUlhCode->Text = "";
          scUlhSupply->ItemIndex=-1;
          deUlhDate->Text = g_sdCurDate;
          labSystemDate->Caption  = g_sdCurDate;
          labUserCode->Caption = g_sdUserCode;
       }
       sgUlh->RowCount=1;
    }
    else if (Section==2)
    {
        if (!BringToNext)
        {
            seUldLine->Text = AnsiString(comServer->ItemCount+1);
            seUldPoCode->Text = "";
            seUldPodLine->Text="";
            seUldGoods->Text = "";
            seUldGoodsName->Text = "";
            seUldUnit->ItemIndex = -1;
            seUldPoQty->Text = "";

            seUldUrQty->Text = "0";
            deUldSendDate->Text = "";
            seUldDelay->Text = "0";
            seUldPsite->Text = "";
            scUldStatus->ItemIndex=0;
            deUldRecDate->Text = g_sdCurDate;
        }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmUlh::GetDataFromComObject(int Section)
{
    if (Section==1)
    {
        seUlhCode->Text=GetHeadValue(fiUlhCode);
        scUlhSupply->LocateKey(GetHeadValue(fiUlhSupply));         //供应商
        deUlhDate->Text=GetHeadValue(fiUlhDate);
        labUserCode->Caption = GetHeadValue(fiUlhUser);
        labSystemDate->Caption=GetHeadValue(fiUlhSysDate);
    }
    else
    {
        seUldLine->Text = GetDetailValue(fiUldLine);
        seUldPoCode->Text = GetDetailValue(fiUldPoCode);
        seUldPodLine->Text = GetDetailValue(fiUldPodLine);
        seUldGoods->Text=GetDetailValue(fiUldGoods);
        g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiUldGoods)));
        seUldGoodsName->Text =GetGoodsValue("GoodsName");
        seUldUnit->LocateKey(GetDetailValue(fiUldUnit));
        seUldUrQty->Text=GetDetailValue(fiUldUrQty);
        seUldDelay->Text = GetDetailValue(fiUldDelay);
        seUldPsite->LocateKey(GetDetailValue(fiUldPsite));
        scUldStatus->ItemIndex = StrToInt(GetDetailValue(fiUldStatus))-1;
        deUldRecDate->Text = GetDetailValue(fiUldRecDate);
        deUldSendDate->Text = GetDetailValue(fiUldSendDate);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmUlh::SendDataToComObject(int Section)
{
    if (Section==1)  //保存抬头
    {
        SetHeadValue(fiUlhCode,seUlhCode->Text);
        SetHeadValue(fiUlhSupply,scUlhSupply->ItemData[1]);
        SetHeadValue(fiUlhDate,deUlhDate->Text);
        SetHeadValue(fiUlhUser,labUserCode->Caption);
    }
    else   //保存细表记录
    {
        SetDetailValue(fiUldCode,   seUlhCode->Text);
        if(seUldLine->Text == "")
         throw Exception("请输入催货单行号");
        SetDetailValue(fiUldLine,   seUldLine->Text);
        SetDetailValue(fiUldPoCode,   seUldPoCode->Text);
        SetDetailValue(fiUldPodLine,   seUldPodLine->Text);
        SetDetailValue(fiUldSendDate,   deUldSendDate->Text);
        SetDetailValue(fiUldDelay,   seUldDelay->Text);
        SetDetailValue(fiUldUrQty,seUldUrQty->Text);
        SetDetailValue(fiUldStatus,AnsiString(scUldStatus->ItemIndex+1));
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmUlh::RefreshGridData(int mAction)
{
    int i;
    AnsiString ItemStr=GetDataToGrid();
    switch(mAction)
    {
       case 0:
         sgUlh->AddItem(ItemStr);
         break;
       case 1:
         i=sgUlh->Row;
         sgUlh->ChangeItem(ItemStr,i);
         break;
       case 2:
         sgUlh->RemoveItem(sgUlh->Row);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmUlh::DisplayBill()
{
        if (comServer->RecordCount > 0)
        {
           GetDataFromComObject(1);   //向抬头中增加记录
           FillGridWithData();

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

void __fastcall TfrmUlh::GetBill(AnsiString BillID)
{
       int iRow;

       iRow=comServer->Find("UlhCode='"+BillID+"'");
       if (iRow>0)      //FIND THIS BILL
            {
              DisplayBill();
            }
       else
           if (ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
           {
               AddHeadRecord();
           }
}
//---------------------------------------------------------------------------

void __fastcall TfrmUlh::FillGridWithData()
{
       int i;
       AnsiString ItemStr;
       sgUlh->RowCount=1;
       if(comServer->RecordCount>0)
       {
         for (i=0;i<comServer->ItemCount;i++)  {
            comServer->LocateItemByIndex(i);
            RefreshGridData(0);
         }
       }
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmUlh::GetHeadValue(int Index)
{
        WideString S;
        S = ReadFieldValue(comServer,Index);
        return S;
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmUlh::GetDetailValue(int Index)
{
        WideString S;
        S = ReadItemValue(comServer,Index);
        return AnsiString(S);
}
//---------------------------------------------------------------------------
void __fastcall TfrmUlh::SetHeadValue(int Index,AnsiString Value)
{
       WriteFieldValue(comServer,Index,Value);
}

//---------------------------------------------------------------------------

⌨️ 快捷键说明

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