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

📄 sivohcheck.cpp

📁 速达开源ERP系统
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "SivohCheck.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ListBaseForm"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSivohCheck *frmSivohCheck;
//---------------------------------------------------------------------------
__fastcall TfrmSivohCheck::TfrmSivohCheck(TComponent* Owner)
        :TListBaseForm(Owner,euSdSivoh,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSivohCheck::InitEditControl()
{
 FillComboBox(scSivohSaler,"Select SalerCode from sdSaler","SalerCode");
 FillComboBox(scSivohClient,"Select ClientCode from sdClient where ClientCancel=0","ClientCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::ClearControl()
{
           seSivohCodeF->Text            ="";
           seSivohCodeT->Text            ="";
           deSivohDateF->Text            ="";
           deSivohDateT->Text            ="";
           scSivohClient->Text           ="";
           scSivohSaler->Text            ="";

           SivohGrid->RowCount=1;
           SivodGrid->RowCount=1;
           btnCheck->Enabled=false;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::GetDataFromComObject(int Section)
{
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::SendDataToComObject(int Section)
{
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::WaitUserInput(int Section)
{
}
void __fastcall TfrmSivohCheck::ChangeToBrowseState(bool Browse)
{
  ClearControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSivohCheck::DisplayBill()
{
        FillHeadGridWithData();
        comServer->MoveFirst();
        FillDetailGridWithData();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::GetBill(AnsiString WhereStr)
{
    comServer->FilterString=WideString(WhereStr);
    comServer->Query();
    if (comServer->RecordCount!=0)      //Found it
       {
         btnCheck->Enabled=true;
         DisplayBill();
       }
       else
        ShowMessageWindow("在数据库中没有查到记录,请重新输入条件",mwsInformation);
   RecodCount->Caption="查询单据数为:"+IntToStr(comServer->RecordCount);  
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::FillDetailGridWithData()
{
      int i;
      AnsiString ItemStr;
      SivodGrid->RowCount=1;
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          ItemStr="\t"+GetDetailValue(fiSivodLine)+"\t"+
                    GetDetailValue(fiSivodGoods)+"\t"+GetDetailValue(fiSivodUnit)+"\t"+
                    GetDetailValue(fiSivodPrice)+"\t"+GetDetailValue(fiSivodQty)+"\t"+
                    GetDetailValue(fiSivodAmt)+"\t"+GetDetailValue(fiSivodTaxAmt)+"\t"+
                    GetDetailValue(fiSivodZkAmt)+"\t"+GetDetailValue(fiSivodSumAmt);
          SivodGrid->AddItem(ItemStr);
      }
}
void __fastcall TfrmSivohCheck::FillHeadGridWithData()
{
      int i;
      AnsiString HeadStr;
      SivohGrid->RowCount=1;
      for (i=0;i<comServer->RecordCount;i++)
      {
          comServer->LocateByIndex(i);
          HeadStr="\t"+AnsiString("  ")+"\t"+GetHeadValue(fiSivohCode)+"\t"+GetHeadValue(fiSivohSoCode)+"\t"+
                       GetHeadValue(fiSivohClient)+"\t"+GetHeadValue(fiSivohDate)+"\t"+
                       GetHeadValue(fiSivohCurrency)+"\t"+GetHeadValue(fiSivohSettleMode)+"\t"+
                       GetHeadValue(fiSivohSaler);
          SivohGrid->AddItem(HeadStr);
      }

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

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

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

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

void __fastcall TfrmSivohCheck::SetDetailValue(int Index,AnsiString Value)
{
       WriteItemValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------



void __fastcall TfrmSivohCheck::FormShow(TObject *Sender)
{
//       InitEditControl();
       ClearControl();
       ChangeToBrowseState(true);

}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSivohCheck::GetWhereSQLString()
{
     AnsiString WhereStr;
     WhereStr="SivohCheck=0 and SivohCancel=0";
     WhereStr=WhereStr+" and SivohClient in (select ClientCode from sdClient where ClientCancel=0)";
     if(!seSivohCodeF->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohCode>='"+Trim(seSivohCodeF->Text)+"'";
     if(!seSivohCodeT->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohCode<='"+Trim(seSivohCodeT->Text)+"'";
     if(!scSivohSaler->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohSaler='"+Trim(scSivohSaler->Text)+"'";
     if(!deSivohDateF->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohDate>='"+FormatDateTime("YYYY-MM-DD",deSivohDateF->Date)+"'";
     if(!deSivohDateT->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohDate<='"+FormatDateTime("YYYY-MM-DD",deSivohDateT->Date)+"'";
     if(!scSivohClient->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohClient='"+Trim(scSivohClient->Text)+"'";
   return(WhereStr);
}


void __fastcall TfrmSivohCheck::btnClearClick(TObject *Sender)
{
       ClearControl();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::btnQueryClick(TObject *Sender)
{
           SivohGrid->RowCount=1;
           SivodGrid->RowCount=1;
           btnCheck->Enabled=false;

  AnsiString WhereStr=GetWhereSQLString();
  GetBill(WhereStr);
}
//---------------------------------------------------------------------------



void __fastcall TfrmSivohCheck::SivohGridClick(TObject *Sender)
{

     if(SivohGrid->Col == 1&&SivohGrid->Row>0)
     {
      if(SivohGrid->TextMatrix[SivohGrid->Row][1]=="√")
        {
           SivohGrid->TextMatrix[SivohGrid->Row][1]="";
         }
        else
         {
           SivohGrid->TextMatrix[SivohGrid->Row][1]="√";
         }
      }
   comServer->LocateByKey(WideString(SivohGrid->TextMatrix[SivohGrid->Row][2]));
   FillDetailGridWithData();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::btnCheckClick(TObject *Sender)
{
  for(int i=1; i<SivohGrid->RowCount;i++)
  {
   if(SivohGrid->TextMatrix[i][1]=="√")
   {
    comServer->LocateByKey(WideString(SivohGrid->TextMatrix[i][2]));
    SetHeadValue(fiSivohChecker,g_sdUserCode);
    comServer->Check(1);
   }
 }
  ClearControl();
  btnQueryClick(Sender);
}
//---------------------------------------------------------------------------


void __fastcall TfrmSivohCheck::btnQuiteClick(TObject *Sender)
{
 Close();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::SivohGridMouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
   int Column,Row;
   SivohGrid->MouseToCell(X,Y,Column,Row);
   if(Column==1&&Row>0)
      SivohGrid->Cursor=crHandPoint;
   else
      SivohGrid->Cursor=crDefault;

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

⌨️ 快捷键说明

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