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

📄 tsh.cpp

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

TfrmTsh *frmTsh;
//---------------------------------------------------------------------------
__fastcall TfrmTsh::TfrmTsh(TComponent* Owner)
        : TBillBaseForm(Owner,euSdTsh,"")
{
 AutoCtl=seTshCode;
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::InitEditControl()
{
    ClientGroup->AddComponent(1,false,false,true,FloatPanel1,FloatPanel1->Name);
    ClientGroup->AddComponent(1,false,true,false,seTshCode,seTshCode->Name);
    ClientGroup->AddComponent(1,false,true,true,scTshDept,scTshDept->Name);
    ClientGroup->AddComponent(1,true,true,true,scTshFmonth,scTshFmonth->Name);
    ClientGroup->AddComponent(1,true,true,true,chkTshInvFlg,chkTshInvFlg->Name);

    ClientGroup->AddComponent(2,false,false,true,FloatPanel2,FloatPanel2->Name);
    ClientGroup->AddComponent(2,false,true,true,seTsdLine,seTsdLine->Name);
    ClientGroup->AddComponent(2,false,true,true,scTsdLoc,scTsdLoc->Name);
    ClientGroup->AddComponent(2,false,true,true,seTsdGoods,seTsdGoods->Name);
    ClientGroup->AddComponent(2,true,true,true,scTsdUnit,scTsdUnit->Name);
    ClientGroup->AddComponent(2,true,true,true,seTsdAQty,seTsdAQty->Name);
    ClientGroup->AddComponent(2,true,true,true,seTsdAPrice,seTsdAPrice->Name);
    ClientGroup->AddComponent(2,true,true,true,seTsdAAmt,seTsdAAmt->Name);
    ClientGroup->AddComponent(2,true,true,true,seTsdTPrice,seTsdTPrice->Name);
    ClientGroup->AddComponent(2,true,true,true,seTsdDQty,seTsdDQty->Name);
    ClientGroup->AddComponent(2,true,true,true,seTsdIOQty,seTsdIOQty->Name);
    ClientGroup->AddComponent(2,true,true,true,chkTsdFlg1,chkTsdFlg1->Name);
    ClientGroup->AddComponent(2,true,true,true,chkTsdFlg2,chkTsdFlg2->Name);
    ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
    ClientGroup->AddComponent(2,false,true,true,btnOk,btnOk->Name);
    //Tsh
    FillComboBox(scTshFmonth,"Select FcMonth from sdFc order by fcmonth","FcMonth");
    FillComboBox(scTshDept,"select DeptName memo,DeptCode from sdDept where DeptEnd=1 order by deptcode","memo","DeptCode");
    FillComboBox(scTshPosType,"select postypename memo,postypecode from sdPosType where PosTypeFlg=6 order by PosTypeCode","memo","PosTypeCode");
    FillComboBox(scTshKeeper,"select UserCode,UserName from sdKeeper,sduser where UserCode=KeeperCode order by UserCode","UserName","UserCode");

    scTshType->ClearAll();
    scTshType->AddItems("1-常规盘点","1");
    scTshType->AddItems("2-循环盘点","2");

    //Tsd
    FillComboBox(scTsdUnit,"select unitname memo,unitcode from sdunit order by UnitCode","memo","UnitCode");
    FillComboBox(scTsdBatch,"Select BatchCode from sdBatch order by BatchCode","BatchCode");
    FillComboBox(scTsdLoc,"select locname memo,loccode from sdloc order by LocCode","memo","LocCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::ClearControl(int Section,bool BringToNext)
{
    if (Section == 1)
    {
       if (! BringToNext)
       {
          seTshCode->Text       ="";
          scTshFmonth->Text=g_sdIMonth;
          deTshDate->Text       =g_sdCurDate;
          scTshType->ItemIndex  =0;
          scTshDept->ItemIndex   =-1;
          scTshDept->Text="";
          labTshUser->Caption   =g_sdUserCode;
          scTshKeeper->LocateKey(g_sdUserCode);
          deTshEiDate->Text     =g_sdCurDate;
          deTshEoDate->Text     =g_sdCurDate;
          deTshCDate->Text      =g_sdCurDate;
          scTshPosType->ItemIndex   =-1;
          scTshPosType->Text="";
          cbxTshCheck->Checked  =false;
          labTshChecker->Caption    ="";
          labSysDate->Caption="";
          cbxTshCancel->Checked =false;
          chkTshInvFlg->Checked =false;
          memTshDesc->Text      ="";
          //新增单据,工具栏使能
          SetCheckToolbarStatus(false);
       }
       sgTsd->RowCount=1;
    }
    else if (Section==2)
    {
        if (!BringToNext)
        {
          seTsdLine->Text     =AnsiString(comServer->ItemCount+1);
          scTsdLoc->ItemIndex   =-1;
          scTsdLoc->Text="";
          seTsdGoods->Text="";
          pv_GoodsCode="";
          labTsdGoodsName->Caption="";
          scTsdUnit->ItemIndex   =-1;
          scTsdUnit->Text="";
          seTsdAQty->Text     ="0.00";
          seTsdTQty->Text     ="0.00";
          seTsdAPrice->Text   ="0.00";
          seTsdTPrice->Text   ="0.00";
          seTsdAAmt->Text     ="0.00";
          seTsdTAmt->Text     ="0.00";
          seTsdIOQty->Text     ="0.00";
          seTsdSod->Text      ="";
          seTsdSodLine->Text="";
          scTsdBatch->ItemIndex=-1;
          seTsdDQty->Text     ="0";
          chkTsdFlg1->Checked=false;
          chkTsdFlg2->Checked=false;
          memTsdDesc->Text    ="";
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::GetDataFromComObject(int Section)
{
        AnsiString s;
        if (Section==1)
        {
          seTshCode->Text     =GetHeadValue(fiTshCode);
          deTshDate->Text     =GetHeadValue(fiTshDate);
          scTshFmonth->Text   =GetHeadValue(fiTshFmonth);
          scTshType->LocateKey(GetHeadValue(fiTshType));
          s = GetHeadValue(fiTshDept);
          scTshDept->LocateKey(s);
          scTshPosType->LocateKey(GetHeadValue(fiTshPosType));
          labTshUser->Caption     =GetHeadValue(fiTshUser);
          scTshKeeper->LocateKey(GetHeadValue(fiTshKeeper));
          deTshEiDate->Text   =GetHeadValue(fiTshEiDate);
          deTshEoDate->Text   =GetHeadValue(fiTshEoDate);
          deTshCDate->Text    =GetHeadValue(fiTshCDate);
          cbxTshCheck->Checked=GetHeadValue(fiTshCheck)=="1";
          labTshChecker->Caption  =GetHeadValue(fiTshChecker);
          cbxTshCancel->Checked=GetHeadValue(fiTshCancel)=="1";
          chkTshInvFlg->Checked=GetHeadValue(fiTshInvFlg)=="2";
          labSysDate->Caption=GetHeadValue(fiTshSysDate);
          memTshDesc->Text     =GetHeadValue(fiTshDesc);
          //根据审核、取消状态,设置工具栏
          if((GetHeadValue(fiTshCheck)=="1")||(GetHeadValue(fiTshCancel)=="1"))
           SetCheckToolbarStatus(true);
          else
           SetCheckToolbarStatus(false);
        }
        else
        {
          seTsdLine->Text     =GetDetailValue(fiTsdLine);
          scTsdLoc->LocateKey(GetDetailValue(fiTsdLoc));
          if(g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiTsdGoods)))==0)
          {
            seTsdGoods->Text    =GetGoodsValue("GoodsCode");
            labTsdGoodsName->Caption=GetGoodsValue("GoodsName");
            scTsdUnit->LocateKey(GetDetailValue(fiTsdUnit));
          }
          else
          {
            seTsdGoods->Text    ="";
            labTsdGoodsName->Caption="";
            scTsdUnit->ItemIndex=-1;
          }
          seTsdSod->Text      =GetDetailValue(fiTsdSod);
          seTsdSodLine->Text  =GetDetailValue(fiTsdSodLine);
          scTsdBatch->LocateKey(GetDetailValue(fiTsdBatch));
          seTsdAQty->Text     =GetDetailValue(fiTsdAQty);
          seTsdAPrice->Text     =GetDetailValue(fiTsdAPrice);
          seTsdAAmt->Text     =GetDetailValue(fiTsdAAmt);
          seTsdTQty->Text     =GetDetailValue(fiTsdTQty);
          seTsdTPrice->Text     =GetDetailValue(fiTsdTPrice);
          seTsdTAmt->Text     =GetDetailValue(fiTsdTAmt);
          seTsdDQty->Text     =GetDetailValue(fiTsdDQty);
          seTsdIOQty->Text    =GetDetailValue(fiTsdIoQty);
          chkTsdFlg1->Checked =GetDetailValue(fiTsdFlg)=="1";  //盘盈
          chkTsdFlg2->Checked =GetDetailValue(fiTsdFlg)=="-1"; //盘亏
          memTsdDesc->Text    =GetDetailValue(fiTsdDesc);
        }
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::SendDataToComObject(int Section)
{
     AnsiString s;
      if (Section==1)
      {
        SetHeadValue(fiTshCode,seTshCode->Text);
        SetHeadValue(fiTshFmonth,scTshFmonth->Text);
        if(scTshType->ItemData[1] == "")
         throw Exception("请选择盘点类型");
        SetHeadValue(fiTshType,scTshType->ItemData[1]);
        SetHeadValue(fiTshDept,scTshDept->ItemData[1]);
        SetHeadValue(fiTshDate,deTshDate->Text);
        SetHeadValue(fiTshUser,labTshUser->Caption);
        SetHeadValue(fiTshKeeper,scTshKeeper->ItemData[1]);
        SetHeadValue(fiTshEiDate,deTshEiDate->Text);
        SetHeadValue(fiTshEoDate,deTshEoDate->Text);
        SetHeadValue(fiTshCDate,deTshCDate->Text);
        SetHeadValue(fiTshPosType,scTshPosType->ItemData[1]);
        SetHeadValue(fiTshDesc,memTshDesc->Text);
      }
      else
      {
        //计算盘点差额
        SetDetailValue(fiTsdCode,seTshCode->Text);
        if(seTsdLine->Text == "")
         throw Exception("请输入盘点单行号");
        SetDetailValue(fiTsdLine,seTsdLine->Text);
        SetDetailValue(fiTsdLoc,scTsdLoc->ItemData[1]);
        SetDetailValue(fiTsdGoods,seTsdGoods->Text);
        SetDetailValue(fiTsdSod,seTsdSod->Text);
        if(seTsdSodLine->Text == "")
         SetDetailValue(fiTsdSodLine,"0");
        else
         SetDetailValue(fiTsdSodLine,seTsdSodLine->Text);
        SetDetailValue(fiTsdBatch,scTsdBatch->Text);
//        if(seTsdAQty->Text == "")
//         seTsdAQty->Text="0";
//        SetDetailValue(fiTsdAQty,seTsdAQty->Text);
        if(seTsdTQty->Text == "")
         throw Exception("请输入实盘数量");
        SetDetailValue(fiTsdTQty,seTsdTQty->Text);
//        if(seTsdAPrice->Text == "")
//         seTsdAPrice->Text="0";
//        SetDetailValue(fiTsdAPrice,seTsdAPrice->Text);
//        if(seTsdTPrice->Text == "")
//         throw Exception("请输入实盘单价");
//        SetDetailValue(fiTsdTPrice,seTsdTPrice->Text);
        if(seTsdTAmt->Text == "")
         throw Exception("请输入实盘金额");
        SetDetailValue(fiTsdTAmt,seTsdTAmt->Text);
//        if(seTsdDQty->Text == "")
//         seTsdDQty->Text="0";
//        SetDetailValue(fiTsdDQty,seTsdDQty->Text);
//        if(chkTsdFlg1->Checked)
//         SetDetailValue(fiTsdFlg,"1");
//        if(chkTsdFlg2->Checked)
//         SetDetailValue(fiTsdFlg,"-1");
        SetDetailValue(fiTsdDesc,memTsdDesc->Text);
     }
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::WaitUserInput(int Section)
{
    TComResultSet *pRst;
    AnsiString m_Sql;
    if (Section ==1)
    {
      if(seTshCode->Enabled)
        seTshCode->SetFocus();
    }
    else
    {
      sgTsd->Visible=false;
      FloatPanel2->Visible=true;
      pv_GoodsCode=Trim(seTsdGoods->Text);
      if(scTsdLoc->Enabled)
        scTsdLoc->SetFocus();
      else
        seTsdGoodsExit(NULL);
    }
    m_Sql=" select parametervalue from sdparameter where parametercode='10508' ";
    pRst=NewResultSet();
    pRst->Open(m_Sql,"");
    if(pRst->RecordCount<1)
    {
      CancelRecord();
      throw Exception("系统库存状态参数被破坏");
    }
    pRst->MoveFirst();
    m_InvState = pRst->FieldByName("parametervalue");
    if(m_InvState!="2")
    {
      if(Application->MessageBox("系统尚未进入盘点状态,是否自动进入盘点状态?","确认盘点对话框",+MB_ICONQUESTION+MB_OKCANCEL)==IDOK)
      {
        m_Sql="update sdparameter set parametervalue='2' where ParameterCode='10508'";
        pRst->Execute(m_Sql);
      }
      else
        CancelRecord();
    }
    delete pRst;
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::RefreshGridData(int mAction)
{

    int i;
    AnsiString ItemStr;
    switch(mAction)
    {
       case 0:
         ItemStr=GetDataToGrid();
         sgTsd->AddItem(ItemStr);
         break;
       case 1:
         i=sgTsd->Row;
         ItemStr=GetDataToGrid();
         sgTsd->ChangeItem(ItemStr,i);
         break;
       case 2:
         sgTsd->RemoveItem(sgTsd->Row);
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmTsh::GetDataToGrid()
{
    AnsiString ItemStr;
    g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiTsdGoods)));
    ItemStr="\t"+GetDetailValue(fiTsdLine)
           +"\t"+GetDetailValue(fiTsdGoods)
           +"\t"+GetGoodsValue("GoodsName")
           +"\t"+GetDetailValue(fiTsdUnit)
           +"\t"+GetDetailValue(fiTsdAQty)
           +"\t"+GetDetailValue(fiTsdTQty)
           +"\t"+GetDetailValue(fiTsdDQty);
    return ItemStr;
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::DisplayBill()
{
    GetDataFromComObject(1);
    FillGridWithData();
}
//---------------------------------------------------------------------------

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

⌨️ 快捷键说明

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