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

📄 soh.cpp

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

TfrmSoh *frmSoh;
//---------------------------------------------------------------------------
__fastcall TfrmSoh::TfrmSoh(TComponent* Owner)
        : TBillBaseForm(Owner,euSdSoh,"")
{
 AutoCtl=seSohCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoh::InitEditControl()
{
    ClientGroup->AddComponent(1,true,true,false, sgSod,sgSod->Name);
    ClientGroup->AddComponent(1,false,false,true, FloatPanel1,FloatPanel1->Name);
    ClientGroup->AddComponent(1,false,true,false, seSohCode,seSohCode->Name);
    ClientGroup->AddComponent(1,true,true,true, FloatPanel3,FloatPanel3->Name);
    ClientGroup->AddComponent(1,false,true,true,seSohClient,seSohClient->Name);
    ClientGroup->AddComponent(1,false,true,true, scSohSaler,scSohSaler->Name);
    ClientGroup->AddComponent(1,false,true,true, scSohTaxCode,scSohTaxCode->Name);
    ClientGroup->AddComponent(1,false,false,true,seSohEnrate,seSohEnrate->Name);

    ClientGroup->AddComponent(2,false,false,true, GpDetail2,GpDetail2->Name);
    ClientGroup->AddComponent(2,false,false,true, GpDetail1,GpDetail1->Name);
    ClientGroup->AddComponent(2,true,true,true, GpDetailClose,GpDetailClose->Name);
    ClientGroup->AddComponent(2,false,true,true,seSodGoods,seSodGoods->Name);
    ClientGroup->AddComponent(2,true,true,true,seSodGoodsName,seSodGoodsName->Name);
    ClientGroup->AddComponent(2,true,true,true,seSodAmt,seSodAmt->Name);
    ClientGroup->AddComponent(2,true,true,true,seSodDAmt,seSodDAmt->Name);
    ClientGroup->AddComponent(2,true,true,true,seSodConv,seSodConv->Name);
    ClientGroup->AddComponent(2,true,true,true,seSodTaxAmt,seSodTaxAmt->Name);
    ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
    ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);

    //Soh
    FillComboBox(scSohTaxCode,"SELECT TaxName,TaxCode,TaxRate FROM sdTax","TaxName","TaxCode","TaxRate");
    FillComboBox(scSohSaler,"select usercode,username from sduser ,sdsaler where usercode=salercode order by userName","UserName","UserCode");
    FillEdit(scSohUser,"select usercode,username from sduser order by userName","UserName","UserCode");
    FillEdit(seSohChecker,"select usercode,username from sduser order by userName","UserName","UserCode");
    AnsiString sSql;
    sSql =AnsiString("select currencycode,currencyname,currencyrate=coalesce(rateratio,1),currencylocal from sdcurrency,sdrate");
    sSql+=" where currencycode*=ratecurrency and ";
    sSql+=" ratefmonth='"+g_sdSMonth+"'";
    FillEdit(seSohCurrency,sSql,"CurrencyName","CurrencyCode","CurrencyRate","CurrencyLocal");
    FillEdit(seSohClient,"SELECT ClientCode,ClientName FROM sdClient where ClientCancel=0","ClientName","ClientCode");
    FillEdit(seSohSsite,"select SsiteName,SsiteCode from sdSsite","SsiteName","SsiteCode");
    FillComboBox(scSohSettleMode,"SELECT SettleModeCode,SettleModeName FROM sdSettleMode order by SettleModeName","SettleModeName","SettleModeCode");
    FillComboBox(scSohDeliver,"SELECT DeliverName,DeliverCode FROM sdDeliver order by DeliverName","DeliverName","DeliverCode");
    FillComboBox(scSohTransMode,"SELECT TransModeCode,TransModeName FROM sdTransMode order by TransModeName","TransModeName","TransModeCode");

    //Sod
    FillEdit(seSodUnit,"SELECT UnitCode,UnitName FROM sdUnit order by UnitName","UnitName","UnitCode");
    FillEdit(seSodSptCode,"SELECT SptCode,SptName FROM sdSpt order by SptName","SptName","SptCode");

    scSohType->ClearAll();
    scSohType->AddItems("销售订单","1");
    scSohType->AddItems("来料加工订单","2");

    scSodState->ClearAll();
    scSodState->AddItems("预备","1");
    scSodState->AddItems("确认","2");
    scSodState->AddItems("待下达","3");
    scSodState->AddItems("已下达","4");
    scSodState->AddItems("已完成","5");
    scSohPayTrans->ClearAll();
    scSohPayTrans->AddItems("买方","0");
    scSohPayTrans->AddItems("卖方","1");
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::ClearControl(int Section,bool BringToNext)
{
    if (Section == 1)
    {
       if (! BringToNext)
       {
         seSohCode->Text = "";
         scSohType->LocateKey("1");
         deSohDate->Text=g_sdCurDate;
         seSohClient->ItemIndex = -1;
         seSohContract->Text = "";
         seSohCurrency->ItemIndex=-1;
         seSohEnrate->Text = "1";
         scSohTaxCode->ItemIndex =-1;
         scSohSettleMode->ItemIndex =-1;
         seSohSsite->ItemIndex = -1;
         scSohTransMode->ItemIndex =-1;
         scSohSaler->ItemIndex =-1;
         scSohUser->LocateKey(g_sdUserCode);
         seSohDj->Text = "0.00";
         cheSohCheck->Checked = false;
         seSohChecker->ItemIndex =-1;
         cheSohCancel->Checked = false;
         cheSohClose->Checked = false;
         lbSohSysDate->Caption= "";
         scSohPayTrans->ItemIndex=0;
         memSohDesc->Text = "";
       }
       sgSod->RowCount=1;
    }
    else if (Section==2)
    {
        if (!BringToNext)
        {
            if(comServer->ItemCount==0)
               seSodLine->Text =AnsiString(comServer->ItemCount+1);
             else
             {
              comServer->LocateItemByIndex(comServer->ItemCount-1);
              seSodLine->Text=AnsiString(StrToInt(GetDetailValue(fiSodLine))+1);
             }
            seSodGoods->Text="";
            seSodGoodsName->Text ="";
            seSodUnit->ItemIndex=-1;
            seSodConv->Text="1";
            seSodQty->Text="0";
            seSodSptCode->ItemIndex=-1;
            seSodPrice->Text="0";
            seSodAmt->Text="0.00";
            seSodTaxAmt->Text="0.00";
            seSodDisc->Text="0.00";
            seSodDAmt->Text="0.00";
            cheSodClose->Checked = false;
            deSodCloseDate->Text="";
            scSodState->ItemIndex=0;
            deSodSendDate->Text="";
            deSodRecDate->Text="";
            seSodPoCode->Text="";
            meSodDesc->Text="";

            seSodPQty->Text="0";
            seSodSQty->Text="0";
            seSodBQty->Text="0";
            seSodFQty->Text="0";
            seSodEQty->Text="0"; 
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::GetDataFromComObject(int Section)
{
        if (Section==1)
        {
           seSohCode->Text = GetHeadValue(fiSohCode);
           scSohType->LocateKey(GetHeadValue(fiSohType));
           deSohDate->Text= GetHeadValue(fiSohDate);
           seSohClient->LocateKey(GetHeadValue(fiSohClient));
           scSohSaler->LocateKey(GetHeadValue(fiSohSaler));
           seSohContract->Text = GetHeadValue(fiSohContract);
           seSohCurrency->LocateKey(GetHeadValue(fiSohCurrency));
           if(seSohCurrency->ItemData[cbItem4]=="1")
            seSohEnrate->Enabled=false;
           seSohEnrate->Text = GetHeadValue(fiSohEnrate);
           scSohTaxCode->LocateKey(GetHeadValue(fiSohTaxCode));
           scSohSettleMode->LocateKey(GetHeadValue(fiSohSettleMode));
           scSohDeliver->LocateKey(GetHeadValue(fiSohDeliver));
           seSohSsite->LocateKey(GetHeadValue(fiSohSsite));
           scSohTransMode->LocateKey(GetHeadValue(fiSohTransMode));
           seSohDj->Text = GetHeadValue(fiSohDj);
           cheSohCheck->Checked = GetHeadValue(fiSohCheck)=="1";
           seSohChecker->LocateKey(GetHeadValue(fiSohChecker));
           cheSohCancel->Checked = GetHeadValue(fiSohCancel)=="1";
           scSohPayTrans->LocateKey(GetHeadValue(fiSohPayTrans));
           cheSohClose->Checked = GetHeadValue(fiSohClose)=="1";
           lbSohSysDate->Caption = GetHeadValue(fiSohSysDate);
           scSohUser->LocateKey(GetHeadValue(fiSohUser));
           memSohDesc->Text = GetHeadValue(fiSohDesc);
           SetCheckToolbarStatus(cheSohCheck->Checked);
           SetCancelToolbarStatus(cheSohCancel->Checked);
           SetCloseToolbarStatus(cheSohClose->Checked);
        }
        else
        {
            seSodLine->Text = GetDetailValue(fiSodLine);
            seSodGoods->Text=GetDetailValue(fiSodGoods);
            g_sdRsGoods->LocateByKey(WideString(seSodGoods->Text));
            seSodGoodsName->Text =GetGoodsValue("GoodsName");
            SetRelativeState(GetDetailValue(fiSodGoods));
            seSodUnit->LocateKey(GetDetailValue(fiSodUnit));
            seSodConv->Text=GetDetailValue(fiSodConv);
            seSodQty->Text=GetDetailValue(fiSodQty);
            seSodSptCode->LocateKey(GetDetailValue(fiSodSptCode));
            seSodPrice->Text=GetDetailValue(fiSodPrice);
            seSodDisc->Text=GetDetailValue(fiSodDisc);
            seSodAmt->Text=GetDetailValue(fiSodAmt);
            seSodTaxAmt->Text=GetDetailValue(fiSodTaxAmt);
            seSodDAmt->Text=GetDetailValue(fiSodDAmt);
            seSodSQty->Text=GetDetailValue(fiSodSQty);
            seSodPQty->Text=GetDetailValue(fiSodPQty);
            seSodBQty->Text=GetDetailValue(fiSodBQty);
            seSodFQty->Text=GetDetailValue(fiSodFQty);
            seSodEQty->Text=GetDetailValue(fiSodEQty);

            cheSodClose->Checked = GetDetailValue(fiSodClose)=="1";
            deSodCloseDate->Text=GetDetailValue(fiSodCloseDate);
            scSodState->ItemIndex=StrToInt(GetDetailValue(fiSodState))-1;
            deSodSendDate->Text=GetDetailValue(fiSodSendDate);
            deSodRecDate->Text=GetDetailValue(fiSodRecDate);
            seSodPoCode->Text=GetDetailValue(fiSodPoCode);
            SetCloseDetailStatus(cheSodClose->Checked);
        }
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::SendDataToComObject(int Section)
{
       AnsiString s;
        if (Section==1)
        {
            SetHeadValue(fiSohCode,Trim(seSohCode->Text));
            SetHeadValue(fiSohType,scSohType->ItemData[cbItem2]);
            SetHeadValue(fiSohDate,deSohDate->Text);
            SetHeadValue(fiSohClient,seSohClient->ItemData[cbItem2]);
            SetHeadValue(fiSohSaler,scSohSaler->ItemData[cbItem2]);
            SetHeadValue(fiSohUser,g_sdUserCode/*scSohUser->Text*/);
            SetHeadValue(fiSohContract,seSohContract->Text);
            SetHeadValue(fiSohCurrency,seSohCurrency->ItemData[cbItem2]);
            SetHeadValue(fiSohEnrate,seSohEnrate->Text);
            SetHeadValue(fiSohTaxCode,scSohTaxCode->ItemData[cbItem2]);
            SetHeadValue(fiSohSettleMode,scSohSettleMode->ItemData[cbItem2]);
            SetHeadValue(fiSohDeliver,scSohDeliver->ItemData[cbItem2]);
            SetHeadValue(fiSohSsite,seSohSsite->ItemData[cbItem2]);
            SetHeadValue(fiSohTransMode,scSohTransMode->ItemData[cbItem2]);
            SetHeadValue(fiSohPayTrans,scSohPayTrans->ItemData[cbItem2]);
            SetHeadValue(fiSohDj,seSohDj->Text);
            SetHeadValue(fiSohDesc,memSohDesc->Text);
        }
        else
        {
            CalculateAmt();
            if(seSodPrice->Text.IsEmpty())
               throw Exception("请输入销售单价");
            if(deSodSendDate->Text.IsEmpty())
               throw Exception("发货日期不能为空");
            if(deSodRecDate->Text.IsEmpty())
               throw Exception("交货日不能为空");
             if(deSodRecDate->Text<deSodSendDate->Text)
             throw Exception("收货日期不应早于发货日期");
             if(deSodSendDate->Text<deSohDate->Text)
              throw Exception("发货日期应在订单日期之后");
            SetDetailValue(fiSodCode,seSohCode->Text);
            SetDetailValue(fiSodLine,seSodLine->Text);
            SetDetailValue(fiSodGoods,seSodGoods->Text);
            SetDetailValue(fiSodUnit,seSodUnit->ItemData[cbItem2]);
            SetDetailValue(fiSodConv,seSodConv->Text);
            SetDetailValue(fiSodSptCode,seSodSptCode->ItemData[cbItem2]);
            SetDetailValue(fiSodQty,seSodQty->Text);
            SetDetailValue(fiSodPrice,seSodPrice->Text);
            SetDetailValue(fiSodAmt,seSodAmt->Text);
            SetDetailValue(fiSodTaxAmt,seSodTaxAmt->Text);
            SetDetailValue(fiSodDisc,seSodDisc->Text);
            SetDetailValue(fiSodDAmt,seSodDAmt->Text);
            SetDetailValue(fiSodSendDate,deSodSendDate->Text);
            SetDetailValue(fiSodRecDate,deSodRecDate->Text);
            SetDetailValue(fiSodPoCode,seSodPoCode->Text);
            SetDetailValue(fiSodDesc,meSodDesc->Text);
         }
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoh::WaitUserInput(int Section)
{
       if (Section ==1)
         {
          FloatPanel1->Enabled=true;
          if(seSohCode->Enabled)
             seSohCode->SetFocus();
         }
       else
       {
          sgSod->Visible=false;
          sgSod->Align=alNone;
          FloatPanel2->Visible=true;

⌨️ 快捷键说明

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