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

📄 gosh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Gosh.h"
#include "Gosd.h"
#include "func.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "DateEdit"
#pragma link "fpanel"
#pragma link "GenBaseForm"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"

TfrmGosh *frmGosh;

//---------------------------------------------------------------------------
__fastcall TfrmGosh::TfrmGosh(TComponent* Owner)
    : TGenBaseForm(Owner,euSdGosh,"")
{
 AutoCtl=seGoshCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGosh::InitEditControl()
{
    ClientGroup->AddComponent(1,false,false,true,FloatPanel1,FloatPanel1->Name);
    ClientGroup->AddComponent(1,false,true,false,seGoshCode,seGoshCode->Name);
    ClientGroup->AddComponent(1,false,true,true,chkGoshRed,chkGoshRed->Name);
    ClientGroup->AddComponent(1,false,true,true,scGoshType,scGoshType->Name);
    ClientGroup->AddComponent(1,true,true,true,scGoshState,scGoshState->Name);
    ClientGroup->AddComponent(1,true,true,true,scGoshFmonth,scGoshFmonth->Name);
    ClientGroup->AddComponent(1,false,true,true,scGoshDept,scGoshDept->Name);

    ClientGroup->AddComponent(2,false,false,true,FloatPanel2,FloatPanel2->Name);
    ClientGroup->AddComponent(2,false,true,true,seGosdLine,seGosdLine->Name);
    ClientGroup->AddComponent(2,false,true,true,seGosdLoc,seGosdLoc->Name);
    ClientGroup->AddComponent(2,false,true,true,seGosdGoods,seGosdGoods->Name);
    ClientGroup->AddComponent(2,true,true,true,scGosdUnit,scGosdUnit->Name);
    ClientGroup->AddComponent(2,true,true,true,scGosdState,scGosdState->Name);
    ClientGroup->AddComponent(2,true,true,true,scGosdFrom,scGosdFrom->Name);
    ClientGroup->AddComponent(2,true,true,true,seGosdFromCode,seGosdFromCode->Name);
    ClientGroup->AddComponent(2,true,true,true,seGosdFromLine,seGosdFromLine->Name);
    ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);
    ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);

    //Gosh
    FillComboBox(scGoshFmonth,"SELECT Fcmonth FROM sdFc order by fcmonth","Fcmonth");
    FillComboBox(scGoshDept,"SELECT DeptName,DeptCode FROM sdDept where DeptEnd=1 order by DeptName","DeptName","DeptCode");
    FillComboBox(scGoshPosType,"select postypename memo,postypecode from sdPosType where PosTypeFlg=6 order by PosTypeCode","memo","PosTypeCode");
    FillComboBox(scGoshKeeper,"select UserCode,UserName from sdKeeper,sduser where UserCode=KeeperCode order by UserCode","UserName","UserCode");

    scGoshType->ClearAll();
    scGoshType->AddItems("1-销售发货","1");
    scGoshType->AddItems("2-采购退货","2");
    scGoshType->AddItems("3-领料","3");
    scGoshType->AddItems("4-其它出库","4");

    scGoshState->ClearAll();
    scGoshState->AddItems("1-待审核","1");
    scGoshState->AddItems("2-已生效","2");
    scGoshState->AddItems("3-已结清","3");
    //Gosd
    FillComboBox(scGosdUnit,"select unitname memo,unitcode from sdunit order by UnitCode","memo","UnitCode");
    FillEdit(seGosdLoc,"select locname memo,loccode from sdloc where LocType=1 order by LocCode","memo","LocCode");
    FillComboBox(scGosdBatch,"SELECT BatchCode FROM sdBatch order by BatchCode","BatchCode");

    scGosdState->ClearAll();
    scGosdState->AddItems("0-正常","0");

    scGosdFrom->ClearAll();
    scGosdFrom->AddItems("0-手工录入","0");
    scGosdFrom->AddItems("1-系统生成","1");
}
//---------------------------------------------------------------------------
void __fastcall TfrmGosh::ClearControl(int Section,bool BringToNext)
{
    if (Section == 1)
    {
       if (! BringToNext)
       {
         seGoshCode->Text ="";
         scGoshType->ItemIndex   =0;
         deGoshDate->Text =g_sdCurDate;
         scGoshFmonth->Text =g_sdIMonth;
         scGoshPosType->ItemIndex   =-1;
         scGoshPosType->Text="";
         scGoshDept->ItemIndex=-1;
         scGoshState->ItemIndex=0;
         labGoshUser->Caption =g_sdUserCode;
         scGoshKeeper->LocateKey(g_sdUserCode);
         chkGoshRed->Checked =false;
         chkGoshCheck->Checked =false;
         labGoshChecker->Caption ="";
         chkGoshPost->Checked =false;
         labGoshPoster->Caption ="";
         chkGoshCancel->Checked =false;
         labGoshSysDate->Caption="";
         memGoshDesc->Text="";
          //新增单据,工具栏使能
          SetCheckToolbarStatus(false);
       }
       sgGosh->RowCount=1;
    }
    else if (Section==2)
    {
        if (!BringToNext)
        {
            seGosdLine->Text =AnsiString(comServer->ItemCount+1);
            seGosdGoods->Text="";
            pv_GoodsCode="";
            labGosdGoodsName->Caption ="";
            scGosdUnit->ItemIndex   =-1;
            scGosdUnit->Text="";
            seGosdPrice->Text="0.0";
            seGosdQty->Text="0";
            seGosdAmt->Text="0";
            seGosdSod->Text="";
            seGosdSodLine->Text="";
            seGosdLoc->ItemIndex   =-1;
            seGosdLoc->Text="";
            scGosdBatch->ItemIndex=-1;
            scGosdState->ItemIndex=0;
            memGosdDesc->Text="";
            scGosdFrom->ItemIndex=0;
            seGosdFromCode->Text="";
            seGosdFromLine->Text="0";
        }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGosh::GetDataFromComObject(int Section)
{
        if (Section==1)
        {
            seGoshCode->Text=GetHeadValue(fiGoshCode);
            scGoshType->LocateKey(GetHeadValue(fiGoshType));
            scGoshType->Text=scGoshType->ItemData[0];
            deGoshDate->Text=GetHeadValue(fiGoshDate);
            scGoshFmonth->Text=GetHeadValue(fiGoshFmonth);
            scGoshPosType->LocateKey(GetHeadValue(fiGoshPosType));
            scGoshPosType->Text=scGoshPosType->ItemData[0];
            scGoshDept->LocateKey(GetHeadValue(fiGoshDept));
            scGoshState->LocateKey(GetHeadValue(fiGoshState));
            scGoshState->Text=scGoshState->ItemData[0];
            chkGoshRed->Checked=GetHeadValue(fiGoshRed)=="-1";
            labGoshUser->Caption=GetHeadValue(fiGoshUser);
            scGoshKeeper->LocateKey(GetHeadValue(fiGoshKeeper));

            chkGoshCheck->Checked=GetHeadValue(fiGoshCheck)=="1";
            labGoshChecker->Caption=GetHeadValue(fiGoshChecker);

            chkGoshPost->Checked=GetHeadValue(fiGoshPost)=="1";
            labGoshPoster->Caption=GetHeadValue(fiGoshPoster);

            chkGoshCancel->Checked=GetHeadValue(fiGoshCancel)=="1";

            labGoshSysDate->Caption=GetHeadValue(fiGoshSysDate);
            memGoshDesc->Text=GetHeadValue(fiGoshDesc);
            //根据审核、取消状态,设置工具栏
            if((GetHeadValue(fiGoshCheck)=="1")||(GetHeadValue(fiGoshCancel)=="1"))
             SetCheckToolbarStatus(true);
            else
             SetCheckToolbarStatus(false);
        }
        else
        {
            seGosdLine->Text=GetDetailValue(fiGosdLine);
            seGosdLoc->LocateKey(GetDetailValue(fiGosdLoc));
            seGosdLoc->Text=seGosdLoc->ItemData[0];

            g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiGosdGoods)));
            seGosdGoods->Text = GetGoodsValue("GoodsCode");
            labGosdGoodsName->Caption=GetGoodsValue("GoodsName");
            scGosdUnit->LocateKey(GetDetailValue(fiGosdUnit));
            scGosdUnit->Text=scGosdUnit->ItemData[0];

            seGosdPrice->Text=GetDetailValue(fiGosdPrice);
            seGosdQty->Text=GetDetailValue(fiGosdQty);
            seGosdAmt->Text=GetDetailValue(fiGosdAmt);
            scGosdFrom->LocateKey(GetDetailValue(fiGosdFrom));
            seGosdFromCode->Text=GetDetailValue(fiGosdFromCode);
            seGosdFromLine->Text=GetDetailValue(fiGosdFromLine);
            scGosdBatch->LocateKey(GetDetailValue(fiGosdBatch));
            scGosdState->LocateKey(GetDetailValue(fiGosdState));
            scGosdState->Text=scGosdState->ItemData[0];
            seGosdSod->Text=GetDetailValue(fiGosdSod);
            seGosdSodLine->Text=GetDetailValue(fiGosdSodLine);
            memGosdDesc->Text=GetDetailValue(fiGosdDesc);
        }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGosh::SendDataToComObject(int Section)
{
        if (Section==1)
        {
            SetHeadValue(fiGoshCode,seGoshCode->Text);
            if(scGoshType->ItemData[1] == "")
             throw Exception("请选择出库类型");
            SetHeadValue(fiGoshType,scGoshType->ItemData[1]);
            SetHeadValue(fiGoshDate,deGoshDate->Text);
            SetHeadValue(fiGoshFmonth,scGoshFmonth->Text);
            SetHeadValue(fiGoshPosType,scGoshPosType->ItemData[1]);
            SetHeadValue(fiGoshDept,scGoshDept->ItemData[1]);
            SetHeadValue(fiGoshUser,labGoshUser->Caption);
            SetHeadValue(fiGoshKeeper,scGoshKeeper->ItemData[1]);
            SetHeadValue(fiGoshRed,chkGoshRed->Checked ? "-1":"1");
            SetHeadValue(fiGoshDesc,memGoshDesc->Text);
        }
        else
        {
            SetDetailValue(fiGosdCode,seGoshCode->Text);
            if(seGosdLine->Text == "")
             throw Exception("请输入出库单行号");
            SetDetailValue(fiGosdLine,seGosdLine->Text);
            SetDetailValue(fiGosdGoods,seGosdGoods->Text);
            //SetDetailValue(fiGosdUnit,scGosdUnit->ItemData[1]);
            SetDetailValue(fiGosdLoc,seGosdLoc->ItemData[1]);
            if(seGosdQty->Text == "")
             throw Exception("请输入出库数量");
            SetDetailValue(fiGosdQty,seGosdQty->Text);
            if(seGosdPrice->Text == "")
             throw Exception("请输入出库单价");
            SetDetailValue(fiGosdPrice,seGosdPrice->Text);

            if(seGosdAmt->Text == "")
             throw Exception("请输入出库金额");
            SetDetailValue(fiGosdAmt,seGosdAmt->Text);

            SetDetailValue(fiGosdFrom,scGosdFrom->ItemIndex);
            SetDetailValue(fiGosdFromCode,seGosdFromCode->Text);
            if(seGosdFromLine->Text.IsEmpty())
              seGosdFromLine->Text="0";
            SetDetailValue(fiGosdFromLine,seGosdFromLine->Text);

            SetDetailValue(fiGosdBatch,scGosdBatch->Text);
            SetDetailValue(fiGosdSod,seGosdSod->Text);
            if(seGosdSodLine->Text=="" )
             SetDetailValue(fiGosdSodLine,"0");
            else
             SetDetailValue(fiGosdSodLine,seGosdSodLine->Text);
            SetDetailValue(fiGosdDesc,memGosdDesc->Text);
        }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGosh::WaitUserInput(int Section)
{
    if (Section ==1)
    {
      if(seGoshCode->Enabled)
      seGoshCode->SetFocus();
    }
    else
    {
      sgGosh->Visible=false;
      FloatPanel2->Visible=true;
      if(seGosdGoods->Enabled==true)
      {
        seGosdGoods->SetFocus();
        pv_GoodsCode=seGosdGoods->Text;
        SetDetail(seGosdGoods->Text);
        if(scGosdFrom->ItemData[1]=="1") //生成行只允许修改备注
        {
          seGosdLine->Enabled=false;
          seGosdGoods->Enabled=false;
          seGosdSod->Enabled=false;
          seGosdSodLine->Enabled=false;
          scGosdBatch->Enabled=false;
        }
      }
      else
      {
        seGosdQty->SetFocus();
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGosh::RefreshGridData(int mAction)
{
    int i;
    AnsiString ItemStr=GetItemStringToGrid();
    switch(mAction)
    {
       case 0:
         sgGosh->AddItem(ItemStr);
         break;
       case 1:
         i=sgGosh->Row;
         sgGosh->AddItem(ItemStr,i);
         break;
       case 2:
         sgGosh->RemoveItem(sgGosh->Row);
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGosh::GetItemStringToGrid()
{
    AnsiString s_ItemStr;
    s_ItemStr="\t"+GetDetailValue(fiGosdLine)+
              "\t"+GetDetailValue(fiGosdGoods)+
              "\t"+GetDetailValue(fiGosdUnit)+
              "\t"+GetDetailValue(fiGosdQty)+
              "\t"+GetDetailValue(fiGosdPrice)+
              "\t"+GetDetailValue(fiGosdAmt)+
              "\t"+GetDetailValue(fiGosdLoc);
    return(s_ItemStr);
}
//---------------------------------------------------------------------------

void __fastcall TfrmGosh::DisplayBill()
{
    GetDataFromComObject(1);
    FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmGosh::GetBill(AnsiString BillID)
{
    int iRow;

    iRow=comServer->Find("GoshCode='"+BillID+"'");
    if (iRow>0)      //FIND THIS BILL
    {
       DisplayBill();
    }
    else
       if (ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
       {
           AddHeadRecord();
       }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGosh::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgGosh->RowCount=1;
    if(comServer->RecordCount>0)
    {
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          RefreshGridData(0);
      }

⌨️ 快捷键说明

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