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

📄 scraph.cpp

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

TfrmScraph *frmScraph;
//---------------------------------------------------------------------------
__fastcall TfrmScraph::TfrmScraph(TComponent* Owner)
        : TBillBaseForm(Owner,euSdScraph,"")
{
 AutoCtl=seScraphCode;
}
//---------------------------------------------------------------------------

void __fastcall TfrmScraph::InitEditControl()
{
    ClientGroup->AddComponent(1,false,false,true,fpScrapHead,fpScrapHead->Name);
    ClientGroup->AddComponent(1,false,true,false,seScraphCode,seScraphCode->Name);
    ClientGroup->AddComponent(1,true,true,true,scScraphFmonth,scScraphFmonth->Name);
    ClientGroup->AddComponent(1,true,true,true,scScraphState,scScraphState->Name);

    ClientGroup->AddComponent(2,false,false,true,fpScrapDetail,fpScrapDetail->Name);
    ClientGroup->AddComponent(2,false,true,true,seScrapdLine,seScrapdLine->Name);
    ClientGroup->AddComponent(2,false,true,true,scScrapdLoc,scScrapdLoc->Name);
    ClientGroup->AddComponent(2,false,true,true,seScrapdGoods,seScrapdGoods->Name);
    ClientGroup->AddComponent(2,true,true,true,scScrapdUnit,scScrapdUnit->Name);
    ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
    ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);
    //Scraph
    FillComboBox(scScraphFmonth,"SELECT Fcmonth FROM sdFc order by fcmonth","Fcmonth");
    FillComboBox(scScrapdLoc,"select locname memo,loccode from sdloc order by loccode","memo","LocCode");
    FillComboBox(scScraphPosType,"select postypename memo,postypecode from sdPosType where PosTypeFlg=6 order by PosTypeCode","memo","PosTypeCode");
    FillComboBox(scScraphDept,"select DeptName memo,DeptCode from sdDept where DeptEnd=1 order by DeptCode","memo","DeptCode");
    FillComboBox(scScraphKeeper,"select UserCode,UserName from sdKeeper,sduser where UserCode=KeeperCode order by UserCode","UserName","UserCode");

    scScraphState->ClearAll();
    scScraphState->AddItems("1-未操作","1");
    scScraphState->AddItems("2-已出库","2");

    //Scrapd
    FillComboBox(scScrapdUnit,"select unitname memo,unitcode from sdunit order by UnitCode","memo","UnitCode");
    FillComboBox(scScrapdBatch,"SELECT BatchCode FROM sdBatch order by BatchCode","BatchCode");
    FillComboBox(scScrapdSr,"select srdesc memo,srcode from sdsr order by SrCode","memo","SrCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraph::ClearControl(int Section,bool BringToNext)
{
    if (Section == 1)
    {
       if (! BringToNext)
       {
          seScraphCode->Text ="";
          deScraphDate->Text =g_sdCurDate;
          scScraphFmonth->Text=g_sdIMonth;
          scScraphPosType->ItemIndex   =-1;
          scScraphPosType->Text="";
          scScraphDept->ItemIndex   =-1;
          scScraphDept->Text="";
          scScraphState->ItemIndex =0;
          cbxScraphCheck->Checked = false;
          labScraphChecker->Caption ="";
          cbxScraphCancel->Checked = false;
          labScraphUser->Caption =g_sdUserCode;
          scScraphKeeper->LocateKey(g_sdUserCode);
          labSysDate->Caption ="";
          memDesc->Text ="";
          //新增单据,工具栏使能
          SetCheckToolbarStatus(false);
       }
       sgScraph->RowCount=1;
    }
    else if (Section==2)
    {
        if (!BringToNext)
        {
          seScrapdLine->Text =AnsiString(comServer->ItemCount+1);
          scScrapdLoc->ItemIndex   =-1;
          scScrapdLoc->Text="";
          seScrapdGoods->Text="";
          pv_GoodsCode="";
          labScrapdGoodsName->Caption ="";
          scScrapdUnit->ItemIndex   =-1;
          scScrapdUnit->Text="";
          scScrapdBatch->ItemIndex=-1;
          seScrapdSod->Text ="";
          seScrapdSodLine->Text="";
          seScrapdQty->Text ="0.00";
          seScrapdBfAmt->Text ="0.00";
          seScrapdHsAmt->Text ="0.00";
          scScrapdSr->ItemIndex   =-1;
          scScrapdSr->Text="";
          memScrapdDesc->Text ="";
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmScraph::GetDataFromComObject(int Section)
{
    AnsiString s;
    if (Section==1)
    {
        seScraphCode->Text = GetHeadValue(fiScraphCode);
        deScraphDate->Text = GetHeadValue(fiScraphDate);
        scScraphFmonth->Text = GetHeadValue(fiScraphFmonth);
        scScraphPosType->LocateKey(GetHeadValue(fiScraphPosType));
        scScraphPosType->Text = scScraphPosType->ItemData[0];
        s = GetHeadValue(fiScraphDept);
        scScraphDept->LocateKey(s);
        cbxScraphCheck->Checked = GetHeadValue(fiScraphCheck)=="1";
        labScraphChecker->Caption = GetHeadValue(fiScraphChecker);
        cbxScraphCancel->Checked = GetHeadValue(fiScraphCancel)=="1";
        labScraphUser->Caption = GetHeadValue(fiScraphUser);
        scScraphKeeper->LocateKey(GetHeadValue(fiScraphKeeper));
        scScraphState->LocateKey(GetHeadValue(fiScraphState));
        memDesc->Text = GetHeadValue(fiScraphDesc);
        labSysDate->Caption = GetHeadValue(fiScraphSysDate);
        //根据审核、取消状态,设置工具栏
        if((GetHeadValue(fiScraphCheck)=="1")||(GetHeadValue(fiScraphCancel)=="1"))
         SetCheckToolbarStatus(true);
        else
         SetCheckToolbarStatus(false);
    }
    else
    {
        seScrapdLine->Text = GetDetailValue(fiScrapdLine);
        g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiScrapdGoods)));
        seScrapdGoods->Text = GetGoodsValue("GoodsCode");
        labScrapdGoodsName->Caption=GetGoodsValue("GoodsName");
        scScrapdUnit->LocateKey(GetDetailValue(fiScrapdUnit));
        scScrapdLoc->LocateKey(GetDetailValue(fiScrapdLoc));
        scScrapdBatch->LocateKey(GetDetailValue(fiScrapdBatch));
        seScrapdSod->Text = GetDetailValue(fiScrapdSod);
        seScrapdSodLine->Text = GetDetailValue(fiScrapdSodLine);
        seScrapdQty->Text = GetDetailValue(fiScrapdQty);
        seScrapdBfAmt->Text = GetDetailValue(fiScrapdBfAmt);
        seScrapdHsAmt->Text = GetDetailValue(fiScrapdHsAmt);
        memScrapdDesc->Text = GetDetailValue(fiScrapdDesc);
        scScrapdSr->LocateKey(GetDetailValue(fiScrapdSr));
        scScrapdSr->Text = scScrapdSr->ItemData[0];
    }
}
//---------------------------------------------------------------------------


void __fastcall TfrmScraph::SendDataToComObject(int Section)
{
    if (Section==1)  // Head
    {
        SetHeadValue(fiScraphCode,seScraphCode->Text);
        SetHeadValue(fiScraphDate,deScraphDate->Text);
        SetHeadValue(fiScraphFmonth,scScraphFmonth->Text);
        SetHeadValue(fiScraphPosType,scScraphPosType->ItemData[1]);
        SetHeadValue(fiScraphDept,scScraphDept->ItemData[1]);
        SetHeadValue(fiScraphDesc,memDesc->Text);
        SetHeadValue(fiScraphUser,labScraphUser->Caption);
        SetHeadValue(fiScraphKeeper,scScraphKeeper->ItemData[1]);
    }
    else
    {
        SetDetailValue(fiScrapdCode,seScraphCode->Text);
        SetDetailValue(fiScrapdLine,seScrapdLine->Text);
        SetDetailValue(fiScrapdLoc,scScrapdLoc->ItemData[1]);
        SetDetailValue(fiScrapdGoods,seScrapdGoods->Text);
        if(seScrapdLine->Text == "")
         throw Exception("请输入报废单行号");
        SetDetailValue(fiScrapdBatch,scScrapdBatch->Text);
        SetDetailValue(fiScrapdSod,seScrapdSod->Text);
        if(seScrapdSodLine->Text == "")
         SetDetailValue(fiScrapdSodLine,"0");
        else
         SetDetailValue(fiScrapdSodLine,seScrapdSodLine->Text);
        SetDetailValue(fiScrapdUnit,scScrapdUnit->ItemData[1]);
        if(seScrapdQty->Text == "")
         throw Exception("请输入报废数量");
        SetDetailValue(fiScrapdQty,seScrapdQty->Text);
        if(seScrapdBfAmt->Text == "")
         throw Exception("请输入报废金额");
        SetDetailValue(fiScrapdBfAmt,seScrapdBfAmt->Text);
        if(seScrapdHsAmt->Text == "")
         throw Exception("请输入回收金额");
        SetDetailValue(fiScrapdHsAmt,seScrapdHsAmt->Text);
        SetDetailValue(fiScrapdDesc,memScrapdDesc->Text);
        SetDetailValue(fiScrapdSr,scScrapdSr->ItemData[1]);
   }
}
//---------------------------------------------------------------------------

void __fastcall TfrmScraph::WaitUserInput(int Section)
{
   if (Section ==1)
   {
    if(seScraphCode->Enabled)
      seScraphCode->SetFocus();
   }
   else
   {
      sgScraph->Visible=false;
      fpScrapDetail->Visible=true;
      pv_GoodsCode=Trim(seScrapdGoods->Text);
      SetDetail(Trim(seScrapdGoods->Text));
      if(scScrapdLoc->Enabled)
       scScrapdLoc->SetFocus();
   }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmScraph::GetDataToGrid()
{
    AnsiString ItemStr;
    g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiScrapdGoods)));
    ItemStr="\t"+GetDetailValue(fiScrapdLine)+
            "\t"+GetDetailValue(fiScrapdGoods)+
            "\t"+GetGoodsValue("GoodsName")+
            "\t"+GetDetailValue(fiScrapdUnit)+
            "\t"+GetDetailValue(fiScrapdQty)+
            "\t"+GetDetailValue(fiScrapdSod)+
            "\t"+GetDetailValue(fiScrapdSodLine);
    return ItemStr;
}

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

void __fastcall TfrmScraph::FillGridWithData()
{
    int i;
    AnsiString ItemStr;

    sgScraph->RowCount=1;
    if(comServer->RecordCount > 0)
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          RefreshGridData(0); // Append
      }
}
//---------------------------------------------------------------------------


void __fastcall TfrmScraph::DisplayBill()
{
      if(comServer->RecordCount==0)
         return;
      GetDataFromComObject(1);  // Head
      FillGridWithData();
}
//---------------------------------------------------------------------------

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

⌨️ 快捷键说明

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