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

📄 soghcheck.cpp

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

#include <vcl.h>
#pragma hdrstop

#include "SoghCheck.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ListBaseForm"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSoghCheck *frmSoghCheck;
//---------------------------------------------------------------------------
__fastcall TfrmSoghCheck::TfrmSoghCheck(TComponent* Owner)
        :TListBaseForm(Owner,euSdSogh,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::InitEditControl()
{
 FillComboBox(scSoghSaler,"Select userCode,UserName from sdUser where UserCode in (select SalerCode from SdSaler)","UserName","UserCode");
 FillComboBox(scSoghClient,"Select ClientCode,ClientName from sdClient where ClientCancel=0","ClientName","ClientCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoghCheck::ClearControl()
{
           seSoghCodeF->Text            ="";
           seSoghCodeT->Text            ="";
           deSoghDateF->Text            ="";
           deSoghDateT->Text            ="";
           scSoghClient->ItemIndex      =-1;
           scSoghSaler->ItemIndex       =-1;

           SoghGrid->RowCount=1;
           SogdGrid->RowCount=1;
           btnCheck->Enabled=false;
}
//---------------------------------------------------------------------------

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

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

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

void __fastcall TfrmSoghCheck::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 TfrmSoghCheck::FillDetailGridWithData()
{
      int i;
      AnsiString ItemStr;
      SogdGrid->RowCount=1;
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          ItemStr="\t"+GetDetailValue(fiSogdLine)+"\t"+GetDetailValue(fiSogdSoCode)+"\t"+
                    GetDetailValue(fiSogdSodLine)+"\t"+
                    GetDetailValue(fiSogdGoods)+"\t"+GetDetailValue(fiSogdUnit)+"\t"+
                    GetDetailValue(fiSogdQty)+"\t"+GetDetailValue(fiSogdRecDate);
          SogdGrid->AddItem(ItemStr);
      }
}
void __fastcall TfrmSoghCheck::FillHeadGridWithData()
{
      int i,Type;
      AnsiString HeadStr,TypeStr;
      SoghGrid->RowCount=1;
      for (i=0;i<comServer->RecordCount;i++)
      {
          comServer->LocateByIndex(i);
          Type=StrToInt(GetHeadValue(fiSoghType));
          switch(Type)
          {
           case 1:
                TypeStr="据订单发货";
                break;
           case 2:
                TypeStr="非订单发货";
                break;

          }
          HeadStr="\t"+AnsiString("  ")+"\t"+GetHeadValue(fiSoghCode)+"\t"+
                       GetHeadValue(fiSoghClient)+"\t"+GetHeadValue(fiSoghDate)+"\t"+
                       TypeStr+"\t"+GetHeadValue(fiSoghSaler);
          SoghGrid->AddItem(HeadStr);
      }

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

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

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

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

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



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

}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSoghCheck::GetWhereSQLString()
{
     AnsiString WhereStr;
     WhereStr="SoghCheck=0 and SoghCancel=0";
     WhereStr=WhereStr+" and SoghClient in(select ClientCode from sdClient where ClientCancel=0)";
     if(!seSoghCodeF->Text.IsEmpty())
        WhereStr=WhereStr+" and SoghCode>='"+Trim(seSoghCodeF->Text)+"'";
     if(!seSoghCodeT->Text.IsEmpty())
        WhereStr=WhereStr+" and SoghCode<='"+Trim(seSoghCodeT->Text)+"'";
     if(!scSoghSaler->Text.IsEmpty())
        WhereStr=WhereStr+" and SoghSaler='"+Trim(scSoghSaler->ItemData[1])+"'";
     if(!deSoghDateF->Text.IsEmpty())
        WhereStr=WhereStr+" and SoghDate>='"+FormatDateTime("YYYY-MM-DD",deSoghDateF->Date)+"'";
     if(!deSoghDateT->Text.IsEmpty())
        WhereStr=WhereStr+" and SoghDate<='"+FormatDateTime("YYYY-MM-DD",deSoghDateT->Date)+"'";
     if(!scSoghClient->Text.IsEmpty())
        WhereStr=WhereStr+" and SoghClient='"+Trim(scSoghClient->ItemData[1])+"'";
   return(WhereStr);
}


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

void __fastcall TfrmSoghCheck::btnQueryClick(TObject *Sender)
{
  SoghGrid->RowCount=1;
  SogdGrid->RowCount=1;
  btnCheck->Enabled=false;

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



void __fastcall TfrmSoghCheck::SoghGridClick(TObject *Sender)
{
   if(SoghGrid->Row>0)
   {
     comServer->LocateByKey(WideString(SoghGrid->TextMatrix[SoghGrid->Row][2]));
     if(SoghGrid->Col == 1)
     {
      if(SoghGrid->TextMatrix[SoghGrid->Row][1]=="√")
        {
           SoghGrid->TextMatrix[SoghGrid->Row][1]="";
         }
        else
         {
           SoghGrid->TextMatrix[SoghGrid->Row][1]="√";
         }
      }
     FillDetailGridWithData();
     }
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoghCheck::btnCheckClick(TObject *Sender)
{
  for(int i=1; i<SoghGrid->RowCount;i++)
  {
   if(SoghGrid->TextMatrix[i][1]=="√")
   {
    comServer->LocateByKey(WideString(SoghGrid->TextMatrix[i][2]));
    SetHeadValue(fiSoghChecker,g_sdUserCode);
 try{
       comServer->Check(1);
    }
    catch(Exception &e)
    {
     throw Exception(e.Message);
    }
   }
 }
  ClearControl();
  btnQueryClick(Sender);
}
//---------------------------------------------------------------------------


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

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

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

⌨️ 快捷键说明

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